anki/ts/editor-toolbar/DropdownMenu.svelte

27 lines
717 B
Svelte
Raw Normal View History

<script lang="typescript">
2021-03-31 03:34:08 +02:00
interface DropdownItem {
label: string;
endLabel: string;
onClick: (event: ClickEvent) => void;
}
2021-03-31 03:34:08 +02:00
export let id: string;
export let menuItems: DropdownItem[];
</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>