feat(web): system theme option — follow the OS prefers-color-scheme (stretch of #67)#90
Open
dchaudhari7177 wants to merge 2 commits into
Open
feat(web): system theme option — follow the OS prefers-color-scheme (stretch of #67)#90dchaudhari7177 wants to merge 2 commits into
dchaudhari7177 wants to merge 2 commits into
Conversation
…xterm palette - theme.ts: ThemeName gains "light"; TERMINAL_BG/THEME_COLOR entries; loadTheme keeps the stored-value validation (unknown values fall back to dark); applyTheme sets data-theme="light" (dark still removes the attribute). - tokens.css: [data-theme="light"] ink→paper surface palette. Text 15.9:1 / 6.2:1 / 4.7:1 on the paper bg; coral used AS text/status darkens to #c2481d (4.6:1, WCAG AA) while coral FILLS (primary buttons, brand glyph) keep brand coral with dark ink (7:1). color-scheme: light flips form controls. - SettingsPanel: the OLED checkbox becomes a three-way Theme select (Dark / True black / Light) using the existing rc-settings__field + select idiom; still applies instantly via setTheme. - TerminalView: a full LIGHT_THEME xterm palette (ink-on-paper defaults, ANSI hues darkened to >= 4.5:1); terminalTheme() picks the palette at mount and on rc-theme-change, so an open terminal restyles live without a remount. - Tests: light round-trip + unknown-value fallback, theme-color meta for light, TERMINAL_BG covers all three themes. 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).