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
@@ -29,6 +29,13 @@ var staticFS embed.FS
|
||||
// base/navbar/sidebar/footer templates.
|
||||
const LayoutGlob = "templates/layout/*.tmpl"
|
||||
|
||||
// Values for PageHeader.Theme; each has its own block in static/style.css.
|
||||
const (
|
||||
ThemeDark = "dark"
|
||||
ThemeLight = "light"
|
||||
ThemeSystem = "system"
|
||||
)
|
||||
|
||||
// NavItem is one sidebar entry.
|
||||
type NavItem struct {
|
||||
ID string // matches PageHeader.ActiveNav to mark this item active
|
||||
@@ -53,16 +60,11 @@ type PageHeader struct {
|
||||
AppName string
|
||||
Lang string // <html lang="...">; "" defaults to "en"
|
||||
// Theme selects which --yw-* token block static/style.css applies,
|
||||
// rendered as <html data-theme="...">. "" omits the attribute, which
|
||||
// resolves to the bare :root values -- today that's the only theme
|
||||
// this module ships (dark), so leaving Theme unset is exactly today's
|
||||
// behavior for every current consumer. Setting Theme: "dark" is
|
||||
// equivalent (an explicit :root[data-theme="dark"] block exists with
|
||||
// the same values) -- it's the seam a future second theme (e.g.
|
||||
// "light") would slot into: add its own :root[data-theme="..."]
|
||||
// block to static/style.css, nothing else in this module changes,
|
||||
// and consuming projects opt in per-request/per-user by setting this
|
||||
// field (see README.md's Theming section).
|
||||
// rendered as <html data-theme="...">: ThemeDark, ThemeLight or
|
||||
// ThemeSystem (follows prefers-color-scheme). "" omits the attribute,
|
||||
// which resolves to the bare :root values (dark), so a consumer that
|
||||
// never sets Theme keeps its look. Persisting a user's choice is the
|
||||
// consumer's concern (see README.md's Theming section).
|
||||
Theme string
|
||||
Brand string // navbar brand text, e.g. "YASTA"
|
||||
BrandInitial string // single-letter favicon glyph, e.g. "y"
|
||||
|
||||
Reference in new issue
Block a user