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-03-30 01:23:39 +02:00
|
|
|
<script lang="typescript">
|
2021-04-09 18:59:57 +02:00
|
|
|
import type { ToolbarItem } from "./types";
|
2021-04-14 21:58:58 +02:00
|
|
|
import { getContext } from "svelte";
|
|
|
|
import { nightModeKey } from "./contextKeys";
|
2021-04-08 22:11:50 +02:00
|
|
|
|
2021-04-16 03:10:39 +02:00
|
|
|
export let id: string | undefined = undefined;
|
2021-04-01 16:29:24 +02:00
|
|
|
export let className = "";
|
2021-04-23 18:53:52 +02:00
|
|
|
export let items: ToolbarItem[];
|
2021-04-01 16:29:24 +02:00
|
|
|
|
2021-04-15 02:32:58 +02:00
|
|
|
function filterHidden({ hidden = false, ...props }) {
|
2021-04-08 22:11:50 +02:00
|
|
|
return props;
|
|
|
|
}
|
2021-04-14 21:58:58 +02:00
|
|
|
|
|
|
|
const nightMode = getContext(nightModeKey);
|
2021-03-29 21:48:31 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
ul {
|
2021-04-16 17:14:47 +02:00
|
|
|
display: flex;
|
2021-04-14 21:58:58 +02:00
|
|
|
justify-items: start;
|
|
|
|
|
2021-04-08 18:13:50 +02:00
|
|
|
flex-wrap: var(--toolbar-wrap);
|
2021-04-08 16:31:41 +02:00
|
|
|
overflow-y: auto;
|
2021-03-29 21:48:31 +02:00
|
|
|
|
2021-03-30 00:51:44 +02:00
|
|
|
padding-inline-start: 0;
|
2021-04-16 18:24:43 +02:00
|
|
|
margin: 0 0 calc(var(--toolbar-size) / 10);
|
2021-03-29 21:48:31 +02:00
|
|
|
|
2021-04-23 21:25:44 +02:00
|
|
|
&.border-overlap-group {
|
|
|
|
:global(button),
|
|
|
|
:global(select) {
|
|
|
|
margin-left: -1px;
|
|
|
|
}
|
2021-04-14 21:58:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-30 00:51:44 +02:00
|
|
|
li {
|
|
|
|
display: inline-block;
|
|
|
|
|
2021-04-14 19:36:41 +02:00
|
|
|
> :global(button),
|
|
|
|
> :global(select) {
|
2021-04-14 16:26:23 +02:00
|
|
|
border-radius: 0;
|
|
|
|
}
|
|
|
|
|
2021-03-30 00:51:44 +02:00
|
|
|
&:nth-child(1) {
|
2021-03-31 16:24:28 +02:00
|
|
|
margin-left: calc(var(--toolbar-size) / 7.5);
|
2021-03-30 00:51:44 +02:00
|
|
|
|
2021-04-14 19:36:41 +02:00
|
|
|
> :global(button),
|
|
|
|
> :global(select) {
|
2021-03-31 16:24:28 +02:00
|
|
|
/* 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-29 21:48:31 +02:00
|
|
|
}
|
|
|
|
|
2021-03-30 00:51:44 +02:00
|
|
|
&:nth-last-child(1) {
|
2021-03-31 16:24:28 +02:00
|
|
|
margin-right: calc(var(--toolbar-size) / 7.5);
|
2021-03-30 00:51:44 +02:00
|
|
|
|
2021-04-14 19:36:41 +02:00
|
|
|
> :global(button),
|
|
|
|
> :global(select) {
|
2021-03-31 16:24:28 +02:00
|
|
|
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
|
|
|
}
|
2021-03-29 21:48:31 +02:00
|
|
|
}
|
2021-04-14 17:05:23 +02:00
|
|
|
|
2021-04-16 18:24:43 +02:00
|
|
|
&.gap-item:not(:nth-child(1)) {
|
2021-04-14 17:05:23 +02:00
|
|
|
margin-left: 1px;
|
|
|
|
}
|
2021-03-29 21:48:31 +02:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
2021-04-16 18:24:43 +02:00
|
|
|
<ul {id} class={className} class:border-overlap-group={!nightMode}>
|
2021-04-23 18:53:52 +02:00
|
|
|
{#each items as button}
|
2021-04-08 22:11:50 +02:00
|
|
|
{#if !button.hidden}
|
2021-04-16 18:24:43 +02:00
|
|
|
<li class:gap-item={nightMode}>
|
2021-04-08 22:11:50 +02:00
|
|
|
<svelte:component this={button.component} {...filterHidden(button)} />
|
|
|
|
</li>
|
|
|
|
{/if}
|
2021-03-30 00:51:44 +02:00
|
|
|
{/each}
|
|
|
|
</ul>
|