mirror of
https://github.com/iconify/iconify.git
synced 2025-01-22 14:48:24 +00:00
chore: handle scale
This commit is contained in:
parent
e507252841
commit
affaf1bea0
@ -42,6 +42,7 @@ export async function getCustomIcon(
|
||||
icon,
|
||||
additionalProps,
|
||||
options?.addXmlNs === true,
|
||||
options?.scale,
|
||||
undefined,
|
||||
iconCustomizer,
|
||||
);
|
||||
|
@ -39,6 +39,7 @@ export async function searchForIcon(
|
||||
id,
|
||||
additionalProps,
|
||||
options?.addXmlNs === true,
|
||||
options?.scale,
|
||||
() => attributes,
|
||||
iconCustomizer
|
||||
);
|
||||
|
@ -1,18 +1,23 @@
|
||||
import type { Awaitable } from '@antfu/utils';
|
||||
import type { IconCustomizer } from './types';
|
||||
|
||||
export const isNode = typeof process < 'u' && typeof process.stdout < 'u'
|
||||
|
||||
export async function mergeIconProps(
|
||||
svg: string,
|
||||
collection: string,
|
||||
icon: string,
|
||||
additionalProps: Record<string, string | undefined>,
|
||||
addXmlNs: boolean,
|
||||
scale?: number,
|
||||
propsProvider?: () => Awaitable<Record<string, string>>,
|
||||
iconCustomizer?: IconCustomizer,
|
||||
): Promise<string> {
|
||||
const props: Record<string, string> = (await propsProvider?.()) ?? {};
|
||||
if (!svg.includes(" width=") && !svg.includes(" height=") && typeof scale === 'number') {
|
||||
if ((typeof props.width === 'undefined' || props.width === null) && (typeof props.height === 'undefined' || props.height === null)) {
|
||||
props.width = `${scale}em`;
|
||||
props.height = `${scale}em`;
|
||||
}
|
||||
}
|
||||
await iconCustomizer?.(collection, icon, props);
|
||||
Object.keys(additionalProps).forEach((p) => {
|
||||
const v = additionalProps[p];
|
||||
|
Loading…
x
Reference in New Issue
Block a user