2
0
mirror of https://github.com/iconify/iconify.git synced 2025-01-22 14:48:24 +00:00

chore: handle defaultStyle and defaultClass

This commit is contained in:
Joaquín Sánchez Jiménez 2022-02-26 15:57:00 +01:00
parent 8b7641839e
commit a1592498bb

View File

@ -18,7 +18,20 @@ export async function loadIcon(
}
}
return await loadNodeBuiltinIcon(collection, icon, options);
let svg = await loadNodeBuiltinIcon(collection, icon, options);
if (svg && options) {
const { defaultStyle, defaultClass } = options
// additional props and iconCustomizer takes precedence
if (defaultClass && !svg.includes(' class='))
svg = svg.replace('<svg ', `<svg class="${defaultClass}" `)
// additional props and iconCustomizer takes precedence
if (defaultStyle && !svg.includes(' style='))
svg = svg.replace('<svg ', `<svg style="${defaultStyle}" `)
}
return svg;
}
async function importFsModule(): Promise<typeof import('./fs') | undefined> {