add: dynamic themes and streamlined theme creation system
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user