anki/ts/editor-toolbar/InnerButton.svelte
2021-04-15 13:09:49 +02:00

57 lines
1.1 KiB
Svelte

<script lang="typescript">
export let className: string = "";
export let onClick: (event: ClickEvent) => void;
export let active = false;
export let disabled = false;
</script>
<style lang="scss">
button {
display: inline-block;
vertical-align: middle;
width: 28px;
height: 28px;
background-color: white;
& > :global(svg),
& > :global(img) {
vertical-align: unset;
width: 100%;
height: 100%;
}
&:hover {
background-color: #eee;
}
&:active,
&.active {
box-shadow: inset 0 0 10px 3px rgb(0 0 0 / 30%);
}
&[disabled] {
opacity: 0.4;
&:hover {
background-color: white;
}
&:active,
&.active {
box-shadow: none;
}
}
}
</style>
<button
class="p-1 {className}"
class:active
tabindex="-1"
{disabled}
on:click={onClick}
on:mousedown|preventDefault>
<slot />
</button>