From f9aadaf4926a8b74998b274c60eec2a350eb5702 Mon Sep 17 00:00:00 2001 From: Dallas Hoffman Date: Tue, 26 Sep 2023 00:21:51 -0400 Subject: [PATCH] Change app theme color with theme toggle --- src/app.html | 2 +- src/lib/stores/theme.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app.html b/src/app.html index c4e1f27..05dd9af 100644 --- a/src/app.html +++ b/src/app.html @@ -19,7 +19,7 @@ - + %sveltekit.head% diff --git a/src/lib/stores/theme.ts b/src/lib/stores/theme.ts index 3505eec..69fb865 100644 --- a/src/lib/stores/theme.ts +++ b/src/lib/stores/theme.ts @@ -9,9 +9,12 @@ export class ThemeStore implements Readable { ); constructor() { + const themeMetaTag = document.querySelector('meta[name="theme-color"]'); + this.theme.subscribe((newTheme) => { document.documentElement.dataset.theme = newTheme; localStorage.setItem('theme', newTheme); + themeMetaTag?.setAttribute('content', newTheme === 'dark' ? '#18232c' : '#fbfbfc'); }); }