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">
|
2022-09-10 10:46:59 +02:00
|
|
|
import { createEventDispatcher, onMount } from "svelte";
|
2022-02-04 09:36:34 +01:00
|
|
|
|
2021-05-05 01:22:51 +02:00
|
|
|
export let id: string | undefined = undefined;
|
|
|
|
let className: string = "";
|
|
|
|
export { className as class };
|
2022-09-27 04:16:45 +02:00
|
|
|
export let primary = false;
|
2021-04-22 14:18:48 +02:00
|
|
|
|
2021-05-06 20:48:11 +02:00
|
|
|
export let tooltip: string | undefined = undefined;
|
|
|
|
export let active = false;
|
2021-07-05 18:15:03 +02:00
|
|
|
export let disabled = false;
|
2021-05-05 01:22:51 +02:00
|
|
|
export let tabbable = false;
|
2021-04-09 22:02:34 +02:00
|
|
|
|
2021-05-05 01:22:51 +02:00
|
|
|
let buttonRef: HTMLButtonElement;
|
|
|
|
|
2021-04-14 16:26:23 +02:00
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
onMount(() => dispatch("mount", { button: buttonRef }));
|
2021-03-25 23:32:23 +01:00
|
|
|
</script>
|
2021-03-29 14:54:10 +02:00
|
|
|
|
2021-05-26 01:21:33 +02:00
|
|
|
<button
|
|
|
|
bind:this={buttonRef}
|
|
|
|
{id}
|
2022-09-27 04:16:45 +02:00
|
|
|
class="label-button {className}"
|
2021-05-26 01:21:33 +02:00
|
|
|
class:active
|
2022-09-27 04:16:45 +02:00
|
|
|
class:primary
|
2021-05-26 01:21:33 +02:00
|
|
|
title={tooltip}
|
2021-07-05 18:15:03 +02:00
|
|
|
{disabled}
|
2021-05-26 01:21:33 +02:00
|
|
|
tabindex={tabbable ? 0 : -1}
|
|
|
|
on:click
|
|
|
|
on:mousedown|preventDefault
|
|
|
|
>
|
|
|
|
<slot />
|
|
|
|
</button>
|
|
|
|
|
2021-03-25 23:32:23 +01:00
|
|
|
<style lang="scss">
|
2021-10-09 02:25:03 +02:00
|
|
|
@use "sass/button-mixins" as button;
|
2021-04-14 15:45:14 +02:00
|
|
|
|
2021-03-25 23:32:23 +01:00
|
|
|
button {
|
2022-09-27 04:16:45 +02:00
|
|
|
@include button.base($active-class: active);
|
|
|
|
&.primary {
|
|
|
|
@include button.base($primary: true);
|
|
|
|
}
|
|
|
|
@include button.border-radius;
|
|
|
|
|
2021-11-24 03:09:55 +01:00
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
2021-05-27 17:13:36 +02:00
|
|
|
padding: 0 calc(var(--buttons-size) / 3);
|
2021-10-31 00:29:22 +02:00
|
|
|
font-size: var(--base-font-size);
|
2021-04-14 15:45:14 +02:00
|
|
|
width: auto;
|
2021-05-27 17:13:36 +02:00
|
|
|
height: var(--buttons-size);
|
2021-03-25 23:32:23 +01:00
|
|
|
}
|
|
|
|
</style>
|