vite-awesome-svg-loader
Version:
Imports SVGs as source code, base64 and data URI. Preserves stroke width, replaces colors with currentColor. Optimizes SVGs with SVGO. Creates SVG sprites.
39 lines (38 loc) • 1.31 kB
TypeScript
/**
* ID of an SVG element that contains all symbols
*/
export declare const SVG_ID = "svg-symbols";
/**
* Prepended to the symbol ID
*/
export declare const SYMBOL_ID_PREFIX = "svg-";
/**
* Attribute of a symbol element that contains count of elements that uses that symbol
*/
export declare const USAGES_COUNT_ATTR = "data-count";
/**
* Should be called whenever image source is updated, and component is mounted.
*
* @param prevSrc Previous symbol source code, i.e. value of `import "./my/image.svg"`. If there's no previous source, pass `undefined`.
* @param src Symbol source code, i.e. value of `import "./my/image.svg"`
* @returns Attributes that should be bound to the `<svg>` tag. These attributes should override attributes bound by the user.
*/
export declare function onSrcUpdate(prevSrc: string | undefined, src: string): {
id?: undefined;
attrs?: undefined;
} | {
id: string;
attrs: {
viewBox: string;
width: string;
height: string;
};
} | {
id: string;
attrs?: undefined;
};
/**
* Should be called whenever component is unmounted
* @param symbolOrId Symbol or ID of a symbol. If nullish value is provided, won't do anything.
*/
export declare function onUnmount(symbolOrId: SVGSymbolElement | string | null | undefined): void;