Prepare theming: PageHeader.Theme -> <html data-theme>, explicit dark block

Zero behavior change for every current consumer (Theme defaults to "",
which resolves to the unchanged bare :root block). Adds the seam a
future second theme slots into: its own :root[data-theme="..."] block
in static/style.css, nothing else in this module changes. See
README.md's expanded Theming section for the concrete mechanism.
This commit is contained in:
terminar committed 2026-09-01 22:24:58 +02:00
1 parent adea139888
commit 8875062fc5
5 files changed
+123 -34

No files matched your search

+17 -4
View File
@@ -1,6 +1,7 @@
// Package layout provides the shared server-rendered web UI chrome (base
// layout, navbar, sidebar, footer) used by every Yetano/Yak/Yamase
// ops-tool admin dashboard: yasta, yasl, yaiam, yakwui, and yamase-web.
// ops-tool admin dashboard: yasta, yasl, yaiam, yakwui, yamase-web, and
// yamocir.
//
// Consumers embed PageHeader in their own per-page data struct and use
// NewRenderer to parse the shared layout templates together with their
@@ -41,7 +42,7 @@ type NavItem struct {
// fields simply render nothing (e.g. Username == "" hides the
// username/logout group).
type PageHeader struct {
Title string
Title string
// AppName is the lowercase product name, e.g. "yasta", used in
// <title> and the footer. Deliberately not "Name" -- a consuming
// project's own per-page data struct commonly embeds both PageHeader
@@ -49,8 +50,20 @@ type PageHeader struct {
// resource's name); two same-depth promoted "Name" fields make
// html/template's ".Name" an ambiguous selector that only fails at
// execution time, not at parse time.
AppName string
Lang string // <html lang="...">; "" defaults to "en"
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).
Theme string
Brand string // navbar brand text, e.g. "YASTA"
BrandInitial string // single-letter favicon glyph, e.g. "y"
Subtitle string