From eea424a8265e35e633076fe0ca3e8dfb2db233d4 Mon Sep 17 00:00:00 2001 From: silvertakana Date: Thu, 19 Mar 2026 18:14:43 +1300 Subject: [PATCH] fix: use dynamic lucide icon resolution for all 1700+ icons --- src/components/common/PluginIcon.tsx | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/components/common/PluginIcon.tsx b/src/components/common/PluginIcon.tsx index f9264389..d707e7ba 100644 --- a/src/components/common/PluginIcon.tsx +++ b/src/components/common/PluginIcon.tsx @@ -1,17 +1,9 @@ "use client"; import type { ComponentType } from "react"; -import type { LucideIcon } from "lucide-react"; -import { - MapPin, Plane, Ship, Shield, Flame, Camera, Map, Swords, - Wrench, Atom, Landmark, Package, -} from "lucide-react"; +import { icons, type LucideIcon } from "lucide-react"; -/** Map of lucide icon name strings → React components. */ -const ICON_MAP: Record = { - MapPin, Plane, Ship, Shield, Flame, Camera, Map, Swords, - Wrench, Atom, Landmark, Package, -}; +const FallbackIcon = icons.Package; interface PluginIconProps { icon: string | ComponentType<{ size?: number; color?: string }>; @@ -21,13 +13,15 @@ interface PluginIconProps { /** * Renders a plugin icon consistently across the app. - * Handles lucide icon name strings, emoji strings, and - * React component icons (e.g. lucide-react components). + * Resolves any valid lucide-react icon name string dynamically, + * so new plugins can use any icon without updating this component. + * Also supports emoji strings and React component icons. */ export function PluginIcon({ icon, size = 18, color }: PluginIconProps) { if (typeof icon === "string") { - const Mapped = ICON_MAP[icon]; - if (Mapped) return ; + const Resolved = icons[icon as keyof typeof icons] as LucideIcon | undefined; + if (Resolved) return ; + // Treat as emoji or text fallback return {icon}; } @@ -36,5 +30,5 @@ export function PluginIcon({ icon, size = 18, color }: PluginIconProps) { return ; } - return ; + return ; }