anki/ts/editor-toolbar/ButtonGroup.svelte
2021-04-15 13:09:49 +02:00

60 lines
1.3 KiB
Svelte

<script lang="typescript">
import type { Buttons } from "./types";
export let buttons: Buttons;
</script>
<style lang="scss">
ul {
display: flex;
/* flex-flow: nowrap for a scrollable toolbar */
flex-flow: wrap;
overflow: scroll;
padding-inline-start: 0;
margin-bottom: 0;
& :global(button),
& :global(select) {
margin-left: -1px;
}
}
li {
display: inline-block;
margin-bottom: 2px;
&:nth-child(1) {
margin-left: 0.25rem;
& > :global(button),
& > :global(select) {
border-top-left-radius: 0.25rem;
border-bottom-left-radius: 0.25rem;
}
}
&:nth-last-child(1) {
margin-right: 0.25rem;
& > :global(button),
& > :global(select) {
border-top-right-radius: 0.25rem;
border-bottom-right-radius: 0.25rem;
}
}
}
</style>
<ul>
{#each buttons as button}
<li>
{#if Array.isArray(button)}
<svelte:self buttons={button} />
{:else}
<svelte:component this={button.component} {...button} />
{/if}
</li>
{/each}
</ul>