mirror of
https://github.com/iconify/iconify.git
synced 2024-11-09 23:00:56 +00:00
fix(next): modern module ignores scale
This commit is contained in:
parent
8a5bcb12b6
commit
e88ecf8aeb
@ -21,20 +21,46 @@ export async function searchForIcon(
|
||||
iconData = getIconData(iconSet, id, true);
|
||||
if (iconData) {
|
||||
debug(`${collection}:${id}`);
|
||||
const defaultCustomizations = { ...DefaultIconCustomizations };
|
||||
const { attributes, body } = iconToSVG(
|
||||
iconData,
|
||||
typeof customize === 'function'
|
||||
? customize(defaultCustomizations)
|
||||
: defaultCustomizations
|
||||
);
|
||||
let defaultCustomizations = { ...DefaultIconCustomizations };
|
||||
if (typeof customize === 'function')
|
||||
defaultCustomizations = customize(defaultCustomizations);
|
||||
|
||||
const {
|
||||
attributes: { width, height, ...restAttributes },
|
||||
body,
|
||||
} = iconToSVG(iconData, defaultCustomizations);
|
||||
const scale = options?.scale;
|
||||
return await mergeIconProps(
|
||||
// DON'T remove space on <svg >
|
||||
`<svg >${body}</svg>`,
|
||||
collection,
|
||||
id,
|
||||
options,
|
||||
() => attributes
|
||||
() => {
|
||||
return { ...restAttributes };
|
||||
},
|
||||
(props) => {
|
||||
if (
|
||||
typeof props.width === 'undefined' ||
|
||||
props.width === null
|
||||
) {
|
||||
if (typeof scale === 'number') {
|
||||
props.width = `${scale}em`;
|
||||
} else {
|
||||
props.width = width;
|
||||
}
|
||||
}
|
||||
if (
|
||||
typeof props.height === 'undefined' ||
|
||||
props.height === null
|
||||
) {
|
||||
if (typeof scale === 'number') {
|
||||
props.height = `${scale}em`;
|
||||
} else {
|
||||
props.height = height;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ export async function mergeIconProps(
|
||||
collection: string,
|
||||
icon: string,
|
||||
options?: IconifyLoaderOptions,
|
||||
propsProvider?: () => Awaitable<Record<string, string>>
|
||||
propsProvider?: () => Awaitable<Record<string, string>>,
|
||||
afterCustomizations?: (props: Record<string, string>) => void
|
||||
): Promise<string> {
|
||||
const { scale, addXmlNs = false } = options ?? {};
|
||||
const { additionalProps = {}, iconCustomizer } =
|
||||
@ -51,6 +52,7 @@ export async function mergeIconProps(
|
||||
const v = additionalProps[p];
|
||||
if (v !== undefined && v !== null) props[p] = v;
|
||||
});
|
||||
afterCustomizations?.(props);
|
||||
|
||||
const [widthOnSvg, heightOnSvg] = configureSvgSize(svg, props, scale);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user