Modern style as the new default; style axis, slate palette, nav groups and icons

A third appearance axis, PageHeader.Style (<html data-style>), with
StyleModern -- the default when Style is empty -- and StyleClassic, the
look up to v0.4.x. The modern style is one [data-style="modern"] block
at the end of style.css over the classic rules: navbar without a rule,
the sidebar as a floating rounded card with group headings, icons and
a pill for the active entry, rounder and quieter Bootstrap components.
In it inactive sidebar links use the text color; #0b82b8 now only
colors them in the classic style (owner decision 2026-11-28).

- appearance menu: "Style"/"Stil" section, cookie yw_style
- palette slate (dark slate and lavender)
- NavItem.Group (sidebar group headings) and NavItem.Icon (names from
  the new NavIcons set, shown only in the modern style)
- cmd/webui-demo: a sample page for comparing styles, palettes and modes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
terminarandClaude Opus 5.5 committed 2026-11-28 11:11:28 +01:00
1 parent 7afb6a022a
commit 33dfebab9e
13 files changed
+771 -28

No files matched your search

+105
View File
@@ -0,0 +1,105 @@
// Command webui-demo serves a sample page on the shared layout, for
// looking at themes, palettes and styles in a browser:
//
// go run ./cmd/webui-demo -addr 127.0.0.1:8097
//
// The appearance menu (top right) switches mode, palette and style;
// ?style=, ?palette= and ?theme= set the same cookies (handy for links
// and screenshots). It has no state and serves nothing but the sample.
package main
import (
"embed"
"flag"
"html/template"
"log"
"net/http"
layout "teruna.dev/yetano/yetano-webui-template"
)
//go:embed pages
var pagesFS embed.FS
type page struct {
layout.PageHeader
Section string
}
var nav = []layout.NavItem{
{ID: "overview", Label: "Overview", Href: "/", Icon: "dashboard"},
{ID: "services", Label: "Services", Href: "/services", Group: "Node", Icon: "box"},
{ID: "hosts", Label: "Hosts", Href: "/hosts", Group: "Node", Icon: "server"},
{ID: "network", Label: "Network", Href: "/network", Group: "Node", Icon: "network"},
{ID: "logs", Label: "Logs", Href: "/logs", Group: "Node", Icon: "terminal"},
{ID: "users", Label: "Users", Href: "/users", Group: "Access", Icon: "users"},
{ID: "keys", Label: "Keys", Href: "/keys", Group: "Access", Icon: "key"},
{ID: "security", Label: "Security", Href: "/security", Group: "Access", Icon: "shield"},
{ID: "metrics", Label: "Metrics", Href: "/metrics", Group: "Data", Icon: "chart"},
{ID: "storage", Label: "Storage", Href: "/storage", Group: "Data", Icon: "database"},
{ID: "settings", Label: "Settings", Href: "/settings", Icon: "settings"},
}
func main() {
addr := flag.String("addr", "127.0.0.1:8097", "listen address")
flag.Parse()
r, err := layout.NewRenderer(pagesFS, "pages", []string{"demo"}, ".html.tmpl", template.FuncMap{
"buildInfo": func() string { return "demo" },
})
if err != nil {
log.Fatal(err)
}
mux := http.NewServeMux()
mux.Handle("GET /webui-static/", layout.StaticHandler("/webui-static/"))
mux.Handle("POST /appearance", layout.AppearanceHandler(""))
mux.HandleFunc("GET /", func(w http.ResponseWriter, req *http.Request) {
active := "overview"
for _, n := range nav {
if n.Href == req.URL.Path {
active = n.ID
}
}
p := page{PageHeader: layout.PageHeader{
Title: "Overview", AppName: "demo", Brand: "YETANO", BrandInitial: "y",
Subtitle: "night.local", NavItems: nav, ActiveNav: active,
AppearancePath: "/appearance", Username: "admin", LogoutPath: "/logout",
}}
p.ApplyAppearance(req)
// ?theme=/?palette=/?style= also go into the menu's cookies, so
// the choice stays when you follow a sidebar link.
q := req.URL.Query()
for _, o := range []struct {
key, cookie string
choices []layout.Choice
field *string
}{
{"theme", layout.ThemeCookie, layout.Themes, &p.Theme},
{"palette", layout.PaletteCookie, layout.Palettes, &p.Palette},
{"style", layout.StyleCookie, layout.Styles, &p.Style},
} {
v := q.Get(o.key)
for _, c := range o.choices {
if c.ID == v {
*o.field = v
http.SetCookie(w, &http.Cookie{Name: o.cookie, Value: v, Path: "/",
MaxAge: 365 * 24 * 3600, HttpOnly: true, SameSite: http.SameSiteLaxMode})
}
}
}
if v := q.Get("flash"); v != "" {
p.Flash, p.FlashKind = v, layout.FlashOK
}
for _, n := range nav {
if n.ID == active {
p.Section, p.Title = n.Group, n.Label
}
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
if err := r.Page(w, "demo", p); err != nil {
log.Print(err)
}
})
log.Printf("webui-demo on http://%s/", *addr)
log.Fatal(http.ListenAndServe(*addr, mux))
}
+49
View File
@@ -0,0 +1,49 @@
{{define "content"}}
<nav aria-label="breadcrumb"><ol class="breadcrumb small mb-1"><li class="breadcrumb-item">{{if .Section}}{{.Section}}{{else}}Node{{end}}</li><li class="breadcrumb-item active">{{.Title}}</li></ol></nav>
<h1 class="h3 mb-1">{{.Title}}</h1>
<p class="text-body-secondary mb-3">Status of this node and the services it runs.</p>
<hr class="mb-4">
<div class="row g-3 mb-4">
<div class="col-sm-6 col-xl-3"><div class="card"><div class="card-body"><div class="text-body-secondary small">Services</div><div class="fs-4 fw-bold">12</div><span class="badge text-bg-success">all running</span></div></div></div>
<div class="col-sm-6 col-xl-3"><div class="card"><div class="card-body"><div class="text-body-secondary small">Peers</div><div class="fs-4 fw-bold">3</div><span class="badge text-bg-secondary">kilrathi, yetano1, …</span></div></div></div>
<div class="col-sm-6 col-xl-3"><div class="card"><div class="card-body"><div class="text-body-secondary small">Uptime</div><div class="fs-4 fw-bold">4d 7h</div><span class="badge text-bg-info">since restart</span></div></div></div>
<div class="col-sm-6 col-xl-3"><div class="card"><div class="card-body"><div class="text-body-secondary small">Warnings</div><div class="fs-4 fw-bold">1</div><span class="badge text-bg-warning">certificate expires</span></div></div></div>
</div>
<div class="row g-4">
<div class="col-lg-7">
<h2 class="h6 text-uppercase text-body-secondary mb-2">Services</h2>
<div class="card mb-4">
<table class="table table-hover mb-0 align-middle">
<thead><tr><th>Name</th><th>Version</th><th>State</th><th></th></tr></thead>
<tbody>
<tr><td><a href="#">yasl</a></td><td>0.9.2</td><td><span class="badge text-bg-success">running</span></td><td class="text-end"><button class="btn btn-sm btn-outline-primary">Restart</button></td></tr>
<tr><td><a href="#">yaiam</a></td><td>1.4.0</td><td><span class="badge text-bg-success">running</span></td><td class="text-end"><button class="btn btn-sm btn-outline-primary">Restart</button></td></tr>
<tr><td><a href="#">yamocir</a></td><td>0.7.1</td><td><span class="badge text-bg-danger">failed</span></td><td class="text-end"><button class="btn btn-sm btn-primary">Start</button></td></tr>
<tr><td><a href="#">yareco</a></td><td>0.3.0</td><td><span class="badge text-bg-secondary">stopped</span></td><td class="text-end"><button class="btn btn-sm btn-primary">Start</button></td></tr>
</tbody>
</table>
</div>
<h2 class="h6 text-uppercase text-body-secondary mb-2">Settings</h2>
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action py-2"><div class="fw-semibold text-body-emphasis">Account</div><small class="text-body-secondary">Change your email or delete your account.</small></a>
<a href="#" class="list-group-item list-group-item-action py-2"><div class="fw-semibold text-body-emphasis">Security</div><small class="text-body-secondary">Change your password or sign out all devices.</small></a>
<a href="#" class="list-group-item list-group-item-action py-2"><div class="fw-semibold text-body-emphasis">Keys</div><small class="text-body-secondary">Manage API tokens and SSH keys.</small></a>
</div>
</div>
<div class="col-lg-5">
<h2 class="h6 text-uppercase text-body-secondary mb-2">Add a peer</h2>
<div class="card"><div class="card-body">
<form>
<div class="mb-3"><label class="form-label" for="h">Host</label><input class="form-control" id="h" placeholder="kilrathi.local"></div>
<div class="mb-3"><label class="form-label" for="r">Role</label><select class="form-select" id="r"><option>member</option><option>relay</option></select></div>
<div class="form-check form-switch mb-3"><input class="form-check-input" type="checkbox" id="s" checked><label class="form-check-label" for="s">Trust on first use</label></div>
<button type="button" class="btn btn-primary">Add peer</button>
<button type="button" class="btn btn-outline-danger ms-1">Cancel</button>
</form>
</div></div>
<div class="alert alert-info mt-3 mb-0">Peers join over the YAPL bus; a relay forwards for nodes behind NAT.</div>
</div>
</div>
{{end}}