feat(web): system theme option — follow the OS prefers-color-scheme (stretch of #67) - #90
feat(web): system theme option — follow the OS prefers-color-scheme (stretch of #67)#90dchaudhari7177 wants to merge 2 commits into
Conversation
dfb8b3f to
7692570
Compare
Three-way theme choice in Settings (Dark / True black / Light), replacing the OLED checkbox: - theme.ts: ThemeName gains "light"; stored-value validation keeps unknown values falling back to dark; applyTheme sets data-theme for any non-default theme. - tokens.css: a [data-theme=light] block — paper surfaces, ink text, darkened hairlines; the coral accent shifts to its deep value for contrast on paper; warn/err darkened for AA. The code card stays a dark panel deliberately. - TerminalView: light mode swaps the FULL xterm palette (One Light-derived), not just the background — the dark ANSI ramp would be unreadable on paper. Live switch keeps working via rc-theme-change. - theme.test.ts extended for the new value, fallback, and meta mirror. Closes burakgon#67
- theme.ts: ThemePreference = ThemeName | "system"; resolveTheme() maps "system" to light/dark via (prefers-color-scheme: light) with the AppLayout matchMedia guard idiom (jsdom/SSR falls back to dark); watchSystemTheme() re-applies + re-announces rc-theme-change on OS flips only while the preference is "system". - main.tsx: start the watcher right after the boot applyTheme. - SettingsPanel: fourth "System" option in the Theme select. - TerminalView: terminalTheme() resolves the preference, so an open terminal follows an OS scheme flip live via the re-fired rc-theme-change. - Tests: system round-trip + no-matchMedia fallback, OS-flip announce gating (vi.stubGlobal matchMedia stub with a change-listener registry). Stretch item from burakgon#67
7692570 to
102a7df
Compare
|
Same situation as #89, which this was stacked on — Closing-worthy as written, but the gap it addresses is still open. I checked Against the new design it would be a different and smaller change than what is in this branch: a stored preference of "follow the system", plus a light/dark pair of catalog theme names, with Happy to close this and open that as a fresh PR if you want it — or to close it and leave the idea alone if system-follow is not a direction you want. Your call; I would rather ask than assume, given #89 is being closed for the same reason. |
The stretch item from #67 ("a fourth system option that follows
prefers-color-scheme"), as the separate PR the issue invited.pwa/theme.ts— the stored preference and the rendered palette are now distinct types:ThemeName(dark | oled | light, what tokens.css/xterm can render) vsThemePreference(ThemeName | "system").resolveTheme()maps"system"to light/dark via(prefers-color-scheme: light), using the same defensivematchMediaguard asAppLayout.useIsDesktop(jsdom/SSR → dark).watchSystemTheme()re-applies and re-announcesrc-theme-changewhen the OS scheme flips — but only while the preference is"system", so a concrete choice never gets overridden.main.tsx— starts the watcher immediately after the bootapplyTheme, so a daylight/night OS switch restyles the app (and an open terminal, which re-reads its palette onrc-theme-change) live, no reload.SettingsPanel.tsx— a fourth System option in the Theme select; still applies instantly.Tests — extends
theme.test.ts(8 passing):"system"round-trips and resolves per a stubbedprefers-color-scheme; withoutmatchMediait falls back to dark instead of crashing; the OS-flip watcher announces only while the preference is system (vi.stubGlobalmatchMedia stub with a change-listener registry, the repo's existing idiom).Verification —
pnpm typecheckclean; theme tests 8/8. End-to-end in a real browser: with the stored preference"system", booting under an OS light scheme paints paper (data-theme="light",--bg #f6f6f7) and under an OS dark scheme paints near-black with thetheme-colormeta mirrored (#0a0a0b, attribute removed).