anki/ts/editor-toolbar/ButtonGroup.svelte

56 lines
1.2 KiB
Svelte
Raw Normal View History

<script lang="typescript">
2021-03-30 00:51:44 +02:00
type Buttons =
| { component: SvelteComponent; [...arg: string]: unknown }
| Buttons[];
export let buttons: Buttons;
</script>
<style lang="scss">
ul {
2021-03-29 22:45:11 +02:00
display: inline-block;
2021-03-30 00:51:44 +02:00
padding-inline-start: 0;
margin-bottom: 0;
& :global(button) {
margin-left: -1px;
}
2021-03-30 00:51:44 +02:00
}
2021-03-30 00:51:44 +02:00
li {
display: inline-block;
margin-bottom: 2px;
&:nth-child(1) {
margin-left: 0.25rem;
& > :global(button) {
border-top-left-radius: 0.25rem;
border-bottom-left-radius: 0.25rem;
}
}
2021-03-30 00:51:44 +02:00
&:nth-last-child(1) {
margin-right: 0.25rem;
& > :global(button) {
border-top-right-radius: 0.25rem;
border-bottom-right-radius: 0.25rem;
}
}
}
</style>
2021-03-30 00:51:44 +02:00
<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>