2
0
mirror of https://github.com/iconify/iconify.git synced 2025-01-23 07:08:34 +00:00

chore: configure usedProps with additionalProperties and override width and height from props

This commit is contained in:
Joaquín Sánchez Jiménez 2022-03-17 14:59:51 +01:00
parent a1c7087cf2
commit 23a089b6bf
2 changed files with 11 additions and 15 deletions

View File

@ -142,7 +142,7 @@ export type IconifyLoaderOptions = {
autoInstall?: boolean; autoInstall?: boolean;
/** /**
* Holder to include the properties added to the svg. * The additional icon properties applied to the svg.
* *
* The `width` and `height` will not be set to the `svg` if already present on it, and so, the `width` and `height` will be those you configure on the customizations. * The `width` and `height` will not be set to the `svg` if already present on it, and so, the `width` and `height` will be those you configure on the customizations.
* If you omit the `width/height/scale` options and the `svg` contains the `width` and/or `height`, then, both will be extracted from the `svg`. * If you omit the `width/height/scale` options and the `svg` contains the `width` and/or `height`, then, both will be extracted from the `svg`.

View File

@ -95,20 +95,16 @@ export async function mergeIconProps(
} }
if (options && options.usedProps) { if (options && options.usedProps) {
options.usedProps = Object.keys(props).reduce((acc, k) => { Object.keys(additionalProps).forEach((p) => {
if (k) { const v = props[p];
switch (k) { if (v !== undefined && v !== null) options.usedProps![p] = v;
case 'scale': });
case 'xmlns': if (typeof props.width !== 'undefined' && props.width !== null) {
case 'xmlns:xlink': options.usedProps.width = props.width;
break;
default:
acc[k] = props[k];
break;
} }
if (typeof props.height !== 'undefined' && props.height !== null) {
options.usedProps.height = props.height;
} }
return acc;
}, {} as Record<string, string>);
} }
return svg; return svg;