anki/ts/components/LabelButton.svelte
Matthias Metelka 0a3ac591e6
Flatten buttons to match macOS style (#2159)
* Use button gradient only on hover

* Apply hover effect to main window buttons

* Apply arbitrary change to force recreation of colors.py

* Undo arbitrary change to fix props not being created

* Remember that the comments are used for regex matching

* Yet another try

* Revert "Yet another try"

This reverts commit eaef4805c1618cf93ac2f93bc14ada900dc6d155.

* Update _root-vars.scss
2022-11-02 20:39:30 +10:00

58 lines
1.4 KiB
Svelte

<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import { createEventDispatcher, onMount } from "svelte";
export let id: string | undefined = undefined;
let className: string = "";
export { className as class };
export let primary = false;
export let tooltip: string | undefined = undefined;
export let active = false;
export let disabled = false;
export let tabbable = false;
let buttonRef: HTMLButtonElement;
const dispatch = createEventDispatcher();
onMount(() => dispatch("mount", { button: buttonRef }));
</script>
<button
bind:this={buttonRef}
{id}
class="label-button {className}"
class:active
class:primary
title={tooltip}
{disabled}
tabindex={tabbable ? 0 : -1}
on:click
on:mousedown|preventDefault
>
<slot />
</button>
<style lang="scss">
@use "sass/button-mixins" as button;
.label-button {
@include button.base($active-class: active);
&.primary {
@include button.base($primary: true);
}
@include button.border-radius;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding: 0 calc(var(--buttons-size) / 3);
font-size: var(--base-font-size);
width: auto;
height: var(--buttons-size);
}
</style>