anki/ts/editor-toolbar/ButtonGroup.svelte

61 lines
1.5 KiB
Svelte
Raw Normal View History

<script lang="typescript">
import type { Buttons } from "./types";
2021-03-30 00:51:44 +02:00
export let buttons: Buttons;
</script>
<style lang="scss">
ul {
display: flex;
/* flex-flow: nowrap for a scrollable toolbar */
flex-flow: wrap;
overflow: scroll;
2021-03-30 00:51:44 +02:00
padding-inline-start: 0;
margin-bottom: 0;
2021-03-31 15:40:11 +02:00
& :global(button),
& :global(select) {
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: calc(var(--toolbar-size) / 15);
2021-03-30 00:51:44 +02:00
&:nth-child(1) {
margin-left: calc(var(--toolbar-size) / 7.5);
2021-03-30 00:51:44 +02:00
2021-03-31 15:40:11 +02:00
& > :global(button),
& > :global(select) {
/* default 0.25rem */
border-top-left-radius: calc(var(--toolbar-size) / 7.5);
border-bottom-left-radius: calc(var(--toolbar-size) / 7.5);
2021-03-30 00:51:44 +02:00
}
}
2021-03-30 00:51:44 +02:00
&:nth-last-child(1) {
margin-right: calc(var(--toolbar-size) / 7.5);
2021-03-30 00:51:44 +02:00
2021-03-31 15:40:11 +02:00
& > :global(button),
& > :global(select) {
border-top-right-radius: calc(var(--toolbar-size) / 7.5);
border-bottom-right-radius: calc(var(--toolbar-size) / 7.5);
2021-03-30 00:51:44 +02:00
}
}
}
</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>