feat: unify card runtime and event-driven web ui
Some checks failed
CI / Backend Checks (push) Failing after 36s
CI / Frontend Checks (push) Failing after 40s

This commit is contained in:
kacper 2026-04-06 15:42:53 -04:00
parent 0edf8c3fef
commit 4dfb7ca3cc
105 changed files with 17382 additions and 8505 deletions

View file

@ -0,0 +1,30 @@
import { useEffect, useMemo, useState } from "preact/hooks";
import {
applyThemeToDocument,
DEFAULT_THEME,
getStoredThemeName,
THEME_OPTIONS,
THEME_STORAGE_KEY,
type ThemeName,
} from "./themes";
export function useThemePreference() {
const [themeName, setThemeName] = useState<ThemeName>(() => {
if (typeof window === "undefined") return DEFAULT_THEME;
return getStoredThemeName();
});
useEffect(() => {
applyThemeToDocument(themeName);
window.localStorage.setItem(THEME_STORAGE_KEY, themeName);
}, [themeName]);
return useMemo(
() => ({
themeName,
themeOptions: THEME_OPTIONS,
setThemeName,
}),
[themeName],
);
}