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:
parent
a1c7087cf2
commit
23a089b6bf
@ -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`.
|
||||||
|
@ -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:
|
if (typeof props.height !== 'undefined' && props.height !== null) {
|
||||||
acc[k] = props[k];
|
options.usedProps.height = props.height;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
}, {} as Record<string, string>);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return svg;
|
return svg;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user