Compare commits

..
6 Commits
Author SHA1 Message Date
terminarandClaude Opus 5.5 8774ef62ce no-sidebar: hide the sidebar column on pages without one
A page without a sidebar (a login page) sets BodyAttrs to
class="no-sidebar"; the layout always renders the sidebar column, so
style.css now hides it and gives <main> the full width. yaiam-web had
the rule in its own stylesheet, so yaiam-authd's login pages, which
only load this one, showed an empty column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:25:23 +01:00
terminarandClaude Opus 5.5 e4f88485f2 Menu form: AppearanceFormHTML for a consumer's hidden fields
A consumer whose middleware demands a CSRF token on every POST
(yamase-web) had to exempt the menu's route; it can now put the hidden
token field into the form instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 23:45:34 +01:00
terminarandClaude Opus 5.5 03a1ce56d8 README: every consumer is on v0.2.3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 23:16:07 +01:00
terminarandClaude Opus 5.5 c5d7bdfef0 contrast palette: cyan instead of yellow accent in dark mode
The dashboards use yellow as a status color (warning, "gelb"); a
yellow accent made accent badges and links read as warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 23:04:13 +01:00
terminarandClaude Opus 5.5 e09effa2ca Default primary #2595c8, the family's button color
Every consumer styled .btn-primary as #2595c8 (hover #1d7baa) in its
own stylesheet; with that as the default palette's --yw-primary the
template's Bootstrap bridge matches it, and the consumers' hard-coded
rules can go so that the other palettes reach their buttons too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 23:01:28 +01:00
terminarandClaude Opus 5.5 148062ec28 ApplyAppearance: cut BasePath only as a whole path segment
Behind http.StripPrefix the request path is already relative, and a
blind TrimPrefix turned /release-notes into "elease-notes" for
BasePath /r, sending the menu back to the start page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 23:00:50 +01:00
6 changed files with 76 additions and 28 deletions

No files matched your search

