portfolio_site/src/routes/+layout.svelte

51 lines
1.2 KiB
Svelte
Raw Normal View History

2025-01-18 23:06:09 +02:00
<script lang="ts">
import '../app.css';
2025-01-21 15:22:19 +02:00
import '@fontsource-variable/smooch-sans';
import '@fontsource-variable/kode-mono';
2025-01-21 15:22:19 +02:00
import { ModeWatcher, resetMode, setMode } from 'mode-watcher';
2025-01-21 15:22:19 +02:00
import { Button } from '$lib/components/ui/button/index.js';
2025-01-21 15:22:19 +02:00
import Sun from 'lucide-svelte/icons/sun';
import Moon from 'lucide-svelte/icons/moon';
import LaptopMinimal from 'lucide-svelte/icons/laptop-minimal';
2025-01-21 15:22:19 +02:00
2025-01-18 23:06:09 +02:00
let { children } = $props();
let theme: string = $state('system');
const cycleTheme = () => {
if (theme === 'dark') {
theme = 'light';
setMode('light');
} else if (theme === 'light') {
theme = 'system';
resetMode();
} else {
theme = 'dark';
setMode('dark');
}
};
2025-01-18 23:06:09 +02:00
</script>
2025-01-21 15:22:19 +02:00
<ModeWatcher />
2025-01-21 18:40:40 +02:00
<header class="absolute top-0 flex w-full justify-between px-8 py-6">
2025-01-21 15:22:19 +02:00
<a href="/">
<img src="/favicon.svg" alt="Mihkel Martin Kasterpalu logo" class="h-10" />
</a>
<Button onclick={() => cycleTheme()} variant="outline" size="icon">
{#if theme === 'dark'}
<Moon class="absolute h-[1.2rem] w-[1.2rem]" />
{:else if theme === 'light'}
<Sun class="h-[1.2rem] w-[1.2rem] " />
{:else}
<LaptopMinimal class="h-[1.2rem] w-[1.2rem]" />
{/if}
2025-01-21 15:22:19 +02:00
<span class="sr-only">Toggle theme</span>
</Button>
</header>
{@render children()}