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-10-26 00:43:02 +02:00
|
|
|
<script lang="ts">
|
2021-04-22 14:32:44 +02:00
|
|
|
import { onMount, createEventDispatcher, getContext } from "svelte";
|
2021-06-30 19:55:56 +02:00
|
|
|
import { nightModeKey } from "./context-keys";
|
2021-04-14 19:36:41 +02:00
|
|
|
|
2021-05-07 15:10:28 +02:00
|
|
|
export let id: string | undefined = undefined;
|
2021-04-28 22:15:24 +02:00
|
|
|
let className = "";
|
|
|
|
export { className as class };
|
2021-04-01 01:22:06 +02:00
|
|
|
|
2021-05-07 15:10:28 +02:00
|
|
|
export let tooltip: string | undefined = undefined;
|
2021-06-25 18:09:58 +02:00
|
|
|
export let tabbable: boolean = false;
|
2021-04-14 19:36:41 +02:00
|
|
|
|
2021-04-22 14:32:44 +02:00
|
|
|
let buttonRef: HTMLButtonElement;
|
|
|
|
|
2021-04-14 19:36:41 +02:00
|
|
|
const nightMode = getContext(nightModeKey);
|
2021-04-22 14:32:44 +02:00
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
onMount(() => dispatch("mount", { button: buttonRef }));
|
2021-04-01 01:22:06 +02:00
|
|
|
</script>
|
|
|
|
|
2021-05-26 01:21:33 +02:00
|
|
|
<button
|
|
|
|
{id}
|
2021-06-25 17:34:04 +02:00
|
|
|
tabindex={tabbable ? 0 : -1}
|
2021-05-26 01:21:33 +02:00
|
|
|
bind:this={buttonRef}
|
|
|
|
class={`btn dropdown-item ${className}`}
|
|
|
|
class:btn-day={!nightMode}
|
|
|
|
class:btn-night={nightMode}
|
|
|
|
title={tooltip}
|
|
|
|
on:click
|
2021-06-26 03:20:27 +02:00
|
|
|
on:mouseenter
|
2021-06-25 00:49:17 +02:00
|
|
|
on:focus
|
|
|
|
on:keydown
|
2021-05-26 01:21:33 +02:00
|
|
|
on:mousedown|preventDefault
|
|
|
|
>
|
|
|
|
<slot />
|
|
|
|
</button>
|
|
|
|
|
2021-04-14 19:36:41 +02:00
|
|
|
<style lang="scss">
|
2021-10-09 02:25:03 +02:00
|
|
|
@use "sass/button-mixins" as button;
|
2021-04-14 19:36:41 +02:00
|
|
|
|
|
|
|
button {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
2021-04-28 22:15:24 +02:00
|
|
|
|
2021-05-27 17:13:36 +02:00
|
|
|
font-size: calc(var(--buttons-size) / 2.3);
|
2021-05-24 19:53:30 +02:00
|
|
|
|
|
|
|
background: none;
|
2021-06-25 00:49:17 +02:00
|
|
|
box-shadow: none !important;
|
2021-05-24 19:53:30 +02:00
|
|
|
border: none;
|
2021-04-14 19:36:41 +02:00
|
|
|
|
2021-06-25 18:09:58 +02:00
|
|
|
&:active,
|
|
|
|
&.active {
|
2021-04-16 18:14:09 +02:00
|
|
|
background-color: button.$focus-color;
|
2021-04-14 19:36:41 +02:00
|
|
|
color: white;
|
2021-04-16 18:14:09 +02:00
|
|
|
}
|
|
|
|
}
|
2021-04-14 19:36:41 +02:00
|
|
|
|
2021-06-29 01:37:23 +02:00
|
|
|
.btn-day {
|
|
|
|
color: black;
|
|
|
|
}
|
|
|
|
|
2021-04-16 18:14:09 +02:00
|
|
|
.btn-night {
|
|
|
|
color: white;
|
2021-04-14 19:36:41 +02:00
|
|
|
|
2021-04-16 18:14:09 +02:00
|
|
|
&:hover,
|
2021-06-29 01:37:23 +02:00
|
|
|
&:focus {
|
2021-04-16 18:14:09 +02:00
|
|
|
@include button.btn-night-base;
|
2021-04-14 19:36:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|