oficina / estilo Public

chrome: Bar.Menubar and Bar.Lead slots, WideOnly and toggle actions, the title's size

Bar.Menubar (template.HTML) is drawn under the title in <div
estilo-bar-stack> and makes the header estilo-bar~="stacked" ("sticky
stacked" with Sticky). Bar.Lead is drawn first in the end group at
every width and never in the Menu sheet. In a bar with either slot each
action sits in <div estilo-bar-control> ("primary", "wide"), the hook
the controls set is styled on, since estilo's CSS never selects rst-.

Action.WideOnly marks the action estilo-bar-wide and leaves it out of
the sheet; a sheet left empty is not drawn. Action.Icon is an optional
app glyph before the label. A toggle action (menu.Item.Controls) is a
disabled <button aria-expanded aria-controls data-estilo-toggle>.

A stacked bar's title is estilo-bar-title-fit, the same form with
size=TitleEdit.Size(): the title's length in characters, at least 4.

A bar with neither slot is byte for byte main's (goldens).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev f42d56c0a95f134821c5ce87cf7bdb1268082535 parent fc949b7
3 files changed, +337 −20
  • chrome/chrome.go +44 −5
  • chrome/stack_test.go +237 −0
  • chrome/templates/bar.html +56 −15

CI passed — run details

diff --git a/chrome/chrome.go b/chrome/chrome.go
index a51b5b4..c424cf3 100644
--- a/chrome/chrome.go
+++ b/chrome/chrome.go
@@ -21,10 +21,12 @@ package chrome
import (
"embed"
+ "html/template"
"net/http"
"strings"
"time"
"unicode"
+ "unicode/utf8"
"amadan.net/oficina/estilo.git/menu"
"amadan.net/oficina/estilo.git/sky"
@@ -48,8 +50,8 @@ func CSS() []byte { return append([]byte(nil), css...) }
// editable title on Escape. Nothing depends on it.
func JS() []byte { return append([]byte(nil), js...) }
-// Templates holds estilo-bar, estilo-bar-title, estilo-bar-actions,
-// estilo-account, estilo-switcher, estilo-error, estilo-signin,
+// Templates holds estilo-bar, estilo-bar-title, estilo-bar-title-fit,
+// estilo-bar-actions, estilo-bar-action, estilo-account, estilo-switcher, estilo-error, estilo-signin,
// estilo-signin-sent, estilo-signed-out and the bar's icons.
func Templates() embed.FS { return templateFS }
@@ -76,10 +78,21 @@ type TitleEdit struct {
Label, Submit string
}
+// Size is the title field's size attribute in a stacked bar
+// (Bar.Menubar set), where the field is as wide as its title rather than
+// the bar's room: the title's length in characters, and never under 4,
+// so an empty or one-letter title still leaves something to click.
+// It is a first approximation, painted before any script runs;
+// chrome.js then measures the field and corrects its width (a few pixels
+// either way). Nothing after the title on its row moves when it does.
+func (t TitleEdit) Size() int {
+ return max(4, utf8.RuneCountInString(t.Value))
+}
+
// Action is one page action. Its Item says what activating it does (a
-// link, a POST or a dialog; see menu.Item), so the bar's button and the
-// Menu sheet's row are the same element kind and cannot disagree. Primary
-// marks the page's main action, drawn as the primary button.
+// link, a POST, a dialog or a toggle; see menu.Item), so the bar's button
+// and the Menu sheet's row are the same element kind and cannot disagree.
+// Primary marks the page's main action, drawn as the primary button.
//
// Docs' actions were all links (chrome.Link). Sheets' Create is a POST,
// and a link in the sheet would be a GET to the list that creates
@@ -87,6 +100,15 @@ type TitleEdit struct {
type Action struct {
menu.Item
Primary bool
+ // WideOnly is an action that only means something on a wide screen
+ // (Docs' Format, which toggles an inspector that exists only from
+ // 64rem): the bar hides it below 64rem (estilo-bar-wide) and the
+ // narrow Menu sheet leaves it out.
+ WideOnly bool
+ // Icon is an optional decorative glyph drawn before the label in the
+ // 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
}
// BarLabels are the bar's own strings: the skip link (rendered by the
@@ -118,6 +140,23 @@ type Bar struct {
// Sticky pins the bar to the top of the viewport.
Sticky bool
Labels BarLabels
+ // Menubar is the app's menu bar ([estilo-menubar] markup it rendered
+ // itself, File, Edit...). Set, it makes the bar stacked
+ // (estilo-bar~="stacked"): from 800px the 56px header with the title
+ // over the menus beside a 32px icon, and below 800px the one-row bar
+ // with the menus as a full-width second row under it. The bar's height
+ // is published as --estilo-bar-block-size either way. Trusted markup:
+ // the app's own template output, never user input.
+ Menubar template.HTML
+ // Lead is app markup drawn at the start of the end group, before the
+ // actions, at every width (Docs' undo/redo pair). It never goes into
+ // the Menu sheet; the app hides it where it does not want it. Trusted
+ // markup, like Menubar.
+ //
+ // A bar with Menubar or Lead set draws its end group as one set of
+ // controls (28px pills, the avatar as a circle, a divider before the
+ // account); a bar with neither is unchanged.
+ Lead template.HTML
}
// AccountLabels are the account menu's headings.
diff --git a/chrome/stack_test.go b/chrome/stack_test.go
new file mode 100644
index 0000000..6ae7d26
--- /dev/null
+++ b/chrome/stack_test.go
@@ -0,0 +1,237 @@
+package chrome
+
+import (
+ "html/template"
+ "regexp"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/estilo.git/menu"
+)
+
+// What Docs puts in the slots: its own menu bar and its undo/redo pair,
+// markup it rendered itself.
+const (
+ testMenubar = template.HTML(`<nav estilo-menubar aria-label="Menus"><details estilo-menubar-menu name="estilo-menus"><summary estilo-menubar-title>File</summary><div estilo-menu></div></details></nav>`)
+ testLead = template.HTML(`<button type="button" data-docs-command="undo" aria-label="Undo"></button>`)
+)
+
+func stacked() Bar {
+ b := signedIn("x")
+ b.Menubar = testMenubar
+ return b
+}
+
+func header(html string) string { return html[:strings.Index(html, ">")+1] }
+
+// The Menubar slot makes the bar stacked, and only it does: the title and
+// the app's menus share one stack, so the same markup serves the 56px
+// header from 800px and the two-row bar below it.
+func TestTheMenubarSlotStacksTheBar(t *testing.T) {
+ b := stacked()
+ html := render(t, "estilo-bar", b)
+ if got := header(html); got != `<header estilo-bar="stacked">` {
+ t.Errorf("a bar with a menubar opens %s", got)
+ }
+ stack := html[strings.Index(html, "<div estilo-bar-stack>"):strings.Index(html, "<div estilo-bar-end>")]
+ title := strings.Index(stack, "<form estilo-bar-title")
+ menus := strings.Index(stack, "<div estilo-bar-menubar>"+string(testMenubar)+"</div>")
+ if title < 0 || menus < 0 || menus < title {
+ t.Fatalf("the stack is not the title over the app's menubar, verbatim:\n%s", stack)
+ }
+ if strings.Count(html, "estilo-menubar-title") != 1 {
+ t.Error("the menubar is drawn more than once; the narrow row must be the same markup")
+ }
+
+ b.Sticky = true
+ if got := header(render(t, "estilo-bar", b)); got != `<header estilo-bar="sticky stacked">` {
+ t.Errorf("a sticky stacked bar opens %s", got)
+ }
+
+ // A read-only title (a public page) stacks the same way.
+ b.ContextEdit, b.Context = nil, "A document"
+ html = render(t, "estilo-bar", b)
+ if !strings.Contains(html, "<div estilo-bar-stack>\n <span estilo-bar-context dir=\"auto\" title=\"A document\">A document</span>\n <div estilo-bar-menubar>") {
+ t.Errorf("the read-only title is not in the stack:\n%s", html)
+ }
+
+ // Lead alone does not stack the bar, and neither slot set draws no
+ // stack at all.
+ b = signedIn("x")
+ b.Lead = testLead
+ html = render(t, "estilo-bar", b)
+ if strings.Contains(header(html), "stacked") || strings.Contains(html, "estilo-bar-stack") || strings.Contains(html, "estilo-bar-menubar") {
+ t.Errorf("a bar with only a lead is stacked:\n%s", header(html))
+ }
+ html = render(t, "estilo-bar", signedIn("x"))
+ if strings.Contains(html, "stacked") || strings.Contains(html, "estilo-bar-stack") {
+ t.Error("a bar with no slots is stacked")
+ }
+}
+
+// The lead opens the end group, before the actions, at every width, and
+// never goes into the Menu sheet: it is the app's, not an action.
+func TestTheLeadSlotOpensTheEndGroup(t *testing.T) {
+ b := stacked()
+ b.Lead = testLead
+ html := render(t, "estilo-bar", b)
+ end := html[strings.Index(html, "<div estilo-bar-end>"):]
+ if !strings.HasPrefix(end, "<div estilo-bar-end>\n <div estilo-bar-lead>"+string(testLead)+"</div>\n <div estilo-bar-actions>") {
+ t.Errorf("the lead is not first in the end group, before the actions:\n%s", end)
+ }
+ sheet := html[strings.Index(html, `<div estilo-menu="sheet">`):]
+ sheet = sheet[:strings.Index(sheet, "</details>")]
+ if strings.Contains(sheet, "data-docs-command") {
+ t.Error("the lead went into the Menu sheet")
+ }
+ // The end group's order stands with a lead in it.
+ order := []string{"<div estilo-bar-lead>", "<div estilo-bar-actions>", "<details estilo-bar-more", "<details estilo-switcher", "<details estilo-account"}
+ last := -1
+ for _, marker := range order {
+ i := strings.Index(html, marker)
+ if i < 0 || i < last {
+ t.Fatalf("%q is missing or out of order", marker)
+ }
+ last = i
+ }
+}
+
+// Format toggles an inspector that exists only from 64rem: the bar marks
+// it estilo-bar-wide (hidden below 64rem) and the narrow sheet leaves it
+// out. A sheet with nothing left in it is not drawn.
+func TestAWideOnlyActionStaysOutOfTheSheet(t *testing.T) {
+ b := stacked()
+ b.Actions = []Action{
+ {Item: menu.Item{Controls: "docs-inspector", Expanded: true, Label: "x-format"}, WideOnly: true},
+ {Item: menu.Item{Href: "/d/abc/share", Label: "x-share"}, Primary: true},
+ }
+ 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="wide"><button rst-btn type="button" aria-expanded="true" aria-controls="docs-inspector" disabled data-estilo-toggle estilo-bar-wide>x-format</button></div>`) {
+ t.Errorf("the wide-only toggle is not marked in the bar:\n%s", actions)
+ }
+ sheet := html[strings.Index(html, `<div estilo-menu="sheet">`):strings.Index(html, "<details estilo-switcher")]
+ if strings.Contains(sheet, "x-format") {
+ t.Errorf("the wide-only action is in the Menu sheet:\n%s", sheet)
+ }
+ if !strings.Contains(sheet, "x-share") {
+ t.Errorf("an ordinary action left the Menu sheet:\n%s", sheet)
+ }
+
+ // Only wide-only actions and no nav: no Menu at all, not an empty one.
+ b.Nav = nil
+ b.Actions = b.Actions[:1]
+ html = render(t, "estilo-bar", b)
+ if strings.Contains(html, "estilo-bar-more") {
+ t.Error("a Menu sheet was drawn with nothing in it")
+ }
+ if !strings.Contains(html, "x-format") {
+ t.Error("the wide-only action left the bar too")
+ }
+ // Nav and only wide-only actions: the nav, and no rule after it.
+ b.Nav = []Link{{Href: "/", Label: "x-nav"}}
+ html = render(t, "estilo-bar", b)
+ if !strings.Contains(html, "estilo-bar-more") {
+ t.Fatal("the nav's Menu sheet is gone")
+ }
+ sheet = html[strings.Index(html, `<div estilo-menu="sheet">`):strings.Index(html, "<details estilo-switcher")]
+ if strings.Contains(sheet, "<hr>") {
+ t.Errorf("the sheet rules off actions it does not hold:\n%s", sheet)
+ }
+
+ // Every kind carries the mark, on its outermost element.
+ for _, it := range []menu.Item{{Href: "/h", Label: "l"}, {Action: "/p", Label: "l"}, {Dialog: "d", Label: "l"}, {Controls: "c", Label: "l"}} {
+ html := render(t, "estilo-bar-action", Action{Item: it, WideOnly: true})
+ if open := html[:strings.Index(html, ">")+1]; !strings.HasSuffix(open, " estilo-bar-wide>") {
+ t.Errorf("%+v: the outermost element %s is not marked", it, open)
+ }
+ }
+}
+
+// The toggle kind in the bar: a button that names its region and its
+// state and is disabled as rendered, until the app's script binds it.
+func TestAToggleActionIsDisabledUntilBound(t *testing.T) {
+ for _, c := range []struct {
+ a Action
+ want string
+ }{
+ {Action{Item: menu.Item{Controls: "docs-inspector", Label: "Format"}}, `<button rst-btn type="button" aria-expanded="false" aria-controls="docs-inspector" disabled data-estilo-toggle>Format</button>`},
+ {Action{Item: menu.Item{Controls: "docs-inspector", Expanded: true, Label: "Format"}}, `<button rst-btn type="button" aria-expanded="true" aria-controls="docs-inspector" disabled data-estilo-toggle>Format</button>`},
+ {Action{Item: menu.Item{Controls: "p", Label: "Panel"}, Primary: true}, `<button rst-btn="primary" type="button" aria-expanded="false" aria-controls="p" disabled data-estilo-toggle>Panel</button>`},
+ } {
+ if got := render(t, "estilo-bar-action", c.a); got != c.want {
+ t.Errorf("got %s\nwant %s", got, c.want)
+ }
+ }
+ // The icon is the app's own markup, drawn before the label in the bar.
+ icon := template.HTML(`<svg aria-hidden="true"></svg>`)
+ if got := render(t, "estilo-bar-action", Action{Item: menu.Item{Controls: "c", Label: "Format"}, Icon: icon}); !strings.HasSuffix(got, `data-estilo-toggle><svg aria-hidden="true"></svg>Format</button>`) {
+ t.Errorf("the icon is not before the label: %s", got)
+ }
+}
+
+// In a bar with a slot each action sits in a display: contents wrapper
+// the controls set is styled on (estilo's CSS never selects rst-btn), and
+// the primary one says so. A bar without a slot draws them bare
+// (TestABarWithoutSlotsIsByteForByteUnchanged).
+func TestSlottedBarsWrapEachActionAsAControl(t *testing.T) {
+ for name, b := range map[string]Bar{"menubar": stacked(), "lead": func() Bar { b := signedIn("x"); b.Lead = testLead; return b }()} {
+ html := render(t, "estilo-bar", b)
+ actions := html[strings.Index(html, "<div estilo-bar-actions>"):strings.Index(html, "<details estilo-bar-more")]
+ for _, want := range []string{
+ `<div estilo-bar-control><a rst-btn href="/d/abc/share">x-share</a></div>`,
+ `<div estilo-bar-control="primary"><form method="post" action="/d/new"><button rst-btn="primary" type="submit">x-create</button></form></div>`,
+ } {
+ if !strings.Contains(actions, want) {
+ t.Errorf("%s: the actions lack %s in\n%s", name, want, actions)
+ }
+ }
+ }
+}
+
+// The first paint's width for the title field: its length in characters
+// (not bytes), and never under 4.
+func TestTheTitleSizeIsItsLengthInCharacters(t *testing.T) {
+ for value, want := range map[string]int{"": 4, "Q3": 4, "Untitled document": 17, "Café plans": 10, "日本語のタイトル": 8, "مستند بلا عنوان": 15} {
+ if got := (TitleEdit{Value: value}).Size(); got != want {
+ t.Errorf("Size(%q) = %d, want %d", value, got, want)
+ }
+ }
+ b := stacked()
+ b.ContextEdit.Value = "Café plans"
+ html := render(t, "estilo-bar", b)
+ if !strings.Contains(html, `<input estilo-bar-title-input name="title" value="Café plans" size="10" aria-label=`) {
+ t.Errorf("the stacked title has no size from its length:\n%s", html)
+ }
+ // Only a stacked bar sizes its title to the text.
+ if strings.Contains(render(t, "estilo-bar", signedIn("x")), " size=") {
+ t.Error("a one-row bar's title has a size")
+ }
+}
+
+// The two title forms are one form: the fitted one is the plain one plus
+// its size attribute, so they cannot drift apart.
+func TestTheFittedTitleIsTheTitlePlusASize(t *testing.T) {
+ edit := signedIn("x").ContextEdit
+ plain := render(t, "estilo-bar-title", edit)
+ fit := render(t, "estilo-bar-title-fit", edit)
+ if got := strings.Replace(fit, ` size="7"`, "", 1); got != plain {
+ t.Errorf("estilo-bar-title-fit is not estilo-bar-title plus size:\n%s\n%s", fit, plain)
+ }
+}
+
+// The stacked bar's whole markup stays free of script, and every bar
+// trigger, menubar menus included, stays in the one group.
+func TestTheStackedBarKeepsTheOneMenuGroup(t *testing.T) {
+ b := stacked()
+ b.Lead = testLead
+ html := render(t, "estilo-bar", b)
+ if strings.Contains(html, "<script") {
+ t.Fatal("the bar requires no script")
+ }
+ for _, d := range regexp.MustCompile(`<details [^>]*>`).FindAllString(html, -1) {
+ if !strings.Contains(d, `name="estilo-menus"`) {
+ t.Errorf("%s is not in the estilo-menus group", d)
+ }
+ }
+}
diff --git a/chrome/templates/bar.html b/chrome/templates/bar.html
index 84bd9e8..2ab497f 100644
--- a/chrome/templates/bar.html
+++ b/chrome/templates/bar.html
@@ -1,42 +1,64 @@
-{{/* estilo-bar: the whole app header, one row at every width.
+{{/* estilo-bar: the whole app header, one row at every width unless it
+ is stacked.
Data: chrome.Bar. Parse this package's templates together with
menu.Templates() and the app's own layout. The skip link and <main>
are the layout's; this is only the <header>.
- Order in the end group is fixed in every app: actions, then Menu
- (narrow only), then the switcher, then the account. The account is
- always the last thing at the inline end.
+ Stacked (Bar.Menubar set, estilo-bar~="stacked"): the title and the
+ app's menu bar share [estilo-bar-stack], the title over the menus.
+ From 800px that is the 56px header; below it the stack dissolves
+ (display: contents) and the menus become a full-width second row, so
+ the markup is the same at every width.
+
+ Order in the end group is fixed in every app: the lead (Bar.Lead),
+ actions, then Menu (narrow only), then the switcher, then the
+ account. The account is always the last thing at the inline end.
The brand is a link to the app root, except on public read-only
pages, where App.Home is empty and it is plain text. */}}
-{{define "estilo-bar"}}<header estilo-bar{{if .Sticky}}="sticky"{{end}}>
+{{define "estilo-bar"}}<header estilo-bar{{if and .Sticky .Menubar}}="sticky stacked"{{else if .Sticky}}="sticky"{{else if .Menubar}}="stacked"{{end}}>
{{- if .App.Home}}
<a estilo-bar-brand href="{{.App.Home}}"><img estilo-brand-icon src="{{.App.Icon}}" alt="" width="28" height="28"><span estilo-bar-name>{{.App.Name}}</span></a>
{{- else}}
<span estilo-bar-brand><img estilo-brand-icon src="{{.App.Icon}}" alt="" width="28" height="28"><span estilo-bar-name>{{.App.Name}}</span></span>
{{- end}}
+ {{- if .Menubar}}
+ <div estilo-bar-stack>
+ {{- with .ContextEdit}}
+ {{template "estilo-bar-title-fit" .}}
+ {{- else}}{{with .Context}}
+ <span estilo-bar-context dir="auto" title="{{.}}">{{.}}</span>
+ {{- end}}{{end}}
+ <div estilo-bar-menubar>{{.Menubar}}</div>
+ </div>
+ {{- else}}
{{- with .ContextEdit}}
{{template "estilo-bar-title" .}}
{{- else}}{{with .Context}}
<span estilo-bar-context dir="auto" title="{{.}}">{{.}}</span>
{{- end}}{{end}}
+ {{- end}}
{{- if .Nav}}
<nav estilo-bar-nav aria-label="{{.NavLabel}}">
{{- range .Nav}}<a href="{{.Href}}"{{if .Current}} aria-current="page"{{end}}>{{.Label}}</a>{{end}}
</nav>
{{- end}}
<div estilo-bar-end>
+ {{- with .Lead}}
+ <div estilo-bar-lead>{{.}}</div>
+ {{- end}}
{{- if .Actions}}
<div estilo-bar-actions>{{template "estilo-bar-actions" .}}</div>
{{- end}}
- {{- if or .Nav .Actions}}
+ {{- $sheet := false}}{{range .Actions}}{{if not .WideOnly}}{{$sheet = true}}{{end}}{{end}}
+ {{- if or .Nav $sheet}}
<details estilo-bar-more name="estilo-menus">
<summary estilo-bar-trigger>{{template "estilo-icon-menu"}}<span>{{.Labels.Menu}}</span></summary>
<div estilo-menu="sheet">
{{- range .Nav}}<a estilo-menu-item href="{{.Href}}"{{if .Current}} aria-current="page"{{end}}><span estilo-menu-label>{{.Label}}</span></a>{{end}}
- {{- if and .Nav .Actions}}<hr>{{end}}
- {{- range .Actions}}{{template "estilo-menu-item" .Item}}{{end}}
+ {{- if and .Nav $sheet}}<hr>{{end}}
+ {{- range .Actions}}{{if not .WideOnly}}{{template "estilo-menu-item" .Item}}{{end}}{{end}}
</div>
</details>
{{- end}}
@@ -52,13 +74,22 @@
</header>{{end}}
{{/* estilo-bar-actions: the wide-screen actions, from Bar.Actions, each
- the element its Item names: a link, a one-button POST form, or a
- button opening a dialog. The same items are rows in the narrow Menu
- sheet, so both stay one list. An app may redefine this after parsing
- to change how they are drawn, but the sheet always renders
- Bar.Actions. */}}
-{{define "estilo-bar-actions"}}{{range .Actions}}{{template "estilo-bar-action" .}}{{end}}{{end}}
-{{define "estilo-bar-action"}}{{if .Action}}<form method="post" action="{{.Action}}"><button rst-btn{{if .Primary}}="primary"{{end}} type="submit">{{.Label}}</button></form>{{else if .Dialog}}<button rst-btn{{if .Primary}}="primary"{{end}} type="button" commandfor="{{.Dialog}}" command="show-modal">{{.Label}}</button>{{else}}<a rst-btn{{if .Primary}}="primary"{{end}} href="{{.Href}}">{{.Label}}</a>{{end}}{{end}}
+ the element its Item names: a link, a one-button POST form, a button
+ opening a dialog, or a toggle (aria-expanded, aria-controls) rendered
+ disabled until the app's script binds it. The same items are rows in
+ the narrow Menu sheet, so both stay one list; a WideOnly action is
+ marked estilo-bar-wide, hidden below 64rem, and left out of the
+ sheet. An app may redefine this after parsing to change how they are
+ drawn, but the sheet always renders Bar.Actions.
+
+ In a bar with a slot (Menubar or Lead) each action sits in its own
+ <div estilo-bar-control> (display: contents), "primary" for the
+ primary one and "wide" for a WideOnly one: the hooks the controls set
+ is styled on, since estilo's CSS never selects rastrillo's rst-
+ 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}}
{{/* 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
@@ -67,3 +98,13 @@
<input estilo-bar-title-input name="{{.Name}}" value="{{.Value}}" aria-label="{{.Label}}" autocomplete="off" spellcheck="false" dir="auto">
<button rst-btn="ghost" type="submit" estilo-bar-title-submit>{{.Submit}}</button>
</form>{{end}}
+
+{{/* estilo-bar-title-fit: the same form in a stacked bar, where the field
+ is as wide as its title: the size attribute (TitleEdit.Size) is the
+ first paint's approximation, and chrome.js measures the field and
+ corrects it. It differs from estilo-bar-title only by that attribute
+ (TestTheFittedTitleIsTheTitlePlusASize). Data: chrome.TitleEdit. */}}
+{{define "estilo-bar-title-fit"}}<form estilo-bar-title method="post" action="{{.Action}}">
+ <input estilo-bar-title-input name="{{.Name}}" value="{{.Value}}" size="{{.Size}}" aria-label="{{.Label}}" autocomplete="off" spellcheck="false" dir="auto">
+ <button rst-btn="ghost" type="submit" estilo-bar-title-submit>{{.Submit}}</button>
+ </form>{{end}}