chrome: the compact phone bar, 44px touch targets, the stacked header from 44rem
The phone web design for Docs (design/phone-web e058917, AUDIT.md),
approved by Paul on 2026-11-28 ("Yeah, those screens look much better")
with its six recommendations. This is slice P0, estilo's part.
- Bar.Compact (estilo-bar~="compact"): below 44rem, or on a phone held
sideways (a coarse pointer under 30rem tall), one 52px row of Back (the
brand: a chevron and the app's name), the title, the lead and the app's
Compact.Trail. The menu row, the actions, the switcher and the account
are not shown there, and a compact bar never draws the Menu sheet: its
trail is the overflow (audit findings 1 and 4). Compact.Title is the
large-title idiom: shown once the app's script sets estilo-bar-folded,
when Back becomes its chevron alone (its name kept as the accessible
name) and the hairline appears. Without script the bar never folds.
- In the trail, [estilo-bar-tool] is a 44px round control in the accent,
and a <details> panel is a drop-down from the bar's inline end with
44px rows, no shortcut hints and iOS's grouped separators (answer 3: a
drop-down, not a bottom sheet). menu.Item.Icon draws a row's glyph.
- The compact title ends in an ellipsis instead of being cut mid-letter
(finding 2); chrome.js leaves the field unfitted there.
- The stacked header starts at 44rem instead of 800px (answer 4, so an
iPad in portrait gets the desktop header), with its actions in the bar
and no Menu sheet between 44rem and 800px; the Rename pill stays in the
title row there. Every other bar keeps the 800px shell breakpoint.
- Touch, in every app (findings 9 and 10): on a coarse pointer the bar's
triggers and every menu row are 44px; where nothing hovers, menus show
no shortcut hints. The stacked header keeps its 32px look and takes 44px
of hit area (pills, switcher, account, menubar titles); its menu rows
are 44px on touch.
- savestatus: a "subtitle" placement (inline subtitle) for the state under
a large title: muted, the warning tone while retrying, negative and bold
once failed (finding 7).
mainChromeCSS and mainMenuCSS are updated deliberately for the touch rules
and the menu icon; nothing changes for a pointer that hovers. Proven in
Chromium 151 by compact_browser_test.go (seen to fail on three mutations:
the account shown, 30px rows, a folded name with display: none), and by a
pixel diff of the stacked and plain bars, menus open, light and dark, at
820, 900, 1024 and 1280px against main: 40 of 40 identical. WebKit could
not be driven here (Playwright 1.62.1 wants webkit-2336; 2311 and 2388
refuse its protocol); Mobile Safari is checked on the simulator with
Docs in P1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 files changed,
+1,183
−49
README.md+18 −2chrome/chrome.css+187 −18chrome/chrome.go+50 −0chrome/chrome.js+17 −7chrome/compact.browser.mjs+143 −0chrome/compact_browser_test.go+320 −0chrome/compact_test.go+278 −0chrome/stack_test.go+9 −9chrome/templates/bar.html+16 −5chrome/templates/icons.html+4 −1chrome/unchanged_test.go+11 −4implementation/save-status.md+5 −0menu/menu.css+15 −0menu/menu.go+8 −0menu/templates/menu.html+3 −2menu/touch_test.go+41 −0savestatus/status.css+16 −0savestatus/status.go+9 −1savestatus/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.005s ok amadan.net/oficina/estilo.git/brand 0.004s 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 2.916s ? 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.005s 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 1.118s ok amadan.net/oficina/estilo.git/homeconnect 0.005s 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.128s ok amadan.net/oficina/estilo.git/side 0.138s ok amadan.net/oficina/estilo.git/sky 0.034s ok amadan.net/oficina/estilo.git/theme 0.014s ok amadan.net/oficina/estilo.git/typeface 0.328s === spacing === go run amadan.net/rastrillo/fiesta/cmd/fiesta@v1.7.0 spacing .
diff --git a/README.md b/README.md| index ea16b11..0648007 100644 |
| --- a/README.md |
| +++ b/README.md |
| @@ -43,8 +43,9 @@ capture phase) and an outside click. |
| Docs' I2 editor added two slots to `chrome.Bar` (spec |
| `docs/superpowers/specs/2026-11-11-editor-i2-design.md` in Docs). |
| `Menubar` takes the app's own `estilo-menubar` markup and makes the bar |
| -stacked (`estilo-bar~="stacked"`): from 800px a 56px header with the title |
| -over the menus, below it the one-row bar with the menus as a second row; |
| +stacked (`estilo-bar~="stacked"`): from 44rem (704px, so an iPad in |
| +portrait; Paul, 2026-11-28) a 56px header with the title over the menus, |
| +below it the one-row bar with the menus as a second row; |
| `--estilo-bar-block-size` is published either way. `Lead` takes app markup |
| for the start of the end group (Docs' undo/redo), which the app must hide |
| on narrow screens itself. A bar with either slot |
| @@ -55,6 +56,21 @@ 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 44rem, 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 a compact bar never draws the Menu sheet. `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 and every menu row 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..508b3dc 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); |
| @@ -430,11 +437,16 @@ |
| [estilo-bar-wide] (Action.WideOnly), [estilo-bar-icon] |
| (Action.IconOnly) and [estilo-appearance]. |
| - Breakpoints: 800px is rastrillo's shell breakpoint, the rule above |
| - 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. */ |
| + Breakpoints: a bar with a slot is the desktop header from 44rem |
| + (704px), where an iPad in portrait (744 to 834px) gets it (Paul, |
| + 2026-11-28: "iPad portrait uses the desktop header from 704 px"); below |
| + that, or on a phone held sideways (a coarse pointer under 30rem tall), |
| + it is narrow. That pair is the only breakpoint these rules use, so the |
| + two can never overlap or leave a gap. It was rastrillo's 800px shell |
| + breakpoint, which every other bar keeps (the rule above this section), |
| + and between 44rem and 800px a stacked or compact bar puts its actions |
| + back in the bar, below. 64rem is where a WideOnly action appears, the |
| + same 64rem Docs' inspector uses. */ |
| /* 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 |
| @@ -461,15 +473,17 @@ |
| [estilo-bar~="stacked"] [estilo-bar-context] { max-inline-size: 100%; } |
| [estilo-bar~="stacked"] [estilo-menubar-title] { cursor: pointer; } |
| -/* Below 800px the stacked header does not fit a phone (spec C6: File to |
| +/* Below 44rem the stacked header does not fit a phone (spec C6: File to |
| Help needs 261px, and at 320px the title fell to "U…"). So the bar |
| stays today's one row, and the app's menus are a full-width second |
| row under it: the stack dissolves and the same markup lays out on a |
| grid. The header grows by that row, and the published block size |
| with it. A menubar that wraps (English at 320px; a long locale |
| sooner) grows it further: chrome.js then publishes the header's real |
| - height, and 85px is what a page without script gets. */ |
| -@media (max-width: 799.98px) { |
| + height, and 85px is what a page without script gets. A compact bar |
| + (Bar.Compact, below) is one row here instead, and its menus are in |
| + its trail. */ |
| +@media (max-width: 43.99rem), (max-height: 30rem) and (pointer: coarse) { |
| :root:has([estilo-bar~="stacked"]) { --estilo-bar-block-size: calc(3.25rem + 2rem + 1px); } /* 85px: the bar's row, one menubar row and the bottom border. PUBLIC */ |
| [estilo-bar~="stacked"] { |
| display: grid; |
| @@ -494,7 +508,16 @@ |
| } |
| } |
| -/* From 800px, the 56px stacked header: a 32px icon 12px in, and beside |
| +/* Between 44rem and the shell breakpoint a stacked or compact bar is the |
| + desktop header, so its actions are in the bar, and a stacked bar's Menu |
| + sheet, which would only repeat them, is gone. (A compact bar never |
| + draws one.) */ |
| +@media (min-width: 44rem) and (max-width: 799.98px) and (not ((max-height: 30rem) and (pointer: coarse))) { |
| + :is([estilo-bar~="stacked"], [estilo-bar~="compact"]) [estilo-bar-actions] { display: flex; } |
| + [estilo-bar~="stacked"] [estilo-bar-more] { display: none; } |
| +} |
| + |
| +/* From 44rem, 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 |
| goes: the icon is the brand. Optical balance, measured at 2x in WebKit |
| @@ -502,7 +525,7 @@ |
| 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. */ |
| -@media (min-width: 800px) { |
| +@media (min-width: 44rem) and (not ((max-height: 30rem) and (pointer: coarse))) { |
| :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); } |
| [estilo-bar~="stacked"] [estilo-bar-brand] img { inline-size: 32px; block-size: 32px; } |
| @@ -550,6 +573,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 +746,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 |
| @@ -765,7 +801,7 @@ |
| would lose every edge. So the set gives it back, at its own weight and |
| after it. An expanded toggle's tint is gone too, so it is drawn in Highlight, |
| two pixels deep with the outline (left to the focus ring while that |
| - shows). At every width: below 800px the same border is rastrillo's. */ |
| + shows). At every width: below 44rem the same border is rastrillo's. */ |
| @media (forced-colors: active) { |
| :is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button) { border: 1px solid ButtonBorder; } |
| :is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button)[aria-expanded="true"] { border-color: Highlight; } |
| @@ -775,6 +811,139 @@ |
| :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 44rem, 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 44rem none of this applies, and the bar is what it would be |
| + without Compact. 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: 43.99rem), (max-height: 30rem) 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~="compact"] [estilo-bar-end] { gap: var(--rst-sp-1); } |
| + [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; |
| + color: var(--rst-accent); |
| + font-size: 1.0625rem; |
| + font-weight: 400; |
| + } |
| + [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; |
| + min-inline-size: 0; |
| + max-inline-size: none; |
| + padding-inline-start: 0; |
| + border-inline-start: 0; |
| + } |
| + [estilo-bar~="compact"] [estilo-bar-title-input] { flex: 1 1 auto; inline-size: 100%; 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-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..ea79261 100644 |
| --- a/chrome/chrome.go |
| +++ b/chrome/chrome.go |
| @@ -192,6 +192,56 @@ 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 44rem |
| + // (estilo-bar~="compact"; the phone web design, Paul 2026-11-28). |
| + // From 44rem nothing changes. A compact bar is never drawn with the |
| + // Menu sheet: its Trail is the app's own overflow at every width it |
| + // shows, and from 44rem its actions are in the bar. |
| + Compact *Compact |
| +} |
| + |
| +// Compact is a compact bar's two slots (Bar.Compact). Below 44rem, 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). 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 44rem (Docs' Aa and •••). |
| + Trail template.HTML |
| + // Title, when set, replaces the bar's own title below 44rem (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..304496a 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 |
| @@ -104,14 +106,21 @@ |
| // paddings in Chromium. Then 2px for the caret at the end of the text. |
| // field-sizing: content, a canvas and a mirror span in the same font |
| // all came out short in WebKit; this did not. CSS caps the width at the |
| - // room the field has (max-inline-size, which from 800px allows for the |
| + // room the field has (max-inline-size, which from 44rem allows for the |
| // field's pulled-back start margin), so a longer title still scrolls |
| // 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). |
| + // The stacked and compact bars' one breakpoint, chrome.css's: below |
| + // 44rem, or a phone held sideways. |
| + const narrow = window.matchMedia && window.matchMedia('(max-width: 43.99rem), (max-height: 30rem) and (pointer: coarse)') |
| const FIT = '[estilo-bar-title-input][size]' |
| const CARET = 2 |
| const fit = (input) => { |
| + if (narrow && narrow.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,18 +134,19 @@ |
| // the first measure, at script time, can come out a few pixels short. |
| window.addEventListener('resize', fitAll) |
| window.addEventListener('load', fitAll) |
| + if (narrow && narrow.addEventListener) narrow.addEventListener('change', fitAll) |
| if (document.fonts && document.fonts.ready) document.fonts.ready.then(fitAll) |
| fitAll() |
| - // Below 800px a stacked bar is the one-row bar with the app's menus as a |
| + // Below 44rem a stacked bar is the one-row bar with the app's menus as a |
| // second row, and that row wraps where the menus do not fit (English |
| // at 320px). CSS publishes the one-row-of-menus height; this publishes |
| // the header's real one, so whatever sticks under it (Docs' strip) |
| - // 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. |
| + // sticks under all of it. (A compact bar is its one 52px row there, |
| + // which this publishes as it is.) Only while narrow: from 44rem 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"]') |
| - const narrow = window.matchMedia && window.matchMedia('(max-width: 799.98px)') |
| if (stacked && narrow && typeof ResizeObserver === 'function') { |
| const root = document.documentElement |
| const publish = () => { |
diff --git a/chrome/compact.browser.mjs b/chrome/compact.browser.mjs| new file mode 100644 |
| index 0000000..9ba34e0 |
| --- /dev/null |
| +++ b/chrome/compact.browser.mjs |
| @@ -0,0 +1,143 @@ |
| +// 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]')) }, |
| + 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') }) |
| + } |
| + 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] }) |
| + } |
| + } |
| + } 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..efea542 |
| --- /dev/null |
| +++ b/chrome/compact_browser_test.go |
| @@ -0,0 +1,320 @@ |
| +//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 |
| +} |
| + |
| +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"` |
| + } `json:"cases"` |
| +} |
| + |
| +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 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 !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) |
| + } |
| + } |
| + 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) |
| + } |
| + } |
| + } |
| +} |
diff --git a/chrome/compact_test.go b/chrome/compact_test.go| new file mode 100644 |
| index 0000000..bc7a8bb |
| --- /dev/null |
| +++ b/chrome/compact_test.go |
| @@ -0,0 +1,278 @@ |
| +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} |
| + return b |
| +} |
| + |
| +// narrowQuery and wideQuery are the one breakpoint pair of a stacked or |
| +// compact bar (Paul, 2026-11-28: the desktop header from 704px): below |
| +// 44rem, or a phone on its side, it is narrow; anything else is wide. |
| +const ( |
| + narrowQuery = "@media (max-width: 43.99rem), (max-height: 30rem) and (pointer: coarse)" |
| + wideQuery = "@media (min-width: 44rem) and (not ((max-height: 30rem) 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 TestTheCompactBarIsOneRowBelow44rem(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 fits the stacked title only where the bar is wide, and |
| +// publishes the narrow height, on the same breakpoint the CSS uses. |
| +func TestTheScriptUsesTheCSSBreakpoint(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 narrow query %q", q) |
| + } |
| + if strings.Contains(js, "799.98") { |
| + t.Error("chrome.js still reads the old 800px breakpoint") |
| + } |
| + css := string(CSS()) |
| + css = css[strings.Index(css, barStackMarker):] |
| + if strings.Contains(css, "(min-width: 800px)") || strings.Contains(css, "@media (max-width: 799.98px) {") { |
| + t.Error("the stacked section still breaks at 800px; it is 44rem now") |
| + } |
| + if !strings.Contains(css, narrowQuery+" {") || !strings.Contains(css, wideQuery+" {") { |
| + t.Error("the stacked section does not use the 44rem pair") |
| + } |
| +} |
| + |
| +// 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, wideQuery):] |
| + 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) |
| + } |
| + } |
| +} |
| + |
| +// Between 44rem and 800px a stacked bar is the desktop header, so its |
| +// actions are in the bar and its Menu sheet is gone, though the shell |
| +// breakpoint for every other bar stays at 800px. The Rename pill stays in |
| +// the title row rather than floating under it as the narrow bar's does. |
| +func TestTheStackedHeaderStartsAt44rem(t *testing.T) { |
| + src := string(CSS()) |
| + stack := src[strings.Index(src, barStackMarker):] |
| + mid := "@media (min-width: 44rem) and (max-width: 799.98px) and (not ((max-height: 30rem) and (pointer: coarse)))" |
| + at := strings.Index(stack, mid) |
| + if at < 0 { |
| + t.Fatal("no rule for a stacked bar between 44rem and the shell breakpoint") |
| + } |
| + block := stack[at:] |
| + block = block[:strings.Index(block, "\n}\n")] |
| + for _, want := range []string{ |
| + `:is([estilo-bar~="stacked"], [estilo-bar~="compact"]) [estilo-bar-actions] { display: flex; }`, |
| + `[estilo-bar~="stacked"] [estilo-bar-more] { display: none; }`, |
| + } { |
| + if !strings.Contains(block, want) { |
| + t.Errorf("the 44rem-800px block lacks %s", want) |
| + } |
| + } |
| + wide := stack[strings.Index(stack, wideQuery):] |
| + 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 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") |
| + } |
| +} |
diff --git a/chrome/stack_test.go b/chrome/stack_test.go| index fc43a5b..5ab0c64 100644 |
| --- a/chrome/stack_test.go |
| +++ b/chrome/stack_test.go |
| @@ -27,7 +27,7 @@ func header(html string) string { return html[:strings.Index(html, ">")+1] } |
| // The Menubar slot makes the bar stacked, and only it does: the title and |
| // the app's menus share one stack, so the same markup serves the 56px |
| -// header from 800px and the two-row bar below it. |
| +// header from 44rem and the two-row bar below it. |
| func TestTheMenubarSlotStacksTheBar(t *testing.T) { |
| b := stacked() |
| html := render(t, "estilo-bar", b) |
| @@ -294,7 +294,7 @@ func TestAppearanceIsASegmentedSelectorSwitchedInPlace(t *testing.T) { |
| } |
| } |
| -// The stacked header's public numbers: 56px from 800px, the one-row bar |
| +// The stacked header's public numbers: 56px from 44rem, the one-row bar |
| // plus its menu row and its 1px bottom border below (85px, as measured in |
| // Chromium and WebKit; 84 left the border out), and WideOnly's 64rem. The 32px menubar floor |
| // goes only inside the stacked header. |
| @@ -302,8 +302,8 @@ func TestTheStackedBarPublishesItsHeight(t *testing.T) { |
| src := string(CSS()) |
| src = src[strings.Index(src, barStackMarker):] |
| for _, re := range []string{ |
| - `@media \(min-width: 800px\) \{\s*:root:has\(\[estilo-bar~="stacked"\]\) \{ --estilo-bar-block-size: 56px; \}`, |
| - `@media \(max-width: 799\.98px\) \{\s*:root:has\(\[estilo-bar~="stacked"\]\) \{ --estilo-bar-block-size: calc\(3\.25rem \+ 2rem \+ 1px\); \}`, |
| + regexp.QuoteMeta(wideQuery) + ` \{\s*:root:has\(\[estilo-bar~="stacked"\]\) \{ --estilo-bar-block-size: 56px; \}`, |
| + regexp.QuoteMeta(narrowQuery) + ` \{\s*:root:has\(\[estilo-bar~="stacked"\]\) \{ --estilo-bar-block-size: calc\(3\.25rem \+ 2rem \+ 1px\); \}`, |
| `@media \(max-width: 63\.99rem\) \{\s*\[estilo-bar-actions\] \[estilo-bar-wide\],\s*\[estilo-bar-actions\] \[estilo-bar-control~="wide"\] \{ display: none; \}`, |
| `\[estilo-bar~="stacked"\] \[estilo-menubar\] \{[^}]*min-block-size: 0;`, |
| `\[estilo-bar~="stacked"\] \[estilo-bar-brand\] img \{ inline-size: 32px; block-size: 32px; \}`, |
| @@ -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. |
| - coarse := src[strings.Index(src, "@media (min-width: 800px) {"):] |
| + // 44px of hit area, 16px up and 4px down, with no change to layout. |
| + coarse := src[strings.Index(src, wideQuery+" {"):] |
| 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) { |
| @@ -370,14 +370,14 @@ func TestTheControlsKeepTheirBoundaryInForcedColours(t *testing.T) { |
| } |
| } |
| -// From 800px the title field is pulled back by its padding and border |
| +// From 44rem the title field is pulled back by its padding and border |
| // (a negative start margin), so its form is that much narrower than the |
| // field, and a cap of 100% of the form trimmed chrome.js's fitted width |
| // by 7.4px. The cap allows for the margin, so the fit stands as measured. |
| func TestTheWideTitleCapAllowsForItsPulledBackMargin(t *testing.T) { |
| src := string(CSS()) |
| src = src[strings.Index(src, barStackMarker):] |
| - wide := src[strings.Index(src, "@media (min-width: 800px) {"):] |
| + wide := src[strings.Index(src, wideQuery+" {"):] |
| rule := regexp.MustCompile(`\[estilo-bar~="stacked"\] \[estilo-bar-title-input\] \{[^}]*\}`).FindString(wide) |
| if !strings.Contains(rule, "margin-inline-start: calc(-1 * var(--rst-sp-2) - 1px);") || !strings.Contains(rule, "max-inline-size: calc(100% + var(--rst-sp-2) + 1px);") { |
| t.Errorf("the wide title field's cap does not give back its pulled-back margin:\n%s", rule) |
diff --git a/chrome/templates/bar.html b/chrome/templates/bar.html| index b6be10d..0183173 100644 |
| --- a/chrome/templates/bar.html |
| +++ b/chrome/templates/bar.html |
| @@ -12,14 +12,20 @@ |
| 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 44rem 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 |
| + never draws the Menu sheet: its trail is the overflow. |
| 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 +45,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 +61,9 @@ |
| <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 .Compact}} |
| + <div estilo-bar-trail>{{.Compact.Trail}}</div> |
| + {{- else if or .Nav $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"> |
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..3526455 100644 |
| --- a/chrome/unchanged_test.go |
| +++ b/chrome/unchanged_test.go |
| @@ -87,17 +87,24 @@ 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]). Nothing changed for a |
| +// pointer that hovers. |
| const ( |
| - mainChromeCSS = "14fbea040b3ab0fba3b4d47c01889915887ad7b164a454154ca6ab790d5a3a14" |
| - mainMenuCSS = "90defb24148756958619c1e96db2bb2bc663f92b4acbb19ea94f9e037ecbab63" |
| + mainChromeCSS = "19bdcab605b3e0069a8f76ac511c1c1323284b0cedb4da2b189161f92532a0d0" |
| + mainMenuCSS = "315318bae391ff677716f602822160deb1871470c32c323582465635dfa3350a" |
| ) |
| // 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 |
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..a3a1ccd 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,16 @@ |
| [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 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; } |
| +} |
| +@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) |
| + } |
| + } |
| +} |