Change app theme color with theme toggle

This commit is contained in:
Dallas Hoffman 2023-09-26 00:21:51 -04:00
parent be1270c10e
commit f9aadaf492
No known key found for this signature in database
2 changed files with 4 additions and 1 deletions

View File

@ -19,7 +19,7 @@
<meta name="msapplication-TileColor" content="#ead40b" /> <meta name="msapplication-TileColor" content="#ead40b" />
<meta name="apple-mobile-web-app-title" content="Notes" /> <meta name="apple-mobile-web-app-title" content="Notes" />
<meta name="application-name" content="Notes" /> <meta name="application-name" content="Notes" />
<meta name="theme-color" content="#11191f" /> <meta name="theme-color" content="#18232c" />
%sveltekit.head% %sveltekit.head%
</head> </head>
<body data-sveltekit-preload-data="hover"> <body data-sveltekit-preload-data="hover">

View File

@ -9,9 +9,12 @@ export class ThemeStore implements Readable<Theme> {
); );
constructor() { constructor() {
const themeMetaTag = document.querySelector('meta[name="theme-color"]');
this.theme.subscribe((newTheme) => { this.theme.subscribe((newTheme) => {
document.documentElement.dataset.theme = newTheme; document.documentElement.dataset.theme = newTheme;
localStorage.setItem('theme', newTheme); localStorage.setItem('theme', newTheme);
themeMetaTag?.setAttribute('content', newTheme === 'dark' ? '#18232c' : '#fbfbfc');
}); });
} }