add: dynamic themes and streamlined theme creation system

This commit is contained in:
2025-12-14 20:06:36 +01:00
parent 152bd7cdb1
commit 23e19932d2
11 changed files with 96 additions and 102 deletions

View File

@@ -12,10 +12,8 @@ class ThemeStore {
this.current = stored || 'system';
this.applyTheme();
// Listen for system theme changes
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
mediaQuery.addEventListener('change', () => {
// Re-apply theme if in system mode
if (this.current === 'system') {
this.applyTheme();
}
@@ -37,6 +35,8 @@ class ThemeStore {
}
getResolvedTheme(): ResolvedTheme {
if (!browser) return 'light';
const isDark = this.current === 'dark' ||
(this.current === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches);
return isDark ? 'dark' : 'light';