2026-08-29 00:19:06 +02:00
|
|
|
# yetano-webui-template
|
|
|
|
|
|
|
|
|
|
Shared server-rendered web UI chrome (base layout, navbar, sidebar,
|
|
|
|
|
footer) for the Yetano/Yak/Yamase family of ops-tool admin dashboards.
|
|
|
|
|
This is a real Go module (`teruna.dev/yetano/yetano-webui-template`,
|
|
|
|
|
package `layout`), imported by each dashboard rather than copy-pasted —
|
|
|
|
|
see `layout.go` for the API (`PageHeader`, `NavItem`, `NewRenderer`,
|
|
|
|
|
`StaticHandler`).
|
|
|
|
|
|
|
|
|
|
## Source of truth
|
|
|
|
|
|
2026-10-23 15:03:33 +02:00
|
|
|
This repo is the **single source of truth** for the shared layout. Every
|
|
|
|
|
consumer -- in `yetano`, `yak` (`yakwui`) and `yamase` (`yamase-web`) --
|
|
|
|
|
imports `teruna.dev/yetano/yetano-webui-template` directly: make layout
|
|
|
|
|
changes here, tag a new version, then bump the consumers. The former
|
|
|
|
|
git-history mirrors `yak/yak-webui-template` and
|
|
|
|
|
`yamase/yamase-webui-template` were removed and their repositories
|
|
|
|
|
archived on 2026-10-23 (nothing imported them).
|
2026-08-29 00:19:06 +02:00
|
|
|
|
|
|
|
|
## What's shared vs. what stays per-project
|
|
|
|
|
|
|
|
|
|
Shared here: the base HTML skeleton, navbar, sidebar (generic nav-item
|
|
|
|
|
list), footer, and the CSS rules that style exactly those elements
|
2026-10-29 22:47:04 +01:00
|
|
|
(`static/style.css` — theme tokens and the Bootstrap bridge, navbar, `.sidebar .nav-link`
|
2026-08-29 00:19:06 +02:00
|
|
|
incl. the `#0b82b8` inactive-link color, footer, flash-banner alerts).
|
|
|
|
|
|
|
|
|
|
Stays in each consuming project: page-specific templates
|
|
|
|
|
(`templates/pages/*.html.tmpl`), page-content CSS (cards, tables, badges,
|
|
|
|
|
forms, buttons, markdown, ...), and anything else specific to that tool.
|
|
|
|
|
|
2026-09-01 21:40:28 +02:00
|
|
|
## Theming
|
|
|
|
|
|
2026-10-29 22:47:04 +01:00
|
|
|
Two independent axes, both set on `<html>` and resolved on the server:
|
2026-09-01 22:24:58 +02:00
|
|
|
|
2026-10-29 22:47:04 +01:00
|
|
|
| Axis | `PageHeader` field | Attribute | Values |
|
|
|
|
|
|---|---|---|---|
|
|
|
|
|
| Mode | `Theme` | `data-theme` | `layout.ThemeDark` (also `""`, unset), `ThemeLight`, `ThemeSystem` (follows `prefers-color-scheme`) |
|
|
|
|
|
| Colors | `Palette` | `data-palette` | `layout.PaletteDefault` (also `""`), `PaletteGraphite` (grey/violet, after nessajina.tv), `PaletteContrast` (high contrast) |
|
2026-09-01 22:24:58 +02:00
|
|
|
|
2026-10-29 22:47:04 +01:00
|
|
|
A consumer that sets neither keeps the original dark look.
|
2026-10-22 19:10:53 +02:00
|
|
|
|
2026-10-29 22:47:04 +01:00
|
|
|
How `static/style.css` does it:
|
2026-10-22 19:10:53 +02:00
|
|
|
|
2026-10-29 22:47:04 +01:00
|
|
|
- **Every color token is written once**, as `--yw-x: light-dark(<light>,
|
|
|
|
|
<dark>)`. The mode only sets `color-scheme` (`dark`, `light`, or
|
|
|
|
|
`light dark` for system), so no mode repeats another's values and
|
|
|
|
|
"system" needs no duplicated media-query block. Needs a browser from
|
|
|
|
|
2024 or later (`light-dark()`, `color-mix()`).
|
|
|
|
|
- **Triplets and images** (`--yw-*-rgb` for Bootstrap's `rgba(var(...),
|
|
|
|
|
a)`, and the few `url()` icons Bootstrap swaps in dark mode) can't use
|
|
|
|
|
`light-dark()`. They pick with the mode switches `--yw-if-light`/
|
|
|
|
|
`--yw-if-dark`: `var(--yw-if-light, <light>) var(--yw-if-dark,
|
|
|
|
|
<dark>)`.
|
|
|
|
|
- **A palette is one `:root[data-palette="..."]` block** that lists only
|
|
|
|
|
what it changes from the default (bare `:root`) block.
|
|
|
|
|
- **Bootstrap follows the palette:** its theme-dependent `--bs-*`
|
|
|
|
|
variables (body, emphasis, secondary/tertiary, links, borders, the
|
|
|
|
|
`*-subtle`/`*-emphasis` colors, form validation) and the components
|
|
|
|
|
that hard-code its primary blue (`.btn-primary`, `.list-group`,
|
|
|
|
|
`.form-check-input:checked`, focus rings, ...) are mapped onto
|
|
|
|
|
`--yw-*`. Bootstrap's own `data-bs-theme` is not used (it has no
|
|
|
|
|
"system" mode without a script); a consumer's local
|
|
|
|
|
`data-bs-theme="dark"` on one element still works.
|
|
|
|
|
- `TestPaletteTokens` checks that every palette in `layout.Palettes` has
|
|
|
|
|
a block, every color is one `light-dark()` pair, every `-rgb` triplet
|
|
|
|
|
matches its color, and a palette only overrides default tokens.
|
|
|
|
|
- `--yw-nav-link` is `#0b82b8` in the default palette in both modes (the
|
|
|
|
|
cross-project design token, see the meta-repo `AGENTS.md`). The other
|
|
|
|
|
palettes use their own nav-link color: blue would clash with
|
|
|
|
|
graphite's violet, and it lacks contrast on black.
|
|
|
|
|
|
|
|
|
|
Tokens a consumer's own stylesheet can use: `--yw-bg`, `--yw-surface`,
|
|
|
|
|
`--yw-surface-2`, `--yw-text`, `--yw-text-strong`, `--yw-muted`,
|
|
|
|
|
`--yw-border`, `--yw-chrome-bg`/`-border`, `--yw-brand`, `--yw-accent`,
|
|
|
|
|
`--yw-link`/`-hover`, `--yw-primary`, `--yw-on-primary`,
|
|
|
|
|
`--yw-{success,danger,warning,info}-{bg,border,text}`, plus the `-rgb`
|
|
|
|
|
triplets of bg/surface/text/accent/link/primary. For its own
|
|
|
|
|
theme-dependent colors a consumer writes `light-dark()` as well, never
|
|
|
|
|
redefines `--yw-*` (that would reskin only that project). The older
|
|
|
|
|
pattern, separate `[data-theme="..."]` blocks, keeps working.
|
|
|
|
|
|
|
|
|
|
### Theme/palette menu
|
|
|
|
|
|
|
|
|
|
The module can store the visitor's choice itself, without any script
|
|
|
|
|
(works under a strict `script-src 'self'` CSP):
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
mux.Handle("POST /appearance", layout.AppearanceHandler(basePath))
|
|
|
|
|
...
|
|
|
|
|
hdr := layout.PageHeader{BasePath: basePath, AppearancePath: "/appearance", ...}
|
|
|
|
|
hdr.ApplyAppearance(r) // Theme/Palette from the cookies, AppearanceBack = current page
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
`AppearancePath` set, the navbar shows a `<details>` dropdown (labels in
|
|
|
|
|
German when `Lang` starts with `de`) with one POST form whose buttons
|
|
|
|
|
submit `theme` or `palette`. `AppearanceHandler` stores the choice in
|
|
|
|
|
the cookies `yw_theme`/`yw_palette` (path `BasePath/`, a year,
|
|
|
|
|
`HttpOnly`, `SameSite=Lax`) and redirects to `back`, but only to a path
|
2026-10-29 23:45:34 +01:00
|
|
|
inside the UI. Any other method gets 405. `ApplyAppearance` ignores
|
|
|
|
|
unknown cookie values, so whatever the consumer set before stays the
|
|
|
|
|
default. A consumer whose middleware wants a CSRF token on every POST
|
|
|
|
|
puts the hidden field into `AppearanceFormHTML`, which is rendered
|
|
|
|
|
inside the menu's form. A consumer with its own switch (e.g. `yareco`'s)
|
|
|
|
|
can keep it and just set `Theme`/`Palette`.
|
2026-10-29 22:47:04 +01:00
|
|
|
|
|
|
|
|
**Adding a palette:** a `:root[data-palette="..."]` block in
|
|
|
|
|
`static/style.css`, a constant and an entry in `Palettes` in
|
|
|
|
|
`appearance.go`. `TestPaletteTokens` reports anything missing.
|
2026-09-01 21:40:28 +02:00
|
|
|
|
2026-08-29 00:19:06 +02:00
|
|
|
## Consuming this module
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
type pageHeader = layout.PageHeader // embed this in your own page data structs
|
|
|
|
|
|
|
|
|
|
r, err := layout.NewRenderer(pagesFS, "templates/pages", pageNames, ".html.tmpl", template.FuncMap{
|
|
|
|
|
"buildInfo": func() string { return version.Get().Compact() },
|
|
|
|
|
})
|
|
|
|
|
...
|
|
|
|
|
mux.Handle("/webui-static/", layout.StaticHandler("/webui-static/"))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
See `yetano/yasta` for a full worked example (the pilot migration of this
|
|
|
|
|
module).
|
|
|
|
|
|
|
|
|
|
## Migration status
|
|
|
|
|
|
2026-10-29 23:16:07 +01:00
|
|
|
Eight projects use it, all on `v0.2.3` (2026-10-29). `yareco` also uses
|
|
|
|
|
the built-in theme menu; `yakwui` still has its own switch.
|
2026-09-01 17:48:08 +02:00
|
|
|
|
2026-08-29 00:19:06 +02:00
|
|
|
| Project | Meta-repo | Status |
|
|
|
|
|
|---|---|---|
|
|
|
|
|
| `yasta` | yetano | migrated (pilot) |
|
2026-09-01 17:48:08 +02:00
|
|
|
| `yasl` | yetano | migrated |
|
|
|
|
|
| `yaiam` | yetano | migrated |
|
|
|
|
|
| `yakwui` | yak | migrated |
|
|
|
|
|
| `yamase-web` | yamase | migrated |
|
2026-09-01 22:11:15 +02:00
|
|
|
| `yamocir` | yetano | migrated |
|
2026-10-18 15:46:37 +02:00
|
|
|
| `yet` (`yet serve`) | yetano | built on it (a server-rendered shell whose content area a small JS app fills) |
|
2026-10-29 23:16:07 +01:00
|
|
|
| `yareco` | yetano | built on it (reference consumer for themes) |
|
2026-09-01 22:11:15 +02:00
|
|
|
|
|
|
|
|
`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`.
|
2026-09-01 17:48:08 +02:00
|
|
|
|
|
|
|
|
## 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.
|
|
|
|
|
|
2026-10-29 23:45:34 +01:00
|
|
|
## PageHeader fields (current as of v0.2.4)
|
2026-09-01 17:48:08 +02:00
|
|
|
|
|
|
|
|
`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`
|
2026-10-22 19:10:53 +02:00
|
|
|
(`<html lang>`, defaults to `"en"`), `Theme` (`<html data-theme>`, see
|
|
|
|
|
Theming), `Brand`, `BrandInitial`, `Subtitle`,
|
2026-09-01 17:48:08 +02:00
|
|
|
`BasePath`, `NavItems`/`ActiveNav`, `Flash`/`FlashKind`, `Username`,
|
2026-10-29 23:45:34 +01:00
|
|
|
`Palette`, `AppearancePath`/`AppearanceBack` (since v0.2.0) and
|
|
|
|
|
`AppearanceFormHTML` (since v0.2.4, see Theming), `LogoutPath` (since v0.1.10 a `<form method="post">` with a submit
|
2026-10-26 15:27:10 +01:00
|
|
|
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
|
2026-09-01 17:48:08 +02:00
|
|
|
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).
|