From 51cce2ee9f1f5846e98423c528fbd14bd6f5e1e0 Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Thu, 28 Nov 2024 23:30:14 +0100 Subject: [PATCH] Add color mode switcher --- src/components/ColorSchemeSwitcher.svelte | 53 +++++++++++++++++++++++ src/lib/style/app.scss | 2 +- src/routes/+layout.svelte | 2 + 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/components/ColorSchemeSwitcher.svelte diff --git a/src/components/ColorSchemeSwitcher.svelte b/src/components/ColorSchemeSwitcher.svelte new file mode 100644 index 0000000..49e3175 --- /dev/null +++ b/src/components/ColorSchemeSwitcher.svelte @@ -0,0 +1,53 @@ + + + + + {theme === 'auto' ? '🌗' : theme === 'dark' ? '🌙' : '☀️'} + + + setTheme('light')} + >☀️ Light + setTheme('dark')}>🌙 Dark + setTheme('auto')}>🌗 Auto + + diff --git a/src/lib/style/app.scss b/src/lib/style/app.scss index 00bf40b..0fd0702 100644 --- a/src/lib/style/app.scss +++ b/src/lib/style/app.scss @@ -9,7 +9,7 @@ @import './satsymbol'; -$color-mode-type: media-query; +$color-mode-type: data; $font-family-base: 'Ubuntu'; $font-size-base: 0.9rem; $input-font-size-sm: $font-size-base * 0.875; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index a34ea20..494ab86 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -15,6 +15,7 @@ import { page } from '$app/stores'; import { locale, locales, isLoading } from 'svelte-i18n'; + import ColorSchemeSwitcher from '../components/ColorSchemeSwitcher.svelte'; export const setLocale = (lang: string) => () => { locale.set(lang); @@ -88,6 +89,7 @@ {/if} +