oficina / docs Public

I2: the editor's bar is stacked, with the menu bar and undo/redo in estilo's slots

The menu bar and the undo/redo pair are views/partials/editor_bar.html,
rendered into chrome.Bar.Menubar and Lead. Format is a WideOnly toggle
for the inspector, from the docs-inspector cookie (open unless exactly
closed); Share is the primary, last. The toolbar sits in
<aside docs-inspector>, its groups labelled sections; the strip keeps
its own pair outside the toolbar. brand/inspector.js binds Format.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev ec5c492b9b4c7b9f481fffa561ca279ec7d55b5e parent 2b47bd3
11 files changed, +431 −74
  • internal/docs/brand/inspector.js +35 −0
  • internal/docs/chrome.go +8 −0
  • internal/docs/chrome_test.go +1 −1
  • internal/docs/export.go +32 −3
  • internal/docs/handlers.go +43 −2
  • internal/docs/i2_test.go +139 −0
  • internal/docs/menu.go +21 −0
  • internal/docs/render.go +31 −3
  • internal/docs/share_nav_test.go +15 −3
  • internal/docs/views/partials/editor_bar.html +74 −0
  • internal/docs/views/show.html +32 −62

CI passed — run details

diff --git a/internal/docs/brand/inspector.js b/internal/docs/brand/inspector.js
new file mode 100644
index 0000000..19cd512
--- /dev/null
+++ b/internal/docs/brand/inspector.js
@@ -0,0 +1,35 @@
+/* inspector.js: the bar's Format toggle (spec I2). From 64rem the
+ formatting bar is an inspector floating under the header, and Format
+ shows and hides it.
+
+ The state is the server's first: the docs-inspector cookie, rendered
+ onto the inspector (data-state) and into the toggle's aria-expanded
+ (handlers.go's show), so the first paint is already right and nothing
+ moves when this runs. estilo renders the toggle disabled, since with
+ no script nothing can toggle the region; this enables it, flips the
+ state in place (no request, no reload, no spinner: a view switch, like
+ Appearance), keeps aria-expanded current and writes the cookie for the
+ next page. Closed hides the inspector only at 64rem and up (show.html);
+ below that the strip shows whatever the state. A plain script, not the
+ editor bundle: a reader's page has the inspector too. */
+(function () {
+ "use strict";
+ var inspector = document.querySelector("[docs-inspector][id]");
+ if (!inspector) return;
+ var toggles = document.querySelectorAll('[data-estilo-toggle][aria-controls="' + inspector.id + '"]');
+ if (!toggles.length) return;
+ var secure = location.protocol === "https:" ? "; Secure" : "";
+
+ function set(open) {
+ inspector.setAttribute("data-state", open ? "open" : "closed");
+ for (var i = 0; i < toggles.length; i++) toggles[i].setAttribute("aria-expanded", open ? "true" : "false");
+ document.cookie = "docs-inspector=" + (open ? "open" : "closed") + "; Path=/; Max-Age=31536000; SameSite=Lax" + secure;
+ }
+
+ for (var i = 0; i < toggles.length; i++) {
+ toggles[i].disabled = false;
+ toggles[i].addEventListener("click", function () {
+ set(inspector.getAttribute("data-state") === "closed");
+ });
+ }
+})();
diff --git a/internal/docs/chrome.go b/internal/docs/chrome.go
index f45a46c..60696e9 100644
--- a/internal/docs/chrome.go
+++ b/internal/docs/chrome.go
@@ -11,6 +11,7 @@ package docs
// §10 (titles).
import (
+ "html/template"
"net/http"
"net/url"
@@ -40,6 +41,11 @@ type frameOptions struct {
context string
edit *chrome.TitleEdit
actions []chrome.Action
+ // menubar and lead fill estilo's two bar slots (spec I2): the editor
+ // passes its menu bar, which makes the bar stacked, and its undo/redo
+ // pair. Every other page leaves both empty and keeps the one-row bar.
+ menubar template.HTML
+ lead template.HTML
// public is a read-only page a stranger reaches: the brand is plain
// text, and "Sign in" carries no return path (the path is a
// capability and must not be copied into another URL).
@@ -63,6 +69,8 @@ func (h *handlers) frame(r *http.Request, o frameOptions) Frame {
Context: o.context,
ContextEdit: o.edit,
Actions: o.actions,
+ Menubar: o.menubar,
+ Lead: o.lead,
Sticky: true,
Labels: chrome.BarLabels{Skip: rastrillo.T(r, "docs.chrome.skip"), Menu: rastrillo.T(r, "docs.chrome.menu")},
}
diff --git a/internal/docs/chrome_test.go b/internal/docs/chrome_test.go
index 6bff17f..7fafd08 100644
--- a/internal/docs/chrome_test.go
+++ b/internal/docs/chrome_test.go
@@ -197,7 +197,7 @@ func TestTheBarRenamesTheDocument(t *testing.T) {
alice := signInCookies(t, app, "alice@example.com")
sqid := createDoc(t, app, alice, "Untitled")
body := get(t, app, alice, "/d/"+sqid).Body.String()
- if !strings.Contains(body, `<form estilo-bar-title method="post" action="/d/`+sqid+`/title">`) || !strings.Contains(body, `name="title" value="Untitled" aria-label="docs.chrome.title.label"`) {
+ if !strings.Contains(body, `<form estilo-bar-title method="post" action="/d/`+sqid+`/title">`) || !strings.Contains(body, `name="title" value="Untitled" size="8" aria-label="docs.chrome.title.label"`) {
t.Fatal("a writer has no editable title in the bar")
}
req := httptest.NewRequest(http.MethodPost, "/d/"+sqid+"/title", strings.NewReader("title=Board+minutes"))
diff --git a/internal/docs/export.go b/internal/docs/export.go
index 5ed613d..0fae790 100644
--- a/internal/docs/export.go
+++ b/internal/docs/export.go
@@ -34,9 +34,18 @@ type toolbarOption struct {
// the bundle carries no copy of its own, the same rule the save-status
// indicator follows.
type toolbarView struct {
- Label string
- Undo string
- Redo string
+ Label string
+ Undo string
+ Redo string
+ // History names the undo/redo pair; the Group* are the four
+ // sections' visible labels in the inspector (spec I2), and Inspector
+ // names the panel itself.
+ History string
+ GroupStyle string
+ GroupText string
+ GroupAlign string
+ GroupLists string
+ Inspector string
Bold string
Italic string
Code string
@@ -75,6 +84,12 @@ func newToolbarView(r *http.Request) toolbarView {
Label: rastrillo.T(r, "docs.editor.toolbar.label"),
Undo: rastrillo.T(r, "docs.editor.toolbar.undo"),
Redo: rastrillo.T(r, "docs.editor.toolbar.redo"),
+ History: rastrillo.T(r, "docs.editor.toolbar.history"),
+ GroupStyle: rastrillo.T(r, "docs.editor.toolbar.group.style"),
+ GroupText: rastrillo.T(r, "docs.editor.toolbar.group.text"),
+ GroupAlign: rastrillo.T(r, "docs.editor.toolbar.group.align"),
+ GroupLists: rastrillo.T(r, "docs.editor.toolbar.group.lists"),
+ Inspector: rastrillo.T(r, "docs.editor.inspector.label"),
Bold: rastrillo.T(r, "docs.editor.toolbar.bold"),
Italic: rastrillo.T(r, "docs.editor.toolbar.italic"),
Code: rastrillo.T(r, "docs.editor.toolbar.code"),
@@ -121,6 +136,20 @@ func newToolbarView(r *http.Request) toolbarView {
}
}
+// historyView is docs-history's data (views/partials/editor_bar.html):
+// the undo/redo pair, in the bar's lead slot (Lead) or in the strip.
+type historyView struct {
+ Label, Undo, Redo string
+ Lead bool
+}
+
+func (t toolbarView) history(lead bool) historyView {
+ return historyView{Label: t.History, Undo: t.Undo, Redo: t.Redo, Lead: lead}
+}
+
+// StripHistory is the strip's pair, for show.html.
+func (t toolbarView) StripHistory() historyView { return t.history(false) }
+
// sizeOptions is the point ladder the size control offers.
//
// THE LABELS ARE NOT CATALOG KEYS, and that is deliberate rather than
diff --git a/internal/docs/handlers.go b/internal/docs/handlers.go
index 11006d7..ee2e830 100644
--- a/internal/docs/handlers.go
+++ b/internal/docs/handlers.go
@@ -550,6 +550,11 @@ type showPage struct {
ViewMode string
PageLabel string
+ // Inspector is "open" or "closed" (menu.go's inspectorState, from the
+ // docs-inspector cookie), rendered onto the inspector and into the
+ // Format toggle's aria-expanded, for the same first-paint reason.
+ Inspector string
+
// Dialogs is the copy for the two <dialog>s Tools opens — word
// count and the shortcuts sheet. Server-rendered like everything
// else, so the bundle carries no strings of its own; it fills in
@@ -608,6 +613,12 @@ func newDialogView(r *http.Request) dialogView {
}
}
+// inspectorID is the inspector's id: the Format toggle's aria-controls.
+const inspectorID = "docs-inspector"
+
+// InspectorID is its value for the template.
+func (showPage) InspectorID() string { return inspectorID }
+
// show serves GET /d/{sqid}: the document read-only, its title and
// its CRDT content — rendered server-side as HTML through Store.HTML,
// not plain text — inside a page-shaped canvas (views/show.html). An
@@ -679,6 +690,7 @@ func (h *handlers) show(w http.ResponseWriter, r *http.Request) {
Menu: newMenuView(r, doc.Sqid, h.member(r), doc.OwnerID == actor.PersonID && h.member(r)),
Fonts: newFontGate(structure).withCopy(r),
ViewMode: viewMode(r),
+ Inspector: inspectorState(r),
PageLabel: rastrillo.T(r, "docs.editor.page.number"),
Dialogs: newDialogView(r),
}
@@ -694,9 +706,35 @@ func (h *handlers) show(w http.ResponseWriter, r *http.Request) {
Submit: rastrillo.T(r, "docs.chrome.title.rename"),
}
}
- if data.CanShare {
- chromeFor.actions = []chrome.Action{{Item: estilomenu.Item{Href: "/d/" + doc.Sqid + "/share", Label: rastrillo.T(r, "docs.share.action")}}}
+ // The I2 header (spec 2026-11-11): the menu bar under the title and
+ // the undo/redo pair in the lead slot, both this app's own partials
+ // (views/partials/editor_bar.html); then the actions in the set's
+ // order, Format, the import report where there is one, and Share,
+ // the one primary, last before the account.
+ //
+ // Format is a toggle for the inspector (aria-controls), wide only:
+ // the inspector exists from 64rem. Its state is the docs-inspector
+ // cookie's, rendered here and onto the inspector, so the first paint
+ // is the final one; estilo renders it disabled, and brand/
+ // inspector.js enables it.
+ var err2 error
+ if chromeFor.menubar, err2 = h.render.fragment("show", "docs-menubar", data.Menu); err2 == nil {
+ chromeFor.lead, err2 = h.render.fragment("show", "docs-history", data.Toolbar.history(true))
+ }
+ var formatIcon template.HTML
+ if err2 == nil {
+ formatIcon, err2 = h.render.fragment("show", "docs-icon-format", nil)
+ }
+ if err2 != nil {
+ h.logger.Error("docs: render the editor's bar", "err", err2)
+ h.fail(w, r, h.internalFailureStatus(), failStatus)
+ return
}
+ chromeFor.actions = []chrome.Action{{
+ Item: estilomenu.Item{Controls: inspectorID, Expanded: data.Inspector == InspectorOpen, Label: rastrillo.T(r, "docs.editor.inspector.toggle")},
+ WideOnly: true,
+ Icon: formatIcon,
+ }}
// An imported document keeps its report one click away, for anybody
// who can read the document; it shows itself once on arrival.
if h.store.hasImportReport(r.Context(), doc.ID) {
@@ -711,6 +749,9 @@ func (h *handlers) show(w http.ResponseWriter, r *http.Request) {
}
}
}
+ if data.CanShare {
+ chromeFor.actions = append(chromeFor.actions, chrome.Action{Item: estilomenu.Item{Href: "/d/" + doc.Sqid + "/share", Label: rastrillo.T(r, "docs.share.action")}, Primary: true})
+ }
data.Frame = h.frame(r, chromeFor)
if err := h.render.page(w, r, "show", data); err != nil {
h.logger.Error("docs: render show", "err", err)
diff --git a/internal/docs/i2_test.go b/internal/docs/i2_test.go
new file mode 100644
index 0000000..86db7bd
--- /dev/null
+++ b/internal/docs/i2_test.go
@@ -0,0 +1,139 @@
+package docs_test
+
+import (
+ "net/http"
+ "regexp"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/docs/internal/docs"
+)
+
+// The I2 header (spec 2026-11-11): on the editor the estilo bar is
+// stacked, with the document's menu bar in its Menubar slot and the
+// undo/redo pair in its Lead slot; every other page keeps the one-row bar
+// with neither.
+func TestTheEditorBarIsStackedWithItsSlots(t *testing.T) {
+ app, _ := docs.NewForTest(t)
+ alice := signInCookies(t, app, "alice@example.com")
+ sqid := createDoc(t, app, alice, "Minutes")
+
+ body := get(t, app, alice, "/d/"+sqid).Body.String()
+ header := body[strings.Index(body, "<header estilo-bar"):]
+ header = header[:strings.Index(header, "</header>")]
+ if !strings.HasPrefix(header, `<header estilo-bar="sticky stacked">`) {
+ t.Errorf("the editor's bar is not stacked: %.60s", header)
+ }
+ if !strings.Contains(header, "<div estilo-bar-menubar><nav estilo-menubar") {
+ t.Error("the editor's menu bar is not in the bar's Menubar slot")
+ }
+ if !strings.Contains(header, `<div estilo-bar-lead><div docs-history="lead" role="group"`) {
+ t.Error("the undo/redo pair is not in the bar's Lead slot")
+ }
+ // One menu bar in the page: its menus have ids, and two would be two
+ // sets of the same ids (estilo draws it as the second row below 800px,
+ // so the strip no longer draws its own).
+ if n := strings.Count(body, "<nav estilo-menubar"); n != 1 {
+ t.Errorf("%d menu bars in the page, want 1", n)
+ }
+ if n := strings.Count(body, `id="docs-menu-file"`); n != 1 {
+ t.Errorf("%d File menus in the page, want 1", n)
+ }
+ // Two homes for the pair, the lead's and the strip's, and neither in
+ // the toolbar or its roving tab stop.
+ if n := strings.Count(body, `data-docs-command="undo" aria-label=`); n != 2 {
+ t.Errorf("%d undo buttons outside the menu, want 2 (the lead's and the strip's)", n)
+ }
+ if !strings.Contains(body, `<div docs-history role="group"`) {
+ t.Error("the strip has no undo/redo pair for below 800px")
+ }
+ toolbar := body[strings.Index(body, "<div docs-toolbar "):]
+ toolbar = toolbar[:strings.Index(toolbar, "</aside>")]
+ if strings.Contains(toolbar, `"undo"`) || strings.Contains(toolbar, `"redo"`) {
+ t.Error("undo or redo is still inside the role=toolbar")
+ }
+ history := regexp.MustCompile(`<button docs-tool[^>]*data-docs-command="(?:undo|redo)"[^>]*>`)
+ for _, b := range history.FindAllString(body, -1) {
+ if strings.Contains(b, "tabindex") {
+ t.Errorf("an undo/redo button carries a tabindex, as a roving control would: %s", b)
+ }
+ }
+
+ // The index's bar is the one-row bar, unchanged.
+ index := get(t, app, alice, "/").Body.String()
+ if !strings.Contains(index, `<header estilo-bar="sticky">`) {
+ t.Error("the index's bar is not the one-row bar")
+ }
+ for _, slot := range []string{"estilo-bar-stack", "estilo-bar-menubar", "estilo-bar-lead", "data-estilo-toggle"} {
+ if strings.Contains(index, slot) {
+ t.Errorf("the index's bar has %s", slot)
+ }
+ }
+}
+
+// The inspector's state is the docs-inspector cookie's, rendered onto the
+// inspector and into Format's aria-expanded, so the first paint is right:
+// open unless the cookie says exactly "closed". Format is rendered
+// disabled (brand/inspector.js enables it) and wide only.
+func TestFormatIsRenderedFromTheInspectorCookie(t *testing.T) {
+ app, _ := docs.NewForTest(t)
+ alice := signInCookies(t, app, "alice@example.com")
+ sqid := createDoc(t, app, alice, "Minutes")
+
+ for _, c := range []struct {
+ cookie string
+ open bool
+ }{
+ {"", true},
+ {"open", true},
+ {"closed", false},
+ {"Closed", true},
+ {"closed ", true},
+ {`"><script>`, true},
+ } {
+ cookies := alice
+ if c.cookie != "" {
+ cookies = append(append([]*http.Cookie(nil), alice...), &http.Cookie{Name: docs.InspectorCookie, Value: c.cookie})
+ }
+ body := get(t, app, cookies, "/d/"+sqid).Body.String()
+ expanded, state := "true", "open"
+ if !c.open {
+ expanded, state = "false", "closed"
+ }
+ toggle := `<button rst-btn type="button" aria-expanded="` + expanded + `" aria-controls="docs-inspector" disabled data-estilo-toggle estilo-bar-wide>`
+ if !strings.Contains(body, toggle) {
+ t.Errorf("cookie %q: Format is not rendered %s", c.cookie, toggle)
+ }
+ aside := `<aside docs-inspector id="docs-inspector" rst-box data-state="` + state + `" aria-label="docs.editor.inspector.label">`
+ if !strings.Contains(body, aside) {
+ t.Errorf("cookie %q: the inspector is not rendered %s", c.cookie, aside)
+ }
+ if strings.Contains(body, "<script>\"") || strings.Contains(body, `"><script>`) {
+ t.Errorf("cookie %q reached the page", c.cookie)
+ }
+ }
+}
+
+// Each of the inspector's sections is a role="group" named by its visible
+// label, and the labels are catalog keys.
+func TestTheInspectorSectionsAreNamedGroups(t *testing.T) {
+ app, _ := docs.NewForTest(t)
+ alice := signInCookies(t, app, "alice@example.com")
+ sqid := createDoc(t, app, alice, "Minutes")
+ body := get(t, app, alice, "/d/"+sqid).Body.String()
+ for _, g := range []string{"style", "text", "align", "lists"} {
+ group := `<div docs-toolbar-group="` + g + `" role="group" aria-labelledby="docs-group-` + g + `">`
+ label := `<span docs-toolbar-label id="docs-group-` + g + `">docs.editor.toolbar.group.` + g + `</span>`
+ at := strings.Index(body, group)
+ if at < 0 {
+ t.Errorf("no %s group: %s", g, group)
+ continue
+ }
+ if !strings.HasPrefix(strings.TrimSpace(body[at+len(group):]), label) {
+ t.Errorf("the %s group does not open with its label %s", g, label)
+ }
+ }
+ if n := strings.Count(body, `role="toolbar"`); n != 1 {
+ t.Errorf("%d toolbars, want one at every width", n)
+ }
+}
diff --git a/internal/docs/menu.go b/internal/docs/menu.go
index 0be3ebe..5d5d8ae 100644
--- a/internal/docs/menu.go
+++ b/internal/docs/menu.go
@@ -183,6 +183,27 @@ func viewMode(r *http.Request) string {
return ViewPaged
}
+// The inspector's open or closed state (spec I2: the Format toggle). A
+// cookie for the same reason docs-view is one: the server renders the
+// state, so the first paint is already right (no flash, CLS 0), which
+// localStorage could not give. Written by brand/inspector.js.
+const (
+ InspectorOpen = "open"
+ InspectorClosed = "closed"
+ InspectorCookie = "docs-inspector"
+)
+
+// inspectorState reads it, defaulting to open. Closed in the strong sense
+// viewMode is: only exactly "closed" is closed, and the value is a key
+// into this comparison, never a string that gets printed.
+func inspectorState(r *http.Request) string {
+ c, err := r.Cookie(InspectorCookie)
+ if err != nil || c.Value != InspectorClosed {
+ return InspectorOpen
+ }
+ return InspectorClosed
+}
+
// fileItems is the File menu, whose first entry is the one thing in this
// bar a guest may not do.
//
diff --git a/internal/docs/render.go b/internal/docs/render.go
index 06cb83e..85ccdb5 100644
--- a/internal/docs/render.go
+++ b/internal/docs/render.go
@@ -480,8 +480,19 @@ var Catalog = rastrillo.Catalog{
// sits next to three headings and the question it answers is
// "which of these is this line", and "Numbered list" rather than
// "Ordered list" for the same reason.
- "docs.editor.toolbar.label": "Formatting",
- "docs.editor.toolbar.undo": "Undo",
+ "docs.editor.toolbar.label": "Formatting",
+ "docs.editor.toolbar.undo": "Undo",
+ // The inspector (spec I2): the undo/redo pair's name, the four
+ // sections' visible labels (each the name of its role="group"), the
+ // panel's own name, and the bar's Format toggle that shows and hides
+ // it.
+ "docs.editor.toolbar.history": "History",
+ "docs.editor.toolbar.group.style": "Style",
+ "docs.editor.toolbar.group.text": "Text",
+ "docs.editor.toolbar.group.align": "Alignment",
+ "docs.editor.toolbar.group.lists": "Lists",
+ "docs.editor.inspector.label": "Format",
+ "docs.editor.inspector.toggle": "Format",
"docs.editor.toolbar.redo": "Redo",
"docs.editor.toolbar.bold": "Bold",
"docs.editor.toolbar.italic": "Italic",
@@ -772,6 +783,23 @@ func (rd *renderer) pageStatus(w http.ResponseWriter, r *http.Request, name stri
return writeGuardedBody(w, r, status, buf.Bytes())
}
+// fragment renders one named template of a page's set into markup the
+// page's data carries on: the editor's menu bar and undo/redo pair go into
+// estilo's bar slots (chrome.Bar.Menubar and Lead), which take trusted
+// template.HTML. Rendered here, from views/partials, so they are this
+// app's own template output and nothing a person typed.
+func (rd *renderer) fragment(page, name string, data any) (template.HTML, error) {
+ tmpl, ok := rd.pages[page]
+ if !ok {
+ return "", fmt.Errorf("docs: unknown page %q", page)
+ }
+ var buf bytes.Buffer
+ if err := tmpl.ExecuteTemplate(&buf, name, data); err != nil {
+ return "", fmt.Errorf("docs: render %q: %w", name, err)
+ }
+ return template.HTML(buf.String()), nil // #nosec: our own template's output
+}
+
// vendoredStaticFS builds the static/ tree rastrillo.Assets serves —
// estilo's theme for Docs (Calma, with Docs' accent; estilo AGENTS.md,
// decisions table, row 8), plus tokens.css and the three scripts
@@ -821,7 +849,7 @@ func vendoredStaticFS() (fs.FS, error) {
// import page (import.go).
"static/estilo/" + googleimport.JSName(): {Data: googleimport.JS()},
}
- for _, name := range []string{"icon-32.png", "apple-touch-icon.png", "brand.css", "LICENSE.lucide", "light.css", "pointer.js", "list.js", "share-pop.js", "share-pop.css"} {
+ for _, name := range []string{"icon-32.png", "apple-touch-icon.png", "brand.css", "LICENSE.lucide", "light.css", "pointer.js", "list.js", "share-pop.js", "share-pop.css", "inspector.js"} {
body, err := brandFS.ReadFile("brand/" + name)
if err != nil {
return nil, err
diff --git a/internal/docs/share_nav_test.go b/internal/docs/share_nav_test.go
index e9237e2..3a60164 100644
--- a/internal/docs/share_nav_test.go
+++ b/internal/docs/share_nav_test.go
@@ -35,15 +35,27 @@ func TestTheOwnerGetsAShareControlInTheBar(t *testing.T) {
// group, beside the account menu, rather than anywhere on the page. A
// test that only asserted presence would pass on a link buried in the
// footer.
+ //
+ // And order (spec I2): the header's controls are one set, undo/redo in
+ // the lead, then Format, then Share, the one primary, last before the
+ // account.
end := strings.Index(body, "<div estilo-bar-end>")
if end < 0 {
t.Fatal("the bar has no end group")
}
tail := body[end:]
+ lead := strings.Index(tail, "<div estilo-bar-lead>")
+ format := strings.Index(tail, `<div estilo-bar-control="wide"><button rst-btn type="button" aria-expanded="true" aria-controls="docs-inspector" disabled data-estilo-toggle estilo-bar-wide>`)
+ link := strings.Index(tail, `<div estilo-bar-control="primary"><a rst-btn="primary" href="/d/`+sqid+`/share">`)
acct := strings.Index(tail, "<details estilo-account")
- link := strings.Index(tail, `<div estilo-bar-actions><a rst-btn href="/d/`+sqid+`/share">`)
- if link < 0 || acct < 0 || link > acct {
- t.Error("the share control is not in the bar's actions before the account menu")
+ if lead < 0 || format < 0 || link < 0 || acct < 0 {
+ t.Fatalf("the bar's end group lacks a piece: lead %d, Format %d, Share %d, account %d", lead, format, link, acct)
+ }
+ if !(lead < format && format < link && link < acct) {
+ t.Errorf("the bar's end group is out of order: lead %d, Format %d, Share %d, account %d; want lead, Format, Share, account", lead, format, link, acct)
+ }
+ if strings.Count(tail[:acct], "estilo-bar-control=\"primary\"") != 1 {
+ t.Error("Share is not the bar's one primary action")
}
}
diff --git a/internal/docs/views/partials/editor_bar.html b/internal/docs/views/partials/editor_bar.html
new file mode 100644
index 0000000..6dd2efa
--- /dev/null
+++ b/internal/docs/views/partials/editor_bar.html
@@ -0,0 +1,74 @@
+{{/* The editor's pieces of the estilo bar (spec I2, revision 2's P2:
+ "both are rendered by Docs from views/ partials"). handlers.go's show
+ renders docs-menubar into chrome.Bar.Menubar and docs-history into
+ chrome.Bar.Lead, through renderer.fragment, so the markup is still
+ this app's template and TestOurTemplatesUseTheAttributeGrammar
+ reads it like any other. */}}
+
+{{/* docs-menubar: the document's menu bar (internal/docs/menu.go for
+ the model and the copy, fixtures/menu.mjs for the keyboard
+ behaviour). estilo draws it under the title from 800px and as the
+ header's second row below that; there is one in the page.
+
+ Each menu is a <details>, and that is the load-bearing decision on
+ this screen rather than a convenience. The export links work with
+ scripts disabled and the whole read view is built on that guarantee
+ (editor_view_test.go's TestShowRendersContentWithoutScript); a
+ JS-driven role="menubar" would have moved the only route to a
+ person's own document behind a control that never opens for them.
+ <details> opens with no script at all, and name="estilo-menus" makes
+ the six an exclusive group with the bar's account menu, switcher and
+ Menu sheet (spec §7.1).
+
+ It stays a disclosure rather than being relabelled role="menubar"
+ with role="menuitem" children: declaring the menu pattern promises
+ typeahead and submenu semantics, and delivering less than that is
+ worse for a screen reader user than the honest disclosure.
+ fixtures/menu.mjs only ADDS to this: arrow keys between and within
+ menus, Escape to close, and a roving tabindex so the bar is one tab
+ stop.
+
+ There are no submenus, and there will not be: a nested <details>
+ inside a name= group collapses its parent. Data: menuView. */}}
+{{define "docs-menubar"}}<nav estilo-menubar aria-label="{{.Label}}">
+ {{range .Menus}}{{$checks := .Checks}}<details estilo-menubar-menu name="estilo-menus" id="docs-menu-{{.ID}}">
+ <summary estilo-menubar-title>{{.Title}}</summary>
+ <div estilo-menu>
+ {{range .Items}}
+ {{- if eq .Kind "divider"}}<hr>
+ {{- else if eq .Kind "link"}}<a estilo-menu-item href="{{.Href}}"{{if .Download}} download{{end}}{{if .JumpTo}} data-docs-jumpto{{end}}{{with .Shortcut}} data-docs-shortcut="{{.}}"{{end}}>{{if $checks}}<span estilo-menu-check aria-hidden="true"></span>{{end}}<span estilo-menu-label>{{.Label}}</span>{{with .Shortcut}}<kbd estilo-menu-key aria-hidden="true">{{.}}</kbd>{{end}}</a>
+ {{- else if eq .Kind "form"}}<form method="post" action="{{.Action}}"><button estilo-menu-item type="submit">{{if $checks}}<span estilo-menu-check aria-hidden="true"></span>{{end}}<span estilo-menu-label>{{.Label}}</span></button></form>
+ {{- else}}{{/* Every command item ships disabled, because without
+ the bundle there is no editor to act on; fixtures/menu.mjs
+ enables each as soon as the editor mounts, and afterwards
+ exactly when its command would do something. A checkable
+ item carries aria-pressed on every row of its group, and
+ the check glyph, not colour, shows the current one. */}}<button estilo-menu-item type="button" data-docs-command="{{.Command}}"{{with .Shortcut}} data-docs-shortcut="{{.}}"{{end}}{{if .Checkable}} aria-pressed="{{if .Pressed}}true{{else}}false{{end}}"{{end}} disabled>{{if $checks}}<span estilo-menu-check aria-hidden="true">{{if .Checkable}}{{template "estilo-icon-check"}}{{end}}</span>{{end}}<span estilo-menu-label>{{.Label}}</span>{{with .Shortcut}}<kbd estilo-menu-key aria-hidden="true">{{.}}</kbd>{{end}}</button>
+ {{- end}}
+ {{end}}
+ </div>
+ </details>{{end}}
+</nav>{{end}}
+
+{{/* docs-history: undo and redo, the one pair (spec I2, P1.2 and C6).
+ It is drawn twice and shown once: in the bar's lead slot from 800px
+ ([docs-history="lead"], inside estilo's [estilo-bar-lead]), and in
+ the strip below 800px, where the stacked header has no room for it
+ (show.html's CSS shows exactly one). Neither is inside the
+ role="toolbar" and neither is in its roving tab stop: they are two
+ ordinary buttons. fixtures/toolbar.mjs binds both by
+ data-docs-command and keeps both current, and editor-entry.js makes
+ both inert during a font wait. Disabled until the editor mounts,
+ like every control that needs it. Data: historyView. */}}
+{{define "docs-history"}}<div docs-history{{if .Lead}}="lead"{{end}} role="group" aria-label="{{.Label}}">
+ <button docs-tool type="button" data-docs-command="undo" aria-label="{{.Undo}}" disabled>
+ <svg viewBox="-0.75 2 20 20" aria-hidden="true" focusable="false"><path d="M6 6 3 9l3 3"/><path d="M3 9h8a4.5 4.5 0 0 1 0 9H7"/></svg>
+ </button>
+ <button docs-tool type="button" data-docs-command="redo" aria-label="{{.Redo}}" disabled>
+ <svg viewBox="0.75 2 20 20" aria-hidden="true" focusable="false"><path d="m14 6 3 3-3 3"/><path d="M17 9H9a4.5 4.5 0 0 0 0 9h4"/></svg>
+ </button>
+ </div>{{end}}
+
+{{/* docs-icon-format: Format's pencil, chrome.Action.Icon (estilo draws
+ it in the bar only; the label still names the button). */}}
+{{define "docs-icon-format"}}<svg viewBox="0 0 20 20" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M13.5 3.5a2.1 2.1 0 0 1 3 3L7 16l-4 1 1-4z"/><path d="m12 5 3 3"/></svg>{{end}}
diff --git a/internal/docs/views/show.html b/internal/docs/views/show.html
index 197af8a..33b247b 100644
--- a/internal/docs/views/show.html
+++ b/internal/docs/views/show.html
@@ -1402,37 +1402,10 @@
from this attribute, because a title is arbitrary text a person
typed and sanitising it belongs server-side (handlers.go's
exportFilename). */}}
-{{/* The menu bar (internal/docs/menu.go for the model and the copy,
- fixtures/menu.mjs for the keyboard behaviour).
-
- Each menu is a <details>, and that is the load-bearing decision on
- this screen rather than a convenience. The export links work today
- with scripts disabled and the whole read view is built on that
- guarantee (editor_view_test.go's TestShowRendersContentWithoutScript);
- a JS-driven role="menubar" would have moved the only route to a
- person's own document behind a control that never opens for them.
- <details> opens with no script at all, and name="estilo-menus"
- makes the five an exclusive group — opening one closes the rest —
- with no state for anything to keep. It is the SAME group as the
- bar's account menu, switcher and Menu sheet, so opening File closes
- the account menu and the other way round (spec §7.1).
-
- It stays a disclosure rather than being relabelled role="menubar"
- with role="menuitem" children. <summary> is a real disclosure
- control that browsers and assistive technology already handle
- correctly; declaring the menu pattern promises typeahead and
- submenu semantics, and delivering less of it than that is worse for
- a screen reader user than the honest disclosure it replaced.
- fixtures/menu.mjs only ADDS to this: arrow keys between and within
- menus, Escape to close, and a roving tabindex so the bar is one tab
- stop. With no JavaScript every one of these still opens, and every
- item that is a link or a form still works.
-
- There are no submenus anywhere, and there will not be: a nested
- <details> inside a name= group collapses its parent (rastrillo's
- rst-menus trap, which the Sheets session hit first). So "Download
- as PDF" is a sibling of "New document" rather than a child of a
- "Download" submenu. */}}
+{{/* The menu bar is in the estilo bar now (spec I2: chrome.Bar.Menubar,
+ rendered from views/partials/editor_bar.html's docs-menubar): under
+ the title from 800px, and estilo's second row below that. There is
+ one menu bar in the page; this strip no longer draws its own. */}}
{{/* [docs-chrome] is the single sticky element wrapping both bars.
It was styled and never rendered for one review cycle, which cost
@@ -1445,25 +1418,6 @@
Both rules were correct. Neither had an element. */}}
<div docs-chrome>
-<nav estilo-menubar aria-label="{{.Menu.Label}}">
- {{range .Menu.Menus}}{{$checks := .Checks}}<details estilo-menubar-menu name="estilo-menus" id="docs-menu-{{.ID}}">
- <summary estilo-menubar-title>{{.Title}}</summary>
- <div estilo-menu>
- {{range .Items}}
- {{- if eq .Kind "divider"}}<hr>
- {{- else if eq .Kind "link"}}<a estilo-menu-item href="{{.Href}}"{{if .Download}} download{{end}}{{if .JumpTo}} data-docs-jumpto{{end}}{{with .Shortcut}} data-docs-shortcut="{{.}}"{{end}}>{{if $checks}}<span estilo-menu-check aria-hidden="true"></span>{{end}}<span estilo-menu-label>{{.Label}}</span>{{with .Shortcut}}<kbd estilo-menu-key aria-hidden="true">{{.}}</kbd>{{end}}</a>
- {{- else if eq .Kind "form"}}<form method="post" action="{{.Action}}"><button estilo-menu-item type="submit">{{if $checks}}<span estilo-menu-check aria-hidden="true"></span>{{end}}<span estilo-menu-label>{{.Label}}</span></button></form>
- {{- else}}{{/* Every command item ships disabled, because without
- the bundle there is no editor to act on; fixtures/menu.mjs
- enables each as soon as the editor mounts, and afterwards
- exactly when its command would do something. A checkable
- item carries aria-pressed on every row of its group, and
- the check glyph, not colour, shows the current one. */}}<button estilo-menu-item type="button" data-docs-command="{{.Command}}"{{with .Shortcut}} data-docs-shortcut="{{.}}"{{end}}{{if .Checkable}} aria-pressed="{{if .Pressed}}true{{else}}false{{end}}"{{end}} disabled>{{if $checks}}<span estilo-menu-check aria-hidden="true">{{if .Checkable}}{{template "estilo-icon-check"}}{{end}}</span>{{end}}<span estilo-menu-label>{{.Label}}</span>{{with .Shortcut}}<kbd estilo-menu-key aria-hidden="true">{{.}}</kbd>{{end}}</button>
- {{- end}}
- {{end}}
- </div>
- </details>{{end}}
-</nav>
<div docs-bar>
{{/* The formatting bar (fixtures/toolbar.mjs). Rendered server-side,
with every label resolved from the catalog (render.go's
@@ -1484,15 +1438,22 @@
from the catalog rather than from its glyph: a button whose only
content is a "B" announces as "B" to a screen reader without
one. */}}
+{{/* Undo and redo, below 800px: the bar's lead slot carries the same
+ pair from 800px (views/partials/editor_bar.html). Outside the
+ toolbar, and out of its roving tab stop (spec I2, P1.2 and C6). */}}
+{{template "docs-history" .Toolbar.StripHistory}}
+{{/* The inspector (spec I2): from 64rem the formatting bar is a panel
+ floating under the header at the inline end, its groups labelled
+ sections; from 800px to 64rem it is the strip under the header, and
+ below 800px the phone's strip, as before. One element at every
+ width, so one role="toolbar", one roving tab stop, and one set of
+ tests. The aside is what the bar's Format toggle controls; its
+ state is the docs-inspector cookie's, rendered here (menu.go's
+ inspectorState), and closed hides it only at 64rem and up: below
+ that the strip shows regardless (C3). rst-box makes it a card for
+ rastrillo's light.js, whose rim and wash brand/light.css draws. */}}
+<aside docs-inspector id="{{.InspectorID}}" rst-box data-state="{{.Inspector}}" aria-label="{{.Toolbar.Inspector}}">
<div docs-toolbar role="toolbar" aria-orientation="horizontal" aria-label="{{.Toolbar.Label}}">
- <div docs-toolbar-group>
- <button docs-tool tabindex="-1" type="button" data-docs-command="undo" aria-label="{{.Toolbar.Undo}}" disabled>
- <svg viewBox="-0.75 2 20 20" aria-hidden="true" focusable="false"><path d="M6 6 3 9l3 3"/><path d="M3 9h8a4.5 4.5 0 0 1 0 9H7"/></svg>
- </button>
- <button docs-tool tabindex="-1" type="button" data-docs-command="redo" aria-label="{{.Toolbar.Redo}}" disabled>
- <svg viewBox="0.75 2 20 20" aria-hidden="true" focusable="false"><path d="m14 6 3 3-3 3"/><path d="M17 9H9a4.5 4.5 0 0 0 0 9h4"/></svg>
- </button>
- </div>
{{/* The three selects opt into rastrillo's searchable-select
enhancement (ui/select.js, already served by render.go's
vendoredStaticFS and linked by the shell's own layout). Paul's
@@ -1521,7 +1482,8 @@
toolbar.mjs mirrors it onto the combobox by hand. Left alone,
the enhancement ships a control that looks usable, accepts focus
and typing, and drives a disabled select behind it. */}}
- <div docs-toolbar-group>
+ <div docs-toolbar-group="style" role="group" aria-labelledby="docs-group-style">
+ <span docs-toolbar-label id="docs-group-style">{{.Toolbar.GroupStyle}}</span>
<select docs-tool-select rst-input id="docs-select-block" tabindex="-1" disabled data-docs-select="block" aria-label="{{.Toolbar.BlockLabel}}"
data-rst-select data-rst-select-filter="{{.Toolbar.SelectFilter}}" data-rst-select-results="{{.Toolbar.SelectResults}}" data-rst-select-result-one="{{.Toolbar.SelectResultOne}}">
{{range .Toolbar.Blocks}}<option value="{{.Value}}" data-rst-class="docs-style-{{.Value}}">{{.Label}}</option>{{end}}
@@ -1540,7 +1502,8 @@
{{range .Toolbar.Sizes}}<option value="{{.Value}}">{{.Label}}</option>{{end}}
</select>
</div>
- <div docs-toolbar-group>
+ <div docs-toolbar-group="text" role="group" aria-labelledby="docs-group-text">
+ <span docs-toolbar-label id="docs-group-text">{{.Toolbar.GroupText}}</span>
<button docs-tool tabindex="-1" type="button" data-docs-command="strong" aria-label="{{.Toolbar.Bold}}" aria-pressed="false" disabled>
<span docs-tool-glyph="bold" aria-hidden="true">B</span>
</button>
@@ -1564,7 +1527,8 @@
that serves B/I/<> — see that rule's own comment, which used to
claim the weight covered every button and did not (§10.3: colour
never carries meaning alone). */}}
- <div docs-toolbar-group>
+ <div docs-toolbar-group="align" role="group" aria-labelledby="docs-group-align">
+ <span docs-toolbar-label id="docs-group-align">{{.Toolbar.GroupAlign}}</span>
<button docs-tool tabindex="-1" type="button" data-docs-command="align_left" aria-label="{{.Toolbar.AlignLeft}}" aria-pressed="false" disabled>
<svg viewBox="0 0 20 20" aria-hidden="true" focusable="false"><path d="M3 5h14M3 9h9M3 13h14M3 17h9"/></svg>
</button>
@@ -1575,7 +1539,8 @@
<svg viewBox="0 0 20 20" aria-hidden="true" focusable="false"><path d="M3 5h14M8 9h9M3 13h14M8 17h9"/></svg>
</button>
</div>
- <div docs-toolbar-group>
+ <div docs-toolbar-group="lists" role="group" aria-labelledby="docs-group-lists">
+ <span docs-toolbar-label id="docs-group-lists">{{.Toolbar.GroupLists}}</span>
<button docs-tool tabindex="-1" type="button" data-docs-command="bullet_list" aria-label="{{.Toolbar.BulletList}}" aria-pressed="false" disabled>
<svg viewBox="0 0 20 20" aria-hidden="true" focusable="false"><circle cx="4" cy="6" r="1.1" fill="currentColor" stroke="none"/><circle cx="4" cy="10" r="1.1" fill="currentColor" stroke="none"/><circle cx="4" cy="14" r="1.1" fill="currentColor" stroke="none"/><path d="M8 6h9M8 10h9M8 14h9"/></svg>
</button>
@@ -1587,6 +1552,7 @@
</button>
</div>
</div>
+</aside>
</div>
{{/* What the page says about its fonts, just under the bars: a font
is loading, a change was refused while it did, a font could not be
@@ -1694,5 +1660,9 @@
has a Share in the bar. */}}
{{if .CanShare}}<link rel="stylesheet" href="{{asset "static/brand/share-pop.css"}}">
<script defer src="{{asset "static/brand/share-pop.js"}}"></script>{{end}}
+{{/* The Format toggle (brand/inspector.js): enables the bar's button,
+ shows and hides the inspector and remembers it in the cookie. Without
+ it the button stays disabled and the inspector open. */}}
+<script defer src="{{asset "static/brand/inspector.js"}}"></script>
{{template "docs-jumpto" .}}
{{end}}