2
0
mirror of https://github.com/iconify/iconify.git synced 2024-11-09 23:00:56 +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;
/**
* 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.
* 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) {
options.usedProps = Object.keys(props).reduce((acc, k) => {
if (k) {
switch (k) {
case 'scale':
case 'xmlns':
case 'xmlns:xlink':
break;
default:
acc[k] = props[k];
break;
Object.keys(additionalProps).forEach((p) => {
const v = props[p];
if (v !== undefined && v !== null) options.usedProps![p] = v;
});
if (typeof props.width !== 'undefined' && props.width !== null) {
options.usedProps.width = props.width;
}
if (typeof props.height !== 'undefined' && props.height !== null) {
options.usedProps.height = props.height;
}
return acc;
}, {} as Record<string, string>);
}
return svg;