MCPcopy Create free account
hub / github.com/PaperDebugger/paperdebugger / useThemeSync

Function useThemeSync

webapp/_webapp/src/hooks/useThemeSync.ts:26–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24}
25
26export function useThemeSync(): void {
27 const themeMode = useSettingStore((s) => s.themeMode);
28
29 useEffect(() => {
30 if (themeMode === "light") {
31 applyTheme(false);
32 return;
33 }
34 if (themeMode === "dark") {
35 applyTheme(true);
36 return;
37 }
38
39 // themeMode === "auto": follow system
40 const media = window.matchMedia("(prefers-color-scheme: dark)");
41 const update = () => applyTheme(media.matches);
42 update();
43 media.addEventListener("change", update);
44 return () => media.removeEventListener("change", update);
45 }, [themeMode]);
46}

Callers 2

MainFunction · 0.90
PaperDebuggerFunction · 0.90

Calls 2

applyThemeFunction · 0.85
updateFunction · 0.70

Tested by

no test coverage detected