Add a dark mode toggle

Personal, per-browser preference (localStorage), not an admin-wide
Display setting like date/time format — every role can pick their own.
Sets data-bs-theme on <html> to hook into Tabler's built-in dark
variant, applied via an inline script in index.html before React
mounts so there's no light-mode flash on load. Toggle button lives in
the sidebar footer next to Sign out.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5 committed 2026-09-19 01:51:59 +02:00
1 parent 82ed25b63f
commit 5c35080e22
3 files changed
+48

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
export type Theme = "light" | "dark";
const THEME_KEY = "hlm-theme";
export function getTheme(): Theme {
return document.documentElement.getAttribute("data-bs-theme") === "dark" ? "dark" : "light";
}
export function setTheme(theme: Theme): void {
document.documentElement.setAttribute("data-bs-theme", theme);
try {
localStorage.setItem(THEME_KEY, theme);
} catch {
// localStorage unavailable (private browsing etc.) — theme still applies for this page load
}
}