side: the app side panel moves from Mapa into estilo
Contra is the second app to use Mapa's side panel, so under the one rule it moves here now (AGENTS.md row 10). Mapa's values and behaviour, copied, not redesigned: the frame that puts nav[estilo-side] under the bar beside <main>, rows of icon, label and shortcut, section headings, the foot pinned to the bottom, the fold to a rail of icons with labels as tooltips, open from 80rem by default, no side below 800px (the bar's Menu sheet carries the places, and the bar's nav hides from 800px), and light and dark from tokens. Light() keeps one full highlight, as Mapa's light() did. The fold is a POST that SetState stores in the app's cookie; side.js folds in place and binds Cmd or Ctrl and backslash. Tests: rendering, Light, State and SetState, tokens defined, Mapa's values pinned, the phone rule last, and side.js under Node.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 files changed,
+903
−0
AGENTS.md+1 −0README.md+12 −0side/side.css+255 −0side/side.go+200 −0side/side.js+55 −0side/side.test.mjs+113 −0side/side_test.go+213 −0side/templates/side.html+54 −0
CI passed — run details
CI log
=== modcache === all modules verified === vet === CGO_ENABLED=0 go vet ./... CGO_ENABLED=0 go vet -tags browser ./... === fmt === === build === CGO_ENABLED=0 go build -buildvcs=false ./... === go-test === CGO_ENABLED=0 go test -count=1 ./... ok amadan.net/oficina/estilo.git/base 0.005s ok amadan.net/oficina/estilo.git/brand 0.003s ok amadan.net/oficina/estilo.git/busy 0.009s ok amadan.net/oficina/estilo.git/callui 0.005s ok amadan.net/oficina/estilo.git/chrome 1.150s ? amadan.net/oficina/estilo.git/cmd/oficina-notices [no test files] ok amadan.net/oficina/estilo.git/colophon 0.025s ok amadan.net/oficina/estilo.git/credits 0.005s ok amadan.net/oficina/estilo.git/credits/catalog 0.005s ok amadan.net/oficina/estilo.git/desk 0.005s ok amadan.net/oficina/estilo.git/googleimport 0.170s ok amadan.net/oficina/estilo.git/homeconnect 0.006s ok amadan.net/oficina/estilo.git/internal/lint 0.007s ? amadan.net/oficina/estilo.git/internal/tokencheck [no test files] ok amadan.net/oficina/estilo.git/menu 0.011s ok amadan.net/oficina/estilo.git/savestatus 0.119s ok amadan.net/oficina/estilo.git/side 0.137s ok amadan.net/oficina/estilo.git/sky 0.032s ok amadan.net/oficina/estilo.git/theme 0.012s
diff --git a/AGENTS.md b/AGENTS.md| index 70182a4..38fd70a 100644 |
| --- a/AGENTS.md |
| +++ b/AGENTS.md |
| @@ -56,6 +56,7 @@ empty repo invites the opposite.) |
| | 7 | **Private module path is `amadan.net/oficina/estilo.git`**, using authenticated Git and `GOPRIVATE` on every builder; checked consumer `go.sum` records integrity. Preserve this path when discovery support changes. | Public visibility solely to obtain Go metadata; local filesystem replaces; a later cosmetic module rename | Overnight coordinator, 2026-09-07; Claude Fable 5.1 branch review | |
| | 8 | **Estilo's theme is Calma, the suite's own — no longer `day`.** Every app's colour sits on one ring of equal OKLCH lightness (`theme/apps.go`); each app is themed with its own accent (`theme.ForApp`). The marks are Calma's (Fanned Oficina mark, app icons with a glow of their own hue) and the suite's ambient effect is a seeded nebula (`sky`), placed at the sign-in, the team's home and the front page, **never inside an app** — §Theme | Keeping `day` "as a base"; one hue per app chosen by eye (Mail and Files would not fit); rim light, cores and motes in the sky | Paul, 2026-09-28/29, after six rounds of design directions: *"Calma is by far the best"*; *"Grain and filaments. No cores, no rim lights. Then go."* | |
| | 9 | **The chrome is set in the system UI face and downloads no font.** `--rst-font` is `system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif` (the Modern Font Stacks "System UI" stack, and `day`'s); no estilo stylesheet declares a face. Calma's typography moves from Onest to system UI. The reason: the chrome must never flash (Paul, 2026-10-24: *"There should never be a flash of unstyled text. Ever."*, invisible text included), and **Onest cannot load in WebKit without a frame of invisible text**. Measured on `fix/chrome-font-no-flash`: with `font-display: optional` and a preload, WebKit paints the page with the chrome text invisible before the fallback; with Onest inlined as a `data:` URL in a render-blocking stylesheet, native WKWebView still painted the page with no text for 6-16 ms before Onest, in 12 of 12 runs. The system face is resolved during layout, so nothing waits and nothing swaps. v1's font files stay served, byte for byte, for old pages; nothing links them. `TestChromeFontIsSystemUI` holds it in CI; `make test-browser` proves it in Chromium and WebKit with pixels — §Theme | Onest with `font-display: swap` (the flash) or `block` (invisible, then the same swap); `optional` with a preload (invisible text in WebKit and Firefox before the fallback); Onest inlined as `data:` (a frame of invisible text in WebKit, every load, and `font-src data:` in every CSP); a metric-matched fallback (still a swap); a script gate (the door and the front page run without scripts) | Paul, 2026-10-25, choosing between Onest with a frame of invisible text in Safari and the system face; reviews: GPT-6-Astra (Codex) on `aab5e14` | |
| +| 10 | **The app side panel is estilo's `side` package**, moved from Mapa when Contra became its second consumer: `estilo-side-frame` (open, rail, or empty for the width to decide) around `nav[estilo-side]` and `<main>`, with `estilo-side-item`, `estilo-side-label`, `estilo-side-key`, `estilo-side-head`, `estilo-side-page`, `estilo-side-foot` and the fold. Mapa's values and behaviour, copied, not redesigned; Contra is the second use that corrects it, and Mapa adopts it by renaming | Contra copying Mapa's `mapa-side` CSS into a second app; designing a side from both apps' specs | Paul, 2026-11-21 | |
| **Two callers at design time is the bar for *extraction*. It says nothing |
| about *destination*.** Both consuming apps were told to propose their |
diff --git a/README.md b/README.md| index b99e0b6..95524a8 100644 |
| --- a/README.md |
| +++ b/README.md |
| @@ -77,6 +77,18 @@ segmented control (`estilo-seg`, `estilo-seg-item`: a button with |
| Docs' own, copied; Slides is the first other app to use them. It is styling |
| only, so it works with scripts off; the app places the card. |
| +`side` is an app's side panel, Mapa's, moved here when Contra became |
| +its second user. `<div estilo-side-frame>` puts `nav[estilo-side]` under |
| +the bar, beside `<main>`; its rows are `estilo-side-item` (an icon, |
| +`estilo-side-label`, an optional `kbd[estilo-side-key]`), page rows sit |
| +under `estilo-side-head` headings, and `estilo-side-foot` is pinned to |
| +the bottom with the fold. The fold turns the side into a rail of icons, |
| +with the labels as tooltips: from 80rem it is open unless folded, below |
| +that a rail, and below 800px it is gone, because its places are in the |
| +bar's Menu sheet. The fold is a form, so it works with scripts off |
| +(`side.SetState` keeps it in the app's cookie); `side.js` folds in place |
| +and adds ⌘\. Link `side.css` after `chrome.css`. |
| + |
| `colophon` is the suite's Colophon, reached from Help: every open-source |
| project an app is made with, in sections (typefaces, libraries by |
| runtime, icons and artwork, data, tools), each with a sentence or two on |
diff --git a/side/side.css b/side/side.css| new file mode 100644 |
| index 0000000..37e788c |
| --- /dev/null |
| +++ b/side/side.css |
| @@ -0,0 +1,255 @@ |
| +/* side.css: an app's side panel and the frame that puts it under the |
| + * bar, beside <main>. Mapa's, copied (its level-up spec, §3.2); Contra is |
| + * the second app to use it. Tokens only, so Calma and light/dark apply. |
| + * Calma: only icons carry colour. |
| + * |
| + * Breakpoints are estilo's: 800px, where the bar stacks and the side |
| + * appears, and 80rem, from which the side is open unless folded. |
| + * |
| + * Markup: <div estilo-side-frame="open|rail|"> holds <nav estilo-side> |
| + * (the estilo-side template) and <main>. An empty value lets the width |
| + * decide. |
| + */ |
| + |
| +[estilo-side-frame] { |
| + --estilo-side-inline-size: 224px; /* PUBLIC: the side's width now, rail included */ |
| + --estilo-side-rail-inline-size: 56px; /* PUBLIC */ |
| + display: grid; |
| + grid-template-columns: var(--estilo-side-inline-size) minmax(0, 1fr); |
| + min-block-size: calc(100dvh - var(--estilo-bar-block-size, 56px)); |
| +} |
| +/* The rail: by state, or by width when there is none (open from 80rem, |
| + the rail below). */ |
| +[estilo-side-frame~="rail"] { --estilo-side-inline-size: var(--estilo-side-rail-inline-size); } |
| +@media (max-width: 79.99rem) { |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) { |
| + --estilo-side-inline-size: var(--estilo-side-rail-inline-size); |
| + } |
| +} |
| +[estilo-side-frame] > main { min-inline-size: 0; } |
| + |
| +/* The places are the side's from 800px; estilo's Menu sheet carries them |
| + below it. */ |
| +@media (min-width: 800px) { |
| + :root:has([estilo-side-frame]) [estilo-bar-nav] { display: none; } |
| +} |
| + |
| +/* ── The side: one grid per row, a 16px icon column and the label, |
| + centred on one axis. ── */ |
| +[estilo-side] { |
| + box-sizing: border-box; |
| + position: sticky; |
| + inset-block-start: var(--estilo-bar-block-size, 56px); |
| + block-size: calc(100dvh - var(--estilo-bar-block-size, 56px)); |
| + display: flex; |
| + flex-direction: column; |
| + gap: 1px; |
| + overflow: auto; |
| + padding: 10px 8px 12px; |
| + background: light-dark(#f8f9fb, #191b21); |
| + border-inline-end: 1px solid var(--rst-line); |
| + font-size: 13px; |
| +} |
| +[estilo-side-item] { |
| + box-sizing: border-box; |
| + position: relative; |
| + display: grid; |
| + grid-template-columns: 16px minmax(0, 1fr) auto; |
| + align-items: center; |
| + column-gap: 10px; |
| + inline-size: 100%; |
| + min-block-size: 30px; |
| + padding: 0 8px 0 10px; |
| + border: 0; |
| + border-radius: 8px; |
| + background: none; |
| + color: var(--rst-text-muted); |
| + font: inherit; |
| + line-height: 18px; |
| + text-align: start; |
| + text-decoration: none; |
| + cursor: pointer; |
| +} |
| +[estilo-side-item] > svg { inline-size: 16px; block-size: 16px; } |
| +[estilo-side-label] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } |
| +[estilo-side-item]:hover { background: var(--rst-surface-2); color: var(--rst-text); } |
| +[estilo-side-item]:focus-visible { outline: 2px solid var(--rst-accent); outline-offset: -2px; } |
| +[estilo-side-item][aria-current] { background: var(--rst-accent-soft); color: var(--rst-text); font-weight: 600; } |
| +[estilo-side-item][aria-current] > svg { color: var(--rst-accent); } |
| +/* One full highlight: a place holding a page that has its own row is |
| + drawn twice, and the open side shows the unlit one; the rail, which |
| + hides the page rows, shows the lit one. The lit copy carries [hidden] |
| + for a page read with no CSS; the rail's display: grid below outranks |
| + the browser's own [hidden] rule. */ |
| +[estilo-side-holds="rail"] { display: none; } |
| +/* A locked row (Mapa: a private note of your own): a lock at its end. */ |
| +[estilo-side-lock] { display: inline-flex; color: var(--rst-text-muted); } |
| +[estilo-side-lock] > svg { inline-size: 12px; block-size: 12px; } |
| +[estilo-side-head] { |
| + margin: 14px 0 2px; |
| + padding: 0 8px 0 10px; |
| + color: var(--rst-text-faint, var(--rst-text-muted)); |
| + font-size: 11.5px; |
| + font-weight: 600; |
| + line-height: 22px; |
| +} |
| +[estilo-side-foot] { margin-block-start: auto; padding-block-start: 10px; display: grid; gap: 1px; } |
| +[estilo-side-foot] form { display: contents; } |
| +kbd[estilo-side-key] { |
| + display: inline-flex; |
| + align-items: center; |
| + justify-content: center; |
| + min-inline-size: 1.4em; |
| + padding: 0 5px; |
| + border: 1px solid var(--rst-line); |
| + border-block-end-width: 2px; |
| + border-radius: 5px; |
| + background: var(--rst-surface); |
| + color: var(--rst-text-muted); |
| + font: 500 10.5px/14px var(--rst-font); |
| +} |
| + |
| +/* The fold: one button per state, shown by what is on screen. */ |
| +[estilo-side-fold-to="open"] { display: none; } |
| +[estilo-side-frame~="rail"] [estilo-side-fold-to="rail"] { display: none; } |
| +[estilo-side-frame~="rail"] [estilo-side-fold-to="open"] { display: grid; } |
| +@media (max-width: 79.99rem) { |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-fold-to="rail"] { display: none; } |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-fold-to="open"] { display: grid; } |
| +} |
| + |
| +/* ── The rail: the same rows, icons only, on one axis. The label stays |
| + in the accessibility tree and is the tooltip. The tooltip is fixed |
| + where its row puts it (its static position, insets left auto), then |
| + moved out beside the 40px row: a fixed box escapes the side's |
| + scrolling, which clipped an absolute one. ── */ |
| +@media (min-width: 800px) { |
| + [estilo-side-frame~="rail"] [estilo-side] { padding-inline: 8px; align-items: center; } |
| + [estilo-side-frame~="rail"] [estilo-side-item] { |
| + grid-template-columns: 18px; |
| + justify-content: center; |
| + inline-size: 40px; |
| + min-block-size: 38px; |
| + padding: 0; |
| + border-radius: 10px; |
| + } |
| + [estilo-side-frame~="rail"] [estilo-side-item] > svg { inline-size: 18px; block-size: 18px; } |
| + [estilo-side-frame~="rail"] [estilo-side-item] > kbd, |
| + [estilo-side-frame~="rail"] [estilo-side-head], |
| + [estilo-side-frame~="rail"] [estilo-side-page] { display: none; } |
| + [estilo-side-frame~="rail"] [estilo-side-item][aria-current] { background: none; } |
| + [estilo-side-frame~="rail"] [estilo-side-holds="open"] { display: none; } |
| + [estilo-side-frame~="rail"] [estilo-side-holds="rail"] { display: grid; } |
| + [estilo-side-frame~="rail"] [estilo-side-item][aria-current]::before { |
| + content: ""; |
| + position: absolute; |
| + inset-inline-start: -8px; |
| + inset-block-start: 10px; |
| + inline-size: 3px; |
| + block-size: 18px; |
| + border-radius: 0 3px 3px 0; |
| + background: var(--rst-accent); |
| + } |
| + [estilo-side-frame~="rail"] [estilo-side-label] { |
| + position: fixed; |
| + margin-inline-start: 50px; |
| + margin-block-start: 19px; |
| + translate: 0 -50%; |
| + z-index: 30; |
| + padding: 4px 8px; |
| + border-radius: 6px; |
| + background: var(--rst-text); |
| + color: var(--rst-surface); |
| + font-size: 12px; |
| + font-weight: 500; |
| + pointer-events: none; |
| + opacity: 0; |
| + clip-path: inset(50%); |
| + } |
| + [estilo-side-frame~="rail"] [estilo-side-item]:hover [estilo-side-label], |
| + [estilo-side-frame~="rail"] [estilo-side-item]:focus-visible [estilo-side-label] { |
| + opacity: 1; |
| + clip-path: none; |
| + } |
| +} |
| +@media (min-width: 800px) and (max-width: 79.99rem) { |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side] { padding-inline: 8px; align-items: center; } |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-item] { |
| + grid-template-columns: 18px; |
| + justify-content: center; |
| + inline-size: 40px; |
| + min-block-size: 38px; |
| + padding: 0; |
| + border-radius: 10px; |
| + } |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-item] > svg { inline-size: 18px; block-size: 18px; } |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-item] > kbd, |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-head], |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-page] { display: none; } |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-item][aria-current] { background: none; } |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-holds="open"] { display: none; } |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-holds="rail"] { display: grid; } |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-item][aria-current]::before { |
| + content: ""; |
| + position: absolute; |
| + inset-inline-start: -8px; |
| + inset-block-start: 10px; |
| + inline-size: 3px; |
| + block-size: 18px; |
| + border-radius: 0 3px 3px 0; |
| + background: var(--rst-accent); |
| + } |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-label] { |
| + position: fixed; |
| + margin-inline-start: 50px; |
| + margin-block-start: 19px; |
| + translate: 0 -50%; |
| + z-index: 30; |
| + padding: 4px 8px; |
| + border-radius: 6px; |
| + background: var(--rst-text); |
| + color: var(--rst-surface); |
| + font-size: 12px; |
| + font-weight: 500; |
| + pointer-events: none; |
| + opacity: 0; |
| + clip-path: inset(50%); |
| + } |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-item]:hover [estilo-side-label], |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-item]:focus-visible [estilo-side-label] { |
| + opacity: 1; |
| + clip-path: none; |
| + } |
| +} |
| + |
| +/* Where the engine anchors, each tooltip is tied to its own row |
| + (anchor-scope keeps the name to that row), so it follows the rail as |
| + it scrolls; a static position is fixed where layout put it. An app |
| + anchoring something else to a row (Mapa's New team page popover) |
| + names both: anchor-name: --its-own, --estilo-side-item. */ |
| +@supports (anchor-name: --estilo-side-item) { |
| + @media (min-width: 800px) { |
| + [estilo-side-item] { anchor-name: --estilo-side-item; anchor-scope: --estilo-side-item; } |
| + [estilo-side-frame~="rail"] [estilo-side-label] { |
| + position-anchor: --estilo-side-item; |
| + inset-block-start: anchor(center); |
| + inset-inline-start: calc(anchor(end) + 10px); |
| + margin: 0; |
| + } |
| + } |
| + @media (min-width: 800px) and (max-width: 79.99rem) { |
| + [estilo-side-frame]:not([estilo-side-frame~="open"], [estilo-side-frame~="rail"]) [estilo-side-label] { |
| + position-anchor: --estilo-side-item; |
| + inset-block-start: anchor(center); |
| + inset-inline-start: calc(anchor(end) + 10px); |
| + margin: 0; |
| + } |
| + } |
| +} |
| + |
| +/* Below 800px there is no side: its places are rows in estilo's Menu |
| + sheet. Last, so it wins over [estilo-side]'s own display. */ |
| +@media (max-width: 799.98px) { |
| + [estilo-side-frame] { grid-template-columns: minmax(0, 1fr); } |
| + [estilo-side] { display: none; } |
| +} |
diff --git a/side/side.go b/side/side.go| new file mode 100644 |
| index 0000000..de552e5 |
| --- /dev/null |
| +++ b/side/side.go |
| @@ -0,0 +1,200 @@ |
| +// Package side is an app's side panel ([estilo-side]) and the frame that |
| +// puts it under the bar, beside <main> ([estilo-side-frame]). Its rows |
| +// ([estilo-side-item]) are an icon and a label ([estilo-side-label]) with |
| +// an optional shortcut ([estilo-side-key]); page rows sit under section |
| +// headings ([estilo-side-head]), and the foot ([estilo-side-foot]) is |
| +// pinned to the bottom with the fold, which turns the side into a rail of |
| +// icons and back. |
| +// |
| +// Mapa built it (its level-up spec, §3.2) and Contra is the second app to |
| +// use it, so it moved here when Contra adopted it (AGENTS.md, decisions |
| +// table). The values and the behaviour are Mapa's, copied; changing them |
| +// is a design decision. |
| +// |
| +// Widths: from 80rem the side is open by default and below it a rail; |
| +// the State (a cookie the app keeps) overrides that from 800px. Below |
| +// 800px there is no side: its places belong in the bar's Menu sheet |
| +// (chrome.Bar.Nav), and the bar's own nav is hidden from 800px on a page |
| +// with a frame, because the side carries the places there. |
| +// |
| +// Script line: everything works with scripts off. Rows are links; the |
| +// fold is a form that POSTs the new state (SetState stores it), and the |
| +// frame draws it on the next page. JS() only folds in place, with the |
| +// same cookie, and adds ⌘\ (Ctrl+\ elsewhere). |
| +// |
| +// It carries no strings. Callers supply every label in their locale. |
| +package side |
| + |
| +import ( |
| + "embed" |
| + "html/template" |
| + "net/http" |
| +) |
| + |
| +//go:embed side.css |
| +var css []byte |
| + |
| +//go:embed side.js |
| +var js []byte |
| + |
| +//go:embed templates/*.html |
| +var templateFS embed.FS |
| + |
| +// CSS returns side.css. Link it after chrome.css: the side's private |
| +// notes use chrome's [estilo-visually-hidden], and it sizes itself by |
| +// chrome's --estilo-bar-block-size. |
| +func CSS() []byte { return append([]byte(nil), css...) } |
| + |
| +// JS returns side.js, an optional classic script (defer) that folds the |
| +// side in place: any control with data-estilo-side-fold (the fold's own |
| +// buttons, or an app's menu row) and ⌘\ or Ctrl+\ switch the frame |
| +// between open and rail and set the fold's cookie. Without it the fold |
| +// posts and the next page is drawn folded. |
| +func JS() []byte { return append([]byte(nil), js...) } |
| + |
| +// Templates holds estilo-side, estilo-side-item, estilo-side-fold and the |
| +// side's two icons (estilo-icon-panel-left, estilo-icon-lock). Parse it |
| +// into the app's page templates with ParseFS(Templates(), "templates/*.html"). |
| +func Templates() embed.FS { return templateFS } |
| + |
| +// Side is estilo-side's data. |
| +// |
| +// The frame is the app's own markup, around the side and <main>: |
| +// |
| +// <div estilo-side-frame="{{.State}}"> |
| +// {{template "estilo-side" .}} |
| +// <main id="main">…</main> |
| +// </div> |
| +type Side struct { |
| + // Label is the side's accessible name: the app's name ("Mapa"). |
| + Label string |
| + // State is what the side shows: "open", "rail", or "" to let the |
| + // width decide (open from 80rem). Write it as the frame's |
| + // estilo-side-frame value. Read it with State. |
| + State string |
| + // Places are the app's sections. They stay on the rail, as icons. |
| + Places []Item |
| + // Sections are lists of page rows under a heading ("Pinned", |
| + // "Recently edited"). The rail hides them. A section with no items |
| + // draws nothing, heading included. |
| + Sections []Section |
| + // Foot is app markup drawn at the top of the foot, before the fold |
| + // (Mapa's New team page): estilo-side-item rows the app rendered |
| + // itself, with estilo-side-label around each label so the rail can |
| + // make it the tooltip. Trusted markup, never user input. |
| + Foot template.HTML |
| + // Fold is the fold to a rail; nil leaves the side always as the |
| + // width draws it. |
| + Fold *Fold |
| +} |
| + |
| +// Section is one heading and its page rows. |
| +type Section struct { |
| + Heading string |
| + Items []Item |
| +} |
| + |
| +// Item is one row. |
| +type Item struct { |
| + Href, Label string |
| + // Icon is the row's glyph: the app's own inline <svg |
| + // aria-hidden="true">, trusted markup. Every row has one; on the rail |
| + // it is all that shows. |
| + Icon template.HTML |
| + // Key is an already-formatted shortcut (menu.Shortcut), shown at the |
| + // row's end in the open side (Mapa's Search, ⌘K). Optional. |
| + Key string |
| + // Current marks the row for the page on screen (aria-current="page"). |
| + // Call Light before rendering so exactly one row carries it. |
| + Current bool |
| + // Holds is set by Light on a place that holds the page on screen when |
| + // that page has its own row: the place is drawn twice, unlit for the |
| + // open side and lit for the rail, which hides the page rows. |
| + Holds bool |
| + // Locked, when set, puts a lock at the row's end (Mapa: a private |
| + // note of your own) and is said after the label (", only you see |
| + // this"). |
| + Locked string |
| +} |
| + |
| +// Fold is the side's fold: a form that POSTs state=rail or state=open |
| +// to Action, with Return as "return", for the app to store with SetState |
| +// and redirect. Both buttons are drawn and CSS shows the one that fits |
| +// what is on screen, so it works with scripts off and with no cookie. |
| +type Fold struct { |
| + Action, Return string |
| + // Hide and Show are the two buttons' labels ("Hide sidebar", "Show |
| + // sidebar"). |
| + Hide, Show string |
| + // Key is the shortcut shown on Hide: menu.Shortcut(r, "Mod+\\"). |
| + // side.js binds ⌘\ and Ctrl+\ whether or not it is shown. |
| + Key string |
| + // Cookie is the cookie that holds the state (Mapa's "mapa-sidebar"), |
| + // for side.js to set when it folds in place. The same name goes to |
| + // State and SetState. |
| + Cookie string |
| +} |
| + |
| +// Light leaves exactly one full highlight (Mapa, Paul 2026-11-16): on the |
| +// page's own row when it has one, the first current row of the |
| +// Sections, and otherwise on its place. When a page row is lit, a place |
| +// that was current becomes Holds instead: drawn twice, unlit while the |
| +// side is open and lit on the rail, which hides the page rows. The |
| +// state, the width and a fold in place all choose between them by CSS |
| +// alone. |
| +func (s *Side) Light() { |
| + lit := false |
| + for i := range s.Sections { |
| + items := s.Sections[i].Items |
| + for j := range items { |
| + if items[j].Current && lit { |
| + items[j].Current = false |
| + } |
| + if items[j].Current { |
| + lit = true |
| + } |
| + } |
| + } |
| + if !lit { |
| + return |
| + } |
| + for i := range s.Places { |
| + place := &s.Places[i] |
| + place.Holds, place.Current = place.Current, false |
| + } |
| +} |
| + |
| +// cookieYear is how long a fold is kept. |
| +const cookieYear = 365 * 24 * 60 * 60 |
| + |
| +// State is the side's state from the request's cookie: "open", "rail", |
| +// or "" when it holds nothing known, which lets the width decide. |
| +func State(r *http.Request, cookie string) string { |
| + c, err := r.Cookie(cookie) |
| + if err != nil { |
| + return "" |
| + } |
| + switch c.Value { |
| + case "open", "rail": |
| + return c.Value |
| + } |
| + return "" |
| +} |
| + |
| +// SetState is the fold's POST handler's work: it reads the form's |
| +// "state", or, without a known one, toggles from "shown" (what the page |
| +// showed), stores it in the cookie for a year and returns it. A fold is |
| +// a view preference, not a write. The app redirects, to the form's |
| +// "return" once it has checked that it is a path on its own site. |
| +func SetState(w http.ResponseWriter, r *http.Request, cookie string) string { |
| + state := r.PostFormValue("state") |
| + if state != "open" && state != "rail" { |
| + state = "rail" |
| + if r.PostFormValue("shown") == "rail" { |
| + state = "open" |
| + } |
| + } |
| + http.SetCookie(w, &http.Cookie{Name: cookie, Value: state, Path: "/", |
| + MaxAge: cookieYear, SameSite: http.SameSiteLaxMode, Secure: true}) |
| + return state |
| +} |
diff --git a/side/side.js b/side/side.js| new file mode 100644 |
| index 0000000..18b1c7d |
| --- /dev/null |
| +++ b/side/side.js |
| @@ -0,0 +1,55 @@ |
| +// side.js: folds the side to its rail, or opens it, in place (estilo |
| +// side). Optional: without it the fold's form posts the new state and the |
| +// next page is drawn folded. It sets the same cookie the form does |
| +// (data-estilo-side-cookie on the fold's form), so the next page is drawn |
| +// the same. Mapa's, copied. |
| +(function () { |
| + "use strict"; |
| + |
| + // shown is what the side shows now: the frame's state, or what CSS |
| + // chose by width when there is none (open from 80rem). |
| + function shown(frame) { |
| + var state = (frame.getAttribute("estilo-side-frame") || "").split(/\s+/); |
| + if (state.indexOf("open") >= 0) return "open"; |
| + if (state.indexOf("rail") >= 0) return "rail"; |
| + return window.matchMedia("(min-width: 80rem)").matches ? "open" : "rail"; |
| + } |
| + |
| + function fold() { |
| + var frame = document.querySelector("[estilo-side-frame]"); |
| + if (!frame) return; |
| + var next = shown(frame) === "open" ? "rail" : "open"; |
| + frame.setAttribute("estilo-side-frame", next); |
| + var form = document.querySelector("form[estilo-side-fold][data-estilo-side-cookie]"); |
| + if (!form) return; |
| + document.cookie = form.getAttribute("data-estilo-side-cookie") + "=" + next + |
| + "; path=/; max-age=31536000; samesite=lax" + |
| + (location.protocol === "https:" ? "; secure" : ""); |
| + } |
| + |
| + function start() { |
| + // The fold's own buttons, and any control an app marks (a View menu |
| + // row): each folds in place instead of posting. |
| + document.querySelectorAll("[data-estilo-side-fold]").forEach(function (control) { |
| + control.disabled = false; |
| + control.addEventListener("click", function (event) { |
| + event.preventDefault(); |
| + var menu = control.closest("details"); |
| + if (menu) menu.open = false; |
| + fold(); |
| + }); |
| + }); |
| + document.addEventListener("keydown", function (event) { |
| + if ((event.metaKey || event.ctrlKey) && event.key === "\\") { |
| + event.preventDefault(); |
| + fold(); |
| + } |
| + }); |
| + } |
| + |
| + if (document.readyState === "loading") { |
| + document.addEventListener("DOMContentLoaded", start); |
| + } else { |
| + start(); |
| + } |
| +})(); |
diff --git a/side/side.test.mjs b/side/side.test.mjs| new file mode 100644 |
| index 0000000..2140cb4 |
| --- /dev/null |
| +++ b/side/side.test.mjs |
| @@ -0,0 +1,113 @@ |
| +// side.js behaviour, run under Node against a minimal DOM: just enough |
| +// elements, attribute selectors and event dispatch for the script's own |
| +// selectors. |
| +import assert from "node:assert/strict"; |
| +import fs from "node:fs"; |
| +import test from "node:test"; |
| +import vm from "node:vm"; |
| + |
| +const src = fs.readFileSync(new URL("./side.js", import.meta.url), "utf8"); |
| + |
| +// A compound selector: tag, [attr] and [attr="value"], comma-separated. |
| +function matches(el, selector) { |
| + return selector.split(",").some((part) => { |
| + const m = part.trim().match(/^([a-z]*)((?:\[[^\]]+\])*)$/); |
| + if (!m) throw new Error("unsupported selector " + part); |
| + if (m[1] && el.tag !== m[1]) return false; |
| + for (const [, name, value] of m[2].matchAll(/\[([^=\]]+)(?:="([^"]*)")?\]/g)) { |
| + if (!el.attrs.has(name)) return false; |
| + if (value !== undefined && el.attrs.get(name) !== value) return false; |
| + } |
| + return true; |
| + }); |
| +} |
| + |
| +class El { |
| + constructor(tag, attrs = {}, children = []) { |
| + this.tag = tag; |
| + this.attrs = new Map(Object.entries(attrs)); |
| + this.children = children; |
| + this.parent = null; |
| + this.listeners = []; |
| + this.disabled = "disabled" in attrs; |
| + for (const c of children) c.parent = this; |
| + } |
| + getAttribute(n) { return this.attrs.has(n) ? this.attrs.get(n) : null; } |
| + setAttribute(n, v) { this.attrs.set(n, String(v)); } |
| + get open() { return this.attrs.has("open"); } |
| + set open(v) { if (v) this.attrs.set("open", ""); else this.attrs.delete("open"); } |
| + addEventListener(type, fn) { this.listeners.push({ type, fn }); } |
| + click() { |
| + const e = { type: "click", defaultPrevented: false, preventDefault() { this.defaultPrevented = true; } }; |
| + for (const l of this.listeners.filter((l) => l.type === "click")) l.fn(e); |
| + return e; |
| + } |
| + *walk() { for (const c of this.children) { yield c; yield* c.walk(); } } |
| + querySelectorAll(s) { return [...this.walk()].filter((e) => matches(e, s)); } |
| + querySelector(s) { return this.querySelectorAll(s)[0] ?? null; } |
| + closest(s) { for (let e = this; e; e = e.parent) if (e.tag && matches(e, s)) return e; return null; } |
| +} |
| + |
| +function page(state, { wide = true, protocol = "https:" } = {}) { |
| + const hide = new El("button", { "estilo-side-fold-to": "rail", "data-estilo-side-fold": "" }); |
| + const show = new El("button", { "estilo-side-fold-to": "open", "data-estilo-side-fold": "" }); |
| + const form = new El("form", { "estilo-side-fold": "", "data-estilo-side-cookie": "app-side" }, [hide, show]); |
| + const row = new El("button", { "estilo-menu-item": "", "data-estilo-side-fold": "", disabled: "" }); |
| + const menu = new El("details", { open: "" }, [row]); |
| + const frame = new El("div", { "estilo-side-frame": state }, [new El("nav", { "estilo-side": "" }, [form])]); |
| + const root = new El("", {}, [menu, frame]); |
| + const listeners = []; |
| + const document = { |
| + readyState: "complete", |
| + cookie: "", |
| + querySelector: (s) => root.querySelector(s), |
| + querySelectorAll: (s) => root.querySelectorAll(s), |
| + addEventListener: (type, fn) => listeners.push({ type, fn }), |
| + }; |
| + const window = { matchMedia: () => ({ matches: wide }) }; |
| + vm.runInNewContext(src, { document, window, location: { protocol } }); |
| + const key = (init) => { |
| + const e = { type: "keydown", defaultPrevented: false, preventDefault() { this.defaultPrevented = true; }, ...init }; |
| + for (const l of listeners.filter((l) => l.type === "keydown")) l.fn(e); |
| + return e; |
| + }; |
| + return { document, frame, hide, show, row, menu, key }; |
| +} |
| + |
| +test("the fold folds in place and sets the form's cookie", () => { |
| + const p = page("open"); |
| + const e = p.hide.click(); |
| + assert.equal(e.defaultPrevented, true); |
| + assert.equal(p.frame.getAttribute("estilo-side-frame"), "rail"); |
| + assert.equal(p.document.cookie, "app-side=rail; path=/; max-age=31536000; samesite=lax; secure"); |
| + p.show.click(); |
| + assert.equal(p.frame.getAttribute("estilo-side-frame"), "open"); |
| +}); |
| + |
| +test("with no state the width decides what is shown", () => { |
| + const wide = page("", { wide: true }); |
| + wide.hide.click(); |
| + assert.equal(wide.frame.getAttribute("estilo-side-frame"), "rail"); |
| + const narrow = page("", { wide: false, protocol: "http:" }); |
| + narrow.show.click(); |
| + assert.equal(narrow.frame.getAttribute("estilo-side-frame"), "open"); |
| + assert.equal(narrow.document.cookie, "app-side=open; path=/; max-age=31536000; samesite=lax"); |
| +}); |
| + |
| +test("an app's menu row folds, is enabled and closes its menu", () => { |
| + const p = page("open"); |
| + assert.equal(p.row.disabled, false); |
| + p.row.click(); |
| + assert.equal(p.menu.open, false); |
| + assert.equal(p.frame.getAttribute("estilo-side-frame"), "rail"); |
| +}); |
| + |
| +test("Cmd or Ctrl and backslash fold; other keys do not", () => { |
| + const p = page("rail"); |
| + assert.equal(p.key({ key: "\\", metaKey: true }).defaultPrevented, true); |
| + assert.equal(p.frame.getAttribute("estilo-side-frame"), "open"); |
| + p.key({ key: "\\", ctrlKey: true }); |
| + assert.equal(p.frame.getAttribute("estilo-side-frame"), "rail"); |
| + assert.equal(p.key({ key: "\\" }).defaultPrevented, false); |
| + assert.equal(p.frame.getAttribute("estilo-side-frame"), "rail"); |
| +}); |
diff --git a/side/side_test.go b/side/side_test.go| new file mode 100644 |
| index 0000000..1a78183 |
| --- /dev/null |
| +++ b/side/side_test.go |
| @@ -0,0 +1,213 @@ |
| +package side |
| + |
| +import ( |
| + "bytes" |
| + "html/template" |
| + "net/http" |
| + "net/http/httptest" |
| + "os/exec" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/estilo.git/internal/tokencheck" |
| +) |
| + |
| +const glyph = template.HTML(`<svg aria-hidden="true"></svg>`) |
| + |
| +func render(t *testing.T, s Side) string { |
| + t.Helper() |
| + tmpl, err := template.ParseFS(Templates(), "templates/*.html") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var b bytes.Buffer |
| + if err := tmpl.ExecuteTemplate(&b, "estilo-side", s); err != nil { |
| + t.Fatal(err) |
| + } |
| + return b.String() |
| +} |
| + |
| +func sample() Side { |
| + return Side{ |
| + Label: "Mapa", |
| + Places: []Item{ |
| + {Href: "/", Label: "Home", Icon: glyph, Current: true}, |
| + {Href: "/search", Label: "Search", Icon: glyph, Key: "⌘K"}, |
| + }, |
| + Sections: []Section{ |
| + {Heading: "Pinned", Items: []Item{ |
| + {Href: "/p/a", Label: "Alpha", Icon: glyph, Current: true, Locked: ", only you see this"}, |
| + }}, |
| + {Heading: "Recently edited", Items: []Item{ |
| + {Href: "/p/a", Label: "Alpha", Icon: glyph, Current: true}, |
| + {Href: "/p/b", Label: "Beta", Icon: glyph}, |
| + }}, |
| + {Heading: "Empty"}, |
| + }, |
| + Foot: template.HTML(`<a estilo-side-item href="/new">` + string(glyph) + `<span estilo-side-label>New</span></a>`), |
| + Fold: &Fold{Action: "/view/sidebar", Return: "/p/a", Hide: "Hide sidebar", |
| + Show: "Show sidebar", Key: `⌘\`, Cookie: "mapa-sidebar"}, |
| + } |
| +} |
| + |
| +// Exactly one full highlight: the first page row for the page, and its |
| +// place drawn twice (unlit open, lit and hidden for the rail). |
| +func TestLightLeavesOneHighlight(t *testing.T) { |
| + s := sample() |
| + s.Light() |
| + if s.Places[0].Current || !s.Places[0].Holds { |
| + t.Errorf("place holding the page: Current %v Holds %v, want false true", s.Places[0].Current, s.Places[0].Holds) |
| + } |
| + if s.Places[1].Holds { |
| + t.Error("a place not holding the page became Holds") |
| + } |
| + if !s.Sections[0].Items[0].Current || s.Sections[1].Items[0].Current { |
| + t.Error("the first page row must keep the highlight and the second lose it") |
| + } |
| + html := render(t, s) |
| + if n := strings.Count(html, `aria-current="page"`); n != 2 { |
| + t.Errorf("%d rows carry aria-current, want 2 (the page row and the rail's hidden place)", n) |
| + } |
| + for _, want := range []string{ |
| + `<a estilo-side-item estilo-side-holds="open" href="/">`, |
| + `<a estilo-side-item estilo-side-holds="rail" href="/" aria-current="page" hidden>`, |
| + `<a estilo-side-item estilo-side-page href="/p/a" aria-current="page">`, |
| + } { |
| + if !strings.Contains(html, want) { |
| + t.Errorf("missing %s", want) |
| + } |
| + } |
| +} |
| + |
| +// With no page row lit, the place keeps the highlight and is drawn once. |
| +func TestLightKeepsThePlaceWithoutAPageRow(t *testing.T) { |
| + s := sample() |
| + s.Sections = nil |
| + s.Light() |
| + if !s.Places[0].Current || s.Places[0].Holds { |
| + t.Error("the place must keep the highlight when no page row has it") |
| + } |
| + if strings.Contains(render(t, s), "estilo-side-holds") { |
| + t.Error("a place is drawn twice with no page row lit") |
| + } |
| +} |
| + |
| +func TestRendersRowsHeadsFootAndFold(t *testing.T) { |
| + s := sample() |
| + s.Light() |
| + html := render(t, s) |
| + for _, want := range []string{ |
| + `<nav estilo-side aria-label="Mapa">`, |
| + `<span estilo-side-label>Search</span><kbd estilo-side-key aria-hidden="true">⌘K</kbd>`, |
| + `<h2 estilo-side-head>Pinned</h2>`, |
| + `<h2 estilo-side-head>Recently edited</h2>`, |
| + `<span estilo-side-label>Alpha<span estilo-visually-hidden>, only you see this</span></span><span estilo-side-lock aria-hidden="true">`, |
| + `<div estilo-side-foot><a estilo-side-item href="/new">`, |
| + `<form method="post" action="/view/sidebar" estilo-side-fold data-estilo-side-cookie="mapa-sidebar">`, |
| + `<input type="hidden" name="return" value="/p/a">`, |
| + `name="state" value="rail" estilo-side-fold-to="rail" data-estilo-side-fold>`, |
| + `<span estilo-side-label>Hide sidebar</span><kbd estilo-side-key aria-hidden="true">⌘\</kbd>`, |
| + `name="state" value="open" estilo-side-fold-to="open" data-estilo-side-fold>`, |
| + `<span estilo-side-label>Show sidebar</span></button>`, |
| + } { |
| + if !strings.Contains(html, want) { |
| + t.Errorf("missing %s", want) |
| + } |
| + } |
| + if strings.Contains(html, "Empty") { |
| + t.Error("a section with no items drew its heading") |
| + } |
| + s.Fold = nil |
| + if strings.Contains(render(t, s), "estilo-side-fold") { |
| + t.Error("a nil Fold still drew the fold") |
| + } |
| +} |
| + |
| +func TestStateAndSetState(t *testing.T) { |
| + r := httptest.NewRequest(http.MethodGet, "/", nil) |
| + if got := State(r, "app-side"); got != "" { |
| + t.Errorf("no cookie: %q, want empty", got) |
| + } |
| + for value, want := range map[string]string{"open": "open", "rail": "rail", "wide": ""} { |
| + r := httptest.NewRequest(http.MethodGet, "/", nil) |
| + r.AddCookie(&http.Cookie{Name: "app-side", Value: value}) |
| + if got := State(r, "app-side"); got != want { |
| + t.Errorf("cookie %q: %q, want %q", value, got, want) |
| + } |
| + } |
| + for _, c := range []struct{ form, want string }{ |
| + {"state=rail", "rail"}, |
| + {"state=open", "open"}, |
| + {"shown=rail", "open"}, |
| + {"shown=open", "rail"}, |
| + {"state=wide", "rail"}, |
| + } { |
| + r := httptest.NewRequest(http.MethodPost, "/view/side", strings.NewReader(c.form)) |
| + r.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| + w := httptest.NewRecorder() |
| + if got := SetState(w, r, "app-side"); got != c.want { |
| + t.Errorf("%s: %q, want %q", c.form, got, c.want) |
| + } |
| + set := w.Result().Cookies() |
| + if len(set) != 1 || set[0].Name != "app-side" || set[0].Value != c.want || |
| + set[0].Path != "/" || !set[0].Secure || set[0].SameSite != http.SameSiteLaxMode || set[0].MaxAge != cookieYear { |
| + t.Errorf("%s: cookie %+v", c.form, set) |
| + } |
| + } |
| +} |
| + |
| +func TestSideTokensAreDefined(t *testing.T) { |
| + missing, n := tokencheck.Undefined(CSS()) |
| + if n == 0 { |
| + t.Fatal("side.css reads no rastrillo token; the check would pass vacuously") |
| + } |
| + if len(missing) > 0 { |
| + t.Fatal("side.css reads undefined tokens:", missing) |
| + } |
| +} |
| + |
| +// The values are Mapa's own, copied; a change here is a design decision. |
| +func TestValuesAreMapas(t *testing.T) { |
| + src := string(CSS()) |
| + for _, want := range []string{ |
| + "--estilo-side-inline-size: 224px", |
| + "--estilo-side-rail-inline-size: 56px", |
| + "background: light-dark(#f8f9fb, #191b21)", |
| + "grid-template-columns: 16px minmax(0, 1fr) auto", |
| + "min-block-size: 30px", |
| + "[estilo-side-item][aria-current] { background: var(--rst-accent-soft)", |
| + "inline-size: 40px", |
| + "min-block-size: 38px", |
| + "@media (max-width: 79.99rem)", |
| + "anchor-scope: --estilo-side-item", |
| + } { |
| + if !strings.Contains(src, want) { |
| + t.Errorf("side.css lost %q", want) |
| + } |
| + } |
| +} |
| + |
| +// Below 800px there is no side; the rule is last so it wins over the |
| +// side's own display at any specificity it shares. |
| +func TestPhoneHidesTheSideLast(t *testing.T) { |
| + src := strings.TrimSpace(string(CSS())) |
| + i := strings.LastIndex(src, "@media (max-width: 799.98px)") |
| + if i < 0 { |
| + t.Fatal("side.css has no phone rule") |
| + } |
| + tail := src[i:] |
| + if !strings.Contains(tail, "[estilo-side] { display: none; }") || |
| + !strings.Contains(tail, "[estilo-side-frame] { grid-template-columns: minmax(0, 1fr); }") || |
| + strings.Count(tail, "}") != 3 { |
| + t.Errorf("the phone rule must be side.css's last block:\n%s", tail) |
| + } |
| +} |
| + |
| +// side.js's behaviour runs under Node against a minimal DOM |
| +// (side.test.mjs), the way chrome's does. |
| +func TestScriptBehaviour(t *testing.T) { |
| + out, err := exec.Command("node", "--test", "side.test.mjs").CombinedOutput() |
| + if err != nil { |
| + t.Fatalf("node --test side.test.mjs: %v\n%s", err, out) |
| + } |
| +} |
diff --git a/side/templates/side.html b/side/templates/side.html| new file mode 100644 |
| index 0000000..4518bb0 |
| --- /dev/null |
| +++ b/side/templates/side.html |
| @@ -0,0 +1,54 @@ |
| +{{/* estilo-side: the app's side panel, one grid per row. In the rail |
| + the labels stay in the accessibility tree and show as tooltips. One |
| + shown row carries aria-current (side.Light): the page's own row, or |
| + its place. A place holding a page that has its own row is drawn twice |
| + (estilo-side-holds): unlit while the side is open, lit in the rail, |
| + which hides the page rows; CSS shows one. The lit copy is [hidden] |
| + too, so with no CSS at all only the page's row is lit; the rail's CSS |
| + draws it all the same. The fold is two submit buttons, one per state; |
| + CSS shows the one that fits what is on screen, so it works with |
| + scripts off and with no cookie. |
| + |
| + Data: side.Side. The frame around it and <main> is the app's: |
| + <div estilo-side-frame="{{.State}}">. */}} |
| +{{define "estilo-side"}}<nav estilo-side aria-label="{{.Label}}"> |
| + {{- range .Places}} |
| + {{- if .Holds}} |
| + <a estilo-side-item estilo-side-holds="open" href="{{.Href}}">{{template "estilo-side-item-body" .}}</a> |
| + <a estilo-side-item estilo-side-holds="rail" href="{{.Href}}" aria-current="page" hidden>{{template "estilo-side-item-body" .}}</a> |
| + {{- else}} |
| + {{template "estilo-side-item" .}} |
| + {{- end}} |
| + {{- end}} |
| + {{- range .Sections}}{{if .Items}} |
| + <h2 estilo-side-head>{{.Heading}}</h2> |
| + {{- range .Items}} |
| + <a estilo-side-item estilo-side-page href="{{.Href}}"{{if .Current}} aria-current="page"{{end}}>{{template "estilo-side-item-body" .}}</a> |
| + {{- end}} |
| + {{- end}}{{end}} |
| + <div estilo-side-foot> |
| + {{- .Foot}} |
| + {{- with .Fold}} |
| + {{template "estilo-side-fold" .}} |
| + {{- end}} |
| + </div> |
| +</nav>{{end}} |
| + |
| +{{/* estilo-side-item: one place row, a link. Data: side.Item. An app |
| + drawing its own foot rows can use it too. */}} |
| +{{define "estilo-side-item"}}<a estilo-side-item href="{{.Href}}"{{if .Current}} aria-current="page"{{end}}>{{template "estilo-side-item-body" .}}</a>{{end}} |
| +{{define "estilo-side-item-body"}}{{.Icon}}<span estilo-side-label>{{.Label}}{{with .Locked}}<span estilo-visually-hidden>{{.}}</span>{{end}}</span>{{if .Locked}}<span estilo-side-lock aria-hidden="true">{{template "estilo-icon-lock"}}</span>{{end}}{{with .Key}}<kbd estilo-side-key aria-hidden="true">{{.}}</kbd>{{end}}{{end}} |
| + |
| +{{/* estilo-side-fold: Hide and Show, one per state. Each is a real |
| + POST of state=rail or state=open; side.js, when present, folds in |
| + place instead. Data: side.Fold. */}} |
| +{{define "estilo-side-fold"}}<form method="post" action="{{.Action}}" estilo-side-fold{{with .Cookie}} data-estilo-side-cookie="{{.}}"{{end}}> |
| + <input type="hidden" name="return" value="{{.Return}}"> |
| + <button estilo-side-item type="submit" name="state" value="rail" estilo-side-fold-to="rail" data-estilo-side-fold>{{template "estilo-icon-panel-left"}}<span estilo-side-label>{{.Hide}}</span>{{with .Key}}<kbd estilo-side-key aria-hidden="true">{{.}}</kbd>{{end}}</button> |
| + <button estilo-side-item type="submit" name="state" value="open" estilo-side-fold-to="open" data-estilo-side-fold>{{template "estilo-icon-panel-left"}}<span estilo-side-label>{{.Show}}</span></button> |
| + </form>{{end}} |
| + |
| +{{/* The side's glyphs. Lucide "panel-left" and "lock" (ISC, |
| + brand/LICENSE.lucide). Decorative: each sits beside a label. */}} |
| +{{define "estilo-icon-panel-left"}}<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/></svg>{{end}} |
| +{{define "estilo-icon-lock"}}<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>{{end}} |