Files
gpx.studio/website/src/lib/components/ModeSwitch.svelte

25 lines
590 B
Svelte
Raw Normal View History

2024-07-05 01:02:53 +02:00
<script lang="ts">
import { Button } from '$lib/components/ui/button';
2025-06-21 21:07:36 +02:00
import { Moon, Sun } from '@lucide/svelte';
2025-06-08 16:32:41 +02:00
import { mode, setMode } from 'mode-watcher';
2025-06-21 21:07:36 +02:00
import { i18n } from '$lib/i18n.svelte';
2024-07-05 01:02:53 +02:00
export let size = '20';
2024-07-05 01:02:53 +02:00
</script>
2024-07-07 18:26:52 +02:00
<Button
variant="ghost"
2025-06-21 21:07:36 +02:00
size="icon"
class="h-8 px-1.5 {$$props.class ?? ''}"
2025-06-21 21:07:36 +02:00
onclick={() => {
2025-06-08 16:32:41 +02:00
setMode(mode.current === 'light' ? 'dark' : 'light');
}}
2025-06-21 21:07:36 +02:00
aria-label={i18n._('menu.mode')}
2024-07-07 18:26:52 +02:00
>
2025-06-08 16:32:41 +02:00
{#if mode.current === 'light'}
<Sun {size} />
{:else}
<Moon {size} />
{/if}
2024-07-07 18:26:52 +02:00
</Button>