anki/ts/editor-toolbar/ButtonGroup.svelte

71 lines
1.7 KiB
Svelte

<script lang="typescript">
import type { DynamicSvelteComponent } from "sveltelib/dynamicComponent";
interface Hidden {
hidden: boolean;
}
export let id;
export let className = "";
export let buttons: DynamicSvelteComponent<Hidden>[];
function filterHidden({
hidden,
...props
}: DynamicSvelteComponent & Hidden): DynamicSvelteComponent {
return props;
}
</script>
<style lang="scss">
ul {
display: flex;
flex-wrap: var(--toolbar-wrap);
overflow-y: auto;
padding-inline-start: 0;
margin-bottom: 0;
& :global(button),
& :global(select) {
margin-left: -1px;
}
}
li {
display: inline-block;
margin-bottom: calc(var(--toolbar-size) / 15);
&:nth-child(1) {
margin-left: calc(var(--toolbar-size) / 7.5);
& > :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);
}
}
&:nth-last-child(1) {
margin-right: calc(var(--toolbar-size) / 7.5);
& > :global(button),
& > :global(select) {
border-top-right-radius: calc(var(--toolbar-size) / 7.5);
border-bottom-right-radius: calc(var(--toolbar-size) / 7.5);
}
}
}
</style>
<ul {id} class={className} {...$$restProps}>
{#each buttons as button}
{#if !button.hidden}
<li>
<svelte:component this={button.component} {...filterHidden(button)} />
</li>
{/if}
{/each}
</ul>