2021-03-30 18:57:50 +02:00
|
|
|
<script lang="typescript">
|
2021-03-31 03:34:08 +02:00
|
|
|
interface DropdownItem {
|
|
|
|
label: string;
|
|
|
|
endLabel: string;
|
|
|
|
onClick: (event: ClickEvent) => void;
|
2021-03-30 18:57:50 +02:00
|
|
|
}
|
|
|
|
|
2021-03-31 03:34:08 +02:00
|
|
|
export let id: string;
|
|
|
|
export let menuItems: DropdownItem[];
|
2021-03-30 18:57:50 +02:00
|
|
|
</script>
|
|
|
|
|
2021-03-31 03:34:08 +02:00
|
|
|
<ul class="dropdown-menu" {id}>
|
|
|
|
{#each menuItems as menuItem}
|
|
|
|
<li>
|
|
|
|
<button
|
|
|
|
class="dropdown-item"
|
|
|
|
on:click={menuItem.onClick}
|
|
|
|
on:mousedown|preventDefault>
|
|
|
|
<span class="float-start">{menuItem.label}</span>
|
|
|
|
{#if menuItem.endLabel}
|
|
|
|
<span class="float-end">{menuItem.endLabel}</span>
|
|
|
|
{/if}
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
{/each}
|
|
|
|
</ul>
|