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-27 21:01:44 +02:00
|
|
|
import { setContext, getContext } from "svelte";
|
|
|
|
import { nightModeKey, buttonGroupKey } 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-27 21:01:44 +02:00
|
|
|
let className = "";
|
2021-04-01 16:29:24 +02:00
|
|
|
|
2021-04-27 21:01:44 +02:00
|
|
|
export { className as class };
|
|
|
|
const nightMode = getContext(nightModeKey);
|
|
|
|
|
|
|
|
export let api = {};
|
|
|
|
|
|
|
|
let index = 0;
|
|
|
|
|
|
|
|
interface ButtonRegistration {
|
|
|
|
order: number;
|
2021-04-08 22:11:50 +02:00
|
|
|
}
|
2021-04-14 21:58:58 +02:00
|
|
|
|
2021-04-27 21:01:44 +02:00
|
|
|
function registerButton(): ButtonRegistration {
|
|
|
|
index++;
|
|
|
|
return { order: index };
|
|
|
|
}
|
|
|
|
|
2021-04-27 22:35:25 +02:00
|
|
|
setContext(
|
|
|
|
buttonGroupKey,
|
|
|
|
Object.assign(api, {
|
|
|
|
registerButton,
|
|
|
|
})
|
|
|
|
);
|
2021-03-29 21:48:31 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2021-04-27 17:20:13 +02:00
|
|
|
div {
|
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-03-29 21:48:31 +02:00
|
|
|
|
2021-04-23 22:22:53 +02:00
|
|
|
padding: calc(var(--toolbar-size) / 10);
|
|
|
|
margin: 0;
|
2021-03-29 21:48:31 +02:00
|
|
|
|
2021-04-27 17:20:13 +02:00
|
|
|
> :global(button),
|
|
|
|
> :global(select) {
|
|
|
|
border-radius: calc(var(--toolbar-size) / 7.5);
|
|
|
|
|
|
|
|
&:not(:nth-of-type(1)) {
|
|
|
|
border-top-left-radius: 0;
|
|
|
|
border-bottom-left-radius: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:not(:nth-last-of-type(1)) {
|
|
|
|
border-top-right-radius: 0;
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-04-23 21:42:44 +02:00
|
|
|
|
|
|
|
&.gap-group {
|
|
|
|
:global(button),
|
|
|
|
:global(select) {
|
|
|
|
margin-left: 1px;
|
|
|
|
}
|
|
|
|
}
|
2021-04-14 21:58:58 +02:00
|
|
|
}
|
2021-03-29 21:48:31 +02:00
|
|
|
</style>
|
|
|
|
|
2021-04-27 17:20:13 +02:00
|
|
|
<div
|
2021-04-23 21:42:44 +02:00
|
|
|
{id}
|
|
|
|
class={className}
|
|
|
|
class:border-overlap-group={!nightMode}
|
2021-04-27 17:20:13 +02:00
|
|
|
class:gap-group={nightMode}
|
|
|
|
div="ltr">
|
2021-04-27 21:01:44 +02:00
|
|
|
<slot />
|
2021-04-27 17:20:13 +02:00
|
|
|
</div>
|