Files
web-app-launcher/src/lib/components/ui/DynamicIcon.svelte
T
alexei.dolgolyov 87ed928a3a feat(phase2): phase 6 - integration & polish
Fix all build/type/lint errors, write 60 new tests (175 total),
update seed with new widget types and team board permissions,
install missing svelte-i18n dependency, fix DynamicIcon for Svelte 5.
2026-03-24 23:43:31 +03:00

29 lines
721 B
Svelte

<script lang="ts">
import * as icons from 'lucide-svelte';
interface Props {
name: string | null;
size?: number;
class?: string;
}
let { name, size = 16, class: className = '' }: Props = $props();
// Convert kebab-case to PascalCase: "layout-dashboard" → "LayoutDashboard"
function toPascalCase(str: string): string {
return str
.split('-')
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
.join('');
}
const iconComponent = $derived(
name ? ((icons as Record<string, unknown>)[toPascalCase(name)] as typeof import('svelte').SvelteComponent | undefined) ?? null : null
);
</script>
{#if iconComponent}
{@const Icon = iconComponent}
<Icon {size} class={className} />
{/if}