From 27fc269a942998651b8ca508e129541752c22a6c Mon Sep 17 00:00:00 2001 From: Lea Verou Date: Tue, 13 May 2025 12:08:28 -0400 Subject: [PATCH] Have system icons fall back to known families/variants if not found --- src/components/icon/library.system.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/icon/library.system.ts b/src/components/icon/library.system.ts index 291194448..79caa29e4 100644 --- a/src/components/icon/library.system.ts +++ b/src/components/icon/library.system.ts @@ -41,14 +41,18 @@ export const icons: { [key: string]: string } = Object.assign({}, ...Object.valu // const systemLibrary: IconLibrary = { name: 'system', - resolver: (name: string, family = 'classic', variant = 'solid') => { - if (family === 'classic') { - // Try given variant first, fall back to any variant - let svg = iconsByVariant[variant]?.[name]; + resolver: (name: string, _family = 'classic', variant = 'solid') => { + // family is ignored for now + // Default to `regular` for unknown variants + variant = variant in iconsByVariant ? variant : 'regular'; - if (svg) { - return dataUri(svg); - } + let icons = iconsByVariant[variant]; + + // Fall back to other variants if icon is not found in the variant requested + let svg = icons[name] ?? iconsByVariant.regular[name] ?? iconsByVariant.solid[name]; + + if (svg) { + return dataUri(svg); } return '';