2021-04-15 15:59:52 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
2021-04-07 23:53:09 +02:00
|
|
|
<script context="module" lang="typescript">
|
2021-04-09 20:55:49 +02:00
|
|
|
import "./legacy.css";
|
2021-04-07 23:53:09 +02:00
|
|
|
import { writable } from "svelte/store";
|
|
|
|
|
|
|
|
const disabled = writable(false);
|
|
|
|
|
|
|
|
export function enableButtons(): void {
|
|
|
|
disabled.set(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function disableButtons(): void {
|
|
|
|
disabled.set(true);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2021-03-25 23:32:23 +01:00
|
|
|
<script lang="typescript">
|
2021-03-30 06:14:00 +02:00
|
|
|
import type { Readable } from "svelte/store";
|
2021-04-09 18:59:57 +02:00
|
|
|
import type { ToolbarItem } from "./types";
|
2021-03-30 06:14:00 +02:00
|
|
|
import { setContext } from "svelte";
|
|
|
|
import { disabledKey, nightModeKey } from "./contextKeys";
|
|
|
|
|
2021-03-29 21:48:31 +02:00
|
|
|
import ButtonGroup from "./ButtonGroup.svelte";
|
2021-03-25 23:32:23 +01:00
|
|
|
|
2021-04-09 18:59:57 +02:00
|
|
|
export let buttons: Readable<ToolbarItem[]>;
|
|
|
|
export let menus: Readable<ToolbarItem[]>;
|
2021-04-01 18:36:03 +02:00
|
|
|
|
|
|
|
$: _buttons = $buttons;
|
|
|
|
$: _menus = $menus;
|
2021-03-31 03:34:08 +02:00
|
|
|
|
2021-03-25 23:32:23 +01:00
|
|
|
export let nightMode: boolean;
|
|
|
|
|
2021-03-30 06:14:00 +02:00
|
|
|
setContext(nightModeKey, nightMode);
|
2021-03-31 03:34:08 +02:00
|
|
|
setContext(disabledKey, disabled);
|
2021-04-08 23:25:13 +02:00
|
|
|
|
|
|
|
export let size: number = 30;
|
|
|
|
export let wraps: boolean = true;
|
|
|
|
|
|
|
|
$: style = `--toolbar-size: ${size}px; --toolbar-wrap: ${
|
|
|
|
wraps ? "wrap" : "nowrap"
|
|
|
|
}`;
|
2021-03-25 21:11:40 +01:00
|
|
|
</script>
|
|
|
|
|
2021-03-30 00:51:44 +02:00
|
|
|
<style lang="scss">
|
2021-03-30 15:56:54 +02:00
|
|
|
nav {
|
2021-03-30 00:51:44 +02:00
|
|
|
position: sticky;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
2021-03-30 03:11:51 +02:00
|
|
|
z-index: 10;
|
2021-03-30 00:51:44 +02:00
|
|
|
|
|
|
|
background: var(--bg-color);
|
2021-03-30 01:23:39 +02:00
|
|
|
border-bottom: 1px solid var(--border);
|
|
|
|
|
2021-03-30 18:57:50 +02:00
|
|
|
/* Remove outermost marigns */
|
2021-03-30 01:23:39 +02:00
|
|
|
& > :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>
|
|
|
|
|
2021-04-08 23:25:13 +02:00
|
|
|
<div {style}>
|
|
|
|
{#each _menus as menu}
|
|
|
|
<svelte:component this={menu.component} {...menu} />
|
|
|
|
{/each}
|
2021-03-31 16:24:28 +02:00
|
|
|
</div>
|
2021-04-08 23:25:13 +02:00
|
|
|
|
|
|
|
<nav {style}>
|
|
|
|
<ButtonGroup buttons={_buttons} />
|
|
|
|
</nav>
|