diff options
| author | Bobby <[email protected]> | 2026-04-22 08:43:21 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-04-22 08:43:21 +0530 |
| commit | aecac4e697deebfb01d2adbd57416b8271460b5b (patch) | |
| tree | e1077ed14f7c66696c4aaf0d9412415c8581c017 /lib/components/ToggleSwitch.svelte | |
| parent | 0423e12d4b38727ffc37f403f5b8bdedb148e711 (diff) | |
| download | hollowdark-aecac4e697deebfb01d2adbd57416b8271460b5b.tar.xz hollowdark-aecac4e697deebfb01d2adbd57416b8271460b5b.zip | |
Add Settings screen with mute toggle and ambient volume slider
Diffstat (limited to 'lib/components/ToggleSwitch.svelte')
| -rw-r--r-- | lib/components/ToggleSwitch.svelte | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/components/ToggleSwitch.svelte b/lib/components/ToggleSwitch.svelte new file mode 100644 index 0000000..9536d6d --- /dev/null +++ b/lib/components/ToggleSwitch.svelte @@ -0,0 +1,60 @@ +<script lang="ts"> + interface Props { + value: boolean + label: string + onChange: (value: boolean) => void + } + + let { value, label, onChange }: Props = $props() + + function handleClick(): void { + onChange(!value) + } +</script> + +<button + type="button" + role="switch" + aria-checked={value} + aria-label={label} + class="toggle" + class:on={value} + onclick={handleClick} +> + <span class="thumb"></span> +</button> + +<style> + .toggle { + position: relative; + width: 38px; + height: 20px; + border-radius: 999px; + background: rgba(232, 226, 213, 0.08); + border: 1px solid rgba(232, 226, 213, 0.12); + transition: + background var(--transition-fast), + border-color var(--transition-fast); + } + + .toggle.on { + background: var(--color-accent); + border-color: var(--color-accent); + } + + .thumb { + position: absolute; + top: 2px; + left: 2px; + width: 14px; + height: 14px; + border-radius: 50%; + background: var(--color-text); + transition: transform var(--transition-fast); + } + + .toggle.on .thumb { + transform: translateX(18px); + background: var(--color-bg); + } +</style> |
