Extract the color palette into --yw-* custom properties (a formal theme)

Preparation for the yamocir migration: same computed colors as before,
now expressed as reusable, documented tokens instead of literals baked
into each rule. Also documents scope in README.md's new Theming
section -- this module ships exactly one theme; per-project theming
(e.g. yaais's light/dark toggle) belongs in that project, not here.
This commit is contained in:
terminar committed 2026-09-01 21:40:28 +02:00
1 parent 5d7f67b3d3
commit ef0714e213
2 files changed
+75 -29

No files matched your search

+19
View File
@@ -59,6 +59,25 @@ Stays in each consuming project: page-specific templates
(`templates/pages/*.html.tmpl`), page-content CSS (cards, tables, badges, (`templates/pages/*.html.tmpl`), page-content CSS (cards, tables, badges,
forms, buttons, markdown, ...), and anything else specific to that tool. forms, buttons, markdown, ...), and anything else specific to that tool.
## Theming
`static/style.css`'s palette is exposed as `--yw-*` CSS custom properties
on `:root` (`--yw-bg`, `--yw-text`, `--yw-chrome-bg`, `--yw-accent`,
`--yw-nav-link`, `--yw-success-*`/`--yw-danger-*`, ...) rather than baked
directly into each rule — it's a documented, reusable theme, not just an
implementation detail. This is the *only* theme the module ships: fixed
dark, no `prefers-color-scheme`, no light mode. Don't add one here on a
per-project basis (redefining `--yw-*` globally in one consumer would
silently reskin every future consumer sharing this CSS file); a project
that genuinely needs a different look — e.g. a light/dark toggle, like
`yaais` has — should own that itself rather than pushing multi-theme
complexity into this module, since `yaais` shows that need doesn't
actually require *this* module either (it's a client-rendered SPA, not a
server-rendered Go-template dashboard). If a real case for a second theme
*in* this module shows up later, the `--yw-*` tokens are exactly the
seam to add one through — redefine them under a `[data-theme="..."]`
selector the way `yaais`'s own stylesheet does.
## Consuming this module ## Consuming this module
```go ```go
+56 -29
View File
@@ -1,15 +1,42 @@
/* Shared web UI chrome -- the dark-theme base layout, navbar, sidebar, and /* Shared web UI chrome -- the dark-theme base layout, navbar, sidebar, and
footer used by every ops-tool dashboard built on this module (yasta, footer used by every ops-tool dashboard built on this module (yasta,
yasl, yaiam, yakwui, yamase-web). Loaded after bootstrap.min.css. yasl, yaiam, yakwui, yamase-web, yamocir). Loaded after
Page-content styling (cards, tables, badges, forms, ...) is each bootstrap.min.css. Page-content styling (cards, tables, badges,
project's own concern and lives in that project's own stylesheet, forms, ...) is each project's own concern and lives in that project's
loaded alongside this one -- see PageHeader.ExtraHeadHTML. Fixed dark own stylesheet, loaded alongside this one -- see
theme only -- no prefers-color-scheme, no light mode. */ PageHeader.ExtraHeadHTML. Fixed dark theme only -- no
prefers-color-scheme, no light mode (see README.md's Theming section
before assuming that's a gap to fill here).
The palette below is exposed as --yw-* custom properties, not just
baked into each rule -- it's the shared "theme" every migrated
project inherits, not an implementation detail. A project needing a
genuinely different look (not just a different accent) should not
redefine these globally -- see README.md. */
:root { :root {
--bs-body-bg: #1a1d23; --yw-bg: #1a1d23;
--bs-body-color: #d4d8e0; --yw-text: #d4d8e0;
--bs-border-color: #333; --yw-border: #333;
--yw-chrome-bg: #14171e;
--yw-chrome-border: #272d3a;
--yw-accent: #4fc3f7;
--yw-accent-rgb: 79, 195, 247;
--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;
--bs-body-bg: var(--yw-bg);
--bs-body-color: var(--yw-text);
--bs-border-color: var(--yw-border);
} }
html { html {
@@ -19,8 +46,8 @@ html {
/* Flex column so the footer sits right after the content when the page is /* Flex column so the footer sits right after the content when the page is
short, and grows naturally when content is long. */ short, and grows naturally when content is long. */
body { body {
background: #1a1d23; background: var(--yw-bg);
color: #d4d8e0; color: var(--yw-text);
font-size: 0.875rem; font-size: 0.875rem;
min-height: 100%; min-height: 100%;
display: flex; display: flex;
@@ -51,71 +78,71 @@ body > .container-fluid > .row {
/* --- Navbar ------------------------------------------------ */ /* --- Navbar ------------------------------------------------ */
.navbar { .navbar {
background: #14171e !important; background: var(--yw-chrome-bg) !important;
border-bottom: 1px solid #272d3a; border-bottom: 1px solid var(--yw-chrome-border);
padding: .6rem 1.2rem; padding: .6rem 1.2rem;
} }
.navbar-brand { .navbar-brand {
color: #4fc3f7 !important; color: var(--yw-accent) !important;
letter-spacing: 2.5px; letter-spacing: 2.5px;
font-size: 1rem; font-size: 1rem;
} }
.navbar-subtitle { .navbar-subtitle {
color: #5a7a9a; color: var(--yw-subtitle);
font-size: .82rem; font-size: .82rem;
text-decoration: none; text-decoration: none;
} }
a.navbar-subtitle:hover { a.navbar-subtitle:hover {
color: #4fc3f7; color: var(--yw-accent);
} }
.navbar-subtitle-sep { .navbar-subtitle-sep {
color: #333c4a; color: var(--yw-subtitle-sep);
margin: 0 .5rem; margin: 0 .5rem;
} }
/* --- Sidebar ------------------------------------------------ */ /* --- Sidebar ------------------------------------------------ */
.sidebar { .sidebar {
background: #14171e; background: var(--yw-chrome-bg);
border-right: 1px solid #272d3a; border-right: 1px solid var(--yw-chrome-border);
padding-top: .5rem; padding-top: .5rem;
} }
.sidebar .nav-link { .sidebar .nav-link {
color: #0b82b8; color: var(--yw-nav-link);
font-size: .85rem; font-size: .85rem;
padding: .5rem 1rem; padding: .5rem 1rem;
border-radius: 0; border-radius: 0;
} }
.sidebar .nav-link:hover { .sidebar .nav-link:hover {
background: rgba(79, 195, 247, .08); background: rgba(var(--yw-accent-rgb), .08);
color: #c8d4e4; color: var(--yw-nav-link-hover-text);
} }
.sidebar .nav-link.active { .sidebar .nav-link.active {
background: rgba(79, 195, 247, .1); background: rgba(var(--yw-accent-rgb), .1);
color: #4fc3f7; color: var(--yw-accent);
font-weight: 600; font-weight: 600;
border-left: 2px solid #4fc3f7; border-left: 2px solid var(--yw-accent);
} }
/* --- Alerts (flash banners) ---------------------------------------- */ /* --- Alerts (flash banners) ---------------------------------------- */
.alert-success { background: #192e22; border-color: #2a5c3a; color: #7ecf98; } .alert-success { background: var(--yw-success-bg); border-color: var(--yw-success-border); color: var(--yw-success-text); }
.alert-danger { background: #2e1820; border-color: #5c2a32; color: #e08090; } .alert-danger { background: var(--yw-danger-bg); border-color: var(--yw-danger-border); color: var(--yw-danger-text); }
/* --- Footer ------------------------------------------------- */ /* --- Footer ------------------------------------------------- */
.footer { .footer {
color: #4a5a72; color: var(--yw-footer-text);
font-size: 0.8rem; font-size: 0.8rem;
text-align: center; text-align: center;
padding: 0.8rem 1rem; padding: 0.8rem 1rem;
border-top: 1px solid #272d3a; border-top: 1px solid var(--yw-chrome-border);
} }
@media (max-width: 767.98px) { @media (max-width: 767.98px) {
.sidebar { border-right: none; border-bottom: 1px solid #272d3a; } .sidebar { border-right: none; border-bottom: 1px solid var(--yw-chrome-border); }
} }