oficina / estilo Public

chrome: compact phone bar, touch-sized targets, stacked header from 704 px for compact bars (#43)

Opt-in Bar.Compact: one 52 px row below 704 px (Back, title with
ellipsis, lead, app controls), folded inline title, ••• drop-down. On
coarse pointers every bar button and menu row is 44 px and ⌘ hints are
hidden. The 704-800 px band applies only to compact bars (generated
scoped copy, :where so specificity is unchanged). New subtitle
save-state style.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from feat/phone-compact-bar into main.
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 2b2beb50e03156fe64681e67700e9937ef1f44b2 parent 49ad7d4
19 files changed, +1,719 −49
  • README.md +19 −0
  • chrome/chrome.css +200 −9
  • chrome/chrome.go +200 −2
  • chrome/chrome.js +18 −2
  • chrome/compact.browser.mjs +239 −0
  • chrome/compact_browser_test.go +459 −0
  • chrome/compact_test.go +415 −0
  • chrome/stack_test.go +2 −2
  • chrome/templates/bar.html +19 −5
  • chrome/templates/icons.html +4 −1
  • chrome/unchanged_test.go +12 −25
  • implementation/save-status.md +5 −0
  • menu/menu.css +17 −0
  • menu/menu.go +8 −0
  • menu/templates/menu.html +3 −2
  • menu/touch_test.go +41 −0
  • savestatus/status.css +16 −0
  • savestatus/status.go +9 −1
  • savestatus/subtitle_test.go +33 −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.004s
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.004s
ok  	amadan.net/oficina/estilo.git/chrome	1.064s
?   	amadan.net/oficina/estilo.git/cmd/oficina-notices	[no test files]
ok  	amadan.net/oficina/estilo.git/colophon	0.023s
ok  	amadan.net/oficina/estilo.git/credits	0.006s
ok  	amadan.net/oficina/estilo.git/credits/catalog	0.004s
ok  	amadan.net/oficina/estilo.git/desk	0.004s
ok  	amadan.net/oficina/estilo.git/googleimport	0.163s
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.112s
ok  	amadan.net/oficina/estilo.git/side	0.134s
ok  	amadan.net/oficina/estilo.git/sky	0.031s
ok  	amadan.net/oficina/estilo.git/theme	0.014s
ok  	amadan.net/oficina/estilo.git/typeface	0.331s
=== spacing ===
go run amadan.net/rastrillo/fiesta/cmd/fiesta@v1.7.0 spacing .
diff --git a/README.md b/README.md
index ea16b11..04419a5 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,25 @@ and keeps it out of the Menu sheet, and `menu.Item.Controls` is a toggle
account menu's Appearance is a three-way segmented selector that
`chrome.js` switches in place.
+Docs' phone web design (Paul, 2026-11-28) added `Bar.Compact`
+(`estilo-bar~="compact"`): below 704px, or on a phone held sideways, the
+bar is one 52px row of Back (the brand: a chevron and the app's name),
+the title, the lead and the app's `Compact.Trail` (Docs' Aa and •••); the
+menu row, the actions, the switcher and the account are not shown there,
+and the Menu sheet is drawn only for `Nav`. From 704px a compact stacked
+bar is the 56px header, which every other stacked bar keeps from 800px
+(Mapa's and Fichas' layouts change there); the 704px band is a copy of
+the header's rules that `CSS()` makes, scoped to a compact bar. `Compact.Title` replaces
+the bar's title for a page with a large title of its own: it shows once
+the app's script sets `estilo-bar-folded` on the header. In the trail,
+`[estilo-bar-tool]` is a 44px round control and a `<details>` panel is a
+drop-down from the bar's inline end with 44px rows. `menu.Item.Icon`
+draws a glyph before a row's label. On a coarse pointer, in every app,
+the bar's triggers, the rail's account row, every menu row and every
+menubar title are 44px, and where nothing hovers
+menus show no shortcut hints. `savestatus` takes a third placement,
+`subtitle`, for the state under a large title.
+
The smart door (spec `docs/superpowers/specs/2026-11-19-smart-door.md` in
Home, step 2) is `estilo-signin-screen` with `chrome.SignInScreen`:
rastrillo's sign-in screen, its ui `signin` partial (the remembered way
diff --git a/chrome/chrome.css b/chrome/chrome.css
index 95a4320..2d0107f 100644
--- a/chrome/chrome.css
+++ b/chrome/chrome.css
@@ -7,6 +7,13 @@
--estilo-z-bar: 45; /* PUBLIC: the bar's stacking level, and the ceiling for in-page layers */
--estilo-trigger-size: 2rem; /* 32px targets, above the 24px floor */
}
+/* On touch every bar trigger (Menu, the switcher, the account) is a 44px
+ target, the size Apple's and Google's guidance ask for, in every app:
+ the phone web audit (2026-11-28, finding 9) measured them at 34x32 and
+ 44x32. The 52px bar has the room. */
+@media (pointer: coarse) {
+ :root { --estilo-trigger-size: 2.75rem; }
+}
[estilo-bar] {
position: relative;
z-index: var(--estilo-z-bar);
@@ -239,6 +246,9 @@
breakpoint): below the foot there is only the window's edge. Below
800px the rail is a disclosure at the top of the page, with the page
under it and too little above, so the panel opens downward there. */
+@media (pointer: coarse) {
+ [estilo-account~="rail"] > [estilo-bar-trigger] { min-block-size: 2.75rem; }
+}
@media (min-width: 800px) {
[estilo-account~="rail"] > [estilo-account-panel] {
inset-block-start: auto;
@@ -434,7 +444,11 @@
this section and every app's, so it stays in px: restated in rem it
would move apart from them whenever the reader's default font size is
not 16px. 64rem is where a WideOnly action appears, the same 64rem
- Docs' inspector uses. */
+ Docs' inspector uses. A compact bar
+ (Bar.Compact, below) is the one exception: it is the 56px header from
+ 704px, so an iPad in portrait gets it (Paul, 2026-11-28), and nothing
+ else moves (Mapa and Fichas stack too, and their layouts change at
+ 800px). */
/* A WideOnly action exists only from 64rem (Docs' Format: the inspector
it toggles exists only there). It is also left out of the Menu sheet
@@ -494,6 +508,12 @@
}
}
+/* On touch the menu row's titles are 44px (menu.css), so the narrow
+ header is that much taller without script too. */
+@media (max-width: 799.98px) and (pointer: coarse) {
+ :root:has([estilo-bar~="stacked"]) { --estilo-bar-block-size: calc(3.25rem + 2.75rem + 1px); } /* 97px: the bar's row, a 44px menubar row and the bottom border. PUBLIC */
+}
+
/* From 800px, the 56px stacked header: a 32px icon 12px in, and beside
it a 44px stack, the 24px title row (16px, 600) over the 20px menu row
(13px, muted), both starting at 56px (12 + 32 + 12). The app's name
@@ -501,7 +521,8 @@
on the mock-up: the title's capitals start at the icon's top, so its
row sits 2.5px low; the menu row sits 1px low, its 24px highlight
stops 3px above the header's bottom edge, and an open panel hangs from
- 1px above that edge. */
+ 1px above that edge. A compact bar gets this block from 704px too, as
+ a copy CSS() makes (buildCSS, chrome.go). */
@media (min-width: 800px) {
:root:has([estilo-bar~="stacked"]) { --estilo-bar-block-size: 56px; } /* PUBLIC */
[estilo-bar~="stacked"] { gap: var(--rst-sp-3); padding-inline: var(--rst-sp-3); }
@@ -550,6 +571,7 @@
transparent 1px border with the fill clipped inside it paints the
22px pill. */
[estilo-bar~="stacked"] [estilo-bar-title]:focus-within [estilo-bar-title-submit] {
+ position: static;
align-self: center;
box-sizing: border-box;
block-size: 24px;
@@ -722,19 +744,31 @@
padding-inline: 0;
}
- /* Coarse pointers: the header's controls rise to 32px, and the menubar
- titles keep their 24px look in the 20px row but take 32px of hit
- area, 4px over each edge, drawn by nothing and taking no room. Where
- that reaches up under the title field, the field stays on top
- (z-index): it keeps all of its own 24px, and a menu under it keeps
- 24px from the field's foot to the header's edge. */
+ /* Coarse pointers (an iPad): the header's controls are drawn 32px and
+ take 44px to a tap, the size the phone web audit asked for
+ (2026-11-28, finding 9), from a hit area drawn by nothing and taking
+ no room: 6px over the top and bottom, inside the 56px header, and 4px
+ either side, inside the 8px to the next control. The switcher keeps
+ the set's 32px rather than the 44px box every bar's trigger takes on
+ touch. The menubar titles keep their 24px look in the 20px row and
+ take 44px of height: 16px up into the title row and 4px down, to the
+ header's edge. Where that reaches up under the title field, the field
+ stays on top (z-index), so it keeps all of its own 24px; beside a
+ short title the space above File and Edit opens them. Menu rows are
+ 44px, as every menu's are on touch. */
@media (pointer: coarse) {
:is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button) { block-size: 32px; min-block-size: 32px; }
+ :is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button) { position: relative; }
+ :is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button)::before { content: ""; position: absolute; inset: -6px -4px; }
:is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-account] > [estilo-bar-trigger],
:is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-account] [estilo-avatar] { inline-size: 32px; block-size: 32px; }
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-switcher] > [estilo-bar-trigger] { min-inline-size: 32px; block-size: 32px; }
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) :is([estilo-account], [estilo-switcher]) > [estilo-bar-trigger] { position: relative; }
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) :is([estilo-account], [estilo-switcher]) > [estilo-bar-trigger]::before { content: ""; position: absolute; inset: -6px; }
[estilo-bar~="stacked"] [estilo-menubar-title] { position: relative; }
- [estilo-bar~="stacked"] [estilo-menubar-title]::before { content: ""; position: absolute; inset-inline: 0; inset-block: -4px; }
+ [estilo-bar~="stacked"] [estilo-menubar-title]::before { content: ""; position: absolute; inset-inline: 0; inset-block: -16px -4px; }
[estilo-bar~="stacked"] [estilo-bar-title] { z-index: 1; }
+ [estilo-bar~="stacked"] [estilo-menu-item] { min-block-size: 44px; }
/* The icon-only action is drawn 32px like the rest, and takes 44px
to a tap: 6px over each edge, drawn by nothing, inside the 56px
header and short of the 8px to its neighbours. ::before, since
@@ -749,6 +783,19 @@
[estilo-bar-actions] [estilo-bar-icon]:not(:focus-visible)::after { display: none; }
}
}
+/* Between 704px and 800px a compact bar is the 56px header, as every
+ stacked bar is from 800px: the copy of the block above that CSS() puts
+ here, and these, which undo the narrow two-row layout below 800px
+ (its stack dissolved, its menu row's margins: the copy keeps the
+ original rules' specificity, so the narrow ones would win) and put its
+ actions back in the bar. A compact bar with nav keeps its Menu
+ sheet there, as below 800px every bar does. */
+@media (min-width: 704px) and (max-width: 799.98px) and (not ((max-height: 480px) and (pointer: coarse))) {
+ [estilo-bar~="stacked"][estilo-bar~="compact"] { display: flex; block-size: var(--estilo-bar-block-size); }
+ [estilo-bar~="stacked"][estilo-bar~="compact"] [estilo-bar-stack] { display: flex; }
+ [estilo-bar~="stacked"][estilo-bar~="compact"] [estilo-bar-menubar] { align-self: auto; margin-inline: calc(-1 * var(--rst-sp-2)) 0; } /* the 56px header's, which the copy, at its own weight, no longer outweighs here */
+ [estilo-bar~="compact"] [estilo-bar-actions] { display: flex; }
+}
@media (min-width: 64rem) {
:is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-bar-end]:has(> [estilo-bar-actions]) > [estilo-account] {
margin-inline-start: var(--rst-sp-1);
@@ -775,6 +822,150 @@
:is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-account] [estilo-avatar] { transition: none; }
}
+/* ── Compact (the phone web design, Paul 2026-11-28) ───────────────────
+ Bar.Compact: below 704px, or on a phone held sideways, the phone's one
+ 52px row, as Docs' native iPhone screen has it: Back (the brand: a
+ chevron and the app's name, in the accent, to App.Home), the title,
+ the app's Lead, then its Trail (Docs' Aa and •••). The menubar row, the
+ actions, the switcher and the account go: the trail carries the
+ commands, and the app's other screens the person's menus (native D4).
+ From 704px none of this applies, and the bar is the 56px header
+ (from 800px every stacked bar's; between 704px and 800px a compact
+ bar's alone, above). The breakpoints are px, as 800px is, so they
+ never part at a reader's larger default font size. A compact bar with
+ Bar.Nav keeps its Menu sheet, in the row, so the nav is never out of
+ reach. Every rule is keyed on a compact hook:
+ [estilo-bar~="compact"], [estilo-bar-back], [estilo-bar-trail],
+ [estilo-bar-compact-title] and [estilo-bar-tool], and the state the
+ app's script sets, [estilo-bar-folded].
+
+ The trail's panels are drop-downs from the bar's inline end (Paul's
+ answer 3: the ••• menu is a drop-down, not a bottom sheet), sized for a
+ finger: 44px rows at 16px, a 16px radius, no shortcut hints, and
+ iOS's grouped separator between sections.
+
+ [estilo-bar-tool] is a 44px round control in the accent, for a button,
+ a link or a <summary> in the trail or the lead. */
+:is([estilo-bar-trail], [estilo-bar-compact-title], [estilo-bar-back]) { display: none; }
+[estilo-bar-tool] {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: var(--rst-sp-1);
+ box-sizing: border-box;
+ min-inline-size: 44px;
+ block-size: 44px;
+ padding: 0 var(--rst-sp-2);
+ border: 0;
+ border-radius: 999px;
+ background: none;
+ color: var(--rst-accent);
+ font: inherit;
+ font-size: 1.0625rem;
+ cursor: pointer;
+ list-style: none;
+ user-select: none;
+ -webkit-tap-highlight-color: transparent;
+}
+[estilo-bar-tool]::-webkit-details-marker { display: none; }
+[estilo-bar-tool]::marker { content: ""; }
+[estilo-bar-tool] svg { flex: none; inline-size: 22px; block-size: 22px; }
+[estilo-bar-tool]:is([aria-pressed="true"], [aria-expanded="true"]),
+[open] > [estilo-bar-tool] { background: var(--rst-accent-soft); }
+[estilo-bar-tool]:focus-visible { outline: 2px solid var(--rst-accent); outline-offset: -2px; }
+[estilo-bar-tool]:disabled { color: var(--rst-text-faint); cursor: default; }
+@media (hover: hover) {
+ [estilo-bar-tool]:hover:not(:disabled):not([aria-pressed="true"], [aria-expanded="true"]) { background: var(--rst-surface-2); }
+}
+/* The trail's details are not positioned, so a panel hangs from the bar
+ itself, 8px in from its inline end, as wide as a phone allows. */
+[estilo-bar-trail] [estilo-menu] {
+ position: absolute;
+ inset-inline-end: var(--rst-sp-2);
+ inset-block-start: calc(100% + var(--rst-sp-1));
+ inline-size: min(17rem, calc(100vw - var(--rst-sp-4)));
+ min-inline-size: 0;
+ max-inline-size: none;
+ padding: var(--rst-sp-1) 0;
+ border-radius: 16px;
+ font-size: 1rem;
+ --estilo-item-padding-inline: var(--rst-sp-4);
+}
+[estilo-bar-trail] [estilo-menu-item] { min-block-size: 44px; gap: var(--rst-sp-3); border-radius: 0; }
+[estilo-bar-trail] [estilo-menu-key] { display: none; }
+[estilo-bar-trail] [estilo-menu-check] { inline-size: 1.25rem; block-size: 1.25rem; }
+[estilo-bar-trail] [estilo-menu] hr {
+ block-size: 7px;
+ margin: var(--rst-sp-1) 0;
+ border: 0;
+ background: light-dark(rgb(0 0 0 / 0.045), rgb(0 0 0 / 0.25));
+}
+@media (max-width: 703.98px), (max-height: 480px) and (pointer: coarse) {
+ :root:has([estilo-bar~="compact"]) { --estilo-bar-block-size: 3.25rem; } /* 52px: the one row. PUBLIC */
+ [estilo-bar~="compact"] {
+ display: flex;
+ gap: var(--rst-sp-1);
+ block-size: 3.25rem;
+ padding-inline: var(--rst-sp-2);
+ }
+ [estilo-bar~="compact"] [estilo-bar-menubar],
+ [estilo-bar~="compact"] [estilo-bar-actions],
+ [estilo-bar~="compact"] [estilo-switcher],
+ [estilo-bar~="compact"] [estilo-account] { display: none; }
+ [estilo-bar][estilo-bar~="compact"] [estilo-bar-end] { gap: var(--rst-sp-1); } /* (0,3,0): on a phone held sideways, past 800px, it outweighs the 56px header's */
+ [estilo-bar~="compact"] [estilo-bar-stack] { display: contents; }
+ [estilo-bar~="compact"] [estilo-bar-more] { display: block; }
+ [estilo-bar~="compact"] [estilo-bar-trail] { display: flex; align-items: center; }
+ [estilo-bar~="compact"] [estilo-bar-compact-title] { display: block; flex: 1 1 auto; min-inline-size: 0; overflow: hidden; }
+ /* Back: the brand without its mark, the chevron before the name. */
+ [estilo-bar~="compact"] [estilo-bar-back] { display: block; flex: none; }
+ [estilo-bar~="compact"] [estilo-bar-back]:dir(rtl) { transform: scaleX(-1); }
+ [estilo-bar~="compact"] [estilo-bar-brand] {
+ gap: 0;
+ min-block-size: 44px;
+ padding-inline: 0 var(--rst-sp-2);
+ border-radius: 999px;
+ font-size: 1.0625rem;
+ font-weight: 400;
+ }
+ /* Only a link is drawn in the accent: on a public page the brand is
+ plain text (App.Home empty) and has no Back. */
+ [estilo-bar~="compact"] a[estilo-bar-brand] { color: var(--rst-accent); }
+ [estilo-bar~="compact"] [estilo-bar-brand] img { display: none; }
+ [estilo-bar~="compact"] [estilo-bar-brand] [estilo-bar-name] { display: inline; }
+ /* The bar's own title fills the room between Back and the end group,
+ one line ending in an ellipsis rather than cut mid-letter (the audit's
+ finding 2), unless Compact.Title takes its place. chrome.js leaves
+ the field unfitted here. */
+ [estilo-bar~="compact"]:has(> [estilo-bar-compact-title]) :is([estilo-bar-title], [estilo-bar-context]) { display: none; }
+ [estilo-bar~="compact"] :is([estilo-bar-title], [estilo-bar-context]) {
+ flex: 1 1 auto;
+ inset-block-start: 0;
+ min-inline-size: 0;
+ max-inline-size: none;
+ block-size: auto;
+ padding-inline-start: 0;
+ border-inline-start: 0;
+ }
+ [estilo-bar~="compact"] [estilo-bar-title-input] { flex: 1 1 auto; inline-size: 100%; block-size: 2rem; max-inline-size: none; margin-inline-start: 0; text-overflow: ellipsis; }
+ /* With Compact.Title the page has a large title of its own (Docs), and
+ the bar is the large-title idiom: at rest Back and the end group on
+ no hairline, the compact title hidden; once the app's script marks
+ the bar folded (estilo-bar-folded, when its large title has scrolled
+ away), the compact title fades in, the hairline appears, and Back is
+ its chevron alone, the name kept as its accessible name. Without
+ script the bar never folds and the large title is the title. */
+ [estilo-bar~="compact"]:has(> [estilo-bar-compact-title]) { border-block-end-color: transparent; }
+ [estilo-bar~="compact"] [estilo-bar-compact-title] { opacity: 0; visibility: hidden; transition: opacity 150ms ease, visibility 0s linear 150ms; }
+ [estilo-bar~="compact"][estilo-bar-folded]:has(> [estilo-bar-compact-title]) { border-block-end-color: var(--rst-line); }
+ [estilo-bar~="compact"][estilo-bar-folded] [estilo-bar-compact-title] { opacity: 1; visibility: visible; transition: opacity 150ms ease; }
+ [estilo-bar~="compact"][estilo-bar-folded]:has(> [estilo-bar-compact-title]) [estilo-bar-brand] { min-inline-size: 44px; justify-content: center; padding-inline: 0; }
+ [estilo-bar~="compact"][estilo-bar-folded]:has(> [estilo-bar-compact-title]) [estilo-bar-name] { position: absolute; clip-path: inset(50%); inline-size: 1px; block-size: 1px; overflow: hidden; white-space: nowrap; }
+}
+@media (prefers-reduced-motion: reduce) {
+ [estilo-bar~="compact"] [estilo-bar-compact-title] { transition: none; }
+}
+
/* Appearance, in every app's account menu: Light, Dark and System as
three equal segments in one well, an icon over each word. The one in
force is raised (the surface, a step lighter in dark, where the
diff --git a/chrome/chrome.go b/chrome/chrome.go
index aa5f2a1..7d07afa 100644
--- a/chrome/chrome.go
+++ b/chrome/chrome.go
@@ -37,14 +37,160 @@ import (
//go:embed chrome.css
var css []byte
+// built is chrome.css as CSS() serves it: the file, with a compact bar's
+// 704px band (buildCSS) after the stacked header's block.
+var built = buildCSS(string(css))
+
//go:embed chrome.js
var js []byte
//go:embed templates/*.html
var templateFS embed.FS
-// CSS returns chrome.css. Link it after menu.css.
-func CSS() []byte { return append([]byte(nil), css...) }
+// CSS returns chrome.css, with a compact bar's 704px band in place. Link
+// it after menu.css.
+func CSS() []byte { return append([]byte(nil), built...) }
+
+// The stacked header's 56px block, which every stacked bar takes from
+// 800px, opens after this comment. A compact bar takes the same block from
+// 704px (Paul, 2026-11-28: the desktop header for an iPad in portrait),
+// and nothing else moves: Mapa and Fichas stack too, and their own layouts
+// change at 800px (Fable on c56314e). A media query cannot ask which bar
+// it is, so the band is a copy of the block, made here rather than kept
+// by hand, with every selector scoped to a compact bar.
+const (
+ wideOpens = "/* From 800px, the 56px stacked header:"
+ wideQuery = "@media (min-width: 800px) {"
+ bandQuery = "@media (min-width: 704px) and (max-width: 799.98px) and (not ((max-height: 480px) and (pointer: coarse)))"
+)
+
+func buildCSS(src string) []byte {
+ start, end := wideBounds(src)
+ band := bandQuery + " {\n" + scopeRules(stripComments(src[start:end])) + "}\n"
+ return []byte(src[:end+2] + band + src[end+2:])
+}
+
+// wideBounds is the stacked header block's body: from after its opening
+// brace to its closing brace.
+func wideBounds(src string) (int, int) {
+ at := strings.Index(src, wideOpens)
+ if at < 0 {
+ panic("chrome.css lost the stacked header's block")
+ }
+ open := strings.Index(src[at:], wideQuery)
+ if open < 0 {
+ panic("chrome.css: the stacked header's block is not " + wideQuery)
+ }
+ start := at + open + len(wideQuery)
+ depth := 1
+ for i := start; i < len(src); i++ {
+ switch src[i] {
+ case '{':
+ depth++
+ case '}':
+ depth--
+ if depth == 0 {
+ return start, i
+ }
+ }
+ }
+ panic("chrome.css: the stacked header's block never closes")
+}
+
+// wideBlock is the stacked header block's body, as chrome.css has it.
+func wideBlock(src string) string {
+ start, end := wideBounds(src)
+ return src[start:end]
+}
+
+func stripComments(s string) string {
+ var b strings.Builder
+ for {
+ i := strings.Index(s, "/*")
+ if i < 0 {
+ return b.String() + s
+ }
+ b.WriteString(s[:i])
+ j := strings.Index(s[i:], "*/")
+ if j < 0 {
+ return b.String()
+ }
+ s = s[i+j+2:]
+ }
+}
+
+// scopeRules copies a block's rules, nested @media blocks included, with
+// every selector scoped to a compact bar and every declaration as it was.
+func scopeRules(body string) string {
+ var b strings.Builder
+ for {
+ open := strings.IndexByte(body, '{')
+ if open < 0 {
+ return b.String()
+ }
+ prelude := strings.TrimSpace(body[:open])
+ depth, close := 1, open+1
+ for ; depth > 0; close++ {
+ switch body[close] {
+ case '{':
+ depth++
+ case '}':
+ depth--
+ }
+ }
+ inner := body[open+1 : close-1]
+ if strings.HasPrefix(prelude, "@") {
+ b.WriteString(prelude + " {\n" + scopeRules(inner) + "}\n")
+ } else {
+ sels := splitSelectors(prelude)
+ for i, sel := range sels {
+ sels[i] = scopeSelector(sel)
+ }
+ b.WriteString(strings.Join(sels, ",\n") + " {" + inner + "}\n")
+ }
+ body = body[close:]
+ }
+}
+
+// scopeSelector limits sel to a compact bar: the bar itself or anything
+// inside one. The scope is :where(), so the copy keeps each rule's own
+// specificity and the cascade around it is the original's: the
+// forced-colors border after the block still outweighs the controls'
+// border: 0 (Fable, on 4757ccc). A pseudo-element stays outside :is(),
+// where it is valid; the root's rule asks for a stacked bar that is also
+// compact.
+func scopeSelector(sel string) string {
+ sel = strings.Join(strings.Fields(sel), " ")
+ if strings.HasPrefix(sel, ":root") {
+ return strings.Replace(sel, `[estilo-bar~="stacked"]`, `[estilo-bar~="stacked"][estilo-bar~="compact"]`, 1)
+ }
+ pseudo := ""
+ if i := strings.LastIndex(sel, "::"); i >= 0 && !strings.ContainsAny(sel[i:], "()[] ") {
+ sel, pseudo = sel[:i], sel[i:]
+ }
+ return ":is(" + sel + `):where([estilo-bar~="compact"], [estilo-bar~="compact"] *)` + pseudo
+}
+
+// splitSelectors splits a selector list at its top-level commas, leaving
+// those inside :is(), :has() and the like.
+func splitSelectors(list string) []string {
+ var out []string
+ depth, start := 0, 0
+ for i, r := range list {
+ switch r {
+ case '(':
+ depth++
+ case ')':
+ depth--
+ case ',':
+ if depth == 0 {
+ out = append(out, strings.TrimSpace(list[start:i]))
+ start = i + 1
+ }
+ }
+ }
+ return append(out, strings.TrimSpace(list[start:]))
+}
// JS returns chrome.js, an optional classic script (defer) that closes an
// open bar panel on Escape or an outside click, restores the editable
@@ -192,6 +338,58 @@ type Bar struct {
// controls (28px pills, the avatar as a circle, a divider before the
// account); a bar with neither is unchanged.
Lead template.HTML
+ // Compact, set, makes the bar the phone's one row below 704px
+ // (estilo-bar~="compact"; the phone web design, Paul 2026-11-28),
+ // and a stacked compact bar the 56px header from 704px rather than
+ // 800px, with its actions in the bar. The Menu sheet is drawn only for
+ // Nav, and shown in the compact row: Trail is the app's own overflow
+ // for everything else, the actions included.
+ Compact *Compact
+}
+
+// Compact is a compact bar's two slots (Bar.Compact). Below 704px, or on
+// a phone held sideways (a coarse pointer under 30rem tall), the bar is
+// one 52px row: the brand as Back (a chevron and the app's name, to
+// App.Home), the title, the Lead, then Trail. The menubar, the actions,
+// the switcher and the account are not shown there; the app's Trail and
+// its other screens carry them (Docs: the switcher and the account stay
+// on the library, as native's D4 has it). A Nav stays reachable in the
+// Menu sheet, drawn before the Trail. The Lead stays, so an app that
+// sets both draws its lead for the phone itself.
+//
+// Both are trusted markup, the app's own template output. Controls in
+// them may take [estilo-bar-tool], a 44px round control in the accent,
+// and a <details name="estilo-menus"> in the Trail with an [estilo-menu]
+// panel is a drop-down from the bar's inline end, with 44px rows and no
+// shortcut hints (Paul's answer 3: a drop-down, not a sheet).
+type Compact struct {
+ // Trail is drawn at the inline end below 704px (Docs' Aa and •••).
+ Trail template.HTML
+ // Title, when set, replaces the bar's own title below 704px (Docs'
+ // inline title): the page has a large title of its own, and the bar
+ // shows this only once the app's script marks the header folded with
+ // the estilo-bar-folded attribute (when the large title has scrolled
+ // away). Folded, Back is its chevron alone, the app's name kept as its
+ // accessible name, and the bar's hairline appears. Without script the
+ // bar never folds. Left empty, the bar's Context or ContextEdit stays,
+ // one line that fills the room and ends in an ellipsis.
+ Title template.HTML
+}
+
+// Kind is estilo-bar's value: "sticky", "stacked" and "compact", in that
+// order, for whichever apply; empty for none.
+func (b Bar) Kind() string {
+ var k []string
+ if b.Sticky {
+ k = append(k, "sticky")
+ }
+ if b.Menubar != "" {
+ k = append(k, "stacked")
+ }
+ if b.Compact != nil {
+ k = append(k, "compact")
+ }
+ return strings.Join(k, " ")
}
// AccountLabels are the account menu's headings.
diff --git a/chrome/chrome.js b/chrome/chrome.js
index f3891fd..a1918f0 100644
--- a/chrome/chrome.js
+++ b/chrome/chrome.js
@@ -15,7 +15,9 @@
// invoker commands;
// - a stacked bar's title field (the one with a size attribute) is
// fitted to its title: the size the server rendered is the first
-// paint's guess, and this measures the field and corrects it;
+// paint's guess, and this measures the field and corrects it (except
+// in a compact bar while it is narrow, where the field fills its
+// room and ends in an ellipsis);
// - Appearance switches in place: the page takes the scheme at once and
// the choice is saved by the same POST, sent in the background, with
// no navigation and no spinner. With scripts off the form posts and
@@ -109,9 +111,17 @@
// inside the field. Nothing after the title on its row moves when it
// changes: the stack takes the room. make test-browser holds it in
// both engines (title_browser_test.go).
+ // Where a compact bar is the phone's one row, chrome.css's own query:
+ // below 704px, or a phone held sideways. Its title field fills the room
+ // there and is not fitted.
+ const compact = window.matchMedia && window.matchMedia('(max-width: 703.98px), (max-height: 480px) and (pointer: coarse)')
const FIT = '[estilo-bar-title-input][size]'
const CARET = 2
const fit = (input) => {
+ if (compact && compact.matches && input.closest('[estilo-bar~="compact"]')) {
+ input.style.inlineSize = ''
+ return
+ }
input.style.inlineSize = '0px'
const w = input.scrollWidth + input.offsetWidth - input.clientWidth
input.style.inlineSize = Math.ceil(w + CARET) + 'px'
@@ -125,6 +135,7 @@
// the first measure, at script time, can come out a few pixels short.
window.addEventListener('resize', fitAll)
window.addEventListener('load', fitAll)
+ if (compact && compact.addEventListener) compact.addEventListener('change', fitAll)
if (document.fonts && document.fonts.ready) document.fonts.ready.then(fitAll)
fitAll()
@@ -135,7 +146,12 @@
// sticks under all of it. Only below 800px: from there the header's
// height is the variable itself, and publishing its measure back would
// hold it at whatever it measured last.
- const stacked = document.querySelector('[estilo-bar~="stacked"]')
+ // Not a compact bar's: its height is the CSS's own at every width (52px
+ // as one row, 56px as the header from 704px), and a measure published
+ // while it was one row held it at 52px once widened into the 704-799px
+ // band, where it is the 56px header (Fable, on 4757ccc).
+ const stacked = Array.prototype.find.call(document.querySelectorAll('[estilo-bar~="stacked"]'),
+ (bar) => (' ' + bar.getAttribute('estilo-bar') + ' ').indexOf(' compact ') < 0)
const narrow = window.matchMedia && window.matchMedia('(max-width: 799.98px)')
if (stacked && narrow && typeof ResizeObserver === 'function') {
const root = document.documentElement
diff --git a/chrome/compact.browser.mjs b/chrome/compact.browser.mjs
new file mode 100644
index 0000000..41ae1ff
--- /dev/null
+++ b/chrome/compact.browser.mjs
@@ -0,0 +1,239 @@
+// compact.browser.mjs: open the compact, stacked bar at each width, with
+// a finger where a phone or a tablet has one, and measure it. Driven by
+// compact_browser_test.go (go test -tags browser ./chrome), which serves
+// the page and makes every assertion; this file only drives the browsers
+// and reports what it measured. With job.shots set it saves screenshots
+// there: each case at rest, and with the ••• menu (or File) open.
+//
+// ESTILO_PLAYWRIGHT=<path to the playwright package> \
+// node compact.browser.mjs <job JSON>
+import { createRequire } from 'node:module'
+import { mkdirSync } from 'node:fs'
+
+const require = createRequire(import.meta.url)
+const pw = require(process.env.ESTILO_PLAYWRIGHT || 'playwright')
+const job = JSON.parse(process.argv[2])
+
+// kind, width, height, touch
+const sizes = [
+ ['phone', 360, 780, true], ['phone', 390, 844, true], ['phone', 430, 932, true],
+ ['landscape', 844, 390, true],
+ ['tablet', 768, 1024, true], ['tablet', 1024, 768, true],
+ ['desktop', 1280, 800, false],
+]
+const cases = []
+for (const [kind, w, h, touch] of sizes) {
+ for (const lang of ['en', 'ar', 'ru']) {
+ for (const scheme of ['light', 'dark']) {
+ if (lang !== 'en' && scheme === 'dark' && !(lang === 'ar' && w === 390)) continue
+ if (lang !== 'en' && kind === 'landscape') continue
+ cases.push({ name: `${kind} ${w} ${lang} ${scheme}`, kind, w, h, touch, lang, scheme })
+ }
+ }
+}
+
+function measure() {
+ const q = (s) => document.querySelector(s)
+ const shown = (el) => !!el && el.getClientRects().length > 0 && getComputedStyle(el).visibility !== 'hidden'
+ const box = (el) => { const r = el.getBoundingClientRect(); return [r.x, r.y, r.width, r.height] }
+ const bar = q('[estilo-bar]')
+ const probe = document.createElement('div')
+ probe.style.blockSize = 'var(--estilo-bar-block-size)'
+ document.body.append(probe)
+ const v = probe.getBoundingClientRect().height
+ probe.remove()
+ const input = q('[estilo-bar-title-input]')
+ const out = {
+ header: bar.getBoundingClientRect().height,
+ var: v,
+ coarse: matchMedia('(pointer: coarse)').matches,
+ overflow: document.documentElement.scrollWidth > window.innerWidth,
+ shown: {
+ menubar: shown(q('[estilo-bar-menubar]')), actions: shown(q('[estilo-bar-actions]')),
+ switcher: shown(q('[estilo-switcher]')), account: shown(q('[estilo-account]')),
+ more: shown(q('[estilo-bar-more]')), icon: shown(q('[estilo-bar-brand] img')),
+ back: shown(q('[estilo-bar-back]')), name: shown(q('[estilo-bar-name]')),
+ title: shown(input), lead: shown(q('[estilo-bar-lead]')), trail: shown(q('[estilo-bar-trail]')),
+ },
+ boxes: { back: box(q('[estilo-bar-brand]')), title: box(q('[estilo-bar-title]')), end: box(q('[estilo-bar-end]')), menubar: box(q('[estilo-bar-menubar]')) },
+ ellipsis: getComputedStyle(input).textOverflow,
+ }
+ Array.prototype.filter.call(document.querySelectorAll('[estilo-bar-tool]'), shown).forEach((el, i) => { out.boxes['tool-' + i] = box(el) })
+ return out
+}
+
+function panel(sel) {
+ const d = document.querySelector(sel)
+ const p = d.querySelector('[estilo-menu]')
+ const r = p.getBoundingClientRect()
+ const shown = (el) => el.getClientRects().length > 0
+ return {
+ panel: [r.x, r.y, r.width, r.height],
+ rows: Array.prototype.filter.call(p.querySelectorAll('[estilo-menu-item]'), shown).map((el) => el.getBoundingClientRect().height),
+ keys: Array.prototype.filter.call(p.querySelectorAll('[estilo-menu-key]'), shown).length,
+ }
+}
+
+function large() {
+ const q = (s) => document.querySelector(s)
+ const box = (el) => { const r = el.getBoundingClientRect(); return [r.x, r.y, r.width, r.height] }
+ const t = q('[estilo-bar-compact-title]')
+ const cs = getComputedStyle(t)
+ return {
+ title: cs.visibility === 'visible' && parseFloat(cs.opacity) > 0.99,
+ name: q('[estilo-bar-name]').getBoundingClientRect().width,
+ label: q('[estilo-bar-brand]').innerText, // drops undisplayed text, keeps a visually hidden name
+ border: getComputedStyle(q('[estilo-bar]')).borderBlockEndColor,
+ box: box(t), back: box(q('[estilo-bar-brand]')), end: box(q('[estilo-bar-end]')),
+ }
+}
+
+const results = []
+for (const engine of job.engines) {
+ const result = { engine, version: '', error: '', cases: [] }
+ results.push(result)
+ let browser
+ try {
+ browser = await pw[engine].launch()
+ result.version = browser.version()
+ if (job.shots) mkdirSync(job.shots, { recursive: true })
+ for (const c of cases) {
+ // One case that cannot be driven is reported and the rest go on,
+ // so a broken layout shows as the assertions it breaks.
+ try {
+ const opts = { viewport: { width: c.w, height: c.h }, deviceScaleFactor: 2, colorScheme: c.scheme }
+ if (c.touch) Object.assign(opts, { hasTouch: true, isMobile: engine !== 'firefox' })
+ const ctx = await browser.newContext(opts)
+ const page = await ctx.newPage()
+ page.setDefaultTimeout(5000)
+ await page.goto(`${job.origin}/?lang=${c.lang}&scheme=${c.scheme}`, { waitUntil: 'load' })
+ await page.evaluate(() => document.fonts.ready)
+ await page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))))
+ const m = await page.evaluate(measure)
+ const file = (s) => `${job.shots}/${engine}-${c.name.replaceAll(' ', '-')}${s}.png`
+ if (job.shots) await page.screenshot({ path: file('') })
+ const sel = (c.kind === 'phone' || c.kind === 'landscape') ? '[data-demo="more"]' : '[estilo-menubar-menu]:has([data-demo="file"])'
+ await page.locator(sel + ' > summary').click()
+ await page.evaluate(() => new Promise((r) => requestAnimationFrame(r)))
+ const p = await page.evaluate(panel, sel)
+ if (job.shots) await page.screenshot({ path: file('-open') })
+ const entry = { name: c.name, width: c.w, touch: c.touch, ...m, ...p }
+ if (c.kind === 'phone' || c.kind === 'landscape') {
+ await page.goto(`${job.origin}/?lang=${c.lang}&scheme=${c.scheme}&inline=1`, { waitUntil: 'load' })
+ await page.evaluate(() => document.fonts.ready)
+ entry.rest = await page.evaluate(large)
+ if (job.shots) await page.screenshot({ path: file('-large') })
+ await page.evaluate(() => document.querySelector('[estilo-bar]').setAttribute('estilo-bar-folded', ''))
+ await page.waitForTimeout(300)
+ entry.folded = await page.evaluate(large)
+ if (job.shots) await page.screenshot({ path: file('-folded') })
+ }
+ if (c.kind === 'phone' && c.lang === 'en' && c.scheme === 'light') {
+ await page.goto(`${job.origin}/?lang=en&scheme=light&public=1`, { waitUntil: 'load' })
+ entry.public = await page.evaluate(() => {
+ const probe = document.createElement('span')
+ probe.style.color = 'var(--rst-accent)'
+ document.body.append(probe)
+ const accent = getComputedStyle(probe).color
+ probe.remove()
+ return { brand: getComputedStyle(document.querySelector('[estilo-bar-brand]')).color, accent }
+ })
+ if (job.shots) await page.screenshot({ path: file('-public') })
+ } else {
+ entry.public = { brand: 'n/a', accent: '' }
+ }
+ result.cases.push(entry)
+ await ctx.close()
+ } catch (e) {
+ result.cases.push({ name: c.name, width: c.w, touch: c.touch, error: String(e && e.message || e).split('\n')[0] })
+ }
+ }
+ // A compact bar loaded narrow and widened into the 704-800px band is
+ // the 56px header there; and in forced colours the band's controls
+ // keep the border the forced-colors rule gives them, as from 800px.
+ result.extra = {}
+ try {
+ const ctx = await browser.newContext({ viewport: { width: 650, height: 900 }, deviceScaleFactor: 2, hasTouch: true, isMobile: engine !== 'firefox' })
+ const page = await ctx.newPage()
+ await page.goto(`${job.origin}/?lang=en&scheme=light`, { waitUntil: 'load' })
+ await page.evaluate(() => document.fonts.ready)
+ const at650 = await page.evaluate(measure)
+ await page.setViewportSize({ width: 768, height: 1024 })
+ await page.waitForTimeout(300)
+ const at768 = await page.evaluate(measure)
+ result.extra.resized = { from: at650.header, header: at768.header, var: at768.var }
+ await ctx.close()
+ } catch (e) {
+ result.extra.resizedError = String(e && e.message || e).split('\n')[0]
+ }
+ result.extra.forced = {}
+ for (const w of [768, 1280]) {
+ try {
+ const ctx = await browser.newContext({ viewport: { width: w, height: 800 }, forcedColors: 'active' })
+ const page = await ctx.newPage()
+ await page.goto(`${job.origin}/?lang=en&scheme=light`, { waitUntil: 'load' })
+ result.extra.forced[w] = await page.evaluate(() => {
+ const el = document.querySelector('[estilo-bar-control~="primary"] > a')
+ return { border: parseFloat(getComputedStyle(el).borderTopWidth), forced: matchMedia('(forced-colors: active)').matches }
+ })
+ await ctx.close()
+ } catch (e) {
+ result.extra.forced[w] = { error: String(e && e.message || e).split('\n')[0] }
+ }
+ }
+ // Mapa and Fichas, as stand-ins: stacked bars with nav, not compact.
+ result.standIns = []
+ for (const kind of ['mapa', 'fichas']) {
+ for (const [w, h, touch] of [[390, 844, true], [768, 1024, true], [844, 390, true], [1280, 800, false]]) {
+ const name = `${kind} ${w}x${h}${touch ? ' touch' : ''}`
+ try {
+ const opts = { viewport: { width: w, height: h }, deviceScaleFactor: 2, colorScheme: 'light' }
+ if (touch) Object.assign(opts, { hasTouch: true, isMobile: engine !== 'firefox' })
+ const ctx = await browser.newContext(opts)
+ const page = await ctx.newPage()
+ page.setDefaultTimeout(5000)
+ await page.goto(`${job.origin}/?kind=${kind}&lang=en&scheme=light`, { waitUntil: 'load' })
+ await page.evaluate(() => document.fonts.ready)
+ await page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))))
+ const shot = (s) => `${job.shots}/${engine}-${kind}-${w}x${h}${s}.png`
+ if (job.shots) await page.screenshot({ path: shot('') })
+ const m = await page.evaluate(() => {
+ const shown = (el) => el.getClientRects().length > 0 && getComputedStyle(el).visibility !== 'hidden'
+ const label = (el) => (el.getAttribute('aria-label') || el.textContent).trim()
+ const bar = document.querySelector('[estilo-bar]')
+ const probe = document.createElement('div')
+ probe.style.blockSize = 'var(--estilo-bar-block-size)'
+ document.body.append(probe)
+ const v = probe.getBoundingClientRect().height
+ probe.remove()
+ const nav = [...bar.querySelectorAll('[estilo-bar-nav] a')]
+ const acts = [...bar.querySelectorAll('[estilo-bar-actions] :is(a, button)')].filter((el) => !el.matches('[estilo-bar-wide], [estilo-bar-control~="wide"] *'))
+ return {
+ header: bar.getBoundingClientRect().height, var: v,
+ overflow: document.documentElement.scrollWidth > window.innerWidth,
+ wanted: [...nav, ...acts].map(label),
+ reached: [...nav, ...acts].filter(shown).map(label),
+ more: !!bar.querySelector('[estilo-bar-more]') && shown(bar.querySelector('[estilo-bar-more]')),
+ }
+ })
+ if (m.more) {
+ await page.locator('[estilo-bar-more] > summary').click()
+ await page.evaluate(() => new Promise((r) => requestAnimationFrame(r)))
+ const rows = await page.evaluate(() => [...document.querySelectorAll('[estilo-bar-more] [estilo-menu-item]')].filter((el) => el.getClientRects().length > 0).map((el) => el.textContent.trim()))
+ m.reached.push(...rows)
+ if (job.shots) await page.screenshot({ path: shot('-open') })
+ }
+ result.standIns.push({ name, width: w, ...m })
+ await ctx.close()
+ } catch (e) {
+ result.standIns.push({ name, width: w, error: String(e && e.message || e).split('\n')[0] })
+ }
+ }
+ }
+ } catch (e) {
+ result.error = String(e && e.stack || e)
+ } finally {
+ if (browser) await browser.close()
+ }
+}
+process.stdout.write(JSON.stringify(results))
diff --git a/chrome/compact_browser_test.go b/chrome/compact_browser_test.go
new file mode 100644
index 0000000..4de60b5
--- /dev/null
+++ b/chrome/compact_browser_test.go
@@ -0,0 +1,459 @@
+//go:build browser
+
+// The compact bar (Bar.Compact) and the touch sizes, in real engines:
+// a stacked, compact bar as Docs draws it on a document, at phone,
+// tablet and desktop widths, with a coarse pointer where a phone or a
+// tablet has one. Not part of `make test`: it needs Node 22+ and
+// Playwright (ESTILO_PLAYWRIGHT, ESTILO_BROWSERS as for the title
+// check). ESTILO_SHOTS=<dir> saves a screenshot of every case there,
+// light and dark, in English, Arabic and Russian.
+package chrome
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "html/template"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/estilo.git/base"
+ "amadan.net/oficina/estilo.git/brand"
+ "amadan.net/oficina/estilo.git/menu"
+ "amadan.net/oficina/estilo.git/theme"
+ "github.com/carlosframework/rastrillo/ui"
+)
+
+const compactPage = `<!doctype html>
+<html lang="%s" dir="%s"%s>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<link rel="stylesheet" href="/tokens.css">
+<link rel="stylesheet" href="/theme.css">
+<link rel="stylesheet" href="/base.css">
+<link rel="stylesheet" href="/menu.css">
+<link rel="stylesheet" href="/chrome.css">
+<script defer src="/chrome.js"></script>
+<style>
+ body { margin: 0; }
+ [demo-title] { margin: 0; padding: var(--rst-sp-2) 20px var(--rst-sp-3); }
+ [demo-title] h1 { margin: 0 0 var(--rst-sp-1); font-size: 28px; line-height: 1.15; }
+ [demo-title] p { margin: 0; color: var(--rst-text-muted); font-size: 13px; }
+ [demo-inline] b, [demo-inline] small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+ [demo-inline] b { font-size: 15px; font-weight: 600; }
+ [demo-inline] small { font-size: 12px; color: var(--rst-text-muted); }
+ [demo-paper] { color-scheme: light; background: #fff; color: #1d1f24; padding: var(--rst-sp-1) 20px 60vh; }
+</style>
+</head>
+<body>
+<div estilo-shell>
+%s
+<main id="main"><div demo-title><h1 dir="auto">%s</h1><p>%s</p></div><div demo-paper><p>%s</p></div></main>
+</div>
+</body>
+</html>
+`
+
+// compactLabels are the demo's words per locale: Arabic to see the bar
+// mirrored, Russian for long labels.
+var compactLabels = map[string]map[string]string{
+ "en": {"app": "Docs", "title": "A History of the Millbrook Waterworks", "sub": "Oficina · Saved", "file": "File", "edit": "Edit", "view": "View", "share": "Share…", "rename": "Rename", "pdf": "Download as PDF", "paged": "Paged", "infinite": "Infinite", "delete": "Delete…", "format": "Format", "more": "More", "undo": "Undo", "redo": "Redo", "body": "Before 1887, Millbrook drew its water the way most small towns did: from private wells and a handful of shared pumps."},
+ "ar": {"app": "المستندات", "title": "ملاحظات الاجتماع الأسبوعي حول مشروع المكتبة الجديدة", "sub": "أوفيسينا · تم الحفظ", "file": "ملف", "edit": "تحرير", "view": "عرض", "share": "مشاركة…", "rename": "إعادة التسمية", "pdf": "تنزيل بصيغة PDF", "paged": "صفحات", "infinite": "متواصل", "delete": "حذف…", "format": "تنسيق", "more": "المزيد", "undo": "تراجع", "redo": "إعادة", "body": "اجتمع الفريق يوم الثلاثاء لمناقشة الجدول الزمني لمشروع المكتبة."},
+ "ru": {"app": "Документы", "title": "Очень длинное название документа, которое кто-то набрал целиком", "sub": "Oficina · Сохранено", "file": "Файл", "edit": "Правка", "view": "Вид", "share": "Поделиться…", "rename": "Переименовать", "pdf": "Скачать как PDF", "paged": "Постранично", "infinite": "Непрерывно", "delete": "Удалить…", "format": "Формат", "more": "Ещё", "undo": "Отменить", "redo": "Повторить", "body": "До 1887 года Миллбрук брал воду так же, как большинство маленьких городов."},
+}
+
+const glyph = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="8"/></svg>`
+
+func compactBar(L map[string]string) Bar {
+ item := func(label, key string) template.HTML {
+ var b bytes.Buffer
+ _ = template.Must(template.New("").ParseFS(menu.Templates(), "templates/*.html")).ExecuteTemplate(&b, "estilo-menu-item", menu.Item{Href: "#", Label: label, Key: key, Icon: glyph})
+ return template.HTML(b.String())
+ }
+ menubar := template.HTML(`<nav estilo-menubar aria-label="Menus">`)
+ for _, m := range []string{"file", "edit", "view"} {
+ menubar += template.HTML(`<details estilo-menubar-menu name="estilo-menus"><summary estilo-menubar-title data-demo="`+m+`">`+template.HTMLEscapeString(L[m])+`</summary><div estilo-menu>`) + item(L["pdf"], "⌘P") + item(L["rename"], "⇧⌘R") + `</div></details>`
+ }
+ menubar += `</nav>`
+ lead := template.HTML(`<button type="button" estilo-bar-tool aria-label="` + template.HTMLEscapeString(L["undo"]) + `">` + glyph + `</button><button type="button" estilo-bar-tool disabled aria-label="` + template.HTMLEscapeString(L["redo"]) + `">` + glyph + `</button>`)
+ more := template.HTML(`<details name="estilo-menus" data-demo="more"><summary estilo-bar-tool aria-label="`+template.HTMLEscapeString(L["more"])+`">`+glyph+`</summary><div estilo-menu>`) +
+ item(L["share"], "") + item(L["rename"], "") + `<hr>` + item(L["pdf"], "⌘P") +
+ template.HTML(`<button estilo-menu-item type="button" aria-pressed="true"><span estilo-menu-check>`+glyph+`</span><span estilo-menu-label>`+template.HTMLEscapeString(L["paged"])+`</span></button>`) +
+ `<hr>` + template.HTML(`<a estilo-menu-item="danger" href="#"><span estilo-menu-label>`+template.HTMLEscapeString(L["delete"])+`</span></a>`) + `</div></details>`
+ trail := template.HTML(`<button type="button" estilo-bar-tool aria-label="`+template.HTMLEscapeString(L["format"])+`"><b>Aa</b></button>`) + more
+ b := signedIn("x")
+ b.App = App{Name: L["app"], Slug: "docs", Home: "/", Icon: brand.Path("docs")}
+ b.ContextEdit = &TitleEdit{Action: "/t", Name: "title", Value: L["title"], Label: "Title", Submit: L["rename"]}
+ b.Nav = nil
+ b.Actions = []Action{{Item: menu.Item{Controls: "inspector", Label: L["format"]}, WideOnly: true}, {Item: menu.Item{Href: "#", Label: L["share"]}, Primary: true}}
+ b.Menubar, b.Lead, b.Sticky = menubar, lead, true
+ b.Compact = &Compact{Trail: trail}
+ return b
+}
+
+// standIn is a stacked bar that is not compact, shaped as Mapa's and
+// Fichas' are (frame.go in each): Menubar, Lead and Nav, with page
+// actions, one of them WideOnly (Mapa's Links). Below 800px their nav and
+// actions are only in the Menu sheet, and their own layouts change at
+// 800px, so nothing about them may move to 704px (Fable on c56314e).
+func standIn(kind string, L map[string]string) Bar {
+ b := compactBar(L)
+ b.Compact = nil
+ b.Lead = `<span>Saved</span>`
+ switch kind {
+ case "mapa":
+ b.App.Name = "Mapa"
+ b.Nav = []Link{{Href: "#home", Label: "Home", Current: true}, {Href: "#pages", Label: "Pages"}, {Href: "#recent", Label: "Recent"}, {Href: "#starred", Label: "Starred"}}
+ b.Actions = []Action{{Item: menu.Item{Href: "#history", Label: "History"}, Icon: glyph},
+ {Item: menu.Item{Controls: "mapa-links", Label: "Links"}, WideOnly: true, Icon: glyph}}
+ default:
+ b.App.Name = "Fichas"
+ b.ContextEdit, b.Context, b.Switcher = nil, "People", nil
+ b.Nav = []Link{{Href: "#search", Label: "Search"}, {Href: "#people", Label: "People", Current: true}, {Href: "#companies", Label: "Companies"}}
+ b.Actions = []Action{{Item: menu.Item{Href: "#history", Label: "History"}, Icon: glyph},
+ {Item: menu.Item{Href: "#new", Label: "New person"}, Primary: true, Icon: glyph}}
+ }
+ return b
+}
+
+// standInCase is what the driver measured on a stand-in: every nav link
+// and every action that is not WideOnly, and those a person can reach:
+// shown in the bar, or a row in the open Menu sheet.
+type standInCase struct {
+ Name string `json:"name"`
+ Error string `json:"error"`
+ Width int `json:"width"`
+ Header float64 `json:"header"`
+ Var float64 `json:"var"`
+ Overflow bool `json:"overflow"`
+ Wanted []string `json:"wanted"`
+ Reached []string `json:"reached"`
+}
+
+type compactCase struct {
+ Engine string `json:"engine"`
+ Version string `json:"version"`
+ Error string `json:"error"`
+ Cases []struct {
+ Name string `json:"name"`
+ Error string `json:"error"`
+ Width int `json:"width"`
+ Touch bool `json:"touch"`
+ Coarse bool `json:"coarse"`
+ Header float64 `json:"header"`
+ Var float64 `json:"var"`
+ Overflow bool `json:"overflow"`
+ Shown map[string]bool `json:"shown"`
+ Boxes map[string][]float64 `json:"boxes"` // x, y, w, h
+ Panel []float64 `json:"panel"`
+ Rows []float64 `json:"rows"`
+ Keys int `json:"keys"`
+ Ellipsis string `json:"ellipsis"`
+ // The large-title idiom (Compact.Title), at rest and folded.
+ Rest largeTitle `json:"rest"`
+ Folded largeTitle `json:"folded"`
+ // A public page's brand (App.Home empty): its colour and the
+ // accent's.
+ Public struct {
+ Brand string `json:"brand"`
+ Accent string `json:"accent"`
+ } `json:"public"`
+ } `json:"cases"`
+ StandIns []standInCase `json:"standIns"`
+ Extra struct {
+ Resized struct {
+ From, Header, Var float64
+ } `json:"resized"`
+ ResizedError string `json:"resizedError"`
+ Forced map[string]struct {
+ Border float64 `json:"border"`
+ Forced bool `json:"forced"`
+ Error string `json:"error"`
+ } `json:"forced"`
+ } `json:"extra"`
+}
+
+type largeTitle struct {
+ Title bool `json:"title"` // the compact title is visible
+ Name float64 `json:"name"` // Back's name, its drawn width
+ Label string `json:"label"` // Back's text, its accessible name
+ Border string `json:"border"` // the bar's bottom border colour
+ Box []float64 `json:"box"` // the compact title
+ Back []float64 `json:"back"`
+ End []float64 `json:"end"`
+}
+
+func TestTheCompactBarInRealEngines(t *testing.T) {
+ if _, err := exec.LookPath("node"); err != nil {
+ t.Fatal("node is required (Node 22+)")
+ }
+ view := parse(t)
+ mux := http.NewServeMux()
+ mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) {
+ lang := r.URL.Query().Get("lang")
+ L, ok := compactLabels[lang]
+ if !ok {
+ lang, L = "en", compactLabels["en"]
+ }
+ // Light is named, not left to the system: this Mac is in dark
+ // mode and headless engines follow it.
+ dir, scheme := "ltr", ` data-theme="light"`
+ if lang == "ar" {
+ dir = "rtl"
+ }
+ if r.URL.Query().Get("scheme") == "dark" {
+ scheme = ` data-theme="dark"`
+ }
+ var bar bytes.Buffer
+ b := compactBar(L)
+ if kind := r.URL.Query().Get("kind"); kind != "" {
+ b = standIn(kind, L)
+ }
+ if r.URL.Query().Get("public") != "" {
+ b.App.Home = ""
+ }
+ if r.URL.Query().Get("inline") != "" {
+ b.Compact.Title = template.HTML(`<div demo-inline><b dir="auto">` + template.HTMLEscapeString(L["title"]) + `</b><small>` + template.HTMLEscapeString(L["sub"]) + `</small></div>`)
+ }
+ if err := view.ExecuteTemplate(&bar, "estilo-bar", b); err != nil {
+ t.Error(err)
+ }
+ w.Header().Set("Content-Type", "text/html; charset=utf-8")
+ fmt.Fprintf(w, compactPage, lang, dir, scheme, bar.String(), template.HTMLEscapeString(L["title"]), template.HTMLEscapeString(L["sub"]), template.HTMLEscapeString(L["body"]))
+ })
+ assets := map[string][]byte{"/tokens.css": ui.TokensCSS(), "/theme.css": theme.CSS(), "/base.css": base.CSS(), "/menu.css": menu.CSS(), "/chrome.css": CSS(), "/chrome.js": JS()}
+ for path, body := range assets {
+ mux.HandleFunc("GET "+path, func(w http.ResponseWriter, r *http.Request) {
+ ct := "text/css; charset=utf-8"
+ if strings.HasSuffix(path, ".js") {
+ ct = "text/javascript; charset=utf-8"
+ }
+ w.Header().Set("Content-Type", ct)
+ _, _ = w.Write(body)
+ })
+ }
+ mux.Handle("GET "+brand.Prefix, brand.Handler())
+ srv := httptest.NewServer(mux)
+ t.Cleanup(srv.Close)
+
+ engines := strings.Split(os.Getenv("ESTILO_BROWSERS"), ",")
+ if engines[0] == "" {
+ engines = []string{"chromium", "webkit"}
+ }
+ job, _ := json.Marshal(map[string]any{"origin": srv.URL, "engines": engines, "shots": os.Getenv("ESTILO_SHOTS")})
+ cmd := exec.Command("node", "compact.browser.mjs", string(job))
+ cmd.Stderr = os.Stderr
+ raw, err := cmd.Output()
+ if err != nil {
+ t.Fatalf("node compact.browser.mjs: %v", err)
+ }
+ var results []compactCase
+ if err := json.Unmarshal(raw, &results); err != nil {
+ t.Fatalf("driver output: %v\n%s", err, raw)
+ }
+ if len(results) != len(engines) {
+ t.Fatalf("%d engines asked for, %d reported", len(engines), len(results))
+ }
+ for _, r := range results {
+ if r.Error != "" {
+ t.Errorf("%s did not launch: %s", r.Engine, r.Error)
+ continue
+ }
+ if len(r.Cases) == 0 {
+ t.Errorf("%s measured nothing", r.Engine)
+ }
+ for _, c := range r.Cases {
+ where := fmt.Sprintf("%s %s, %s", r.Engine, r.Version, c.Name)
+ if c.Error != "" {
+ t.Errorf("%s: could not be driven: %s", where, c.Error)
+ continue
+ }
+ t.Logf("%s: header %.1f (var %.1f), shown %v, panel %v, rows %v, keys %d", where, c.Header, c.Var, c.Shown, c.Panel, c.Rows, c.Keys)
+ if c.Touch != c.Coarse {
+ t.Errorf("%s: (pointer: coarse) is %v with touch %v; the emulation is not what the case says", where, c.Coarse, c.Touch)
+ }
+ if c.Overflow {
+ t.Errorf("%s: the page scrolls sideways", where)
+ }
+ compact := strings.HasPrefix(c.Name, "phone") || strings.HasPrefix(c.Name, "landscape")
+ if compact {
+ if c.Header < 51.5 || c.Header > 52.5 || c.Var != 52 {
+ t.Errorf("%s: the compact bar is %.1fpx tall, published %.1f; want one 52px row", where, c.Header, c.Var)
+ }
+ for _, hidden := range []string{"menubar", "actions", "switcher", "account", "more", "icon"} {
+ if c.Shown[hidden] {
+ t.Errorf("%s: %s is shown in a compact bar", where, hidden)
+ }
+ }
+ for _, shown := range []string{"back", "name", "title", "lead", "trail"} {
+ if !c.Shown[shown] {
+ t.Errorf("%s: %s is not shown in a compact bar", where, shown)
+ }
+ }
+ // Back, then the title, then the end group, left to right
+ // (right to left in Arabic), none on top of another.
+ back, title, end := c.Boxes["back"], c.Boxes["title"], c.Boxes["end"]
+ rtl := strings.Contains(c.Name, " ar")
+ if !rtl && !(back[0]+back[2] <= title[0]+0.5 && title[0]+title[2] <= end[0]+0.5) {
+ t.Errorf("%s: Back %v, title %v and end %v overlap or are out of order", where, back, title, end)
+ }
+ if rtl && !(end[0]+end[2] <= title[0]+0.5 && title[0]+title[2] <= back[0]+0.5) {
+ t.Errorf("%s: in Arabic, end %v, title %v and Back %v overlap or are out of order", where, end, title, back)
+ }
+ // The large-title idiom: hidden at rest, then folded into
+ // the bar between the chevron and the end group, Back still
+ // named, the hairline drawn.
+ if c.Rest.Title || c.Rest.Name < 10 || c.Rest.Border == c.Folded.Border {
+ t.Errorf("%s: at rest the compact title shows %v, Back's name is %.1fpx, the border %q (folded %q)", where, c.Rest.Title, c.Rest.Name, c.Rest.Border, c.Folded.Border)
+ }
+ if len(c.Folded.Back) == 4 && (c.Folded.Back[2] < 43.5 || c.Folded.Back[3] < 43.5) {
+ t.Errorf("%s: folded, Back is %.1fx%.1fpx, under 44", where, c.Folded.Back[2], c.Folded.Back[3])
+ }
+ if c.Public.Brand == "" || c.Public.Brand == c.Public.Accent {
+ t.Errorf("%s: a public page's plain-text brand is %q, the accent %q: it looks like a link", where, c.Public.Brand, c.Public.Accent)
+ }
+ if !c.Folded.Title || c.Folded.Name > 1 || strings.TrimSpace(c.Folded.Label) == "" {
+ t.Errorf("%s: folded, the compact title shows %v, Back's name is %.1fpx wide and Back reads %q", where, c.Folded.Title, c.Folded.Name, c.Folded.Label)
+ }
+ if f := c.Folded; len(f.Box) == 4 && len(f.Back) == 4 && len(f.End) == 4 {
+ rtl := strings.Contains(c.Name, " ar")
+ if !rtl && !(f.Back[0]+f.Back[2] <= f.Box[0]+0.5 && f.Box[0]+f.Box[2] <= f.End[0]+0.5) || rtl && !(f.End[0]+f.End[2] <= f.Box[0]+0.5 && f.Box[0]+f.Box[2] <= f.Back[0]+0.5) {
+ t.Errorf("%s: folded, Back %v, the compact title %v and the end %v overlap", where, f.Back, f.Box, f.End)
+ }
+ if f.Box[2] < 100 {
+ t.Errorf("%s: folded, the compact title has %.1fpx", where, f.Box[2])
+ }
+ }
+ if c.Ellipsis != "ellipsis" {
+ t.Errorf("%s: the title field's overflow is %q, not an ellipsis", where, c.Ellipsis)
+ }
+ for _, tool := range []string{"tool-0", "tool-1", "tool-2", "tool-3"} {
+ if b := c.Boxes[tool]; len(b) != 4 || b[2] < 43.5 || b[3] < 43.5 {
+ t.Errorf("%s: %s is %v, under 44px", where, tool, b)
+ }
+ }
+ // The ••• panel drops from the inline end, inside the
+ // viewport, rows 44px, no shortcut hints.
+ p := c.Panel
+ if len(p) != 4 || p[0] < 0 || p[0]+p[2] > float64(c.Width)+0.5 || p[1] < c.Header-0.5 {
+ t.Errorf("%s: the ••• panel %v is not under the bar inside a %dpx viewport", where, p, c.Width)
+ } else if !rtl && float64(c.Width)-(p[0]+p[2]) > 9 || rtl && p[0] > 9 {
+ t.Errorf("%s: the ••• panel %v does not hang from the inline end", where, p)
+ }
+ for _, h := range c.Rows {
+ if h < 43.5 {
+ t.Errorf("%s: a ••• row is %.1fpx, under 44", where, h)
+ }
+ }
+ if c.Keys != 0 {
+ t.Errorf("%s: %d shortcut hints show in the ••• panel", where, c.Keys)
+ }
+ continue
+ }
+ // Wide: the stacked header, as without Compact.
+ if c.Header < 55.5 || c.Header > 56.5 {
+ t.Errorf("%s: the stacked header is %.1fpx, want 56", where, c.Header)
+ }
+ for _, hidden := range []string{"trail", "back", "more"} {
+ if c.Shown[hidden] {
+ t.Errorf("%s: %s is shown from 44rem", where, hidden)
+ }
+ }
+ // The stack is the title over the menu row, never one row.
+ if ti, mb := c.Boxes["title"], c.Boxes["menubar"]; len(ti) != 4 || len(mb) != 4 || mb[1] < ti[1]+ti[3]/2 { // the title row sits 2.5px low by design
+ t.Errorf("%s: the title %v is not over the menu row %v", where, ti, mb)
+ }
+ for _, shown := range []string{"menubar", "actions", "account", "switcher", "icon"} {
+ if !c.Shown[shown] {
+ t.Errorf("%s: %s is not shown from 44rem", where, shown)
+ }
+ }
+ want := 28.0
+ if c.Coarse {
+ want = 44
+ }
+ for _, h := range c.Rows {
+ if h < want-0.5 || (!c.Coarse && h > want+0.5) {
+ t.Errorf("%s: a File row is %.1fpx, want %v", where, h, want)
+ }
+ }
+ if c.Coarse && c.Keys != 0 {
+ t.Errorf("%s: %d shortcut hints show on a touch screen", where, c.Keys)
+ }
+ if !c.Coarse && c.Keys == 0 {
+ t.Errorf("%s: no shortcut hints with a mouse", where)
+ }
+ }
+ }
+ // Mapa and Fichas, as their bars are: everything in reach at every
+ // width, the header the height it publishes, and 56px only from 800px.
+ for _, r := range results {
+ if r.Error != "" {
+ continue
+ }
+ if len(r.StandIns) == 0 {
+ t.Errorf("%s measured no stand-in", r.Engine)
+ }
+ for _, c := range r.StandIns {
+ where := fmt.Sprintf("%s %s, %s", r.Engine, r.Version, c.Name)
+ t.Logf("%s: header %.1f (var %.1f), reached %v of %v", where, c.Header, c.Var, c.Reached, c.Wanted)
+ if c.Error != "" {
+ t.Errorf("%s: could not be driven: %s", where, c.Error)
+ continue
+ }
+ if c.Overflow {
+ t.Errorf("%s: the page scrolls sideways", where)
+ }
+ reached := map[string]bool{}
+ for _, l := range c.Reached {
+ reached[strings.TrimSpace(l)] = true
+ }
+ if len(c.Wanted) < 3 {
+ t.Errorf("%s: only %v to reach; the check is not reading the bar", where, c.Wanted)
+ }
+ for _, w := range c.Wanted {
+ if !reached[strings.TrimSpace(w)] {
+ t.Errorf("%s: %q is out of reach: not in the bar and not in an open Menu sheet", where, w)
+ }
+ }
+ if d := c.Header - c.Var; d > 0.5 || d < -0.5 {
+ t.Errorf("%s: the header is %.1fpx and publishes %.1f", where, c.Header, c.Var)
+ }
+ wide := c.Width >= 800
+ if wide != (c.Header > 55.5 && c.Header < 56.5) {
+ t.Errorf("%s: the header is %.1fpx at %dpx; a stacked bar that is not compact is the 56px header exactly from 800px", where, c.Header, c.Width)
+ }
+ }
+ }
+ // A compact bar loaded below 704px and widened to 768px is the 56px
+ // header: the script must not hold it at the 52px it measured (Fable's
+ // delta review, item 1). And in forced colours the band's controls
+ // keep their border, as from 800px (item 2).
+ for _, r := range results {
+ if r.Error != "" {
+ continue
+ }
+ x := r.Extra
+ if x.ResizedError != "" {
+ t.Errorf("%s: the resize could not be driven: %s", r.Engine, x.ResizedError)
+ } else if x.Resized.From < 51.5 || x.Resized.From > 52.5 || x.Resized.Header < 55.5 || x.Resized.Header > 56.5 || x.Resized.Var < 55.5 || x.Resized.Var > 56.5 {
+ t.Errorf("%s: 650px then 768px: the bar went from %.1fpx to %.1fpx (publishing %.1f); want 52 then 56", r.Engine, x.Resized.From, x.Resized.Header, x.Resized.Var)
+ }
+ for _, w := range []string{"768", "1280"} {
+ f := x.Forced[w]
+ switch {
+ case f.Error != "":
+ t.Errorf("%s: forced colours at %s could not be driven: %s", r.Engine, w, f.Error)
+ case !f.Forced:
+ t.Errorf("%s: forced colours at %s were not emulated; the check is blind", r.Engine, w)
+ case f.Border < 1:
+ t.Errorf("%s: in forced colours at %spx the primary control's border is %.1fpx: it has no edge", r.Engine, w, f.Border)
+ }
+ }
+ }
+}
diff --git a/chrome/compact_test.go b/chrome/compact_test.go
new file mode 100644
index 0000000..75755a5
--- /dev/null
+++ b/chrome/compact_test.go
@@ -0,0 +1,415 @@
+package chrome
+
+import (
+ "html/template"
+ "regexp"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/estilo.git/menu"
+)
+
+// What Docs puts in the compact slots on a phone: its Aa and ••• at the
+// inline end, and its inline title (shown once its large title has
+// scrolled away). Markup it rendered itself.
+const (
+ testTrail = template.HTML(`<button type="button" estilo-bar-tool aria-label="Format">Aa</button><details name="estilo-menus"><summary estilo-bar-tool aria-label="More"></summary><div estilo-menu></div></details>`)
+ testTitle = template.HTML(`<b>x-inline-title</b>`)
+)
+
+func compact() Bar {
+ b := stacked()
+ b.Lead = testLead
+ b.Compact = &Compact{Trail: testTrail}
+ b.Nav = nil // Docs has none; a compact bar with nav keeps a sheet for it (TestACompactBarWithNavKeepsItsSheet)
+ return b
+}
+
+// narrowQuery is where a compact bar is the phone's one row: below 704px,
+// or a phone held sideways. bandQuery is where a compact bar, and only a
+// compact bar, is already the 56px desktop header that every other
+// stacked bar starts at 800px (Paul, 2026-11-28: the desktop header from
+// 704px for an iPad in portrait; Fable on c56314e: Mapa and Fichas stack
+// too, and their own layouts break at 800px). In px, as the 800px
+// breakpoint is, so the two never part at a reader's larger default font.
+// (bandQuery is chrome.go's.)
+const narrowQuery = "@media (max-width: 703.98px), (max-height: 480px) and (pointer: coarse)"
+
+// The Compact slot marks the bar compact and adds only what a compact bar
+// needs: the Back chevron in the brand, the app's trail in the end group
+// before the switcher and the account, and no Menu sheet, since the trail
+// carries the app's own overflow.
+func TestTheCompactSlotMarksTheBar(t *testing.T) {
+ b := compact()
+ html := render(t, "estilo-bar", b)
+ if got := header(html); got != `<header estilo-bar="stacked compact">` {
+ t.Errorf("a compact stacked bar opens %s", got)
+ }
+ b.Sticky = true
+ if got := header(render(t, "estilo-bar", b)); got != `<header estilo-bar="sticky stacked compact">` {
+ t.Errorf("a sticky compact stacked bar opens %s", got)
+ }
+ plain := signedIn("x")
+ plain.Compact = &Compact{Trail: testTrail}
+ if got := header(render(t, "estilo-bar", plain)); got != `<header estilo-bar="compact">` {
+ t.Errorf("a compact one-row bar opens %s", got)
+ }
+
+ brand := html[strings.Index(html, "<a estilo-bar-brand"):]
+ brand = brand[:strings.Index(brand, "</a>")]
+ if !strings.Contains(brand, `<svg estilo-bar-back `) || !strings.Contains(brand, `aria-hidden="true"`) {
+ t.Errorf("the compact brand has no hidden Back chevron:\n%s", brand)
+ }
+ if !strings.Contains(brand, "<span estilo-bar-name>x-app</span>") {
+ t.Errorf("the Back link lost the app's name, its label:\n%s", brand)
+ }
+
+ if strings.Contains(html, "estilo-bar-more") {
+ t.Error("a compact bar drew the Menu sheet; its trail is the overflow")
+ }
+ if !strings.Contains(html, "<div estilo-bar-trail>"+string(testTrail)+"</div>") {
+ t.Errorf("the trail is not drawn verbatim:\n%s", html)
+ }
+ order := []string{"<div estilo-bar-lead>", "<div estilo-bar-actions>", "<div estilo-bar-trail>", "<details estilo-switcher", "<details estilo-account"}
+ last := -1
+ for _, marker := range order {
+ i := strings.Index(html, marker)
+ if i < 0 || i < last {
+ t.Fatalf("%q is missing or out of order", marker)
+ }
+ last = i
+ }
+ if strings.Contains(html, "estilo-bar-compact-title") {
+ t.Error("a compact bar with no Title drew the compact title slot")
+ }
+
+ // A Title replaces the bar's own title below 44rem: it is drawn after
+ // the brand and the stack, before the end group.
+ b.Compact.Title = testTitle
+ html = render(t, "estilo-bar", b)
+ at := strings.Index(html, "<div estilo-bar-compact-title>"+string(testTitle)+"</div>")
+ if at < 0 || at < strings.Index(html, "<div estilo-bar-stack>") || at > strings.Index(html, "<div estilo-bar-end>") {
+ t.Errorf("the compact title is not between the stack and the end group:\n%s", html)
+ }
+
+ // A public page's brand is plain text: no Back.
+ pub := compact()
+ pub.App.Home = ""
+ if strings.Contains(render(t, "estilo-bar", pub), "estilo-bar-back") {
+ t.Error("a brand that links nowhere drew a Back chevron")
+ }
+}
+
+// Every rule a compact bar adds is keyed on a compact hook, and the
+// hooks are in the opt-in list (TestEverythingAfterTheMarkerIsOptIn).
+func TestTheCompactHooksAreOptIn(t *testing.T) {
+ for _, h := range []string{`[estilo-bar~="compact"]`, "[estilo-bar-trail]", "[estilo-bar-back]", "[estilo-bar-compact-title]", "[estilo-bar-tool]"} {
+ found := false
+ for _, o := range optInHooks {
+ found = found || o == h
+ }
+ if !found {
+ t.Errorf("%s is not an opt-in hook", h)
+ }
+ }
+}
+
+// Below 44rem a compact bar is the phone's one 52px row: Back, the
+// title, the lead and the trail. The menus, the actions, the switcher and
+// the account go (the trail and the app's other screens carry them), and
+// the published block size is the row's.
+func TestTheCompactBarIsOneRowBelow704px(t *testing.T) {
+ src := string(CSS())
+ src = src[strings.Index(src, barStackMarker):]
+ at := strings.Index(src, "/* ── Compact")
+ if at < 0 {
+ t.Fatal("chrome.css has no compact section")
+ }
+ section := src[at:]
+ narrow := section[strings.Index(section, narrowQuery):]
+ narrow = narrow[:strings.Index(narrow, "\n}\n")]
+ for _, want := range []string{
+ `:root:has([estilo-bar~="compact"]) { --estilo-bar-block-size: 3.25rem; }`,
+ `[estilo-bar~="compact"] [estilo-bar-menubar],`,
+ `[estilo-bar~="compact"] [estilo-bar-actions],`,
+ `[estilo-bar~="compact"] [estilo-switcher],`,
+ `[estilo-bar~="compact"] [estilo-account] { display: none; }`,
+ `[estilo-bar~="compact"] [estilo-bar-trail] { display: flex;`,
+ `[estilo-bar~="compact"] [estilo-bar-compact-title] { display: block;`,
+ `[estilo-bar~="compact"] [estilo-bar-back] { display: block;`,
+ } {
+ if !strings.Contains(narrow, want) {
+ t.Errorf("the compact narrow block lacks %s", want)
+ }
+ }
+ // The trail's panel is a drop-down from the inline end (Paul's answer
+ // 3), sized for a finger: 44px rows, no shortcut hints.
+ for _, re := range []string{
+ `\[estilo-bar-trail\] \[estilo-menu\] \{[^}]*position: absolute;[^}]*inset-inline-end: var\(--rst-sp-2\);`,
+ `\[estilo-bar-trail\] \[estilo-menu-item\] \{[^}]*min-block-size: 44px;`,
+ `\[estilo-bar-trail\] \[estilo-menu-key\] \{ display: none; \}`,
+ `\[estilo-bar-tool\] \{[^}]*min-inline-size: 44px;[^}]*block-size: 44px;`,
+ } {
+ if !regexp.MustCompile(re).MatchString(section) {
+ t.Errorf("the compact section lacks %s", re)
+ }
+ }
+ // The editable title fills its room and ends in an ellipsis there,
+ // instead of being cut mid-letter (audit finding 2).
+ if !regexp.MustCompile(`\[estilo-bar~="compact"\] \[estilo-bar-title-input\] \{[^}]*inline-size: 100%;[^}]*text-overflow: ellipsis;`).MatchString(narrow) {
+ t.Error("the compact title field does not fill its room with an ellipsis")
+ }
+ // From 44rem the trail and the compact title are gone.
+ if !regexp.MustCompile(`\n:is\(\[estilo-bar-trail\], \[estilo-bar-compact-title\], \[estilo-bar-back\]\) \{ display: none; \}`).MatchString(section) {
+ t.Error("the trail, compact title and Back are not hidden by default")
+ }
+}
+
+// chrome.js leaves a compact title unfitted where the compact bar is
+// narrow, on the CSS's own query, and publishes a stacked bar's narrow
+// height below 800px, as it always has.
+func TestTheScriptUsesTheCSSBreakpoints(t *testing.T) {
+ js := string(JS())
+ q := strings.TrimPrefix(narrowQuery, "@media ")
+ if !strings.Contains(js, "matchMedia('"+q+"')") {
+ t.Errorf("chrome.js does not read the compact query %q", q)
+ }
+ if !strings.Contains(js, "matchMedia('(max-width: 799.98px)')") {
+ t.Error("chrome.js no longer publishes the stacked bar's height below 800px")
+ }
+ if !strings.Contains(js, `(bar) => (' ' + bar.getAttribute('estilo-bar') + ' ').indexOf(' compact ') < 0)`) {
+ t.Error("chrome.js publishes a compact bar's measured height, which holds it at 52px past 704px")
+ }
+ css := string(CSS())
+ if !strings.Contains(css, narrowQuery+" {") || !strings.Contains(css, bandQuery+" {") {
+ t.Error("chrome.css does not use the compact pair")
+ }
+ if strings.Contains(css, "43.99rem") || strings.Contains(css, "(min-width: 44rem)") {
+ t.Error("a rem breakpoint is left; at a larger default font it parts from 800px")
+ }
+}
+
+// Touch: every bar trigger is a 44px target on a coarse pointer, in every
+// app (audit finding 9). The stacked header keeps its 32px look and takes
+// 44px of hit area.
+func TestTouchTargetsAre44px(t *testing.T) {
+ src := string(CSS())
+ main := src[:strings.Index(src, barStackMarker)]
+ if !regexp.MustCompile(`@media \(pointer: coarse\) \{\s*:root \{ --estilo-trigger-size: 2\.75rem; \}`).MatchString(main) {
+ t.Error("the bar's triggers are not 44px on a coarse pointer")
+ }
+ stack := src[strings.Index(src, barStackMarker):]
+ wide := stack[strings.Index(stack, "@media (min-width: 800px) {"):]
+ coarse := wide[strings.Index(wide, "@media (pointer: coarse) {"):]
+ coarse = coarse[:strings.Index(coarse, "\n }\n")]
+ for _, want := range []string{
+ `[estilo-bar~="stacked"] [estilo-menubar-title]::before { content: ""; position: absolute; inset-inline: 0; inset-block: -16px -4px; }`,
+ `[estilo-bar~="stacked"] [estilo-menu-item] { min-block-size: 44px; }`,
+ `:is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button)::before { content: ""; position: absolute; inset: -6px -4px; }`,
+ } {
+ if !strings.Contains(coarse, want) {
+ t.Errorf("the stacked header's coarse rules lack %s", want)
+ }
+ }
+}
+
+// Only a compact bar moves to 704px. Every other stacked bar (Mapa and
+// Fichas set Menubar, Lead and Nav, and their layouts break at 800px)
+// keeps main's rules: the 56px header from 800px, the two-row bar and its
+// Menu sheet below. Between 704px and 800px a compact bar gets the very
+// same 56px header, a copy of that block CSS() makes at init with every
+// selector scoped to a compact bar, so the two can never drift.
+func TestOnlyACompactBarMovesTo704px(t *testing.T) {
+ src := string(CSS())
+ at := strings.Index(src, bandQuery+" {")
+ if at < 0 {
+ t.Fatal("no 704px band for a compact bar")
+ }
+ if strings.Contains(string(css), `[estilo-bar~="stacked"][estilo-bar~="compact"]) { --estilo-bar-block-size: 56px; }`) {
+ t.Error("the band's copy is written by hand in chrome.css; it must be the generated one")
+ }
+ wide := regexp.MustCompile(`(?s)/\*.*?\*/`).ReplaceAllString(wideBlock(string(css)), "")
+ band := block(src, at+len(bandQuery)+2)
+ rules := func(block string) []string {
+ var out []string
+ for _, m := range regexp.MustCompile(`([^{};]+)\{`).FindAllStringSubmatch(block, -1) {
+ if l := strings.TrimSpace(m[1]); !strings.HasPrefix(l, "@") {
+ out = append(out, l)
+ }
+ }
+ return out
+ }
+ w, b := rules(wide), rules(band)
+ if len(w) < 40 || len(w) != len(b) {
+ t.Fatalf("the band has %d rules for the wide block's %d", len(b), len(w))
+ }
+ for i, list := range b {
+ for _, sel := range splitSelectors(list) {
+ if !strings.Contains(sel, `[estilo-bar~="compact"]`) {
+ t.Errorf("band rule %d, %q, reaches a bar that is not compact (from %q)", i, sel, w[i])
+ }
+ }
+ }
+ // The declarations are the wide block's, verbatim.
+ decls := func(block string) string {
+ return regexp.MustCompile(`[^{};]+\{`).ReplaceAllString(block, "{")
+ }
+ if strings.Join(strings.Fields(decls(wide)), " ") != strings.Join(strings.Fields(decls(band)), " ") {
+ t.Error("the band's declarations are not the wide block's")
+ }
+ // The scope adds no specificity (:where), so the cascade around the
+ // copy is the original's; a pseudo-element stays outside :is().
+ if strings.Contains(band, `):is([estilo-bar~="compact"]`) {
+ t.Error("the band's scope adds specificity; the forced-colors border would lose to the controls' border: 0")
+ }
+ if !strings.Contains(band, `:is([estilo-bar~="stacked"] [estilo-menubar-title]):where([estilo-bar~="compact"], [estilo-bar~="compact"] *)::before`) {
+ t.Error("the band does not keep ::before outside :is()")
+ }
+ if !strings.Contains(band, `:root:has([estilo-bar~="stacked"][estilo-bar~="compact"]) { --estilo-bar-block-size: 56px; }`) {
+ t.Error("the band does not publish the compact bar's 56px")
+ }
+ // Nothing written by hand for the band reaches a bar without Compact.
+ hand := src[strings.Index(src, "/* Between 704px and 800px"):]
+ hand = regexp.MustCompile(`(?s)/\*.*?\*/`).ReplaceAllString(block(hand, strings.Index(hand, "{")+1), "")
+ for _, list := range rules(hand) {
+ for _, sel := range splitSelectors(list) {
+ if !strings.Contains(sel, `[estilo-bar~="compact"]`) {
+ t.Errorf("%q, in the band, reaches a bar that is not compact", sel)
+ }
+ }
+ }
+ // The Rename pill stays in the title row in the band, where the narrow
+ // rule would float it under the title.
+ pill := regexp.MustCompile(`\[estilo-bar~="stacked"\] \[estilo-bar-title\]:focus-within \[estilo-bar-title-submit\] \{[^}]*\}`).FindString(wide)
+ if !strings.Contains(pill, "position: static;") {
+ t.Errorf("the wide Rename pill can still float under the title:\n%s", pill)
+ }
+}
+
+// A compact bar with Nav draws the Menu sheet (with the nav and the
+// actions) and shows it in the compact row, so the nav is never
+// unreachable; without Nav the trail is the only overflow.
+func TestACompactBarWithNavKeepsItsSheet(t *testing.T) {
+ b := compact()
+ b.Nav = []Link{{Href: "/places", Label: "x-place"}}
+ html := render(t, "estilo-bar", b)
+ sheet := html[strings.Index(html, "<details estilo-bar-more"):]
+ sheet = sheet[:strings.Index(sheet, "</details>")]
+ if !strings.Contains(sheet, "x-place") || !strings.Contains(sheet, "x-share") {
+ t.Errorf("a compact bar with nav has no sheet holding it:\n%s", html)
+ }
+ if strings.Index(html, "<details estilo-bar-more") > strings.Index(html, "<div estilo-bar-trail>") {
+ t.Error("the sheet is not before the trail")
+ }
+ b.Nav = nil
+ if strings.Contains(render(t, "estilo-bar", b), "estilo-bar-more") {
+ t.Error("a compact bar without nav drew the sheet")
+ }
+ src := string(CSS())
+ narrow := src[strings.Index(src, "/* ── Compact"):]
+ narrow = narrow[strings.Index(narrow, narrowQuery):]
+ if !strings.Contains(narrow[:strings.Index(narrow, "\n}\n")], `[estilo-bar~="compact"] [estilo-bar-more] { display: block; }`) {
+ t.Error("the compact row does not show a compact bar's sheet")
+ }
+}
+
+// Folded, Back is its chevron alone, still a 44px target (Fable, item 2).
+func TestFoldedBackIsA44pxTarget(t *testing.T) {
+ src := string(CSS())
+ src = src[strings.Index(src, "/* ── Compact"):]
+ if !regexp.MustCompile(`\[estilo-bar~="compact"\]\[estilo-bar-folded\]:has\(> \[estilo-bar-compact-title\]\) \[estilo-bar-brand\] \{[^}]*min-inline-size: 44px;[^}]*justify-content: center;`).MatchString(src) {
+ t.Error("folded Back is not a centred 44px target")
+ }
+}
+
+// A public page's brand is plain text, not a link: it is not drawn in the
+// link's accent (Fable, item 4).
+func TestOnlyALinkedBrandTakesTheAccent(t *testing.T) {
+ src := string(CSS())
+ src = src[strings.Index(src, "/* ── Compact"):]
+ for _, m := range regexp.MustCompile(`([^{};]+)\{([^}]*)\}`).FindAllStringSubmatch(src, -1) {
+ if !strings.Contains(m[2], "var(--rst-accent)") || !strings.Contains(m[1], "[estilo-bar-brand]") {
+ continue
+ }
+ for _, sel := range splitSelectors(strings.TrimSpace(m[1])) {
+ if strings.HasSuffix(sel, "[estilo-bar-brand]") && !strings.HasSuffix(sel, "a[estilo-bar-brand]") {
+ t.Errorf("%q draws a plain-text brand in the accent", sel)
+ }
+ }
+ }
+}
+
+// On a coarse pointer the rail's account row and every menubar title
+// outside the wide stacked header are 44px too (Fable, item 5), and the
+// narrow stacked bar publishes the taller menu row.
+func TestTheRemainingTouchTargetsAre44px(t *testing.T) {
+ src := string(CSS())
+ main := src[:strings.Index(src, barStackMarker)]
+ if !regexp.MustCompile(`@media \(pointer: coarse\) \{[^}]*\[estilo-account~="rail"\] > \[estilo-bar-trigger\] \{ min-block-size: 2\.75rem; \}`).MatchString(main) {
+ t.Error("the rail's account row is not 44px on touch")
+ }
+ if !regexp.MustCompile(`@media \(pointer: coarse\) \{[^@]*\[estilo-menubar-title\] \{ min-block-size: 2\.75rem; \}`).MatchString(string(menu.CSS())) {
+ t.Error("menubar titles are not 44px on touch")
+ }
+ if !strings.Contains(src, "@media (max-width: 799.98px) and (pointer: coarse) {\n :root:has([estilo-bar~=\"stacked\"]) { --estilo-bar-block-size: calc(3.25rem + 2.75rem + 1px); }") {
+ t.Error("the narrow stacked bar does not publish its 44px menu row on touch")
+ }
+}
+
+// A compact bar fits 360px with room for the title: Back, the lead and a
+// two-button trail are 300px in the mock-up, and the bar's own padding
+// and gaps are the small steps.
+func TestTheCompactBarUsesTheSmallSteps(t *testing.T) {
+ src := string(CSS())
+ src = src[strings.Index(src, "/* ── Compact"):]
+ if !regexp.MustCompile(`\[estilo-bar~="compact"\] \{[^}]*gap: var\(--rst-sp-1\);[^}]*padding-inline: var\(--rst-sp-2\);`).MatchString(src) {
+ t.Error("the compact bar is not laid out on the small steps")
+ }
+}
+
+// The menu's Icon is drawn in the compact trail's rows (and any menu that
+// passes one); a row without one is byte for byte what it was.
+func TestTheCompactTrailCanDrawIconRows(t *testing.T) {
+ got := render(t, "estilo-menu-item", menu.Item{Href: "/s", Label: "x-share", Icon: `<svg aria-hidden="true"></svg>`})
+ if got != `<a estilo-menu-item href="/s"><span estilo-menu-icon><svg aria-hidden="true"></svg></span><span estilo-menu-label>x-share</span></a>` {
+ t.Errorf("an icon row: %s", got)
+ }
+}
+
+// With Compact.Title the bar is the large-title idiom: the compact title
+// shows only once the app marks the bar folded, and then Back is its
+// chevron, its name visually hidden but still its accessible name.
+func TestACompactTitleShowsOnlyWhenFolded(t *testing.T) {
+ src := string(CSS())
+ src = src[strings.Index(src, "/* ── Compact"):]
+ for _, want := range []string{
+ `[estilo-bar~="compact"] [estilo-bar-compact-title] { opacity: 0; visibility: hidden;`,
+ `[estilo-bar~="compact"][estilo-bar-folded] [estilo-bar-compact-title] { opacity: 1; visibility: visible;`,
+ `[estilo-bar~="compact"][estilo-bar-folded]:has(> [estilo-bar-compact-title]) [estilo-bar-name] { position: absolute; clip-path: inset(50%);`,
+ `[estilo-bar~="compact"]:has(> [estilo-bar-compact-title]) { border-block-end-color: transparent; }`,
+ } {
+ if !strings.Contains(src, want) {
+ t.Errorf("the compact section lacks %s", want)
+ }
+ }
+ if strings.Contains(src, `[estilo-bar-folded]:has(> [estilo-bar-compact-title]) [estilo-bar-name] { display: none`) {
+ t.Error("folded, Back would lose its accessible name")
+ }
+}
+
+// block is the body of the block whose opening brace is just before
+// start, up to its matching closing brace.
+func block(src string, start int) string {
+ depth := 1
+ for i := start; i < len(src); i++ {
+ switch src[i] {
+ case '{':
+ depth++
+ case '}':
+ if depth--; depth == 0 {
+ return src[start:i]
+ }
+ }
+ }
+ return src[start:]
+}
diff --git a/chrome/stack_test.go b/chrome/stack_test.go
index fc43a5b..74d7768 100644
--- a/chrome/stack_test.go
+++ b/chrome/stack_test.go
@@ -314,13 +314,13 @@ func TestTheStackedBarPublishesItsHeight(t *testing.T) {
}
}
// Coarse pointers: the menubar titles keep their 24px look but take
- // 32px of hit area, 4px over each edge, with no change to layout.
+ // 44px of hit area, 16px up and 4px down, with no change to layout.
coarse := src[strings.Index(src, "@media (min-width: 800px) {"):]
coarse = coarse[strings.Index(coarse, "@media (pointer: coarse) {"):]
coarse = coarse[:strings.Index(coarse, "\n }\n")]
for _, want := range []string{
`[estilo-bar~="stacked"] [estilo-menubar-title] { position: relative; }`,
- `[estilo-bar~="stacked"] [estilo-menubar-title]::before { content: ""; position: absolute; inset-inline: 0; inset-block: -4px; }`,
+ `[estilo-bar~="stacked"] [estilo-menubar-title]::before { content: ""; position: absolute; inset-inline: 0; inset-block: -16px -4px; }`,
`[estilo-bar~="stacked"] [estilo-bar-title] { z-index: 1; }`, // the title field keeps its own 24px on top
} {
if !strings.Contains(coarse, want) {
diff --git a/chrome/templates/bar.html b/chrome/templates/bar.html
index b6be10d..fd0ed79 100644
--- a/chrome/templates/bar.html
+++ b/chrome/templates/bar.html
@@ -12,14 +12,22 @@
the markup is the same at every width.
Order in the end group is fixed in every app: the lead (Bar.Lead),
- actions, then Menu (narrow only), then the switcher, then the
- account. The account is always the last thing at the inline end.
+ actions, then Menu (narrow only) or a compact bar's trail, then the
+ switcher, then the account. The account is always the last thing at
+ the inline end.
+
+ Compact (Bar.Compact set, estilo-bar~="compact"): below 704px the
+ phone's one row, Back (the brand, with a chevron before it), the
+ title or Compact.Title, the lead and Compact.Trail. A compact bar
+ draws the Menu sheet only for its nav (Bar.Nav), before the trail,
+ so the nav is never out of reach: the trail is the overflow for
+ everything else, the actions included.
The brand is a link to the app root, except on public read-only
pages, where App.Home is empty and it is plain text. */}}
-{{define "estilo-bar"}}<header estilo-bar{{if and .Sticky .Menubar}}="sticky stacked"{{else if .Sticky}}="sticky"{{else if .Menubar}}="stacked"{{end}}>
+{{define "estilo-bar"}}<header estilo-bar{{with .Kind}}="{{.}}"{{end}}>
{{- if .App.Home}}
- <a estilo-bar-brand href="{{.App.Home}}"><img estilo-brand-icon src="{{.App.Icon}}" alt="" width="28" height="28"><span estilo-bar-name>{{.App.Name}}</span></a>
+ <a estilo-bar-brand href="{{.App.Home}}">{{if .Compact}}{{template "estilo-icon-back"}}{{end}}<img estilo-brand-icon src="{{.App.Icon}}" alt="" width="28" height="28"><span estilo-bar-name>{{.App.Name}}</span></a>
{{- else}}
<span estilo-bar-brand><img estilo-brand-icon src="{{.App.Icon}}" alt="" width="28" height="28"><span estilo-bar-name>{{.App.Name}}</span></span>
{{- end}}
@@ -39,6 +47,9 @@
<span estilo-bar-context dir="auto" title="{{.}}">{{.}}</span>
{{- end}}{{end}}
{{- end}}
+ {{- with .Compact}}{{with .Title}}
+ <div estilo-bar-compact-title>{{.}}</div>
+ {{- end}}{{end}}
{{- if .Nav}}
<nav estilo-bar-nav aria-label="{{.NavLabel}}">
{{- range .Nav}}<a href="{{.Href}}"{{if .Current}} aria-current="page"{{end}}>{{.Label}}</a>{{end}}
@@ -52,7 +63,7 @@
<div estilo-bar-actions>{{template "estilo-bar-actions" .}}</div>
{{- end}}
{{- $sheet := false}}{{range .Actions}}{{if not .WideOnly}}{{$sheet = true}}{{end}}{{end}}
- {{- if or .Nav $sheet}}
+ {{- if or .Nav (and (not .Compact) $sheet)}}
<details estilo-bar-more name="estilo-menus">
<summary estilo-bar-trigger>{{template "estilo-icon-menu"}}<span>{{.Labels.Menu}}</span></summary>
<div estilo-menu="sheet">
@@ -62,6 +73,9 @@
</div>
</details>
{{- end}}
+ {{- with .Compact}}
+ <div estilo-bar-trail>{{.Trail}}</div>
+ {{- end}}
{{- with .Switcher}}
{{template "estilo-switcher" .}}
{{- end}}
diff --git a/chrome/templates/icons.html b/chrome/templates/icons.html
index 99d5a93..dd1c25e 100644
--- a/chrome/templates/icons.html
+++ b/chrome/templates/icons.html
@@ -1,4 +1,6 @@
-{{/* The bar's glyphs. Lucide "menu", "user" and "layout-grid", and for
+{{/* The bar's glyphs. Lucide "menu", "user", "layout-grid" and, for a
+ compact bar's Back, "chevron-left" (flipped in a right-to-left page by
+ chrome.css), and for
Appearance "sun", "moon" and "monitor" (lucide-static 1.72.0) (ISC,
brand/LICENSE.lucide). Decorative: every trigger that carries one has
a text label or an aria-label of its own. */}}
@@ -8,3 +10,4 @@
{{define "estilo-icon-sun"}}<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"><circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/></svg>{{end}}
{{define "estilo-icon-moon"}}<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"><path d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"/></svg>{{end}}
{{define "estilo-icon-display"}}<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="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>{{end}}
+{{define "estilo-icon-back"}}<svg estilo-bar-back viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="m15 18-6-6 6-6"/></svg>{{end}}
diff --git a/chrome/unchanged_test.go b/chrome/unchanged_test.go
index 5adf381..6d93dd9 100644
--- a/chrome/unchanged_test.go
+++ b/chrome/unchanged_test.go
@@ -87,17 +87,25 @@ const barStackMarker = "\n/* ── Bar stack"
// became a stack, its rules all keyed on estilo-signin. chrome.css's
// again on fix/door-stack-lows, for the door's card only: its gap is the
// table's smallest step as in Fiesta's stack, so a hidden child leaves no
-// relation touching, and the card takes a hint and a section hook.
+// relation touching, and the card takes a hint and a section hook. Both
+// again on feat/phone-compact-bar (Paul 2026-11-28, the phone web design,
+// approved with its six answers): on a coarse pointer every bar trigger
+// is 44px (--estilo-trigger-size 2.75rem) and every menu row 44px, and on
+// a touch screen that cannot hover a menu shows no shortcut hints; a menu
+// row may carry an icon ([estilo-menu-icon]); and, after Fable's review
+// of c56314e, the rail's account row and every menubar title are 44px on
+// a coarse pointer too. Nothing changed for a pointer that hovers.
const (
- mainChromeCSS = "14fbea040b3ab0fba3b4d47c01889915887ad7b164a454154ca6ab790d5a3a14"
- mainMenuCSS = "90defb24148756958619c1e96db2bb2bc663f92b4acbb19ea94f9e037ecbab63"
+ mainChromeCSS = "52435a1fee808fa6d20a1f32e823da9cf7eaac6a762963d45281361d316fea2c"
+ mainMenuCSS = "a76fb85446799156a2debeb263bd6bfb4a57a358183e05d441d1f90953613896"
)
// optInHooks are the attributes only a bar with a slot, a WideOnly or
-// IconOnly action, or the Appearance form renders.
+// IconOnly action, the Appearance form or a compact bar renders.
var optInHooks = []string{
`[estilo-bar~="stacked"]`, "[estilo-bar-stack]", "[estilo-bar-menubar]", "[estilo-bar-lead]",
"[estilo-bar-control", "[estilo-bar-wide]", "[estilo-appearance", "[estilo-bar-icon]",
+ `[estilo-bar~="compact"]`, "[estilo-bar-trail]", "[estilo-bar-back]", "[estilo-bar-compact-title]", "[estilo-bar-tool]",
}
// A bar with no slot must look as it did, not only read as it did: main's
@@ -139,24 +147,3 @@ func TestEverythingAfterTheMarkerIsOptIn(t *testing.T) {
t.Fatalf("found only %d selectors after the marker; the check is not reading the section", n)
}
}
-
-// splitSelectors splits a selector list at its top-level commas, leaving
-// those inside :is(), :has() and the like.
-func splitSelectors(list string) []string {
- var out []string
- depth, start := 0, 0
- for i, r := range list {
- switch r {
- case '(':
- depth++
- case ')':
- depth--
- case ',':
- if depth == 0 {
- out = append(out, strings.TrimSpace(list[start:i]))
- start = i + 1
- }
- }
- }
- return append(out, strings.TrimSpace(list[start:]))
-}
diff --git a/implementation/save-status.md b/implementation/save-status.md
index 14a75ce..a441d88 100644
--- a/implementation/save-status.md
+++ b/implementation/save-status.md
@@ -51,6 +51,11 @@ The floating failure retains Docs' negative background/foreground tone tokens.
Inline placement retains Slides' minimum inline size of 8ch to avoid jitter.
Both variants disappear for print via the component's own print rule.
+A third placement, `subtitle` (2026-11-28, Docs' phone web design), is
+inline (`estilo-save-status="inline subtitle"`) for the line under a large
+title: the line's own size and weight, muted, the warning tone while
+retrying and the negative tone, bold, once failed, and no minimum size.
+
Silent status is an empty rendered live region: never display:none, visibility:
hidden, hidden, or aria-hidden. Empty floating state has no padding/background/
shadow, but the element remains present before a subsequent text mutation. This
diff --git a/menu/menu.css b/menu/menu.css
index eb420e2..5d90c8f 100644
--- a/menu/menu.css
+++ b/menu/menu.css
@@ -84,6 +84,8 @@
[estilo-menu-check] svg { inline-size: 100%; block-size: 100%; }
[estilo-menu-item][aria-pressed="true"] [estilo-menu-check],
[estilo-menu-item][aria-current] [estilo-menu-check] { visibility: visible; }
+[estilo-menu-icon] { display: inline-flex; flex: none; inline-size: 1.25rem; block-size: 1.25rem; color: currentColor; }
+[estilo-menu-icon] svg { inline-size: 100%; block-size: 100%; }
[estilo-menu-label] { flex: 1 1 auto; min-inline-size: 0; }
[estilo-menu-key] {
flex: none;
@@ -145,3 +147,18 @@
[estilo-menubar] { position: relative; }
[estilo-menubar-menu] > [estilo-menu] { inset-inline: 0.5rem; inline-size: auto; min-inline-size: 0; max-inline-size: none; }
}
+
+/* Touch (the phone web audit, 2026-11-28, findings 9 and 10). A row is a
+ 44px target on a coarse pointer, as Apple's and Google's guidance ask,
+ in every app's menus, and so is a menubar title (the wide stacked
+ header keeps its 24px look and takes 44px of hit area, chrome.css). And where nothing hovers and the pointer is a
+ finger, a shortcut hint is noise: nobody can press it, and it takes the
+ room a long label needs. A hardware keyboard on a tablet still works;
+ the shortcuts sheet in Help still lists them. */
+@media (pointer: coarse) {
+ [estilo-menu-item] { min-block-size: 2.75rem; }
+ [estilo-menubar-title] { min-block-size: 2.75rem; }
+}
+@media (hover: none) and (pointer: coarse) {
+ [estilo-menu-key] { display: none; }
+}
diff --git a/menu/menu.go b/menu/menu.go
index 478fca3..74f97c5 100644
--- a/menu/menu.go
+++ b/menu/menu.go
@@ -12,6 +12,7 @@ package menu
import (
"embed"
+ "html/template"
"net/http"
"strings"
)
@@ -69,6 +70,13 @@ type Item struct {
// goes to its own confirm page; the tone only says it is the one to
// read twice.
Danger bool
+ // Icon is an optional decorative glyph drawn before the label
+ // ([estilo-menu-icon]): the app's own inline <svg aria-hidden="true">,
+ // trusted markup it rendered itself; the label still names the row.
+ // Docs' ••• menu on a phone was the first with one (2026-11-28, the
+ // phone web mock-ups). A chrome.Action has an Icon of its own for the
+ // bar; this one is the row's.
+ Icon template.HTML
}
// Apple reports whether the request comes from an Apple platform, the
diff --git a/menu/templates/menu.html b/menu/templates/menu.html
index 0f3cd43..4307f04 100644
--- a/menu/templates/menu.html
+++ b/menu/templates/menu.html
@@ -7,9 +7,10 @@
invoker commands. Callers
supply the label in their own locale; Key is an already-formatted
shortcut (menu.Shortcut). Danger marks a destructive row
- (estilo-menu-item="danger"), drawn in the negative tone. */}}
+ (estilo-menu-item="danger"), drawn in the negative tone. Icon, when
+ set, is drawn before the label as decoration. */}}
{{define "estilo-menu-item"}}{{if .Action}}<form method="post" action="{{.Action}}"><button estilo-menu-item{{if .Danger}}="danger"{{end}} type="submit">{{template "estilo-menu-item-body" .}}</button></form>{{else if .Dialog}}<button estilo-menu-item{{if .Danger}}="danger"{{end}} type="button" commandfor="{{.Dialog}}" command="show-modal">{{template "estilo-menu-item-body" .}}</button>{{else if .Controls}}<button estilo-menu-item{{if .Danger}}="danger"{{end}} type="button" aria-expanded="{{if .Expanded}}true{{else}}false{{end}}" aria-controls="{{.Controls}}" disabled data-estilo-toggle>{{template "estilo-menu-item-body" .}}</button>{{else}}<a estilo-menu-item{{if .Danger}}="danger"{{end}} href="{{.Href}}">{{template "estilo-menu-item-body" .}}</a>{{end}}{{end}}
-{{define "estilo-menu-item-body"}}<span estilo-menu-label>{{.Label}}</span>{{with .Key}}<kbd estilo-menu-key>{{.}}</kbd>{{end}}{{end}}
+{{define "estilo-menu-item-body"}}{{with .Icon}}<span estilo-menu-icon>{{.}}</span>{{end}}<span estilo-menu-label>{{.Label}}</span>{{with .Key}}<kbd estilo-menu-key>{{.}}</kbd>{{end}}{{end}}
{{/* estilo-icon-check: the glyph inside an estilo-menu-check column.
Lucide "check" (ISC, brand/LICENSE.lucide). */}}
{{define "estilo-icon-check"}}<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"><path d="M20 6 9 17l-5-5"/></svg>{{end}}
diff --git a/menu/touch_test.go b/menu/touch_test.go
new file mode 100644
index 0000000..02b222b
--- /dev/null
+++ b/menu/touch_test.go
@@ -0,0 +1,41 @@
+package menu
+
+import (
+ "html/template"
+ "regexp"
+ "strings"
+ "testing"
+)
+
+// On touch every row is a 44px target (audit finding 9), and a shortcut
+// hint, which nobody with only a finger can press, is not shown (finding
+// 10). A pointer that hovers keeps both as they were.
+func TestRowsAreFingerSizedAndKeylessOnTouch(t *testing.T) {
+ src := string(CSS())
+ if !regexp.MustCompile(`@media \(pointer: coarse\) \{\s*\[estilo-menu-item\] \{ min-block-size: 2\.75rem; \}`).MatchString(src) {
+ t.Error("menu rows are not 44px on a coarse pointer")
+ }
+ if !regexp.MustCompile(`@media \(hover: none\) and \(pointer: coarse\) \{\s*\[estilo-menu-key\] \{ display: none; \}`).MatchString(src) {
+ t.Error("shortcut hints still show on a touch screen")
+ }
+}
+
+// A row's Icon is drawn before its label, decoration only; a row without
+// one renders as it always has.
+func TestAnItemCanCarryAnIcon(t *testing.T) {
+ icon := `<svg aria-hidden="true"></svg>`
+ for _, it := range []Item{{Href: "/x", Label: "l"}, {Action: "/x", Label: "l"}, {Dialog: "d", Label: "l"}, {Controls: "c", Label: "l"}} {
+ plain := render(t, "estilo-menu-item", it)
+ if strings.Contains(plain, "estilo-menu-icon") {
+ t.Errorf("%+v drew an icon slot with no icon: %s", it, plain)
+ }
+ it.Icon = template.HTML(icon)
+ got := render(t, "estilo-menu-item", it)
+ if !strings.Contains(got, `<span estilo-menu-icon>`+icon+`</span><span estilo-menu-label>l</span>`) {
+ t.Errorf("%+v: %s", it, got)
+ }
+ }
+ if !regexp.MustCompile(`\[estilo-menu-icon\] \{[^}]*flex: none;`).MatchString(string(CSS())) {
+ t.Error("menu.css does not lay out the icon")
+ }
+}
diff --git a/savestatus/status.css b/savestatus/status.css
index 1f829b3..d1b12c7 100644
--- a/savestatus/status.css
+++ b/savestatus/status.css
@@ -15,6 +15,22 @@
color: var(--rst-text);
font-weight: 600;
}
+/* The subtitle under a large title (Docs on a phone, 2026-11-28): the
+ line's own size and weight, muted, so "Saved" and "Saving…" read as
+ the quiet state they are; the warning tone while it retries and the
+ negative tone, bold, once it has failed. The words carry the state, so
+ colour is never the only sign of it. It takes no room when idle. */
+[estilo-save-status~="subtitle"],
+[estilo-save-status~="subtitle"]:not([data-state="saved"]) {
+ min-inline-size: 0;
+ min-block-size: 0;
+ color: var(--rst-text-muted);
+ font-size: inherit;
+ font-weight: inherit;
+ line-height: inherit;
+}
+[estilo-save-status~="subtitle"][data-state="retrying"] { color: var(--rst-tone-warning-fg); }
+[estilo-save-status~="subtitle"][data-state="failed"] { color: var(--rst-tone-negative-fg); font-weight: 600; }
[estilo-save-status~="floating"] {
position: fixed;
inset-inline-end: var(--rst-sp-4);
diff --git a/savestatus/status.go b/savestatus/status.go
index 484900e..b7ed1fa 100644
--- a/savestatus/status.go
+++ b/savestatus/status.go
@@ -11,6 +11,8 @@ var css []byte
//go:embed status.mjs
var javascript []byte
+// Data is one save status. Placement is "inline" (the default),
+// "floating" or "subtitle" (Mode).
type Data struct {
State, Placement string
Saved, Saving, Retrying, Failed, Label string
@@ -40,9 +42,15 @@ func (d Data) CurrentText() string {
}
}
+// Mode is the placement as estilo-save-status's value: "floating" (the
+// corner toast), "inline subtitle" (the line under a large title, Docs
+// on a phone) or "inline", the default, for anything else.
func (d Data) Mode() string {
- if d.Placement == "floating" {
+ switch d.Placement {
+ case "floating":
return "floating"
+ case "subtitle":
+ return "inline subtitle"
}
return "inline"
}
diff --git a/savestatus/subtitle_test.go b/savestatus/subtitle_test.go
new file mode 100644
index 0000000..e053d79
--- /dev/null
+++ b/savestatus/subtitle_test.go
@@ -0,0 +1,33 @@
+package savestatus
+
+import (
+ "regexp"
+ "strings"
+ "testing"
+)
+
+// The subtitle placement is the state under a large title (Docs on a
+// phone, audit finding 7): inline, quiet while things are well, in the
+// warning tone while retrying and the negative tone, bold, once it has
+// failed. Inline and floating are unchanged.
+func TestTheSubtitlePlacement(t *testing.T) {
+ got := render(t, Data{State: "retrying", Placement: "subtitle", Retrying: "r"})
+ if !strings.Contains(got, `estilo-save-status="inline subtitle"`) {
+ t.Errorf("the subtitle placement is not an inline variant: %s", got)
+ }
+ for p, want := range map[string]string{"": "inline", "inline": "inline", "floating": "floating", "subtitle": "inline subtitle"} {
+ if m := (Data{Placement: p}).Mode(); m != want {
+ t.Errorf("Placement %q: mode %q, want %q", p, m, want)
+ }
+ }
+ src := string(CSS())
+ for _, re := range []string{
+ `\[estilo-save-status~="subtitle"\],\s*\[estilo-save-status~="subtitle"\]:not\(\[data-state="saved"\]\) \{[^}]*color: var\(--rst-text-muted\);[^}]*font-weight: inherit;`,
+ `\[estilo-save-status~="subtitle"\]\[data-state="retrying"\] \{ color: var\(--rst-tone-warning-fg\); \}`,
+ `\[estilo-save-status~="subtitle"\]\[data-state="failed"\] \{ color: var\(--rst-tone-negative-fg\); font-weight: 600; \}`,
+ } {
+ if !regexp.MustCompile(re).MatchString(src) {
+ t.Errorf("status.css lacks %s", re)
+ }
+ }
+}