+16 -9
View File
@@ -96,10 +96,12 @@ German when `Lang` starts with `de`) with one POST form whose buttons
submit `theme` or `palette`. `AppearanceHandler` stores the choice in submit `theme` or `palette`. `AppearanceHandler` stores the choice in
the cookies `yw_theme`/`yw_palette` (path `BasePath/`, a year, the cookies `yw_theme`/`yw_palette` (path `BasePath/`, a year,
`HttpOnly`, `SameSite=Lax`) and redirects to `back`, but only to a path `HttpOnly`, `SameSite=Lax`) and redirects to `back`, but only to a path
inside the UI. Any other method gets 405. `ApplyAppearance` ignores unknown cookie inside the UI. Any other method gets 405. `ApplyAppearance` ignores
values, so whatever the consumer set before stays the default. A unknown cookie values, so whatever the consumer set before stays the
consumer with its own switch (e.g. `yareco`'s) can keep it and just set default. A consumer whose middleware wants a CSRF token on every POST
`Theme`/`Palette`. 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`.
**Adding a palette:** a `:root[data-palette="..."]` block in **Adding a palette:** a `:root[data-palette="..."]` block in
`static/style.css`, a constant and an entry in `Palettes` in `static/style.css`, a constant and an entry in `Palettes` in
@@ -122,7 +124,8 @@ module).
## Migration status ## Migration status
Seven projects use it (`yet serve` on `v0.1.7`, the others on `v0.1.6`). 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.
| Project | Meta-repo | Status | | Project | Meta-repo | Status |
|---|---|---| |---|---|---|
@@ -133,6 +136,7 @@ Seven projects use it (`yet serve` on `v0.1.7`, the others on `v0.1.6`).
| `yamase-web` | yamase | migrated | | `yamase-web` | yamase | migrated |
| `yamocir` | yetano | migrated | | `yamocir` | yetano | migrated |
| `yet` (`yet serve`) | yetano | built on it (a server-rendered shell whose content area a small JS app fills) | | `yet` (`yet serve`) | yetano | built on it (a server-rendered shell whose content area a small JS app fills) |
| `yareco` | yetano | built on it (reference consumer for themes) |
`yaais` was evaluated too and deliberately NOT migrated: it's a `yaais` was evaluated too and deliberately NOT migrated: it's a
client-rendered SPA (static `index.html` + vanilla JS), not a client-rendered SPA (static `index.html` + vanilla JS), not a
@@ -150,7 +154,7 @@ concurrent-edit conflict during the initial rollout) and can produce a
force-move an existing tag again for any future change — always cut a force-move an existing tag again for any future change — always cut a
new one, even for a one-line fix. new one, even for a one-line fix.
## PageHeader fields (current as of v0.2.0) ## PageHeader fields (current as of v0.2.5)
`Title`, `AppName` (lowercase product name for `<title>`/footer — not `Title`, `AppName` (lowercase product name for `<title>`/footer — not
`Name`, which collides with a domain type's own `Name` field once `Name`, which collides with a domain type's own `Name` field once
@@ -158,8 +162,8 @@ embedded in the same struct, as yakwui's viewmodel types do), `Lang`
(`<html lang>`, defaults to `"en"`), `Theme` (`<html data-theme>`, see (`<html lang>`, defaults to `"en"`), `Theme` (`<html data-theme>`, see
Theming), `Brand`, `BrandInitial`, `Subtitle`, Theming), `Brand`, `BrandInitial`, `Subtitle`,
`BasePath`, `NavItems`/`ActiveNav`, `Flash`/`FlashKind`, `Username`, `BasePath`, `NavItems`/`ActiveNav`, `Flash`/`FlashKind`, `Username`,
`Palette`, `AppearancePath`/`AppearanceBack` (since v0.2.0, see `Palette`, `AppearancePath`/`AppearanceBack` (since v0.2.0) and
Theming), `LogoutPath` (since v0.1.10 a `<form method="post">` with a submit `AppearanceFormHTML` (since v0.2.4, see Theming), `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 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 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 link prefetchers; the consumer registers the route as `POST` only and
@@ -171,4 +175,7 @@ brand link, e.g. a mobile sidebar-toggle button),
`ExtraHeadHTML`/`ExtraBodyHTML`, and `BodyAttrs`/`SidebarAttrs` — `ExtraHeadHTML`/`ExtraBodyHTML`, and `BodyAttrs`/`SidebarAttrs` —
`template.HTMLAttr`, not `template.HTML` — raw extra attributes on `template.HTMLAttr`, not `template.HTML` — raw extra attributes on
`<body>` and the sidebar `<nav>` for a consumer's own client-side `<body>` and the sidebar `<nav>` for a consumer's own client-side
framework state (e.g. yakwui's Alpine.js collapsible sidebar). framework state (e.g. yakwui's Alpine.js collapsible sidebar). A page
without a sidebar (a login page) sets `BodyAttrs` to
`` ` class="no-sidebar"` ``: since v0.2.5 `static/style.css` then hides
the sidebar column and gives `<main>` the full width.
+11 -1
View File
@@ -67,7 +67,17 @@ func (h *PageHeader) ApplyAppearance(r *http.Request) {
if c, err := r.Cookie(PaletteCookie); err == nil && known(Palettes, c.Value) { if c, err := r.Cookie(PaletteCookie); err == nil && known(Palettes, c.Value) {
h.Palette = c.Value h.Palette = c.Value
} }
back := url.URL{Path: strings.TrimPrefix(r.URL.Path, h.BasePath), RawQuery: r.URL.RawQuery} // Only a whole leading BasePath segment is cut: behind
// http.StripPrefix the path is already relative, and "/r" must not
// eat the start of "/release-notes".
path := r.URL.Path
if h.BasePath != "" && (path == h.BasePath || strings.HasPrefix(path, h.BasePath+"/")) {
path = strings.TrimPrefix(path, h.BasePath)
}
if path == "" {
path = "/"
}
back := url.URL{Path: path, RawQuery: r.URL.RawQuery}
h.AppearanceBack = back.String() h.AppearanceBack = back.String()
} }
+12 -2
View File
@@ -142,6 +142,15 @@ func TestApplyAppearance(t *testing.T) {
if h.AppearanceBack != "/tasks?f=1" { if h.AppearanceBack != "/tasks?f=1" {
t.Errorf("AppearanceBack = %q, want %q", h.AppearanceBack, "/tasks?f=1") t.Errorf("AppearanceBack = %q, want %q", h.AppearanceBack, "/tasks?f=1")
} }
// Behind http.StripPrefix the path is already relative to BasePath.
for path, want := range map[string]string{"/release-notes": "/release-notes", "/r": "/", "/r/x": "/x"} {
h := PageHeader{BasePath: "/r"}
h.ApplyAppearance(httptest.NewRequest(http.MethodGet, path, nil))
if h.AppearanceBack != want {
t.Errorf("BasePath /r, path %s: AppearanceBack = %q, want %q", path, h.AppearanceBack, want)
}
}
} }
func TestAppearanceHandler(t *testing.T) { func TestAppearanceHandler(t *testing.T) {
@@ -200,14 +209,15 @@ func TestAppearanceMenu(t *testing.T) {
buf.Reset() buf.Reset()
data := PageHeader{Title: "Dashboard", Lang: "de", BasePath: "/ui", AppearancePath: "/appearance", data := PageHeader{Title: "Dashboard", Lang: "de", BasePath: "/ui", AppearancePath: "/appearance",
AppearanceBack: "/tasks", Theme: ThemeLight, Palette: PaletteGraphite} AppearanceBack: "/tasks", Theme: ThemeLight, Palette: PaletteGraphite,
AppearanceFormHTML: `<input type="hidden" name="csrf_token" value="t0k">`}
if err := r.Page(&buf, "dashboard", data); err != nil { if err := r.Page(&buf, "dashboard", data); err != nil {
t.Fatalf("Page: %v", err) t.Fatalf("Page: %v", err)
} }
out := buf.String() out := buf.String()
for _, want := range []string{ for _, want := range []string{
`<form method="post" action="/ui/appearance"`, `<form method="post" action="/ui/appearance"`,
`name="back" value="/tasks"`, `name="back" value="/tasks"><input type="hidden" name="csrf_token" value="t0k">`,
`name="theme" value="light" aria-pressed="true"><span aria-hidden="true">☀</span> Hell</button>`, `name="theme" value="light" aria-pressed="true"><span aria-hidden="true">☀</span> Hell</button>`,
`name="theme" value="dark" aria-pressed="false">`, `name="theme" value="dark" aria-pressed="false">`,
`name="palette" value="graphite" aria-pressed="true">Graphit</button>`, `name="palette" value="graphite" aria-pressed="true">Graphit</button>`,
+4
View File
@@ -75,6 +75,10 @@ type PageHeader struct {
// the menu returns to (ApplyAppearance sets it). // the menu returns to (ApplyAppearance sets it).
AppearancePath string AppearancePath string
AppearanceBack string AppearanceBack string
// AppearanceFormHTML is extra markup inside the menu's POST form,
// e.g. a hidden CSRF token field for a consumer whose middleware
// demands one on every POST.
AppearanceFormHTML template.HTML
Brand string // navbar brand text, e.g. "YASTA" Brand string // navbar brand text, e.g. "YASTA"
BrandInitial string // single-letter favicon glyph, e.g. "y" BrandInitial string // single-letter favicon glyph, e.g. "y"
Subtitle string Subtitle string
+32 -15
View File
@@ -82,8 +82,8 @@
--yw-link-rgb: var(--yw-if-light, 10, 114, 163) var(--yw-if-dark, 79, 195, 247); --yw-link-rgb: var(--yw-if-light, 10, 114, 163) var(--yw-if-dark, 79, 195, 247);
--yw-link-hover: light-dark(#085a80, #81d4fa); --yw-link-hover: light-dark(#085a80, #81d4fa);
--yw-link-hover-rgb: var(--yw-if-light, 8, 90, 128) var(--yw-if-dark, 129, 212, 250); --yw-link-hover-rgb: var(--yw-if-light, 8, 90, 128) var(--yw-if-dark, 129, 212, 250);
--yw-primary: light-dark(#0d6efd, #0d6efd); --yw-primary: light-dark(#2595c8, #2595c8);
--yw-primary-rgb: var(--yw-if-light, 13, 110, 253) var(--yw-if-dark, 13, 110, 253); --yw-primary-rgb: var(--yw-if-light, 37, 149, 200) var(--yw-if-dark, 37, 149, 200);
--yw-on-primary: light-dark(#ffffff, #ffffff); --yw-on-primary: light-dark(#ffffff, #ffffff);
--yw-nav-link: light-dark(#0b82b8, #0b82b8); --yw-nav-link: light-dark(#0b82b8, #0b82b8);
--yw-nav-link-hover-text: light-dark(#0a4f72, #c8d4e4); --yw-nav-link-hover-text: light-dark(#0a4f72, #c8d4e4);
@@ -141,8 +141,10 @@
--yw-info-text: light-dark(#463a59, #c4adff); --yw-info-text: light-dark(#463a59, #c4adff);
} }
/* contrast: high contrast for readability -- black/white, yellow /* contrast: high contrast for readability -- black/white, a bright
accent in dark mode, deep blue in light. */ cyan accent in dark mode, deep blue in light. Not the classic yellow:
in these dashboards yellow means "warning", and an accent in that
color reads as a status. */
:root[data-palette="contrast"] { :root[data-palette="contrast"] {
--yw-bg: light-dark(#ffffff, #000000); --yw-bg: light-dark(#ffffff, #000000);
--yw-bg-rgb: var(--yw-if-light, 255, 255, 255) var(--yw-if-dark, 0, 0, 0); --yw-bg-rgb: var(--yw-if-light, 255, 255, 255) var(--yw-if-dark, 0, 0, 0);
@@ -158,17 +160,17 @@
--yw-border: light-dark(#555555, #8a8a8a); --yw-border: light-dark(#555555, #8a8a8a);
--yw-chrome-bg: light-dark(#ffffff, #000000); --yw-chrome-bg: light-dark(#ffffff, #000000);
--yw-chrome-border: light-dark(#555555, #8a8a8a); --yw-chrome-border: light-dark(#555555, #8a8a8a);
--yw-brand: light-dark(#0040a0, #ffd60a); --yw-brand: light-dark(#0040a0, #66e0ff);
--yw-accent: light-dark(#0040a0, #ffd60a); --yw-accent: light-dark(#0040a0, #66e0ff);
--yw-accent-rgb: var(--yw-if-light, 0, 64, 160) var(--yw-if-dark, 255, 214, 10); --yw-accent-rgb: var(--yw-if-light, 0, 64, 160) var(--yw-if-dark, 102, 224, 255);
--yw-link: light-dark(#0040a0, #ffd60a); --yw-link: light-dark(#0040a0, #66e0ff);
--yw-link-rgb: var(--yw-if-light, 0, 64, 160) var(--yw-if-dark, 255, 214, 10); --yw-link-rgb: var(--yw-if-light, 0, 64, 160) var(--yw-if-dark, 102, 224, 255);
--yw-link-hover: light-dark(#002a6b, #ffe766); --yw-link-hover: light-dark(#002a6b, #b3f0ff);
--yw-link-hover-rgb: var(--yw-if-light, 0, 42, 107) var(--yw-if-dark, 255, 231, 102); --yw-link-hover-rgb: var(--yw-if-light, 0, 42, 107) var(--yw-if-dark, 179, 240, 255);
--yw-primary: light-dark(#0040a0, #ffd60a); --yw-primary: light-dark(#0040a0, #66e0ff);
--yw-primary-rgb: var(--yw-if-light, 0, 64, 160) var(--yw-if-dark, 255, 214, 10); --yw-primary-rgb: var(--yw-if-light, 0, 64, 160) var(--yw-if-dark, 102, 224, 255);
--yw-on-primary: light-dark(#ffffff, #000000); --yw-on-primary: light-dark(#ffffff, #000000);
--yw-nav-link: light-dark(#00549e, #7fd4ff); --yw-nav-link: light-dark(#00549e, #a8e6ff);
--yw-nav-link-hover-text: light-dark(#000000, #ffffff); --yw-nav-link-hover-text: light-dark(#000000, #ffffff);
--yw-subtitle: light-dark(#333333, #d0d0d0); --yw-subtitle: light-dark(#333333, #d0d0d0);
--yw-subtitle-sep: light-dark(#888888, #8a8a8a); --yw-subtitle-sep: light-dark(#888888, #8a8a8a);
@@ -246,7 +248,9 @@
} }
/* Bootstrap writes its primary blue straight into these components /* Bootstrap writes its primary blue straight into these components
rather than reading --bs-primary, so they get the palette's here. */ rather than reading --bs-primary, so they get the palette's here.
The default palette's #2595c8 is the button color every consumer's
own stylesheet used (as yasta), so those rules can go. */
.btn-primary { .btn-primary {
--bs-btn-color: var(--yw-on-primary); --bs-btn-color: var(--yw-on-primary);
--bs-btn-bg: var(--yw-primary); --bs-btn-bg: var(--yw-primary);
@@ -504,6 +508,19 @@ a.navbar-subtitle:hover {
border-left: 2px solid var(--yw-accent); border-left: 2px solid var(--yw-accent);
} }
/* A page without a sidebar (a login page): BodyAttrs ` class="no-sidebar"`.
The layout always renders the sidebar column; this hides it and gives
<main> the full width. !important: Bootstrap's d-md-block, column and
ms-sm-auto classes on those elements are !important or more specific. */
body.no-sidebar .sidebar {
display: none !important;
}
body.no-sidebar main {
width: 100% !important;
margin-left: 0 !important;
}
/* --- Alerts (flash banners) ---------------------------------------- */ /* --- Alerts (flash banners) ---------------------------------------- */
.alert-success { background: var(--yw-success-bg); border-color: var(--yw-success-border); color: var(--yw-success-text); } .alert-success { background: var(--yw-success-bg); border-color: var(--yw-success-border); color: var(--yw-success-text); }
.alert-danger { background: var(--yw-danger-bg); border-color: var(--yw-danger-border); color: var(--yw-danger-text); } .alert-danger { background: var(--yw-danger-bg); border-color: var(--yw-danger-border); color: var(--yw-danger-text); }
+1 -1
View File
@@ -12,7 +12,7 @@
{{if .AppearancePath}}{{with .AppearanceMenu}}<details class="yw-appearance"> {{if .AppearancePath}}{{with .AppearanceMenu}}<details class="yw-appearance">
<summary class="btn btn-outline-secondary btn-sm" title="{{.ThemeHeading}}: {{.Current.Label}}"><span aria-hidden="true">{{.Current.Symbol}}</span> {{.Current.Label}}</summary> <summary class="btn btn-outline-secondary btn-sm" title="{{.ThemeHeading}}: {{.Current.Label}}"><span aria-hidden="true">{{.Current.Symbol}}</span> {{.Current.Label}}</summary>
<form method="post" action="{{$.BasePath}}{{$.AppearancePath}}" class="yw-appearance-menu m-0"> <form method="post" action="{{$.BasePath}}{{$.AppearancePath}}" class="yw-appearance-menu m-0">
<input type="hidden" name="back" value="{{$.AppearanceBack}}"> <input type="hidden" name="back" value="{{$.AppearanceBack}}">{{$.AppearanceFormHTML}}
<h6>{{.ThemeHeading}}</h6> <h6>{{.ThemeHeading}}</h6>
{{range .Themes}}<button type="submit" name="theme" value="{{.ID}}" aria-pressed="{{.Current}}"><span aria-hidden="true">{{.Symbol}}</span> {{.Label}}</button> {{range .Themes}}<button type="submit" name="theme" value="{{.ID}}" aria-pressed="{{.Current}}"><span aria-hidden="true">{{.Symbol}}</span> {{.Label}}</button>
{{end}}<hr> {{end}}<hr>