Skip to content

Commit

Permalink
Use snippet for icons
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfsblu committed Dec 28, 2024
1 parent fc98982 commit ff339f5
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions webapp/src/lib/components/dropdown/Dropdown.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type {Snippet} from "svelte";
import type {Component, Snippet} from "svelte";
import type {MenuItem} from "./types";
interface Props {
Expand All @@ -21,7 +21,7 @@
isOpen = !isOpen;
}
const iconClass = "relative h-5 w-5"
const iconClass = ""
const menuItemClass = "flex gap-x-3 items-center justify-self-stretch px-4 py-2 text-gray-700 text-sm"
</script>

Expand Down Expand Up @@ -49,6 +49,14 @@
"
role="menu" aria-orientation="vertical" aria-labelledby="menu-button" tabindex="-1">
<div class="py-1" role="none">
{#snippet icon(IconComponent?: Component)}
{#if IconComponent}
<span class="relative h-5 w-5">
<IconComponent />
</span>
{/if}
{/snippet}

{#each menu as item}
{#if item.href}
<a href={item.href}
Expand All @@ -59,9 +67,7 @@
${menuItemClass}
${item.class}
`}>
<span class={iconClass}>
<item.icon />
</span>
{@render icon(item.icon)}
{item.label}
</a>
{:else if item.onClick}
Expand All @@ -73,9 +79,7 @@
${menuItemClass}
${item.class}
`}>
<span class={iconClass}>
<item.icon />
</span>
{@render icon(item.icon)}
{item.label}
</button>
{:else}
Expand Down

0 comments on commit ff339f5

Please sign in to comment.