diff --git a/src/app.css b/src/app.css index 193a062..b761127 100644 --- a/src/app.css +++ b/src/app.css @@ -71,6 +71,10 @@ } } +body { + transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out; +} + @layer base { * { @apply border-border; diff --git a/src/lib/components/ThemeSwitch.svelte b/src/lib/components/ThemeSwitch.svelte new file mode 100644 index 0000000..cd4f708 --- /dev/null +++ b/src/lib/components/ThemeSwitch.svelte @@ -0,0 +1,39 @@ + + + + + diff --git a/src/lib/theme.ts b/src/lib/theme.ts new file mode 100644 index 0000000..55ad19f --- /dev/null +++ b/src/lib/theme.ts @@ -0,0 +1,13 @@ +import { writable } from 'svelte/store' +import { browser } from "$app/environment" + +type Theme = 'tokiwa' | 'star' + +const userTheme = browser && localStorage.getItem('color-scheme') + +export const theme = writable(userTheme ?? 'tokiwa') + +// set the theme +export function setTheme(newTheme: Theme) { + theme.set(newTheme) +} diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 8c0ad4f..7b2e80b 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -40,7 +40,7 @@ color: rgb(128,128,128); pointer-events: none; } - :global(a) { + :global(a), :global(button) { color: theme('colors.eucalyptus.400'); &:hover, &:focus { diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 04c862e..1b5e70d 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -2,6 +2,7 @@ import { routes } from "$lib/sitemap.ts" import { Separator } from "$lib/components/ui/separator/index.js"; import { Rss } from "lucide-svelte"; + import ThemeSwitch from "$lib/components/ThemeSwitch.svelte" let scrollPosition: number = .5; let scrollHeight: number = 1; let progress: number = 0; @@ -58,6 +59,8 @@ {/if} {/each} + + @@ -65,7 +68,7 @@
-
+
@@ -130,6 +133,7 @@ main { width: 100%; @apply bg-background; + @apply dark:bg-gray-800; box-shadow: 0px -5px 10px 10px rgba(200,200,200,0.4); } diff --git a/src/routes/Navbar.svelte b/src/routes/Navbar.svelte index cc0e47c..0f63ef0 100644 --- a/src/routes/Navbar.svelte +++ b/src/routes/Navbar.svelte @@ -2,6 +2,7 @@ import { page } from '$app/stores'; import { routes } from "$lib/sitemap.ts" import { name } from '$content/metadata.json'; + import ThemeSwitch from "$lib/components/ThemeSwitch.svelte" import { Rss } from "lucide-svelte"; function isCurrentLink(pathname, route) { @@ -19,6 +20,7 @@ class:disabled-link={item.disabled} href={item.route}>{item.name} {/each} +