diff --git a/packages/core/src/modern/index.ts b/packages/core/src/modern/index.ts index 45f1727..2c7c519 100644 --- a/packages/core/src/modern/index.ts +++ b/packages/core/src/modern/index.ts @@ -4,6 +4,7 @@ import type { FullIconifyIcon } from '@iconify/utils/lib/icon'; import { defaultCustomisations as DefaultIconCustomizations, iconToSVG, getIconData, tryInstallPkg } from '@iconify/utils'; import createDebugger from 'debug'; import { isPackageExists, resolveModule } from 'local-pkg'; +import type { FullIconCustomisations } from '@iconify/utils/lib/customisations'; const debug = createDebugger('@iconify-core:icon'); const debugModern = createDebugger('@iconify-core:modern'); @@ -53,17 +54,15 @@ export async function loadCollection(name: string, autoInstall = false): Promise } } -export function searchForIcon(iconSet: IconifyJSON, collection: string, ids: string[], scale = 1): string | null { +export function searchForIcon(iconSet: IconifyJSON, collection: string, ids: string[], customize?: (defaults: FullIconCustomisations) => void): string | null { let iconData: FullIconifyIcon | null; for (const id of ids) { iconData = getIconData(iconSet, id, true); if (iconData) { debug(`${collection}:${id}`); - const { attributes, body } = iconToSVG(iconData, { - ...DefaultIconCustomizations, - height: `${scale}em`, - width: `${scale}em`, - }); + const customizations: FullIconCustomisations = { ...DefaultIconCustomizations } + customize?.(customizations) + const { attributes, body } = iconToSVG(iconData, customizations); return ` `${i[0]}="${i[1]}"`).join(' ')}>${body}`; } }