React 19 + Vite 8 + TanStack Router SPA for browsing and chatting with a self-hosted Honcho instance. Configurable base URL stored in localStorage only. Dark/light theme, framer-motion animations, lucide-react icons.
15 lines
487 B
TypeScript
15 lines
487 B
TypeScript
const THEME_KEY = "honcho-ui:theme";
|
|
|
|
export type Theme = "dark" | "light";
|
|
|
|
export function getStoredTheme(): Theme {
|
|
const stored = localStorage.getItem(THEME_KEY) as Theme | null;
|
|
if (stored === "dark" || stored === "light") return stored;
|
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
}
|
|
|
|
export function applyTheme(theme: Theme): void {
|
|
document.documentElement.setAttribute("data-theme", theme);
|
|
localStorage.setItem(THEME_KEY, theme);
|
|
}
|