Something went wrong. Try again.
Tour the Atmosphere. Switch clients, share universal links, browse any PDS. forked from atpota.to/aturi
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940export type Theme = 'dark' | 'light';
export const THEME_STORAGE_KEY = 'aturi.theme';export const DEFAULT_THEME: Theme = 'dark';
export function isTheme(value: unknown): value is Theme { return value === 'dark' || value === 'light';}
export function getStoredTheme(): Theme { if (typeof window === 'undefined') return DEFAULT_THEME; try { const raw = window.localStorage.getItem(THEME_STORAGE_KEY); return isTheme(raw) ? raw : DEFAULT_THEME; } catch { return DEFAULT_THEME; }}
export function setStoredTheme(theme: Theme): void { if (typeof window === 'undefined') return; try { window.localStorage.setItem(THEME_STORAGE_KEY, theme); } catch { // localStorage can throw in private modes; ignore. }}
export function applyTheme(theme: Theme): void { if (typeof document === 'undefined') return; document.documentElement.dataset.theme = theme;}
/** * Inline script body, stringified for injection into <head>. Runs before * React hydrates so the saved theme is applied without a flash. Falls back * to the dark default when localStorage is unavailable or unparseable. */export const THEME_INIT_SCRIPT = `(function(){try{var t=localStorage.getItem('${THEME_STORAGE_KEY}');if(t!=='dark'&&t!=='light')t='${DEFAULT_THEME}';document.documentElement.setAttribute('data-theme',t);}catch(e){document.documentElement.setAttribute('data-theme','${DEFAULT_THEME}');}})();`;