chrome: only a compact bar moves to 704px; a compact bar with nav keeps its sheet
Fable on c56314e, HIGH: the 704px move was not Docs-only. Mapa and Fichas set Menubar, Lead and Nav. Between 704 and 800px the move hid the Menu sheet of every stacked bar while their nav stayed hidden below 800px, and both apps hide their rail below 800px, so Mapa's places and Fichas' types and Search were out of reach. At 844x390 they fell to the narrow bar. Every stacked bar that is not compact now keeps main's rules exactly: the 56px header from 800px, and the two-row bar with its Menu sheet below. Only a compact bar (Docs) is the 56px header from 704px. A media query cannot ask which bar it is, so the 704px band is a copy of the header's block that CSS() makes at init (compactBand, chrome.go), with every selector scoped to a compact bar, plus three hand rules that undo the two-row layout there. The block is written once and the copy cannot drift (TestOnlyACompactBarMovesTo704px). The phone-sideways clause now applies only to compact bars, which override the 56px header's rules where both apply past 800px. chrome.js publishes the stacked bar's height below 800px, as on main. A compact bar with Nav now draws the Menu sheet for it, before the trail, and shows it in the compact row, so its nav is never out of reach (TestACompactBarWithNavKeepsItsSheet). Browser cases: stand-ins for Mapa's and Fichas' bars (Menubar, Lead, Nav, actions, one WideOnly) at 390, 768 and 844x390 with touch and at 1280 with a mouse. Every nav link and action must be in the bar or in the open Menu sheet, the header must match what it publishes, and it is 56px exactly from 800px. These fail on c56314e (nav out of reach at 768; a 107.8px header at 844x390) and pass here. Rendered against main: with a mouse at 768 and 1280, and closed at 844x390 on touch, they are pixel-identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10 files changed,
+482
−132
README.md+7 −5chrome/chrome.css+39 −33chrome/chrome.go+155 −11chrome/chrome.js+12 −11chrome/compact.browser.mjs+49 −0chrome/compact_browser_test.go+83 −0chrome/compact_test.go+122 −39chrome/stack_test.go+7 −7chrome/templates/bar.html+8 −5chrome/unchanged_test.go+0 −21
diff --git a/README.md b/README.md| index 0648007..31ceec0 100644 |
| --- a/README.md |
| +++ b/README.md |
| @@ -43,9 +43,8 @@ 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 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; |
| +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; |
| `--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 |
| @@ -57,11 +56,14 @@ 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 |
| +(`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 a compact bar never draws the Menu sheet. `Compact.Title` replaces |
| +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 |
diff --git a/chrome/chrome.css b/chrome/chrome.css| index 508b3dc..d534e52 100644 |
| --- a/chrome/chrome.css |
| +++ b/chrome/chrome.css |
| @@ -437,16 +437,15 @@ |
| [estilo-bar-wide] (Action.WideOnly), [estilo-bar-icon] |
| (Action.IconOnly) and [estilo-appearance]. |
| - 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. */ |
| + 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. 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 |
| @@ -473,17 +472,15 @@ |
| [estilo-bar~="stacked"] [estilo-bar-context] { max-inline-size: 100%; } |
| [estilo-bar~="stacked"] [estilo-menubar-title] { cursor: pointer; } |
| -/* Below 44rem the stacked header does not fit a phone (spec C6: File to |
| +/* Below 800px 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. 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) { |
| + height, and 85px is what a page without script gets. */ |
| +@media (max-width: 799.98px) { |
| :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; |
| @@ -508,24 +505,16 @@ |
| } |
| } |
| -/* 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 |
| +/* 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 |
| goes: the icon is the brand. Optical balance, measured at 2x in WebKit |
| 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. */ |
| -@media (min-width: 44rem) and (not ((max-height: 30rem) and (pointer: coarse))) { |
| + 1px above that edge. A compact bar gets this block from 704px too, as |
| + a copy CSS() makes (compactBand, 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); } |
| [estilo-bar~="stacked"] [estilo-bar-brand] img { inline-size: 32px; block-size: 32px; } |
| @@ -785,6 +774,16 @@ |
| [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 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: 44rem) and (max-width: 799.98px) and (not ((max-height: 30rem) 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-menubar] { align-self: auto; margin-inline-end: 0; } |
| + [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); |
| @@ -801,7 +800,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 44rem the same border is rastrillo's. */ |
| + shows). At every width: below 800px 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; } |
| @@ -812,14 +811,17 @@ |
| } |
| /* ── Compact (the phone web design, Paul 2026-11-28) ─────────────────── |
| - Bar.Compact: below 44rem, or on a phone held sideways, the phone's one |
| + 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 44rem none of this applies, and the bar is what it would be |
| - without Compact. Every rule is keyed on a compact hook: |
| + 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). 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]. |
| @@ -897,7 +899,9 @@ |
| [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][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. */ |
| @@ -921,12 +925,14 @@ |
| [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%; text-overflow: ellipsis; } |
| + [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 |
diff --git a/chrome/chrome.go b/chrome/chrome.go| index ea79261..41b994f 100644 |
| --- a/chrome/chrome.go |
| +++ b/chrome/chrome.go |
| @@ -37,14 +37,156 @@ 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 (compactBand) 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: 44rem) and (max-width: 799.98px) and (not ((max-height: 30rem) 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. 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 + `):is([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,21 +334,23 @@ 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, 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 44rem, or on |
| +// 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). The Lead stays, so an app that |
| +// 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 |
| @@ -215,9 +359,9 @@ type Bar struct { |
| // 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 is drawn at the inline end below 704px (Docs' Aa and •••). |
| Trail template.HTML |
| - // Title, when set, replaces the bar's own title below 44rem (Docs' |
| + // 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 |
diff --git a/chrome/chrome.js b/chrome/chrome.js| index 304496a..7a7c44b 100644 |
| --- a/chrome/chrome.js |
| +++ b/chrome/chrome.js |
| @@ -106,18 +106,19 @@ |
| // 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 44rem allows for the |
| + // room the field has (max-inline-size, which from 800px 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)') |
| + // 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: 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"]')) { |
| + if (compact && compact.matches && input.closest('[estilo-bar~="compact"]')) { |
| input.style.inlineSize = '' |
| return |
| } |
| @@ -134,19 +135,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 (compact && compact.addEventListener) compact.addEventListener('change', fitAll) |
| if (document.fonts && document.fonts.ready) document.fonts.ready.then(fitAll) |
| fitAll() |
| - // Below 44rem a stacked bar is the one-row bar with the app's menus as a |
| + // Below 800px 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. (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. |
| + // 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"]') |
| + 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| index 9ba34e0..8255072 100644 |
| --- a/chrome/compact.browser.mjs |
| +++ b/chrome/compact.browser.mjs |
| @@ -134,6 +134,55 @@ for (const engine of job.engines) { |
| result.cases.push({ name: c.name, width: c.w, touch: c.touch, 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 { |
diff --git a/chrome/compact_browser_test.go b/chrome/compact_browser_test.go| index efea542..08662fc 100644 |
| --- a/chrome/compact_browser_test.go |
| +++ b/chrome/compact_browser_test.go |
| @@ -96,6 +96,45 @@ func compactBar(L map[string]string) Bar { |
| 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"` |
| @@ -119,6 +158,7 @@ type compactCase struct { |
| Rest largeTitle `json:"rest"` |
| Folded largeTitle `json:"folded"` |
| } `json:"cases"` |
| + StandIns []standInCase `json:"standIns"` |
| } |
| type largeTitle struct { |
| @@ -154,6 +194,9 @@ func TestTheCompactBarInRealEngines(t *testing.T) { |
| } |
| var bar bytes.Buffer |
| b := compactBar(L) |
| + if kind := r.URL.Query().Get("kind"); kind != "" { |
| + b = standIn(kind, 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>`) |
| } |
| @@ -317,4 +360,44 @@ func TestTheCompactBarInRealEngines(t *testing.T) { |
| } |
| } |
| } |
| + // 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) |
| + } |
| + } |
| + } |
| } |
diff --git a/chrome/compact_test.go b/chrome/compact_test.go| index bc7a8bb..a56f70c 100644 |
| --- a/chrome/compact_test.go |
| +++ b/chrome/compact_test.go |
| @@ -21,16 +21,18 @@ 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 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)))" |
| -) |
| +// 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). |
| +// (bandQuery is chrome.go's.) |
| +const narrowQuery = "@media (max-width: 43.99rem), (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 |
| @@ -115,7 +117,7 @@ func TestTheCompactHooksAreOptIn(t *testing.T) { |
| // 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) { |
| +func TestTheCompactBarIsOneRowBelow704px(t *testing.T) { |
| src := string(CSS()) |
| src = src[strings.Index(src, barStackMarker):] |
| at := strings.Index(src, "/* ── Compact") |
| @@ -162,24 +164,21 @@ func TestTheCompactBarIsOneRowBelow44rem(t *testing.T) { |
| } |
| } |
| -// 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) { |
| +// 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 narrow query %q", q) |
| + t.Errorf("chrome.js does not read the compact query %q", q) |
| } |
| - if strings.Contains(js, "799.98") { |
| - t.Error("chrome.js still reads the old 800px breakpoint") |
| + if !strings.Contains(js, "matchMedia('(max-width: 799.98px)')") { |
| + t.Error("chrome.js no longer publishes the stacked bar's height below 800px") |
| } |
| 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") |
| + if !strings.Contains(css, narrowQuery+" {") || !strings.Contains(css, bandQuery+" {") { |
| + t.Error("chrome.css does not use the compact pair") |
| } |
| } |
| @@ -193,7 +192,7 @@ func TestTouchTargetsAre44px(t *testing.T) { |
| 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):] |
| + 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{ |
| @@ -207,35 +206,102 @@ func TestTouchTargetsAre44px(t *testing.T) { |
| } |
| } |
| -// 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) { |
| +// 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()) |
| - 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) |
| + at := strings.Index(src, bandQuery+" {") |
| if at < 0 { |
| - t.Fatal("no rule for a stacked bar between 44rem and the shell breakpoint") |
| + t.Fatal("no 704px band for a compact bar") |
| } |
| - 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) |
| + 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)) |
| } |
| - wide := stack[strings.Index(stack, wideQuery):] |
| + 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") |
| + } |
| + // A pseudo-element stays outside :is(), where it is valid. |
| + if !strings.Contains(band, `:is([estilo-bar~="stacked"] [estilo-menubar-title]):is([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 = 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") |
| + } |
| +} |
| + |
| // 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. |
| @@ -276,3 +342,20 @@ func TestACompactTitleShowsOnlyWhenFolded(t *testing.T) { |
| 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 5ab0c64..74d7768 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 44rem and the two-row bar below it. |
| +// header from 800px 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 44rem, the one-row bar |
| +// The stacked header's public numbers: 56px from 800px, 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{ |
| - 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 \(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\); \}`, |
| `@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; \}`, |
| @@ -315,7 +315,7 @@ func TestTheStackedBarPublishesItsHeight(t *testing.T) { |
| } |
| // Coarse pointers: the menubar titles keep their 24px look but take |
| // 44px of hit area, 16px up and 4px down, with no change to layout. |
| - coarse := src[strings.Index(src, wideQuery+" {"):] |
| + 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{ |
| @@ -370,14 +370,14 @@ func TestTheControlsKeepTheirBoundaryInForcedColours(t *testing.T) { |
| } |
| } |
| -// From 44rem the title field is pulled back by its padding and border |
| +// From 800px 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, wideQuery+" {"):] |
| + wide := src[strings.Index(src, "@media (min-width: 800px) {"):] |
| 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 0183173..fd0ed79 100644 |
| --- a/chrome/templates/bar.html |
| +++ b/chrome/templates/bar.html |
| @@ -16,10 +16,12 @@ |
| 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 |
| + 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 |
| - never draws the Menu sheet: its trail is the overflow. |
| + 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. */}} |
| @@ -61,9 +63,7 @@ |
| <div estilo-bar-actions>{{template "estilo-bar-actions" .}}</div> |
| {{- end}} |
| {{- $sheet := false}}{{range .Actions}}{{if not .WideOnly}}{{$sheet = true}}{{end}}{{end}} |
| - {{- if .Compact}} |
| - <div estilo-bar-trail>{{.Compact.Trail}}</div> |
| - {{- else 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"> |
| @@ -73,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/unchanged_test.go b/chrome/unchanged_test.go| index 3526455..cfb625c 100644 |
| --- a/chrome/unchanged_test.go |
| +++ b/chrome/unchanged_test.go |
| @@ -146,24 +146,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:])) |
| -} |