mirror of
https://github.com/iconify/iconify.git
synced 2024-12-13 22:18:24 +00:00
chore: move encodeCssSvg
to its own module
This commit is contained in:
parent
ef22738574
commit
8b7641839e
@ -39,6 +39,7 @@ export { convertIconSetInfo } from './icon-set/convert-info';
|
|||||||
export { iconToSVG } from './svg/build';
|
export { iconToSVG } from './svg/build';
|
||||||
export { replaceIDs } from './svg/id';
|
export { replaceIDs } from './svg/id';
|
||||||
export { calculateSize } from './svg/size';
|
export { calculateSize } from './svg/size';
|
||||||
|
export { encodeSvgForCss } from './svg/encode-svg-for-css';
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
export { colorKeywords } from './colors/keywords';
|
export { colorKeywords } from './colors/keywords';
|
||||||
@ -53,7 +54,7 @@ export type {
|
|||||||
IconifyLoaderOptions,
|
IconifyLoaderOptions,
|
||||||
InlineCollection,
|
InlineCollection,
|
||||||
} from './loader/types';
|
} from './loader/types';
|
||||||
export { encodeCssSvg, mergeIconProps } from './loader/utils';
|
export { mergeIconProps } from './loader/utils';
|
||||||
export { loadIcon } from './loader/loader';
|
export { loadIcon } from './loader/loader';
|
||||||
export { FileSystemIconLoader } from './loader/loaders';
|
export { FileSystemIconLoader } from './loader/loaders';
|
||||||
export { getCustomIcon } from './loader/custom';
|
export { getCustomIcon } from './loader/custom';
|
||||||
|
@ -31,14 +31,3 @@ export async function mergeIconProps(
|
|||||||
`${replacement}${Object.keys(props).map((p) => `${p}="${props[p]}"`).join(' ')}`
|
`${replacement}${Object.keys(props).map((p) => `${p}="${props[p]}"`).join(' ')}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://bl.ocks.org/jennyknuth/222825e315d45a738ed9d6e04c7a88d0
|
|
||||||
export function encodeCssSvg(svg: string): string {
|
|
||||||
return svg.replace(/"/g, '\'')
|
|
||||||
.replace(/%/g, '%25')
|
|
||||||
.replace(/#/g, '%23')
|
|
||||||
.replace(/{/g, '%7B')
|
|
||||||
.replace(/}/g, '%7D')
|
|
||||||
.replace(/</g, '%3C')
|
|
||||||
.replace(/>/g, '%3E')
|
|
||||||
}
|
|
||||||
|
10
packages/utils/src/svg/encode-svg-for-css.ts
Normal file
10
packages/utils/src/svg/encode-svg-for-css.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// https://bl.ocks.org/jennyknuth/222825e315d45a738ed9d6e04c7a88d0
|
||||||
|
export function encodeSvgForCss(svg: string): string {
|
||||||
|
return svg.replace(/"/g, '\'')
|
||||||
|
.replace(/%/g, '%25')
|
||||||
|
.replace(/#/g, '%23')
|
||||||
|
.replace(/{/g, '%7B')
|
||||||
|
.replace(/}/g, '%7D')
|
||||||
|
.replace(/</g, '%3C')
|
||||||
|
.replace(/>/g, '%3E')
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user