oficina / estilo Public

chrome: an icon-only bar action, named, with its shortcut and a tooltip

Action.IconOnly draws the action in the bar as its icon alone, for
Mapa's and Fichas' Search (Paul, 2026-11-18: the header's Search can
be a lens with ⌘K). Its label becomes the accessible name
(aria-label) and, followed by Key, the tooltip on hover and focus,
rastrillo's rst-tip ("Search ⌘K"). Action.KeyShortcuts sets the
control's aria-keyshortcuts. The Menu sheet's row is unchanged: label
and key.

The CSS is opt-in, keyed on the new [estilo-bar-icon] hook (added to
TestEverythingAfterTheMarkerIsOptIn's list): a square of the set's
height, positioned so the tooltip hangs from it, and on a coarse
pointer a 44px hit area drawn by nothing (::before; ::after is the
tooltip's). A bar that sets neither field writes the same bytes as
before (TestABarWithoutSlotsIsByteForByteUnchanged), so Docs, Sheets
and Slides see nothing change on their next re-pin.

Copy reviewed by Luna (recorded in each app's
copy-review/search-icon). Browser checks live in Mapa and Fichas.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 311a28194033ec4fba09c00ea89532bea5c1f8ce parent c1773e0
5 files changed, +88 −7
  • chrome/chrome.css +23 −3
  • chrome/chrome.go +10 −0
  • chrome/stack_test.go +41 −0
  • chrome/templates/bar.html +11 −1
  • chrome/unchanged_test.go +3 −3

CI passed — run details

diff --git a/chrome/chrome.css b/chrome/chrome.css
index 548c881..024bfe3 100644
--- a/chrome/chrome.css
+++ b/chrome/chrome.css
@@ -302,15 +302,16 @@
/* ── 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
+ with a slot, a WideOnly or IconOnly action or the Appearance form
+ renders, so a bar with none of them 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].
+ [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
@@ -591,6 +592,19 @@
background-position: right center;
}
+ /* An icon-only action (Action.IconOnly: Search in Mapa and Fichas):
+ a square as tall as the set's controls, the glyph centred. Its
+ label is its accessible name and, with its shortcut, the tooltip
+ the template asks rastrillo's rst-tip for, which hangs from this
+ box, so the box is positioned. (0,2,0) outweighs the set's pill. */
+ [estilo-bar-actions] [estilo-bar-icon] {
+ position: relative;
+ justify-content: center;
+ inline-size: 28px;
+ min-inline-size: 28px;
+ 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
@@ -604,6 +618,12 @@
[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-bar-title] { z-index: 1; }
+ /* 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
+ ::after is the tooltip. */
+ [estilo-bar-actions] [estilo-bar-icon] { inline-size: 32px; min-inline-size: 32px; }
+ [estilo-bar-actions] [estilo-bar-icon]::before { content: ""; position: absolute; inset: -6px; }
}
}
@media (min-width: 64rem) {
diff --git a/chrome/chrome.go b/chrome/chrome.go
index 4be639a..df73284 100644
--- a/chrome/chrome.go
+++ b/chrome/chrome.go
@@ -130,6 +130,16 @@ type Action struct {
// bar (not in the sheet): the app's own inline <svg aria-hidden="true">,
// trusted markup the app renders itself. The label still names it.
Icon template.HTML
+ // IconOnly draws the action in the bar as its Icon alone (Mapa's and
+ // Fichas' Search, 2026-11-18). Label is then its accessible name
+ // (aria-label) and, followed by Key when there is one, its tooltip on
+ // hover and focus: rastrillo's rst-tip, so "Search ⌘K". The Menu
+ // sheet's row is unchanged, label and key. Set it only with an Icon.
+ IconOnly bool
+ // KeyShortcuts is the bar control's aria-keyshortcuts, in ARIA's own
+ // spelling ("Meta+K Control+K"): Key is the shortcut people read,
+ // this the one assistive technology does. Optional.
+ KeyShortcuts string
}
// BarLabels are the bar's own strings: the skip link (rendered by the
diff --git a/chrome/stack_test.go b/chrome/stack_test.go
index 60ccdb5..8ebc578 100644
--- a/chrome/stack_test.go
+++ b/chrome/stack_test.go
@@ -383,3 +383,44 @@ func TestTheWideTitleCapAllowsForItsPulledBackMargin(t *testing.T) {
t.Errorf("the wide title field's cap does not give back its pulled-back margin:\n%s", rule)
}
}
+
+// An icon-only action (Mapa's and Fichas' Search) shows its icon alone in
+// the bar: its label is the accessible name and, with its key, the
+// tooltip; its shortcut is aria-keyshortcuts. The Menu sheet's row keeps
+// the label and the key. Every kind draws it the same way.
+func TestAnIconOnlyActionIsNamedButShowsNoText(t *testing.T) {
+ icon := template.HTML(`<svg aria-hidden="true"></svg>`)
+ search := Action{Item: menu.Item{Href: "/search", Label: "x-search", Key: "⌘K"},
+ Icon: icon, IconOnly: true, KeyShortcuts: "Meta+K Control+K"}
+ // html/template writes + as &#43;; the attribute's value is Meta+K.
+ want := `<a rst-btn href="/search" aria-keyshortcuts="Meta&#43;K Control&#43;K" aria-label="x-search" estilo-bar-icon rst-tip data-tip="x-search ⌘K"><svg aria-hidden="true"></svg></a>`
+ if got := render(t, "estilo-bar-action", search); got != want {
+ t.Errorf("got %s\nwant %s", got, want)
+ }
+
+ b := stacked()
+ b.Actions = []Action{search}
+ html := render(t, "estilo-bar", b)
+ actions := html[strings.Index(html, "<div estilo-bar-actions>"):strings.Index(html, "<details estilo-bar-more")]
+ if !strings.Contains(actions, `<div estilo-bar-control>`+want+`</div>`) {
+ t.Errorf("the bar does not draw the icon-only control:\n%s", actions)
+ }
+ sheet := html[strings.Index(html, `<div estilo-menu="sheet">`):strings.Index(html, "<details estilo-switcher")]
+ if !strings.Contains(sheet, `<span estilo-menu-label>x-search</span><kbd estilo-menu-key>⌘K</kbd>`) {
+ t.Errorf("the sheet's row lost its label or key:\n%s", sheet)
+ }
+
+ // No key: the tooltip is the label alone.
+ noKey := search
+ noKey.Key, noKey.KeyShortcuts = "", ""
+ if got := render(t, "estilo-bar-action", noKey); !strings.Contains(got, ` aria-label="x-search" estilo-bar-icon rst-tip data-tip="x-search">`) || strings.Contains(got, "aria-keyshortcuts") {
+ t.Errorf("without a key: %s", got)
+ }
+
+ for _, it := range []menu.Item{{Action: "/p", Label: "l"}, {Dialog: "d", Label: "l"}, {Controls: "c", Label: "l"}} {
+ got := render(t, "estilo-bar-action", Action{Item: it, Icon: icon, IconOnly: true})
+ if !strings.Contains(got, ` aria-label="l" estilo-bar-icon rst-tip data-tip="l"><svg aria-hidden="true"></svg></button>`) {
+ t.Errorf("%+v: %s", it, got)
+ }
+ }
+}
diff --git a/chrome/templates/bar.html b/chrome/templates/bar.html
index 2ab497f..05c33ec 100644
--- a/chrome/templates/bar.html
+++ b/chrome/templates/bar.html
@@ -89,7 +89,17 @@
attributes (AGENTS.md, the prefix rule). A bar with no slot draws the
actions bare, as it always has. */}}
{{define "estilo-bar-actions"}}{{$controls := or .Menubar .Lead}}{{range .Actions}}{{if $controls}}<div estilo-bar-control{{if and .Primary .WideOnly}}="primary wide"{{else if .Primary}}="primary"{{else if .WideOnly}}="wide"{{end}}>{{template "estilo-bar-action" .}}</div>{{else}}{{template "estilo-bar-action" .}}{{end}}{{end}}{{end}}
-{{define "estilo-bar-action"}}{{if .Action}}<form method="post" action="{{.Action}}"{{if .WideOnly}} estilo-bar-wide{{end}}><button rst-btn{{if .Primary}}="primary"{{end}} type="submit">{{.Icon}}{{.Label}}</button></form>{{else if .Dialog}}<button rst-btn{{if .Primary}}="primary"{{end}} type="button" commandfor="{{.Dialog}}" command="show-modal"{{if .WideOnly}} estilo-bar-wide{{end}}>{{.Icon}}{{.Label}}</button>{{else if .Controls}}<button rst-btn{{if .Primary}}="primary"{{end}} type="button" aria-expanded="{{if .Expanded}}true{{else}}false{{end}}" aria-controls="{{.Controls}}" disabled data-estilo-toggle{{if .WideOnly}} estilo-bar-wide{{end}}>{{.Icon}}{{.Label}}</button>{{else}}<a rst-btn{{if .Primary}}="primary"{{end}} href="{{.Href}}"{{if .WideOnly}} estilo-bar-wide{{end}}>{{.Icon}}{{.Label}}</a>{{end}}{{end}}
+{{define "estilo-bar-action"}}{{if .Action}}<form method="post" action="{{.Action}}"{{if .WideOnly}} estilo-bar-wide{{end}}><button rst-btn{{if .Primary}}="primary"{{end}} type="submit"{{template "estilo-bar-action-name" .}}>{{template "estilo-bar-action-face" .}}</button></form>{{else if .Dialog}}<button rst-btn{{if .Primary}}="primary"{{end}} type="button" commandfor="{{.Dialog}}" command="show-modal"{{if .WideOnly}} estilo-bar-wide{{end}}{{template "estilo-bar-action-name" .}}>{{template "estilo-bar-action-face" .}}</button>{{else if .Controls}}<button rst-btn{{if .Primary}}="primary"{{end}} type="button" aria-expanded="{{if .Expanded}}true{{else}}false{{end}}" aria-controls="{{.Controls}}" disabled data-estilo-toggle{{if .WideOnly}} estilo-bar-wide{{end}}{{template "estilo-bar-action-name" .}}>{{template "estilo-bar-action-face" .}}</button>{{else}}<a rst-btn{{if .Primary}}="primary"{{end}} href="{{.Href}}"{{if .WideOnly}} estilo-bar-wide{{end}}{{template "estilo-bar-action-name" .}}>{{template "estilo-bar-action-face" .}}</a>{{end}}{{end}}
+
+{{/* estilo-bar-action-name and -face: what an action's control says.
+ Most show their icon and label. An IconOnly one (Action.IconOnly)
+ shows its icon alone, carries its label as aria-label, and shows
+ the label and Key as a tooltip on hover and focus (rastrillo's
+ rst-tip, drawn from the estilo-bar-icon box). KeyShortcuts, when
+ set, is the control's aria-keyshortcuts. Neither writes a byte for
+ an action that sets none of these. */}}
+{{define "estilo-bar-action-name"}}{{with .KeyShortcuts}} aria-keyshortcuts="{{.}}"{{end}}{{if .IconOnly}} aria-label="{{.Label}}" estilo-bar-icon rst-tip data-tip="{{.Label}}{{with .Key}} {{.}}{{end}}"{{end}}{{end}}
+{{define "estilo-bar-action-face"}}{{.Icon}}{{if not .IconOnly}}{{.Label}}{{end}}{{end}}
{{/* estilo-bar-title: the open object's title, editable in place. A real
form, so Enter renames with scripts off. The submit button is visually
diff --git a/chrome/unchanged_test.go b/chrome/unchanged_test.go
index 9376b8d..eb091f9 100644
--- a/chrome/unchanged_test.go
+++ b/chrome/unchanged_test.go
@@ -79,11 +79,11 @@ const (
mainMenuCSS = "6b3435a18591d20ad62b40df3e64e159b501f9d1c183b2f42aa32b4faa9c0669"
)
-// optInHooks are the attributes only a bar with a slot, a WideOnly action
-// or the Appearance form renders.
+// optInHooks are the attributes only a bar with a slot, a WideOnly or
+// IconOnly 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",
+ "[estilo-bar-control", "[estilo-bar-wide]", "[estilo-appearance", "[estilo-bar-icon]",
}
// A bar with no slot must look as it did, not only read as it did: main's