2024-06-17 21:17:27 +01:00
|
|
|
<script>
|
2024-06-28 06:19:00 +01:00
|
|
|
import { play_sound } from '../../sound.js';
|
2024-06-28 08:43:12 +01:00
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
const dispatch = createEventDispatcher();
|
2024-06-17 21:17:27 +01:00
|
|
|
|
2024-06-28 08:43:12 +01:00
|
|
|
export let type = "react";
|
|
|
|
export let label = "React";
|
2024-06-17 21:17:27 +01:00
|
|
|
export let title = label;
|
|
|
|
export let count = 0;
|
2024-06-28 08:43:12 +01:00
|
|
|
export let active = false;
|
|
|
|
export let disabled = false;
|
2024-06-17 21:17:27 +01:00
|
|
|
export let sound = "default";
|
2024-06-28 08:43:12 +01:00
|
|
|
|
|
|
|
function click() {
|
|
|
|
play_sound(sound);
|
|
|
|
dispatch('click');
|
|
|
|
}
|
2024-06-17 21:17:27 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<button
|
|
|
|
type="button"
|
2024-06-28 08:43:12 +01:00
|
|
|
class={[
|
|
|
|
type,
|
|
|
|
active ? "active" : "",
|
|
|
|
disabled ? "disabled" : "",
|
|
|
|
].join(' ')}
|
2024-06-17 21:17:27 +01:00
|
|
|
aria-label="{label}"
|
|
|
|
title="{title}"
|
2024-06-28 08:43:12 +01:00
|
|
|
on:click={click}>
|
|
|
|
<span class="icon">
|
|
|
|
<slot/>
|
|
|
|
</span>
|
2024-06-17 21:17:27 +01:00
|
|
|
{#if count}
|
|
|
|
<span class="count">{count}</span>
|
|
|
|
{/if}
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
button {
|
2024-06-19 22:13:16 +01:00
|
|
|
height: 32px;
|
2024-06-17 21:17:27 +01:00
|
|
|
padding: 6px 8px;
|
2024-06-19 22:13:16 +01:00
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
gap: 4px;
|
2024-06-17 21:17:27 +01:00
|
|
|
font-size: 1em;
|
|
|
|
background: none;
|
|
|
|
color: inherit;
|
|
|
|
border: none;
|
|
|
|
border-radius: 8px;
|
2024-06-28 08:43:12 +01:00
|
|
|
transition: background-color .1s, color .1s;
|
|
|
|
cursor: pointer;
|
2024-06-17 21:17:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
button.active {
|
2024-06-28 08:43:12 +01:00
|
|
|
background-color: color-mix(in srgb, transparent, var(--accent) 50%);
|
|
|
|
color: var(--bg-1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
button:not(.disabled):hover {
|
|
|
|
background-color: var(--bg-600);
|
|
|
|
color: var(--text);
|
2024-06-17 21:17:27 +01:00
|
|
|
}
|
|
|
|
|
2024-06-28 08:43:12 +01:00
|
|
|
button:not(.disabled):active {
|
|
|
|
background-color: var(--bg-1000);
|
|
|
|
color: var(--text);
|
2024-06-17 21:17:27 +01:00
|
|
|
}
|
|
|
|
|
2024-06-28 08:43:12 +01:00
|
|
|
button.disabled {
|
|
|
|
cursor: initial;
|
2024-06-17 21:17:27 +01:00
|
|
|
}
|
|
|
|
|
2024-06-19 22:13:16 +01:00
|
|
|
.icon {
|
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
2024-06-17 21:17:27 +01:00
|
|
|
.count {
|
|
|
|
opacity: .5;
|
|
|
|
}
|
|
|
|
|
|
|
|
button:hover .count {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
</style>
|