Add light and system themes next to dark
PageHeader.Theme now has three values (ThemeDark, ThemeLight, ThemeSystem). "system" follows prefers-color-scheme. Unset Theme is still the dark palette, but every block now also sets color-scheme, so native controls and scrollbars match it. TestThemeBlocksInSync keeps the duplicated light values and the property lists in step. Persisting the choice stays the consumer's job (README, Theming). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
000bb42240
commit
6b40ff059c
4 files changed
+158
-72
No files matched your search
+66
-32
@@ -7,17 +7,21 @@
|
||||
|
||||
The palette is exposed as --yw-* custom properties, not baked into
|
||||
each rule -- a documented, reusable theme, not an implementation
|
||||
detail. Exactly one theme ships today ("dark"); PageHeader.Theme
|
||||
(see layout.go) renders as <html data-theme="...">, which is the seam
|
||||
a second theme slots into: add its own :root[data-theme="..."] block
|
||||
below with the same property list, new values -- nothing else in this
|
||||
module changes, and unset Theme (every current consumer) keeps
|
||||
resolving to the bare :root block, i.e. today's exact look. A project
|
||||
needing a genuinely different look (not just a different accent)
|
||||
should not redefine these globally -- see README.md's Theming
|
||||
section. */
|
||||
detail. Three values for PageHeader.Theme (see layout.go), rendered
|
||||
as <html data-theme="...">: "dark", "light", and "system" (follows
|
||||
the browser's prefers-color-scheme). Unset Theme (every consumer
|
||||
that never sets it) resolves to the bare :root block, i.e. dark --
|
||||
today's exact look. A consumer's own stylesheet that needs
|
||||
theme-dependent colors mirrors the same selector structure for its
|
||||
own custom properties instead of redefining these -- see README.md's
|
||||
Theming section. */
|
||||
|
||||
:root {
|
||||
/* Dark: the default (bare :root), explicit "dark", and "system" unless
|
||||
the media query below switches it to light. */
|
||||
:root,
|
||||
:root[data-theme="dark"],
|
||||
:root[data-theme="system"] {
|
||||
color-scheme: dark;
|
||||
--yw-bg: #1a1d23;
|
||||
--yw-text: #d4d8e0;
|
||||
--yw-border: #333;
|
||||
@@ -42,35 +46,65 @@
|
||||
--bs-border-color: var(--yw-border);
|
||||
}
|
||||
|
||||
/* Theme: "dark" -- explicit opt-in via PageHeader.Theme = "dark",
|
||||
byte-identical to the bare :root block above (which is what unset
|
||||
Theme resolves to). Kept in sync manually -- there are only ever a
|
||||
handful of themes here, a preprocessor would be overkill. */
|
||||
:root[data-theme="dark"] {
|
||||
--yw-bg: #1a1d23;
|
||||
--yw-text: #d4d8e0;
|
||||
--yw-border: #333;
|
||||
--yw-chrome-bg: #14171e;
|
||||
--yw-chrome-border: #272d3a;
|
||||
--yw-accent: #4fc3f7;
|
||||
--yw-accent-rgb: 79, 195, 247;
|
||||
/* Light: explicit "light", and "system" on a light-preferring browser.
|
||||
The two blocks are kept identical by hand -- CSS can't share one
|
||||
declaration block between a plain rule and a media query.
|
||||
--yw-nav-link stays #0b82b8 (a cross-project design token, see the
|
||||
meta-repo AGENTS.md); it reads fine on both backgrounds. */
|
||||
:root[data-theme="light"] {
|
||||
color-scheme: light;
|
||||
--yw-bg: #f4f6f9;
|
||||
--yw-text: #1f2530;
|
||||
--yw-border: #d3d9e2;
|
||||
--yw-chrome-bg: #ffffff;
|
||||
--yw-chrome-border: #dde2ea;
|
||||
--yw-accent: #0a72a3;
|
||||
--yw-accent-rgb: 10, 114, 163;
|
||||
--yw-nav-link: #0b82b8;
|
||||
--yw-nav-link-hover-text: #c8d4e4;
|
||||
--yw-subtitle: #5a7a9a;
|
||||
--yw-subtitle-sep: #333c4a;
|
||||
--yw-footer-text: #4a5a72;
|
||||
--yw-success-bg: #192e22;
|
||||
--yw-success-border: #2a5c3a;
|
||||
--yw-success-text: #7ecf98;
|
||||
--yw-danger-bg: #2e1820;
|
||||
--yw-danger-border: #5c2a32;
|
||||
--yw-danger-text: #e08090;
|
||||
--yw-nav-link-hover-text: #0a4f72;
|
||||
--yw-subtitle: #5a7088;
|
||||
--yw-subtitle-sep: #c3cad5;
|
||||
--yw-footer-text: #6a7a90;
|
||||
--yw-success-bg: #e5f4ea;
|
||||
--yw-success-border: #a6d4b4;
|
||||
--yw-success-text: #1c5e33;
|
||||
--yw-danger-bg: #fbe9ec;
|
||||
--yw-danger-border: #e6b0b8;
|
||||
--yw-danger-text: #9b2335;
|
||||
|
||||
--bs-body-bg: var(--yw-bg);
|
||||
--bs-body-color: var(--yw-text);
|
||||
--bs-border-color: var(--yw-border);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root[data-theme="system"] {
|
||||
color-scheme: light;
|
||||
--yw-bg: #f4f6f9;
|
||||
--yw-text: #1f2530;
|
||||
--yw-border: #d3d9e2;
|
||||
--yw-chrome-bg: #ffffff;
|
||||
--yw-chrome-border: #dde2ea;
|
||||
--yw-accent: #0a72a3;
|
||||
--yw-accent-rgb: 10, 114, 163;
|
||||
--yw-nav-link: #0b82b8;
|
||||
--yw-nav-link-hover-text: #0a4f72;
|
||||
--yw-subtitle: #5a7088;
|
||||
--yw-subtitle-sep: #c3cad5;
|
||||
--yw-footer-text: #6a7a90;
|
||||
--yw-success-bg: #e5f4ea;
|
||||
--yw-success-border: #a6d4b4;
|
||||
--yw-success-text: #1c5e33;
|
||||
--yw-danger-bg: #fbe9ec;
|
||||
--yw-danger-border: #e6b0b8;
|
||||
--yw-danger-text: #9b2335;
|
||||
|
||||
--bs-body-bg: var(--yw-bg);
|
||||
--bs-body-color: var(--yw-text);
|
||||
--bs-border-color: var(--yw-border);
|
||||
}
|
||||
}
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user