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
|
|
|
|
|
(`static/style.css` — theme root variables, navbar, `.sidebar .nav-link`
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
`static/style.css`'s palette is exposed as `--yw-*` CSS custom properties
|
2026-09-01 22:24:58 +02:00
|
|
|
(`--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.
|
|
|
|
|
|
2026-10-22 19:10:53 +02:00
|
|
|
Three themes ship, selected by `PageHeader.Theme` (see `layout.go`),
|
|
|
|
|
which renders as `<html data-theme="...">`:
|
2026-09-01 22:24:58 +02:00
|
|
|
|
2026-10-22 19:10:53 +02:00
|
|
|
| `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`.
|
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-18 15:46:37 +02:00
|
|
|
Seven projects use it (`yet serve` on `v0.1.7`, the others on `v0.1.6`).
|
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-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-22 19:10:53 +02:00
|
|
|
## PageHeader fields (current as of v0.1.9)
|
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`,
|
|
|
|
|
`LogoutPath` (a plain GET link — for a POST-form logout or any other
|
|
|
|
|
markup mismatch, render it yourself into `NavbarRightExtra` instead and
|
|
|
|
|
leave `Username`/`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).
|