oficina / estilo Public

chrome: the stacked header, the controls set and Appearance as a segmented selector

CSS, all in one opt-in section after main's rules, which stay byte for
byte (TestEverythingAfterTheMarkerIsOptIn: main's rules hashed, every
added selector keyed on a slot, WideOnly or Appearance hook).

- From 800px a bar with Menubar is the 56px stacked header: 32px icon
  12px in, title row 24px (16px/600) over menu row 20px (13px muted),
  both at 56px, name hidden; --estilo-bar-block-size: 56px published.
  Menubar floor dropped, titles pointer, 24px/6px highlight pill by
  -2px margins, panels hang 1px above the edge with 28px rows, 13px,
  muted keys, 4px padding, 10px radius. Rename a 22px accent-soft pill
  in a 24px box.
- Below 800px the one-row bar, with the menus as a full-width second
  row on a grid (same markup); 84px published.
- Controls set in a bar with a slot: 28px pills 8px apart, the primary
  filled with a top highlight and 0 5px 12px -5px accent shadow, the
  avatar a circle that darkens and rings, a 20px divider before the
  account only after a lead or actions, 32px on coarse pointers,
  fainter glows in dark.
- WideOnly hidden below 64rem.
- Appearance (every app): three equal segments, icon over word (Lucide
  sun, moon, monitor), the current raised and bold with an accent icon;
  the form is estilo-appearance with data-busy="false".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev d03e25832c05c4397cee42dfa247232d497ae4d0 parent f42d56c
6 files changed, +509 −7
  • chrome/chrome.css +354 −0
  • chrome/chrome_test.go +2 −1
  • chrome/stack_test.go +54 −0
  • chrome/templates/account.html +9 −5
  • chrome/templates/icons.html +5 −1
  • chrome/unchanged_test.go +85 −0

CI passed — run details

