Dough Git

clove/pkviewer

web/src/lib/components/Icon.svelte

back to web/src/lib/components

<!-- web/src/lib/components/Icon.svelte -->
<script lang="ts">
  import { ICONS, type IconName } from "$lib/icons.ts";

  let {
    name,
    class: className = "",
    size = "1em",
  }: {
    name: IconName;
    class?: string;
    size?: string | number;
  } = $props();

  // The files are trusted, static bootstrap-icons artwork; only the inner paths are kept
  const inner = $derived(ICONS[name].replace(/^[\s\S]*?<svg[^>]*>/, "").replace(/<\/svg>\s*$/, ""));
</script>

<svg
  xmlns="http://www.w3.org/2000/svg"
  viewBox="0 0 16 16"
  width={size}
  height={size}
  fill="currentColor"
  class="bi bi-{name} {className}"
  aria-hidden="true"
>{@html inner}</svg>