portfolio_site/src/routes/+layout.svelte

93 lines
2.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-22 18:08:27 +02:00
import { site } from '$lib/config';
2025-01-31 20:20:07 +02:00
import { onMount } from 'svelte';
2025-01-21 15:22:19 +02:00
2025-01-18 23:06:09 +02:00
let { children } = $props();
let theme: string = $state('system');
2025-01-31 20:20:07 +02:00
let email: string | undefined = $state(undefined);
const cycleTheme = () => {
if (theme === 'dark') {
theme = 'light';
setMode('light');
} else if (theme === 'light') {
theme = 'system';
resetMode();
} else {
theme = 'dark';
setMode('dark');
}
};
2025-01-31 20:20:07 +02:00
onMount(() => {
email = site.email;
});
2025-01-18 23:06:09 +02:00
</script>
<svelte:head>
2025-01-22 18:08:27 +02:00
<meta name="author" content={site.author} />
</svelte:head>
2025-01-21 15:22:19 +02:00
<ModeWatcher />
2025-01-30 15:49:45 +02:00
<div class="grid min-h-screen grid-rows-[auto_1fr_auto]">
<header class="container flex w-full items-center justify-between px-8 py-6">
<a href="/">
<img src="/favicon.svg" alt="Mihkel Martin Kasterpalu logo" class="h-9" />
</a>
<a class="font-mono font-medium underline underline-offset-4" href="/vinge"> vinge värk </a>
2025-01-30 15:49:45 +02:00
<Button onclick={() => cycleTheme()} variant="ghost" size="icon" class="h-12 w-12">
{#if theme === 'dark'}
<Moon class="!h-6 !w-6" />
2025-01-30 15:49:45 +02:00
{:else if theme === 'light'}
<Sun class="!h-6 !w-6" />
2025-01-30 15:49:45 +02:00
{:else}
<LaptopMinimal class="!h-6 !w-6" />
2025-01-30 15:49:45 +02:00
{/if}
<span class="sr-only">Toggle theme</span>
</Button>
</header>
<div class="container relative mt-16 flex flex-col items-center">
2025-01-30 15:49:45 +02:00
{@render children()}
</div>
2025-01-31 20:20:07 +02:00
<footer class="container flex w-full justify-between px-9 py-6">
2025-01-30 16:08:24 +02:00
<a
href="https://koodi.lenn.uk/mihkelmk/portfolio_site"
2025-01-30 16:08:24 +02:00
target="_blank"
2025-01-31 20:20:07 +02:00
class="text-sm text-muted-foreground underline underline-offset-4"
2025-01-30 16:08:24 +02:00
>
saidi kood
</a>
2025-01-31 20:20:07 +02:00
{#if email}
<a
href="mailto://{email}"
target="_blank"
class="text-right text-sm text-muted-foreground underline underline-offset-4"
>
{email}
</a>
{:else}
<p class="text-sm text-muted-foreground">
{'<email_protected>'}
</p>
{/if}
2025-01-30 15:49:45 +02:00
</footer>
2025-01-22 16:04:16 +02:00
</div>