From 1e72ec7172a559548219bad82f4692ee917e46cd Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Wed, 2 Mar 2022 10:22:14 +0100 Subject: [PATCH] fix(front/Icon): better match icon type against Lucide Icons full name instead of starting with fa to avoid collisions --- src/assets/ts/icons.ts | 6 ++++++ src/assets/views/utils/Icon.svelte | 8 ++++---- src/common/StringUtils.ts | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 src/common/StringUtils.ts diff --git a/src/assets/ts/icons.ts b/src/assets/ts/icons.ts index b2bfe86..d659309 100644 --- a/src/assets/ts/icons.ts +++ b/src/assets/ts/icons.ts @@ -1,5 +1,7 @@ import {createIcons, icons} from "lucide"; +import {toLucideIconsPascalCase} from "../../common/StringUtils.js"; + let hasAlreadyReplacedIcons = false; export function replaceIcons(once: boolean): void { @@ -9,3 +11,7 @@ export function replaceIcons(once: boolean): void { hasAlreadyReplacedIcons = true; } } + +export function isLucideIcon(iconName: string): boolean { + return Object.keys(icons).indexOf(toLucideIconsPascalCase(iconName)) >= 0; +} diff --git a/src/assets/views/utils/Icon.svelte b/src/assets/views/utils/Icon.svelte index ff5da20..78f232e 100644 --- a/src/assets/views/utils/Icon.svelte +++ b/src/assets/views/utils/Icon.svelte @@ -1,5 +1,5 @@