mirror of
https://github.com/iconify/iconify.git
synced 2025-01-07 15:44:05 +00:00
feat(iconify-icon): function to append custom style to all nodes
This commit is contained in:
parent
565822758c
commit
e7987a9384
@ -43,6 +43,7 @@ import type {
|
|||||||
IconifyBrowserCacheType,
|
IconifyBrowserCacheType,
|
||||||
IconifyBrowserCacheFunctions,
|
IconifyBrowserCacheFunctions,
|
||||||
} from '@iconify/core/lib/browser-storage/functions';
|
} from '@iconify/core/lib/browser-storage/functions';
|
||||||
|
import { appendCustomStyle } from './render/style';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for exported functions
|
* Interface for exported functions
|
||||||
@ -52,7 +53,11 @@ export interface IconifyExportedFunctions
|
|||||||
IconifyBuilderFunctions,
|
IconifyBuilderFunctions,
|
||||||
IconifyBrowserCacheFunctions,
|
IconifyBrowserCacheFunctions,
|
||||||
IconifyAPIFunctions {
|
IconifyAPIFunctions {
|
||||||
|
// API internal functions
|
||||||
_api: IconifyAPIInternalFunctions;
|
_api: IconifyAPIInternalFunctions;
|
||||||
|
|
||||||
|
// Append custom style to all components
|
||||||
|
appendCustomStyle: (value: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -164,6 +169,7 @@ export function exportFunctions(): IconifyExportedFunctions {
|
|||||||
loadIcons,
|
loadIcons,
|
||||||
loadIcon,
|
loadIcon,
|
||||||
addAPIProvider,
|
addAPIProvider,
|
||||||
|
appendCustomStyle,
|
||||||
_api,
|
_api,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ import type {
|
|||||||
IconifyIconHTMLElementClass,
|
IconifyIconHTMLElementClass,
|
||||||
} from './component';
|
} from './component';
|
||||||
import { exportFunctions } from './functions';
|
import { exportFunctions } from './functions';
|
||||||
|
import { appendCustomStyle } from './render/style';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export used types
|
* Export used types
|
||||||
@ -135,5 +136,6 @@ export {
|
|||||||
loadIcons,
|
loadIcons,
|
||||||
loadIcon,
|
loadIcon,
|
||||||
addAPIProvider,
|
addAPIProvider,
|
||||||
|
appendCustomStyle,
|
||||||
_api,
|
_api,
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,20 @@
|
|||||||
*/
|
*/
|
||||||
const nodeAttr = 'data-style';
|
const nodeAttr = 'data-style';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom style to add to each node
|
||||||
|
*/
|
||||||
|
let customStyle = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set custom style to add to all components
|
||||||
|
*
|
||||||
|
* Affects only components rendered after function call
|
||||||
|
*/
|
||||||
|
export function appendCustomStyle(style: string) {
|
||||||
|
customStyle = style;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add/update style node
|
* Add/update style node
|
||||||
*/
|
*/
|
||||||
@ -24,5 +38,6 @@ export function updateStyle(parent: Element | ShadowRoot, inline: boolean) {
|
|||||||
styleNode.textContent =
|
styleNode.textContent =
|
||||||
':host{display:inline-block;vertical-align:' +
|
':host{display:inline-block;vertical-align:' +
|
||||||
(inline ? '-0.125em' : '0') +
|
(inline ? '-0.125em' : '0') +
|
||||||
'}span,svg{display:block}';
|
'}span,svg{display:block}' +
|
||||||
|
customStyle;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user