anki/ts/editor-toolbar/EditorToolbar.svelte

53 lines
1.4 KiB
Svelte
Raw Normal View History

2021-03-25 23:32:23 +01:00
<script lang="typescript">
import DropdownItem from "./DropdownItem.svelte";
import type { Readable } from "svelte/store";
import { setContext } from "svelte";
import { disabledKey, nightModeKey } from "./contextKeys";
import ButtonGroup from "./ButtonGroup.svelte";
import type { Buttons } from "./ButtonGroup.svelte";
2021-03-25 23:32:23 +01:00
export let buttons: Buttons = [];
2021-03-25 23:32:23 +01:00
export let nightMode: boolean;
export let disabled: Readable<boolean> = false;
2021-03-25 23:32:23 +01:00
setContext(disabledKey, disabled);
setContext(nightModeKey, nightMode);
2021-03-25 21:11:40 +01:00
</script>
2021-03-30 00:51:44 +02:00
<style lang="scss">
nav {
2021-03-30 00:51:44 +02:00
position: sticky;
top: 0;
left: 0;
z-index: 10;
2021-03-30 00:51:44 +02:00
background: var(--bg-color);
border-bottom: 1px solid var(--border);
/* Remove most outer marigns */
& > :global(ul) {
& > :global(li:nth-child(1)) {
margin-left: 0;
}
& > :global(li:nth-last-child(1)) {
margin-right: 0;
}
}
2021-03-30 00:51:44 +02:00
}
</style>
<ul class="dropdown-menu" id="dropdownMenuButton123" aria-labelledby="dropdownMenuButton123">
<DropdownItem>
<svelte:fragment slot="start">Action</svelte:fragment>
<svelte:fragment slot="end">Shortcut</svelte:fragment>
</DropdownItem>
<DropdownItem>Action 1</DropdownItem>
<DropdownItem>Action 2</DropdownItem>
</ul>
<nav>
2021-03-30 00:51:44 +02:00
<ButtonGroup {buttons} />
</nav>