2
0
mirror of https://github.com/iconify/iconify.git synced 2025-01-06 07:20:40 +00:00

Optimise duplicate properties in background mode in svg framework

This commit is contained in:
Vjacheslav Trushkin 2022-04-07 18:52:20 +03:00
parent f5bc7b4ea2
commit fa8b70513b

View File

@ -14,22 +14,31 @@ const commonProps: Record<string, string> = {
};
const monotoneProps: Record<string, string> = {
'-webkit-mask-image': 'var(--svg)',
'-webkit-mask-repeat': 'no-repeat',
'-webkit-mask-size': '100% 100%',
'mask-image': 'var(--svg)',
'mask-repeat': 'no-repeat',
'mask-size': '100% 100%',
'background-color': 'currentColor',
};
const coloredProps: Record<string, string> = {
'background-image': 'var(--svg)',
'background-repeat': 'no-repeat',
'background-size': '100% 100%',
'background-color': 'transparent',
};
// Dynamically add common props to variables above
const propsToAdd: Record<string, string> = {
image: 'var(--svg)',
repeat: 'no-repeat',
size: '100% 100%',
};
const propsToAddTo: Record<string, Record<string, string>> = {
'-webkit-mask': monotoneProps,
'mask': monotoneProps,
'background': coloredProps,
};
for (const prefix in propsToAddTo) {
const list = propsToAddTo[prefix];
for (const prop in propsToAdd) {
list[prefix + '-' + prop] = propsToAdd[prop];
}
}
/**
* Render icon as inline SVG
*/