import {Injectable, EventEmitter} from '@angular/core'; export interface SiteTheme { name: string; displayName?: string; accent: string; primary: string; isDark?: boolean; isDefault?: boolean; } @Injectable({providedIn: 'root'}) export class ThemeStorage { static storageKey = 'ThemePickerExample-theme'; onThemeUpdate: EventEmitter = new EventEmitter(); storeTheme(theme: SiteTheme) { try { window.localStorage[ThemeStorage.storageKey] = theme.name; } catch { } this.onThemeUpdate.emit(theme); } getStoredThemeName(): string | null { try { return window.localStorage[ThemeStorage.storageKey] || null; } catch { return null; } } clearStorage() { try { window.localStorage.removeItem(ThemeStorage.storageKey); } catch { } } }