diff --git a/dev/App.tsx b/dev/App.tsx index 68f7340..dfd77d9 100644 --- a/dev/App.tsx +++ b/dev/App.tsx @@ -11,6 +11,7 @@ import { validateStateAndSource, } from "../src/Activity/activityState"; import { isReportScoreByItemMessage, isReportStateMessage } from "../src/types"; +import { useResolvedTheme } from "../src/utils/theme"; import type { ThemeSetting } from "../src/utils/theme"; function App() { @@ -55,6 +56,35 @@ function App() { darkMode, } = testSettings; + // Resolve the selected dark-mode setting so the dev-harness chrome (the + // gray header box and its controls) tracks the same theme as the viewer + // below it, rather than staying light. + const resolvedTheme = useResolvedTheme(darkMode); + + // Keep the whole dev page — the body backdrop and native form controls — + // in step with the selection, not just the OS preference that index.css + // keys off of. Match the backdrop to the viewer's `--canvas` color so the + // area below/around the activities doesn't read as a lighter black. + useEffect(() => { + const root = document.documentElement; + root.style.colorScheme = resolvedTheme; + root.style.backgroundColor = + resolvedTheme === "dark" ? "#121212" : "#ffffff"; + return () => { + root.style.colorScheme = ""; + root.style.backgroundColor = ""; + }; + }, [resolvedTheme]); + + // Native