Compare commits

...
13 Commits
Author SHA1 Message Date
terminarandClaude Opus 5.5 d0e49b2365 Navbar logout as a POST form instead of a GET link
A GET logout can be triggered from any foreign page (img/link) and by
link prefetchers. LogoutPath now renders <form method="post"> with a
submit button styled like the former link; consumers register the route
as POST only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 15:27:10 +01:00
terminarandClaude Opus 5.5 b6a6298353 README: the yak/yamase mirrors are gone, consumers import this module directly
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 15:03:33 +02:00
terminarandClaude Opus 5.5 6b40ff059c 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>
2026-10-22 19:10:53 +02:00
terminarandClaude Opus 5.5 000bb42240 Narrow screens: sidebar as a wrapping tab bar, wrapping navbar
Below the md breakpoint, where the sidebar column stacks above the
content, the sidebar becomes a row of tabs in the look of Bootstrap's
.nav-tabs (the active one underlined in the accent color) that wraps onto
further rows instead of scrolling sideways. The stacked row no longer
shares its extra height out to the tab bar (align-content: flex-start),
which left an empty band below the links, and the navbar's extras (a
config path, action buttons) wrap instead of widening the page past the
screen.

README: add yet ("yet serve") to the migration status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 15:46:37 +02:00
terminarandClaude Sonnet 5 31af3819b4 Ignore local resume.sh helper script
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-08 23:10:20 +02:00
terminar 8875062fc5 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.
2026-09-01 22:24:58 +02:00
terminar adea139888 Update migration-status table: yamocir migrated, yaais deliberately not 2026-09-01 22:11:15 +02:00
terminar ef0714e213 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.
2026-09-01 21:40:28 +02:00
terminar 5d7f67b3d3 Update README: all five projects migrated, v0.1.5, versioning note 2026-09-01 17:48:08 +02:00
terminar 84a9faff29 Rename PageHeader.Name to AppName to avoid a field collision
A consuming project's own per-page data struct commonly embeds both
PageHeader and a domain type that has its own Name field (e.g. a
Kubernetes resource's name, as in yakwui's node/deployment/pod detail
pages) -- two same-depth promoted "Name" fields make html/template's
".Name" an ambiguous selector that only fails at execution time, not
at parse time.
2026-09-01 14:11:33 +02:00
terminar 1c1878cfca Add PageHeader.Lang, BodyAttrs, SidebarAttrs escape hatches
Lang: <html lang> override (defaults to "en") for a non-English UI.
BodyAttrs/SidebarAttrs: raw extra attributes spliced into <body> and
the sidebar's <nav> tag, typed template.HTMLAttr (not template.HTML --
the contextual autoescaper requires the attribute-list sentinel type
in this position or it silently drops the value). Needed by yakwui's
Alpine.js-driven collapsible mobile sidebar, which has no other way to
carry x-data state onto a common ancestor of the toggle button and the
sidebar nav.
2026-09-01 09:40:26 +02:00
terminar c99b000b1d Add PageHeader.BodyAttrs/SidebarAttrs escape hatches
Needed by yakwui's Alpine.js-based collapsible sidebar (x-data on
<body>, :class binding on the sidebar <nav>) -- the shared markup has
no generic opinion about a consumer's own client-side framework state.
2026-08-31 14:13:01 +02:00
terminar 671d9bd92d Add PageHeader.NavbarBeforeBrand for a pre-brand navbar element
Needed by yakwui's mobile sidebar-toggle button, which renders before
the brand link rather than after Subtitle.
2026-08-31 10:21:15 +02:00
8 changed files with 446 additions and 96 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
resume.sh
+96 -42
View File
@@ -9,44 +9,13 @@ see `layout.go` for the API (`PageHeader`, `NavItem`, `NewRenderer`,
## Source of truth ## Source of truth
This repo is the **source of truth** for the shared layout. `yak/yak-webui-template` This repo is the **single source of truth** for the shared layout. Every
and `yamase/yamase-webui-template` are git-history mirrors of it (each repo's consumer -- in `yetano`, `yak` (`yakwui`) and `yamase` (`yamase-web`) --
root mirrors this repo's root — not a subdirectory — created via `git merge imports `teruna.dev/yetano/yetano-webui-template` directly: make layout
--allow-unrelated-histories`, so the histories are related and can be changes here, tag a new version, then bump the consumers. The former
re-merged incrementally). Each mirror has exactly one intentional local git-history mirrors `yak/yak-webui-template` and
difference: its `go.mod` `module` line, which names that repo's own import `yamase/yamase-webui-template` were removed and their repositories
path instead of this one. Make layout changes *here first*, tag a new archived on 2026-10-23 (nothing imported them).
version, then pull the change into each mirror — never edit the mirrored
copies directly.
### Pulling a change into a mirror
From inside `yak-webui-template` or `yamase-webui-template` (each already
has a `source` remote pointing back here):
```sh
git fetch source main
git merge source/main
# resolve the go.mod conflict: keep the mirror's own module line, take
# everything else from source
git checkout --ours go.mod # if go.mod conflicted
git add go.mod
git commit
go test ./...
git push origin main
```
### One-time mirror setup (already done, kept here for reference/re-setup)
```sh
git init -b main
git remote add source git@teruna.dev:yetano/yetano-webui-template.git
git fetch source main
git merge --allow-unrelated-histories -m "Initial mirror of yetano-webui-template" source/main
go mod edit -module teruna.dev/<org>/<org>-webui-template
git remote add origin git@teruna.dev:<org>/<org>-webui-template.git
git push -u origin main
```
## What's shared vs. what stays per-project ## What's shared vs. what stays per-project
@@ -59,6 +28,49 @@ 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
(`--yw-bg`, `--yw-text`, `--yw-chrome-bg`, `--yw-accent`, `--yw-nav-link`,
`--yw-success-*`/`--yw-danger-*`, ...) rather than baked directly into
each rule — a documented, reusable theme, not an implementation detail.
Three themes ship, selected by `PageHeader.Theme` (see `layout.go`),
which renders as `<html data-theme="...">`:
| `Theme` | Look |
|---|---|
| `""` (unset) | dark, the bare `:root` block, i.e. what every consumer had before themes existed |
| `layout.ThemeDark` (`"dark"`) | dark, the same values |
| `layout.ThemeLight` (`"light"`) | light |
| `layout.ThemeSystem` (`"system"`) | follows the browser's `prefers-color-scheme` |
Every block also sets `color-scheme`, so native controls and scrollbars
match the palette.
- The light values appear twice in `static/style.css` (as
`:root[data-theme="light"]` and inside `@media (prefers-color-scheme:
light)` for `"system"`). `TestThemeBlocksInSync` fails if the two drift
apart or if a theme is missing a property.
- `--yw-nav-link` is `#0b82b8` in every theme. It is a cross-project
design token (see the meta-repo `AGENTS.md`).
- This module does **not** persist a choice (no cookie, localStorage or
JS). That is the consuming project's job: keep the preference
(e.g. in a cookie set by a POST form), resolve it server-side into
`Theme` before rendering, and offer the switch itself (e.g. via
`NavbarRightExtra`). Resolving server-side avoids a flash of the wrong
theme without an inline script, so it works under a strict
`script-src 'self'` CSP. `yareco` is the reference consumer.
- A consumer whose own stylesheet needs theme-dependent colors defines
its **own** custom properties with the same selector structure
(`:root, [data-theme="dark"], [data-theme="system"]` / `[data-theme="light"]`
/ the `prefers-color-scheme: light` media query). Don't redefine
`--yw-*` in one consumer's stylesheet: that reskins only that
project and makes it drift from everyone else sharing this file.
- **Adding another theme:** add its own `:root[data-theme="..."]` block
with the same property list, a constant in `layout.go`, and a case in
`TestThemeAttribute`.
## Consuming this module ## Consuming this module
```go ```go
@@ -76,10 +88,52 @@ module).
## Migration status ## Migration status
Seven projects use it (`yet serve` on `v0.1.7`, the others on `v0.1.6`).
| Project | Meta-repo | Status | | Project | Meta-repo | Status |
|---|---|---| |---|---|---|
| `yasta` | yetano | migrated (pilot) | | `yasta` | yetano | migrated (pilot) |
| `yasl` | yetano | not yet migrated | | `yasl` | yetano | migrated |
| `yaiam` | yetano | not yet migrated | | `yaiam` | yetano | migrated |
| `yakwui` | yak | not yet migrated | | `yakwui` | yak | migrated |
| `yamase-web` | yamase | not yet migrated | | `yamase-web` | yamase | migrated |
| `yamocir` | yetano | migrated |
| `yet` (`yet serve`) | yetano | built on it (a server-rendered shell whose content area a small JS app fills) |
`yaais` was evaluated too and deliberately NOT migrated: it's a
client-rendered SPA (static `index.html` + vanilla JS), not a
server-rendered Go-template dashboard, so this module's actual
deliverable (Go templates) doesn't apply. It adopted the same dark
palette independently in its own stylesheet instead, plus its own
light/dark toggle — see its `internal/yaais/static/style.css`.
## Versioning note
Use `v0.1.5` or later. `v0.1.3` and `v0.1.4` were force-moved to
different content after being tagged (a mistake, made while resolving a
concurrent-edit conflict during the initial rollout) and can produce a
`go.sum` checksum mismatch for anyone who fetched them beforehand. Don't
force-move an existing tag again for any future change — always cut a
new one, even for a one-line fix.
## PageHeader fields (current as of v0.1.10)
`Title`, `AppName` (lowercase product name for `<title>`/footer — not
`Name`, which collides with a domain type's own `Name` field once
embedded in the same struct, as yakwui's viewmodel types do), `Lang`
(`<html lang>`, defaults to `"en"`), `Theme` (`<html data-theme>`, see
Theming), `Brand`, `BrandInitial`, `Subtitle`,
`BasePath`, `NavItems`/`ActiveNav`, `Flash`/`FlashKind`, `Username`,
`LogoutPath` (since v0.1.10 a `<form method="post">` with a submit
button styled like the former link, never a GET link: a logout reachable
by GET can be triggered from any foreign page via an `<img>`/link and by
link prefetchers; the consumer registers the route as `POST` only and
answers `GET` with 405 + `Allow: POST`. If the form needs a hidden CSRF
field or other markup, render it yourself into `NavbarRightExtra` and
leave `LogoutPath` unset), `NavbarBeforeBrand` (before the
brand link, e.g. a mobile sidebar-toggle button),
`NavbarLeftExtra`/`NavbarRightExtra` (the navbar's two groups),
`ExtraHeadHTML`/`ExtraBodyHTML`, and `BodyAttrs`/`SidebarAttrs` —
`template.HTMLAttr`, not `template.HTML` — raw extra attributes on
`<body>` and the sidebar `<nav>` for a consumer's own client-side
framework state (e.g. yakwui's Alpine.js collapsible sidebar).
+51 -17
View File
@@ -1,6 +1,7 @@
// Package layout provides the shared server-rendered web UI chrome (base // Package layout provides the shared server-rendered web UI chrome (base
// layout, navbar, sidebar, footer) used by every Yetano/Yak/Yamase // 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 // Consumers embed PageHeader in their own per-page data struct and use
// NewRenderer to parse the shared layout templates together with their // NewRenderer to parse the shared layout templates together with their
@@ -28,6 +29,13 @@ var staticFS embed.FS
// base/navbar/sidebar/footer templates. // base/navbar/sidebar/footer templates.
const LayoutGlob = "templates/layout/*.tmpl" 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. // NavItem is one sidebar entry.
type NavItem struct { type NavItem struct {
ID string // matches PageHeader.ActiveNav to mark this item active ID string // matches PageHeader.ActiveNav to mark this item active
@@ -41,22 +49,48 @@ type NavItem struct {
// fields simply render nothing (e.g. Username == "" hides the // fields simply render nothing (e.g. Username == "" hides the
// username/logout group). // username/logout group).
type PageHeader struct { type PageHeader struct {
Title string Title string
Name string // lowercase product name, e.g. "yasta"; used in <title> and the footer // AppName is the lowercase product name, e.g. "yasta", used in
Brand string // navbar brand text, e.g. "YASTA" // <title> and the footer. Deliberately not "Name" -- a consuming
BrandInitial string // single-letter favicon glyph, e.g. "y" // project's own per-page data struct commonly embeds both PageHeader
Subtitle string // and a domain type that has its own Name field (e.g. a Kubernetes
BasePath string // resource's name); two same-depth promoted "Name" fields make
NavItems []NavItem // html/template's ".Name" an ambiguous selector that only fails at
ActiveNav string // execution time, not at parse time.
Flash string AppName string
FlashKind string // "ok" or "error"; meaningless if Flash == "" Lang string // <html lang="...">; "" defaults to "en"
Username string // Theme selects which --yw-* token block static/style.css applies,
LogoutPath string // BasePath-relative, e.g. "/logout"; "" hides the logout link // rendered as <html data-theme="...">: ThemeDark, ThemeLight or
NavbarLeftExtra template.HTML // extra markup rendered after Subtitle in the navbar's left group // ThemeSystem (follows prefers-color-scheme). "" omits the attribute,
NavbarRightExtra template.HTML // extra markup rendered after Username/Logout in the navbar's right group // which resolves to the bare :root values (dark), so a consumer that
ExtraHeadHTML template.HTML // extra <link>/<script> tags appended to <head> // never sets Theme keeps its look. Persisting a user's choice is the
ExtraBodyHTML template.HTML // extra <script> tags appended before </body> // 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"
Subtitle string
BasePath string
NavItems []NavItem
ActiveNav string
Flash string
FlashKind string // "ok" or "error"; meaningless if Flash == ""
Username string
LogoutPath string // BasePath-relative, e.g. "/logout"; rendered as a POST form (never a GET link); "" hides it
NavbarBeforeBrand template.HTML // extra markup rendered before the brand link, e.g. a mobile sidebar toggle
NavbarLeftExtra template.HTML // extra markup rendered after Subtitle in the navbar's left group
NavbarRightExtra template.HTML // extra markup rendered after Username/Logout in the navbar's right group
ExtraHeadHTML template.HTML // extra <link>/<script> tags appended to <head>
ExtraBodyHTML template.HTML // extra <script> tags appended before </body>
// BodyAttrs/SidebarAttrs are raw extra attributes (include their own
// leading space, e.g. ` x-data="{ open: true }"`) spliced into
// <body...> and the sidebar's <nav...> tag -- an escape hatch for a
// consuming project's own client-side framework state (e.g. yakwui's
// Alpine.js collapsible sidebar), which the shared markup has no
// generic opinion about. template.HTMLAttr, not template.HTML --
// html/template's contextual autoescaper requires the attribute-list
// sentinel type in this position or it silently drops the value.
BodyAttrs template.HTMLAttr
SidebarAttrs template.HTMLAttr
} }
// Renderer holds one independently parsed *template.Template per page: // Renderer holds one independently parsed *template.Template per page:
+123 -1
View File
@@ -30,7 +30,7 @@ func TestNewRendererAndPage(t *testing.T) {
var buf bytes.Buffer var buf bytes.Buffer
data := PageHeader{ data := PageHeader{
Title: "Dashboard", Title: "Dashboard",
Name: "example", AppName: "example",
Brand: "EXAMPLE", Brand: "EXAMPLE",
BrandInitial: "e", BrandInitial: "e",
BasePath: "", BasePath: "",
@@ -47,6 +47,8 @@ func TestNewRendererAndPage(t *testing.T) {
`class="nav-link active"`, `class="nav-link active"`,
"test-build", "test-build",
"<title>Dashboard · example</title>", "<title>Dashboard · example</title>",
`<html lang="en">`,
"<body>",
} { } {
if !strings.Contains(out, want) { if !strings.Contains(out, want) {
t.Errorf("rendered output missing %q\n---\n%s", want, out) t.Errorf("rendered output missing %q\n---\n%s", want, out)
@@ -54,6 +56,64 @@ func TestNewRendererAndPage(t *testing.T) {
} }
} }
func TestPageHeaderOverrides(t *testing.T) {
r, err := NewRenderer(testPagesFS(), "pages", []string{"dashboard"}, ".html.tmpl", testFuncs())
if err != nil {
t.Fatalf("NewRenderer: %v", err)
}
var buf bytes.Buffer
data := PageHeader{
Title: "Dashboard",
Lang: "de",
BodyAttrs: template.HTMLAttr(` x-data="{ open: true }"`),
SidebarAttrs: template.HTMLAttr(` :class="{ hidden: !open }"`),
}
if err := r.Page(&buf, "dashboard", data); err != nil {
t.Fatalf("Page: %v", err)
}
out := buf.String()
for _, want := range []string{
`<html lang="de">`,
`<body x-data="{ open: true }">`,
`sidebar d-md-block" :class="{ hidden: !open }">`,
} {
if !strings.Contains(out, want) {
t.Errorf("rendered output missing %q\n---\n%s", want, out)
}
}
}
func TestThemeAttribute(t *testing.T) {
r, err := NewRenderer(testPagesFS(), "pages", []string{"dashboard"}, ".html.tmpl", testFuncs())
if err != nil {
t.Fatalf("NewRenderer: %v", err)
}
cases := []struct {
name string
theme string
want string
}{
{"unset resolves to the bare :root theme", "", `<html lang="en">`},
{"explicit dark", ThemeDark, `<html lang="en" data-theme="dark">`},
{"light", ThemeLight, `<html lang="en" data-theme="light">`},
{"system", ThemeSystem, `<html lang="en" data-theme="system">`},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
var buf bytes.Buffer
if err := r.Page(&buf, "dashboard", PageHeader{Title: "Dashboard", Theme: c.theme}); err != nil {
t.Fatalf("Page: %v", err)
}
if out := buf.String(); !strings.Contains(out, c.want) {
t.Errorf("rendered output missing %q\n---\n%s", c.want, out)
}
})
}
}
func TestExecuteNamed(t *testing.T) { func TestExecuteNamed(t *testing.T) {
r, err := NewRenderer(testPagesFS(), "pages", []string{"dashboard"}, ".html.tmpl", testFuncs()) r, err := NewRenderer(testPagesFS(), "pages", []string{"dashboard"}, ".html.tmpl", testFuncs())
if err != nil { if err != nil {
@@ -78,3 +138,65 @@ func TestPageUnknown(t *testing.T) {
t.Fatal("expected error for unknown page") t.Fatal("expected error for unknown page")
} }
} }
// TestThemeBlocksInSync guards the hand-kept duplication in
// static/style.css: every theme declares the same --yw-* properties, and
// the "system" media-query block is identical to "light".
func TestThemeBlocksInSync(t *testing.T) {
css, err := staticFS.ReadFile("static/style.css")
if err != nil {
t.Fatal(err)
}
block := func(selector string) string {
s := string(css)
i := strings.Index(s, selector+" {")
if i < 0 {
t.Fatalf("style.css: no block %q", selector)
}
s = s[i+len(selector)+2:]
return s[:strings.Index(s, "}")]
}
decls := func(b string) (names, full []string) {
for _, line := range strings.Split(b, "\n") {
line = strings.TrimSpace(line)
if line == "" {
continue
}
full = append(full, line)
names = append(names, strings.SplitN(line, ":", 2)[0])
}
return names, full
}
darkNames, _ := decls(block(`:root[data-theme="system"]`))
lightNames, light := decls(block(`:root[data-theme="light"]`))
_, system := decls(block(` :root[data-theme="system"]`))
if strings.Join(darkNames, ",") != strings.Join(lightNames, ",") {
t.Errorf("dark and light declare different properties:\ndark: %v\nlight: %v", darkNames, lightNames)
}
if strings.Join(light, "\n") != strings.Join(system, "\n") {
t.Errorf("light and prefers-color-scheme: light blocks differ:\nlight: %v\nsystem: %v", light, system)
}
}
// TestLogoutIsPostForm pins the navbar's logout control to a POST form:
// a GET link would let any foreign page (an <img>, a link prefetcher)
// log the user out.
func TestLogoutIsPostForm(t *testing.T) {
r, err := NewRenderer(testPagesFS(), "pages", []string{"dashboard"}, ".html.tmpl", testFuncs())
if err != nil {
t.Fatalf("NewRenderer: %v", err)
}
var buf bytes.Buffer
data := PageHeader{Title: "Dashboard", BasePath: "/ui", Username: "alice", LogoutPath: "/logout"}
if err := r.Page(&buf, "dashboard", data); err != nil {
t.Fatalf("Page: %v", err)
}
out := buf.String()
if !strings.Contains(out, `<form method="post" action="/ui/logout"`) {
t.Errorf("logout is not a POST form\n---\n%s", out)
}
if strings.Contains(out, `href="/ui/logout"`) {
t.Errorf("logout still rendered as a GET link\n---\n%s", out)
}
}
+168 -30
View File
@@ -1,15 +1,108 @@
/* Shared web UI chrome -- the dark-theme base layout, navbar, sidebar, and /* Shared web UI chrome -- the base layout, navbar, sidebar, and footer
footer used by every ops-tool dashboard built on this module (yasta, used by every ops-tool dashboard built on this module (yasta, yasl,
yasl, yaiam, yakwui, yamase-web). Loaded after bootstrap.min.css. yaiam, yakwui, yamase-web, yamocir). Loaded after bootstrap.min.css.
Page-content styling (cards, tables, badges, forms, ...) is each Page-content styling (cards, tables, badges, forms, ...) is each
project's own concern and lives in that project's own stylesheet, project's own concern and lives in that project's own stylesheet,
loaded alongside this one -- see PageHeader.ExtraHeadHTML. Fixed dark loaded alongside this one -- see PageHeader.ExtraHeadHTML.
theme only -- no prefers-color-scheme, no light mode. */
:root { The palette is exposed as --yw-* custom properties, not baked into
--bs-body-bg: #1a1d23; each rule -- a documented, reusable theme, not an implementation
--bs-body-color: #d4d8e0; detail. Three values for PageHeader.Theme (see layout.go), rendered
--bs-border-color: #333; 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. */
/* 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;
--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);
}
/* 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: #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 { html {
@@ -19,8 +112,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 +144,116 @@ 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);
} }
/* Narrow screens (below Bootstrap's md breakpoint, where the sidebar
column stacks above the content): the sidebar becomes a tab bar --
the same look as a page's own Bootstrap .nav-tabs (e.g. a manual's
topic tabs): one row of links that wraps onto further rows when they
don't fit, never a sideways-scrolling strip, the active one
underlined in the accent color. */
@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);
padding-top: 0;
}
/* !important: Bootstrap's .flex-column utility is !important itself. */
.sidebar .nav.flex-column {
flex-direction: row !important;
flex-wrap: wrap;
padding-top: 0 !important;
}
.sidebar .nav-link {
padding: .55rem .85rem;
border-bottom: 2px solid transparent;
white-space: nowrap;
}
.sidebar .nav-link.active {
border-left: none;
border-bottom: 2px solid var(--yw-accent);
}
/* The navbar's own extras (a project's config path, action buttons)
wrap onto a second line instead of widening the page past the
screen. */
.navbar > .container-fluid {
flex-wrap: wrap;
row-gap: .4rem;
}
.navbar > .container-fluid > div {
flex-wrap: wrap;
min-width: 0;
}
.navbar-subtitle {
overflow-wrap: anywhere;
}
/* The stacked row still grows to fill the page (see above); without
this, the extra height is shared out between its wrapped lines and
the tab bar gets an empty band below its links. */
body > .container-fluid > .row {
align-content: flex-start;
}
} }
+4 -4
View File
@@ -1,20 +1,20 @@
{{define "base"}}<!doctype html> {{define "base"}}<!doctype html>
<html lang="en"> <html lang="{{if .Lang}}{{.Lang}}{{else}}en{{end}}"{{if .Theme}} data-theme="{{.Theme}}"{{end}}>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{.Title}}{{if .Name}} · {{.Name}}{{end}}</title> <title>{{.Title}}{{if .AppName}} · {{.AppName}}{{end}}</title>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3E%3Crect%20width='100'%20height='100'%20rx='20'%20fill='%2314171e'/%3E%3Ctext%20x='50'%20y='71'%20font-size='58'%20font-family='system-ui,sans-serif'%20font-weight='700'%20fill='%230b82b8'%20text-anchor='middle'%3E{{.BrandInitial}}%3C/text%3E%3C/svg%3E"> <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3E%3Crect%20width='100'%20height='100'%20rx='20'%20fill='%2314171e'/%3E%3Ctext%20x='50'%20y='71'%20font-size='58'%20font-family='system-ui,sans-serif'%20font-weight='700'%20fill='%230b82b8'%20text-anchor='middle'%3E{{.BrandInitial}}%3C/text%3E%3C/svg%3E">
<link rel="stylesheet" href="{{.BasePath}}/webui-static/bootstrap.min.css"> <link rel="stylesheet" href="{{.BasePath}}/webui-static/bootstrap.min.css">
<link rel="stylesheet" href="{{.BasePath}}/webui-static/style.css"> <link rel="stylesheet" href="{{.BasePath}}/webui-static/style.css">
<script src="{{.BasePath}}/webui-static/bootstrap.bundle.min.js" defer></script> <script src="{{.BasePath}}/webui-static/bootstrap.bundle.min.js" defer></script>
{{.ExtraHeadHTML}} {{.ExtraHeadHTML}}
</head> </head>
<body> <body{{.BodyAttrs}}>
{{template "navbar" .}} {{template "navbar" .}}
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<nav class="col-md-2 col-lg-2 sidebar d-md-block"> <nav class="col-md-2 col-lg-2 sidebar d-md-block"{{.SidebarAttrs}}>
{{template "sidebar" .}} {{template "sidebar" .}}
</nav> </nav>
<main class="col-md-10 col-lg-10 ms-sm-auto px-md-4 py-3"> <main class="col-md-10 col-lg-10 ms-sm-auto px-md-4 py-3">
+1 -1
View File
@@ -1,3 +1,3 @@
{{define "footer"}} {{define "footer"}}
<footer class="footer">{{.Name}} web UI · {{buildInfo}}</footer> <footer class="footer">{{.AppName}} web UI · {{buildInfo}}</footer>
{{end}} {{end}}
+2 -1
View File
@@ -2,13 +2,14 @@
<nav class="navbar navbar-dark navbar-expand"> <nav class="navbar navbar-dark navbar-expand">
<div class="container-fluid d-flex justify-content-between align-items-center"> <div class="container-fluid d-flex justify-content-between align-items-center">
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
{{.NavbarBeforeBrand}}
<a class="navbar-brand" href="{{.BasePath}}/">{{.Brand}}</a> <a class="navbar-brand" href="{{.BasePath}}/">{{.Brand}}</a>
{{if .Subtitle}}<span class="navbar-subtitle">{{.Subtitle}}</span>{{end}} {{if .Subtitle}}<span class="navbar-subtitle">{{.Subtitle}}</span>{{end}}
{{.NavbarLeftExtra}} {{.NavbarLeftExtra}}
</div> </div>
<div class="d-flex align-items-center gap-2"> <div class="d-flex align-items-center gap-2">
{{if .Username}}<span class="navbar-subtitle">{{.Username}}</span>{{end}} {{if .Username}}<span class="navbar-subtitle">{{.Username}}</span>{{end}}
{{if .LogoutPath}}<a href="{{.BasePath}}{{.LogoutPath}}" class="btn btn-outline-secondary btn-sm">Logout</a>{{end}} {{if .LogoutPath}}<form method="post" action="{{.BasePath}}{{.LogoutPath}}" class="d-inline m-0"><button type="submit" class="btn btn-outline-secondary btn-sm">Logout</button></form>{{end}}
{{.NavbarRightExtra}} {{.NavbarRightExtra}}
</div> </div>
</div> </div>