diff --git a/chrome/chrome.css b/chrome/chrome.css
index d16395d..2af42f8 100644
--- a/chrome/chrome.css
+++ b/chrome/chrome.css
@@ -299,3 +299,357 @@
:where([estilo-signin]) a { color: var(--rst-accent); text-underline-offset: 0.15em; }
[estilo-signin-foot] a { color: inherit; }
[estilo-signin-foot] a:hover, [estilo-signin-foot] a:focus-visible { color: var(--rst-text); }
+
+/* ── Bar stack (Docs' I2 editor header, spec 2026-11-11) ────────────────
+ Everything below is opt-in. Each rule is keyed on a hook only a bar
+ with a slot, a WideOnly action or the Appearance form renders, so a bar
+ with neither Menubar nor Lead looks exactly as it did
+ (TestEverythingAfterTheMarkerIsOptIn holds this, and that main's rules
+ above are unchanged).
+
+ The hooks: [estilo-bar~="stacked"] (Bar.Menubar), [estilo-bar-stack]
+ and [estilo-bar-menubar] inside it, [estilo-bar-lead] (Bar.Lead),
+ [estilo-bar-control] (each action in a bar with a slot),
+ [estilo-bar-wide] (Action.WideOnly) 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. */
+
+/* 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
+ (the template). (0,2,0), so it outweighs a POST action's display:
+ contents form. */
+@media (max-width: 63.99rem) {
+ [estilo-bar-actions] [estilo-bar-wide],
+ [estilo-bar-actions] [estilo-bar-control~="wide"] { display: none; }
+}
+
+/* Each action in a bar with a slot sits in its own wrapper, which lays
+ out as its control. */
+[estilo-bar-control] { display: contents; }
+[estilo-bar-lead] { display: flex; align-items: center; gap: var(--rst-sp-2); }
+
+/* The stacked bar's title is as wide as its title, never the bar's
+ room: its size attribute is the first paint's guess, chrome.js
+ measures the field and corrects it, and it is capped at the space it
+ has, where a longer title scrolls inside the field as it always has. */
+[estilo-bar~="stacked"] [estilo-bar-title] { flex: none; max-inline-size: 100%; }
+[estilo-bar~="stacked"] [estilo-bar-title-input] { flex: 0 1 auto; inline-size: auto; min-inline-size: 0; max-inline-size: 100%; }
+[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
+ 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 (a long locale at 320px) grows it
+ further, beyond what is published. */
+@media (max-width: 799.98px) {
+ :root:has([estilo-bar~="stacked"]) { --estilo-bar-block-size: calc(3.25rem + 2rem); } /* 84px: the bar's row and one menubar row. PUBLIC */
+ [estilo-bar~="stacked"] {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr) auto;
+ grid-template-rows: 3.25rem auto;
+ grid-template-areas: "brand title end" "menus menus menus";
+ column-gap: var(--rst-sp-3);
+ row-gap: 0;
+ align-items: center;
+ block-size: auto;
+ }
+ [estilo-bar~="stacked"] > [estilo-bar-brand] { grid-area: brand; }
+ [estilo-bar~="stacked"] > [estilo-bar-end] { grid-area: end; }
+ [estilo-bar~="stacked"] [estilo-bar-stack] { display: contents; }
+ [estilo-bar~="stacked"] [estilo-bar-title],
+ [estilo-bar~="stacked"] [estilo-bar-context] { grid-area: title; justify-self: start; }
+ [estilo-bar~="stacked"] [estilo-bar-menubar] {
+ grid-area: menus;
+ align-self: stretch;
+ min-inline-size: 0;
+ margin-inline: calc(var(--rst-sp-3) - var(--rst-sp-4)); /* the menus' edge 12px in, as Docs' own row had it */
+ }
+}
+
+/* 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: 800px) {
+ :root:has([estilo-bar~="stacked"]) { --estilo-bar-block-size: 56px; } /* PUBLIC */
+ [estilo-bar~="stacked"] { gap: 12px; padding-inline: 12px; }
+ [estilo-bar~="stacked"] [estilo-bar-brand] img { inline-size: 32px; block-size: 32px; }
+ [estilo-bar~="stacked"] [estilo-bar-name] { display: none; }
+ [estilo-bar-stack] {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: flex-start;
+ flex: 1 1 auto;
+ min-inline-size: 0;
+ block-size: 44px;
+ }
+ [estilo-bar~="stacked"] [estilo-bar-title] {
+ position: relative;
+ inset-block-start: 2.5px;
+ block-size: 24px;
+ margin: 0;
+ padding: 0;
+ border: 0;
+ }
+ [estilo-bar~="stacked"] [estilo-bar-title-input] {
+ block-size: 24px;
+ padding-block: 0;
+ margin-inline-start: calc(-0.4rem - 1px); /* the field's padding and border pulled back: the text sits on the edge */
+ font-size: 16px;
+ line-height: 24px;
+ font-weight: 600;
+ letter-spacing: -0.01em;
+ }
+ [estilo-bar~="stacked"] [estilo-bar-context] {
+ position: relative;
+ inset-block-start: 2.5px;
+ padding: 0;
+ border: 0;
+ font-size: 16px;
+ line-height: 24px;
+ font-weight: 600;
+ letter-spacing: -0.01em;
+ }
+ /* Rename, while the title is being edited: a 22px pill in the
+ accent's tint inside the 24px title row, not the 2rem button. The
+ box is the row's 24px, the 24px target floor (AGENTS.md); a
+ 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] {
+ align-self: center;
+ box-sizing: border-box;
+ block-size: 24px;
+ min-block-size: 0;
+ min-inline-size: 0;
+ margin: 0;
+ padding: 0 10px;
+ border: 1px solid transparent;
+ border-radius: 999px;
+ background-color: var(--rst-accent-soft);
+ background-image: none;
+ background-clip: padding-box;
+ box-shadow: none;
+ color: var(--rst-accent);
+ font: 600 12px/22px var(--rst-font);
+ }
+ [estilo-bar~="stacked"] [estilo-bar-title]:focus-within [estilo-bar-title-submit]:hover {
+ border-color: transparent;
+ background-color: var(--rst-accent);
+ color: var(--rst-on-accent);
+ }
+
+ /* The menu row. estilo's 32px menubar floor goes here, and only here:
+ the row is 20px, and each title's highlight is a 24px pill with a 6px
+ radius, 2px over each edge by negative margins, so it takes no room. */
+ [estilo-bar-menubar] {
+ position: relative;
+ inset-block-start: 1px;
+ block-size: 20px;
+ max-inline-size: calc(100% + 7px);
+ margin-inline-start: -7px; /* the titles' padding pulled back: the first title's text sits on the edge */
+ }
+ [estilo-bar~="stacked"] [estilo-menubar] { block-size: 20px; min-block-size: 0; align-items: center; flex-wrap: nowrap; }
+ [estilo-bar~="stacked"] [estilo-menubar-menu] { block-size: 20px; }
+ [estilo-bar~="stacked"] [estilo-menubar-title] {
+ block-size: 24px;
+ min-block-size: 0;
+ margin-block: -2px;
+ padding-inline: 7px;
+ border-radius: 6px;
+ color: var(--rst-text-muted);
+ font-size: 13px;
+ line-height: 24px;
+ }
+ [estilo-bar~="stacked"] [estilo-menubar-title]:hover,
+ [estilo-bar~="stacked"] [open] > [estilo-menubar-title] { color: var(--rst-text); }
+ [estilo-bar~="stacked"] [estilo-menubar-menu] > [estilo-menu] { inset-block-start: calc(100% + 4px); } /* 51 + 4: 1px above the 56px edge */
+
+ /* Every panel in the stacked header matches it: 28px rows, 13px type,
+ shortcuts muted, 4px padding and a 10px radius. */
+ [estilo-bar~="stacked"] [estilo-menu] {
+ --estilo-float-padding: 4px;
+ --estilo-item-padding-block: 4px;
+ --estilo-item-padding-inline: 10px;
+ border-radius: 10px;
+ font-size: 13px;
+ }
+ [estilo-bar~="stacked"] [estilo-menu-item] { min-block-size: 28px; border-radius: 6px; }
+ [estilo-bar~="stacked"] [estilo-menu] hr { margin-block: 4px; }
+ [estilo-bar~="stacked"] [estilo-menu-key] { color: var(--rst-text-muted); font-size: 12px; }
+
+ /* The controls set, in a bar with a slot: every action a 28px pill,
+ 13px semibold, 8px apart; the primary the one filled pill; the
+ account its circle; and a divider between the page's controls and
+ the person's. Lit from above as the index's New document is, and far
+ fainter in dark. */
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-bar-end],
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-bar-actions] { gap: 8px; }
+ :is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button) {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ box-sizing: border-box;
+ block-size: 28px;
+ min-block-size: 28px;
+ min-inline-size: 28px;
+ padding: 0 12px;
+ border: 0;
+ border-radius: 999px;
+ background-color: transparent;
+ box-shadow: inset 0 1px 0 light-dark(rgb(255 255 255 / 0.7), rgb(255 255 255 / 0.06));
+ color: var(--rst-text-muted);
+ font: 600 13px/1 var(--rst-font);
+ text-decoration: none;
+ white-space: nowrap;
+ }
+ :is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button) svg { flex: none; inline-size: 15px; block-size: 15px; }
+ :is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button):hover:not(:disabled) {
+ background-color: var(--rst-surface-2);
+ color: var(--rst-text);
+ box-shadow: inset 0 1px 0 light-dark(rgb(255 255 255 / 0.8), rgb(255 255 255 / 0.08)), 0 1px 2px rgb(23 32 60 / 0.08);
+ }
+ /* A toggle whose region is shown takes the accent's tint. */
+ :is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button)[aria-expanded="true"] {
+ background-color: var(--rst-accent-soft);
+ color: var(--rst-accent);
+ box-shadow: inset 0 1px 0 light-dark(rgb(255 255 255 / 0.8), rgb(255 255 255 / 0.08)), 0 1px 2px rgb(23 32 60 / 0.08);
+ }
+ /* The primary: the one filled pill, a fine highlight on its top edge
+ and a shadow tinted with its own accent, 0 5px 12px -5px. */
+ :is([estilo-bar-control~="primary"] > a, [estilo-bar-control~="primary"] > button, [estilo-bar-control~="primary"] > form > button),
+ :is([estilo-bar-control~="primary"] > a, [estilo-bar-control~="primary"] > button, [estilo-bar-control~="primary"] > form > button):hover:not(:disabled) {
+ padding-inline: 14px;
+ background-color: var(--rst-accent);
+ color: var(--rst-on-accent);
+ box-shadow:
+ inset 0 1px 0 rgb(255 255 255 / 0.22),
+ 0 1px 1px rgb(23 32 60 / 0.10),
+ 0 5px 12px -5px light-dark(color-mix(in srgb, var(--rst-accent) 75%, transparent), color-mix(in srgb, var(--rst-accent) 25%, transparent));
+ }
+ :is([estilo-bar-control~="primary"] > a, [estilo-bar-control~="primary"] > button, [estilo-bar-control~="primary"] > form > button):hover:not(:disabled) {
+ background-color: var(--rst-accent-strong);
+ }
+
+ /* The account is its circle: no square box behind it on hover or
+ open. The avatar darkens on hover and takes a 2px ring while its menu
+ is open; with no initials the glyph's own circle does the same. */
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-account] > [estilo-bar-trigger] {
+ inline-size: 28px;
+ min-inline-size: 0;
+ block-size: 28px;
+ padding: 0;
+ border-radius: 50%;
+ background: none;
+ }
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-account] > [estilo-bar-trigger]:focus-visible { outline-offset: 2px; }
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-account] [estilo-avatar] {
+ inline-size: 28px;
+ block-size: 28px;
+ font-size: 12px;
+ box-shadow: inset 0 1px 0 light-dark(rgb(255 255 255 / 0.8), rgb(255 255 255 / 0.06)), 0 1px 2px rgb(23 32 60 / 0.08);
+ transition: background-color 120ms ease, box-shadow 120ms ease;
+ }
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-account] > [estilo-bar-trigger]:hover [estilo-avatar] {
+ background: color-mix(in srgb, var(--rst-accent) 18%, var(--rst-surface));
+ }
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-account][open] [estilo-avatar],
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-account][open] > [estilo-bar-trigger]:not(:has([estilo-avatar])) {
+ box-shadow: 0 0 0 2px var(--rst-surface), 0 0 0 4px color-mix(in srgb, var(--rst-accent) 45%, transparent);
+ }
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-account] > [estilo-bar-trigger]:not(:has([estilo-avatar])):hover {
+ background: var(--rst-surface-2);
+ }
+
+ /* The divider: a 20px hairline before the account, 12px either side
+ (the set's 8px gap and 4px more, then 12px of padding), drawn as the
+ account's own background so it takes no element. Only when something
+ of the page's precedes it: never on a bar with no actions and no
+ lead. Below 64rem a WideOnly action is hidden, so it does not count
+ there. */
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-bar-end]:has(> [estilo-bar-lead], > [estilo-bar-actions] > :not([estilo-bar-control~="wide"])) > [estilo-account] {
+ margin-inline-start: 4px;
+ padding-inline-start: 12px;
+ background: linear-gradient(var(--rst-line), var(--rst-line)) left center / 1px 20px no-repeat;
+ }
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-bar-end]:has(> [estilo-bar-lead], > [estilo-bar-actions] > :not([estilo-bar-control~="wide"])) > [estilo-account]:dir(rtl) {
+ background-position: right center;
+ }
+
+ /* Coarse pointers: the header's controls rise to 32px. */
+ @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~="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; }
+ }
+}
+@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: 4px;
+ padding-inline-start: 12px;
+ background: linear-gradient(var(--rst-line), var(--rst-line)) left center / 1px 20px no-repeat;
+ }
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-bar-end]:has(> [estilo-bar-actions]) > [estilo-account]:dir(rtl) {
+ background-position: right center;
+ }
+}
+@media (prefers-reduced-motion: reduce) {
+ :is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-account] [estilo-avatar] { 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
+ surface is barely off the well), bold, with its icon in the accent:
+ raised and bold, so more than colour says which. aria-pressed is the
+ state. chrome.js switches it in place. */
+[estilo-appearance] {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: 2px;
+ margin: 2px 6px 6px;
+ padding: 3px;
+ border-radius: 10px;
+ background: var(--rst-surface-2);
+ box-shadow: inset 0 1px 2px light-dark(rgb(23 32 60 / 0.06), rgb(0 0 0 / 0.25));
+}
+[estilo-appearance] [estilo-menu-item] {
+ flex-direction: column;
+ justify-content: center;
+ gap: 4px;
+ min-block-size: 46px;
+ padding: 6px 4px;
+ border-radius: 8px;
+ background: none;
+ color: var(--rst-text-muted);
+ font-size: 12px;
+ text-align: center;
+}
+[estilo-appearance] [estilo-menu-label] { flex: none; max-inline-size: 100%; overflow-wrap: anywhere; }
+[estilo-appearance-icon] { display: inline-flex; flex: none; inline-size: 16px; block-size: 16px; }
+[estilo-appearance-icon] svg { inline-size: 100%; block-size: 100%; }
+[estilo-appearance] [estilo-menu-item]:hover:not([aria-pressed="true"]) {
+ background: light-dark(rgb(255 255 255 / 0.5), rgb(255 255 255 / 0.04));
+ color: var(--rst-text);
+}
+[estilo-appearance] [estilo-menu-item][aria-pressed="true"] {
+ background: light-dark(var(--rst-surface), #2f333d);
+ color: var(--rst-text);
+ font-weight: 600;
+ box-shadow:
+ inset 0 1px 0 light-dark(rgb(255 255 255 / 0.9), rgb(255 255 255 / 0.06)),
+ 0 1px 2px rgb(23 32 60 / 0.12),
+ 0 0 0 1px light-dark(rgb(23 32 60 / 0.06), rgb(255 255 255 / 0.06));
+}
+[estilo-appearance] [estilo-menu-item][aria-pressed="true"] [estilo-appearance-icon] { color: var(--rst-accent); }
diff --git a/chrome/chrome_test.go b/chrome/chrome_test.go
index fd3a4b2..ff719d3 100644
--- a/chrome/chrome_test.go
+++ b/chrome/chrome_test.go
@@ -44,7 +44,8 @@ func TestBarHeightIsFixedAndPublic(t *testing.T) {
// Narrow: the title field may shrink to nothing and the Rename button
// floats under it rather than taking room from Menu and the switcher.
// The browser proof is polish-audit/r2-chrome-check.mjs's reach checks.
- narrow := src[strings.LastIndex(src, "@media (max-width: 799.98px)"):]
+ main := src[:strings.Index(src, barStackMarker)]
+ narrow := main[strings.LastIndex(main, "@media (max-width: 799.98px)"):]
for _, want := range []string{"[estilo-bar-title-input] { min-inline-size: 0; }", "[estilo-bar-title]:focus-within [estilo-bar-title-submit] {\n position: absolute;"} {
if !strings.Contains(narrow, want) {
t.Errorf("the narrow title layout lost %q", want)
diff --git a/chrome/stack_test.go b/chrome/stack_test.go
index 6ae7d26..33b0195 100644
--- a/chrome/stack_test.go
+++ b/chrome/stack_test.go
@@ -235,3 +235,57 @@ func TestTheStackedBarKeepsTheOneMenuGroup(t *testing.T) {
}
}
}
+
+// Appearance is three equal segments, an icon over each word, the current
+// one pressed; the form opts out of the busy rule (a view switch holds
+// nothing), and it is still a plain POST form for a page without script.
+func TestAppearanceIsASegmentedSelectorSwitchedInPlace(t *testing.T) {
+ html := render(t, "estilo-account", signedIn("x").Account)
+ form := regexp.MustCompile(`<form estilo-appearance [^>]*>`).FindString(html)
+ if form != `<form estilo-appearance method="post" action="/appearance" role="group" aria-labelledby="estilo-appearance" data-busy="false">` {
+ t.Errorf("the Appearance form opens %q", form)
+ }
+ if !strings.Contains(html, `<input type="hidden" name="return_to" value="/d/abc">`) {
+ t.Error("the Appearance form lost return_to, which the script-off POST needs")
+ }
+ for mode, icon := range map[string]string{"light": `<circle cx="12" cy="12" r="4"/>`, "dark": `<path d="M20.985 12.486`, "system": `<rect width="20" height="14" x="2" y="3" rx="2"/>`} {
+ button := regexp.MustCompile(`<button estilo-menu-item type="submit" name="mode" value="` + mode + `" aria-pressed="(true|false)"><span estilo-appearance-icon aria-hidden="true"><svg [^>]*>(.*?)</svg></span><span estilo-menu-label>x-` + mode + `</span></button>`).FindStringSubmatch(html)
+ if button == nil {
+ t.Errorf("no %s segment with an icon over its word in\n%s", mode, html)
+ continue
+ }
+ if (button[1] == "true") != (mode == "dark") {
+ t.Errorf("%s is aria-pressed=%s; only the current mode is pressed", mode, button[1])
+ }
+ if !strings.HasPrefix(button[2], icon) {
+ t.Errorf("%s has the wrong icon: %s", mode, button[2])
+ }
+ }
+ if strings.Contains(html[strings.Index(html, "<form estilo-appearance"):strings.Index(html, "</form>")], "estilo-menu-check") {
+ t.Error("the segments still carry the check column")
+ }
+}
+
+// The stacked header's public numbers: 56px from 800px, the one-row bar
+// plus its menu row below, and WideOnly's 64rem. The 32px menubar floor
+// goes only inside the stacked header.
+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\); \}`,
+ `@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; \}`,
+ `\[estilo-bar~="stacked"\] \[estilo-menubar-menu\] > \[estilo-menu\] \{ inset-block-start: calc\(100% \+ 4px\); \}`,
+ } {
+ if !regexp.MustCompile(re).MatchString(src) {
+ t.Errorf("chrome.css lacks %s", re)
+ }
+ }
+ // Coarse pointers raise the controls to 32px.
+ if !regexp.MustCompile(`@media \(pointer: coarse\) \{\s*:is\(\[estilo-bar-control\] > a, [^)]*\) \{ block-size: 32px; min-block-size: 32px; \}`).MatchString(src) {
+ t.Error("the controls do not rise to 32px on a coarse pointer")
+ }
+}
diff --git a/chrome/templates/account.html b/chrome/templates/account.html
index 0b5b20d..a692ab1 100644
--- a/chrome/templates/account.html
+++ b/chrome/templates/account.html
@@ -3,9 +3,13 @@
Order: who is signed in (not interactive), the app's account-scoped
items, Appearance, Help, then Sign out, which appears exactly once in
- the app. Appearance is a form of three buttons; the current one is
- aria-pressed="true" and every other "false", and the check glyph, not
- colour, shows which.
+ the app. Appearance is a form of three buttons, drawn as three equal
+ segments in one well, an icon (sun, moon, display) over each word;
+ the current one is aria-pressed="true" and every other "false", and
+ it is raised, in bold, so more than colour shows which. The form is
+ data-busy="false": choosing a scheme is a view switch, not an action
+ held for the busy rule. chrome.js applies it in place and saves it
+ with a background POST; with scripts off it posts and redirects.
Rail (Account.Rail) puts it at a sidebar rail's foot instead: the
trigger is a row naming who is signed in, and the panel opens upward
@@ -25,10 +29,10 @@
{{- with .Appearance}}
<hr>
<p estilo-menu-heading id="estilo-appearance">{{$.Labels.Appearance}}</p>
- <form method="post" action="{{.Action}}" role="group" aria-labelledby="estilo-appearance">
+ <form estilo-appearance method="post" action="{{.Action}}" role="group" aria-labelledby="estilo-appearance" data-busy="false">
<input type="hidden" name="return_to" value="{{.Return}}">
{{- range .Options}}
- <button estilo-menu-item type="submit" name="mode" value="{{.Value}}" aria-pressed="{{if .Current}}true{{else}}false{{end}}"><span estilo-menu-check aria-hidden="true">{{template "estilo-icon-check"}}</span><span estilo-menu-label>{{.Label}}</span></button>
+ <button estilo-menu-item type="submit" name="mode" value="{{.Value}}" aria-pressed="{{if .Current}}true{{else}}false{{end}}"><span estilo-appearance-icon aria-hidden="true">{{if eq .Value "light"}}{{template "estilo-icon-sun"}}{{else if eq .Value "dark"}}{{template "estilo-icon-moon"}}{{else}}{{template "estilo-icon-display"}}{{end}}</span><span estilo-menu-label>{{.Label}}</span></button>
{{- end}}
</form>
{{- end}}
diff --git a/chrome/templates/icons.html b/chrome/templates/icons.html
index c2a8762..99d5a93 100644
--- a/chrome/templates/icons.html
+++ b/chrome/templates/icons.html
@@ -1,6 +1,10 @@
-{{/* The bar's glyphs. Lucide "menu", "user" and "layout-grid" (ISC,
+{{/* The bar's glyphs. Lucide "menu", "user" and "layout-grid", 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. */}}
{{define "estilo-icon-menu"}}<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M4 12h16M4 6h16M4 18h16"/></svg>{{end}}
{{define "estilo-icon-person"}}<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>{{end}}
{{define "estilo-icon-grid"}}<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><rect width="7" height="7" x="3" y="3" rx="1"/><rect width="7" height="7" x="14" y="3" rx="1"/><rect width="7" height="7" x="14" y="14" rx="1"/><rect width="7" height="7" x="3" y="14" rx="1"/></svg>{{end}}
+{{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}}
diff --git a/chrome/unchanged_test.go b/chrome/unchanged_test.go
index 7e11172..9376b8d 100644
--- a/chrome/unchanged_test.go
+++ b/chrome/unchanged_test.go
@@ -1,9 +1,13 @@
package chrome
import (
+ "crypto/sha256"
+ "encoding/hex"
"flag"
"os"
"path/filepath"
+ "regexp"
+ "strings"
"testing"
"amadan.net/oficina/estilo.git/menu"
@@ -61,3 +65,84 @@ func TestABarWithoutSlotsIsByteForByteUnchanged(t *testing.T) {
})
}
}
+
+// barStackMarker opens chrome.css's opt-in section: everything bar-stack
+// added sits after it, and main's rules before it are untouched.
+const barStackMarker = "\n/* ── Bar stack"
+
+// mainCSS is the sha256 of chrome.css on main at f6d5605 (and of menu.css,
+// which bar-stack does not touch). A change to the bar's own rules for
+// every app is a design decision: make it deliberately, and update these
+// with the reason in the commit.
+const (
+ mainChromeCSS = "273cb84c55d6f28bff4cc03bcba9401b4cdfbee343fe01765159317beee5cab9"
+ mainMenuCSS = "6b3435a18591d20ad62b40df3e64e159b501f9d1c183b2f42aa32b4faa9c0669"
+)
+
+// optInHooks are the attributes only a bar with a slot, a WideOnly action
+// or the Appearance form renders.
+var optInHooks = []string{
+ `[estilo-bar~="stacked"]`, "[estilo-bar-stack]", "[estilo-bar-menubar]", "[estilo-bar-lead]",
+ "[estilo-bar-control", "[estilo-bar-wide]", "[estilo-appearance",
+}
+
+// A bar with no slot must look as it did, not only read as it did: main's
+// stylesheet rules are byte for byte where they were, and every rule
+// bar-stack added is keyed on an opt-in hook, in every selector of its
+// list. (Appearance is the deliberate exception that every app takes:
+// its hook is the form's own attribute.)
+func TestEverythingAfterTheMarkerIsOptIn(t *testing.T) {
+ src := string(CSS())
+ at := strings.Index(src, barStackMarker)
+ if at < 0 {
+ t.Fatal("chrome.css lost its bar-stack marker")
+ }
+ if sum := sha256.Sum256([]byte(src[:at])); hex.EncodeToString(sum[:]) != mainChromeCSS {
+ t.Error("main's chrome.css rules changed: every app's bar would look different")
+ }
+ if sum := sha256.Sum256(menu.CSS()); hex.EncodeToString(sum[:]) != mainMenuCSS {
+ t.Error("menu.css changed: every app's menus would look different")
+ }
+ section := regexp.MustCompile(`(?s)/\*.*?\*/`).ReplaceAllString(src[at:], "")
+ n := 0
+ for _, m := range regexp.MustCompile(`([^{};]+)\{`).FindAllStringSubmatch(section, -1) {
+ list := strings.TrimSpace(m[1])
+ if strings.HasPrefix(list, "@") {
+ continue
+ }
+ for _, sel := range splitSelectors(list) {
+ n++
+ hooked := false
+ for _, h := range optInHooks {
+ hooked = hooked || strings.Contains(sel, h)
+ }
+ if !hooked {
+ t.Errorf("%q styles every bar, not only one that opted in", sel)
+ }
+ }
+ }
+ if n < 20 {
+ 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:]))
+}