oficina / docs Public

Clone
git clone https://amadan.net/oficina/docs

Plain git — no account needed to clone.

Download

Download this file

1{{/* The editor's pieces of the estilo bar (spec I2, revision 2's P2:
2 "both are rendered by Docs from views/ partials"). handlers.go's show
3 renders docs-menubar into chrome.Bar.Menubar and docs-history into
4 chrome.Bar.Lead, through renderer.fragment, so the markup is still
5 this app's template and TestOurTemplatesUseTheAttributeGrammar
6 reads it like any other. */}}
7
8{{/* docs-menubar: the document's menu bar (internal/docs/menu.go for
9 the model and the copy, fixtures/menu.mjs for the keyboard
10 behaviour). estilo draws it under the title from 800px and as the
11 header's second row below that; there is one in the page.
12
13 Each menu is a <details>, and that is the load-bearing decision on
14 this screen rather than a convenience. The export links work with
15 scripts disabled and the whole read view is built on that guarantee
16 (editor_view_test.go's TestShowRendersContentWithoutScript); a
17 JS-driven role="menubar" would have moved the only route to a
18 person's own document behind a control that never opens for them.
19 <details> opens with no script at all, and name="estilo-menus" makes
20 the six an exclusive group with the bar's account menu, switcher and
21 Menu sheet (spec §7.1).
22
23 It stays a disclosure rather than being relabelled role="menubar"
24 with role="menuitem" children: declaring the menu pattern promises
25 typeahead and submenu semantics, and delivering less than that is
26 worse for a screen reader user than the honest disclosure.
27 fixtures/menu.mjs only ADDS to this: arrow keys between and within
28 menus, Escape to close, and a roving tabindex so the bar is one tab
29 stop.
30
31 There are no submenus, and there will not be: a nested <details>
32 inside a name= group collapses its parent. Data: menuView. */}}
33{{define "docs-menubar"}}<nav estilo-menubar aria-label="{{.Label}}">
34 {{range .Menus}}{{$checks := .Checks}}<details estilo-menubar-menu name="estilo-menus" id="docs-menu-{{.ID}}">
35 <summary estilo-menubar-title>{{.Title}}</summary>
36 <div estilo-menu>
37 {{range .Items}}
38 {{- if eq .Kind "divider"}}<hr>
39 {{- 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>
40 {{- 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>
41 {{- else}}{{/* Every command item ships disabled, because without
42 the bundle there is no editor to act on; fixtures/menu.mjs
43 enables each as soon as the editor mounts, and afterwards
44 exactly when its command would do something. A checkable
45 item carries aria-pressed on every row of its group, and
46 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>
47 {{- end}}
48 {{end}}
49 </div>
50 </details>{{end}}
51</nav>{{end}}
52
53{{/* docs-history: undo and redo, the one pair (spec I2, P1.2 and C6).
54 It is drawn twice and shown once: in the bar's lead slot from 800px
55 ([docs-history="lead"], inside estilo's [estilo-bar-lead]), and in
56 the strip below 800px, where the stacked header has no room for it
57 (show.html's CSS shows exactly one). Neither is inside the
58 role="toolbar" and neither is in its roving tab stop: they are two
59 ordinary buttons. fixtures/toolbar.mjs binds both by
60 data-docs-command and keeps both current, and editor-entry.js makes
61 both inert during a font wait. Disabled until the editor mounts,
62 like every control that needs it. Data: historyView. */}}
63{{define "docs-history"}}<div docs-history{{if .Lead}}="lead"{{end}} role="group" aria-label="{{.Label}}">
64 <button docs-tool type="button" data-docs-command="undo" aria-label="{{.Undo}}" disabled>
65 <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>
66 </button>
67 <button docs-tool type="button" data-docs-command="redo" aria-label="{{.Redo}}" disabled>
68 <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>
69 </button>
70 </div>{{end}}
71
72{{/* docs-icon-format: Format's pencil, chrome.Action.Icon (estilo draws
73 it in the bar only; the label still names the button). */}}
74{{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}}
75
76{{/* docs-trail: the compact bar's trail on a phone (estilo's
77 chrome.Compact.Trail, design/phone-web): Aa for a writer, then •••.
78 Below 704px the menu bar is not drawn, so ••• carries its verbs
79 (menu.go's newMoreView), filtered by capability. Data: moreView.
80
81 Aa opens the Format sheet (brand/phone.js): the inspector, which below
82 704px is a half-height bottom sheet (design/phone-web, P2). It is rendered
83 disabled, as Format is, and the script enables it; with no script
84 there is no editor to format.
85
86 ••• is a <details> in the bar's one exclusive group, so it opens with
87 no script, and estilo draws its panel as a drop-down from the bar's
88 inline end with 44px rows (Paul's answer 3). Its links are plain
89 links; a row the editor runs is a proxy for the menu bar's item of
90 the same command (data-docs-proxy), disabled until the editor
91 mounts, as that item is. Help is a disclosure inside the panel, not
92 in the group: a <details name="estilo-menus"> inside it would close
93 ••• as it opened. */}}
94{{define "docs-trail"}}{{if .Aa}}<button estilo-bar-tool type="button" docs-aa aria-controls="docs-inspector" aria-expanded="false" aria-label="{{.AaLabel}}" disabled><span docs-aa-glyph aria-hidden="true">Aa</span></button>{{end}}<details docs-more name="estilo-menus"><summary estilo-bar-tool aria-label="{{.Label}}">{{template "docs-more-icon" "more"}}</summary><div estilo-menu docs-more-panel>{{$checks := .Checks}}{{range .Rows}}{{template "docs-more-row" (moreRowIn . $checks)}}{{end}}</div></details>{{end}}
95
96{{/* docs-more-row: one row of •••. Data: moreRowView (a row, and
97 whether its panel draws the check column). */}}
98{{define "docs-more-row"}}{{with .Row}}
99 {{- if eq .Kind "divider"}}<hr>
100 {{- else if eq .Kind "help"}}<details docs-more-help><summary estilo-menu-item>{{template "docs-more-row-lead" $}}<span estilo-menu-label>{{.Label}}</span>{{template "docs-more-icon" "chevron"}}</summary>{{range .Help}}{{template "docs-more-row" (moreRowIn . $.Checks)}}{{end}}</details>
101 {{- else if eq .Kind "proxy"}}<button estilo-menu-item type="button" data-docs-proxy="{{.Proxy}}"{{if .Checkable}} aria-pressed="{{if .Pressed}}true{{else}}false{{end}}"{{end}} disabled>{{template "docs-more-row-lead" $}}<span estilo-menu-label>{{.Label}}</span></button>
102 {{- else}}<a estilo-menu-item{{if .Danger}}="danger"{{end}} href="{{.Href}}"{{if .Download}} download{{end}}{{if .JumpTo}} data-docs-jumpto{{end}}{{if .Rename}} data-docs-rename{{end}}>{{template "docs-more-row-lead" $}}<span estilo-menu-label>{{.Label}}</span></a>
103 {{- end}}{{end}}{{end}}
104
105{{/* docs-more-row-lead: a row's check (the paged/infinite pair) or its
106 icon, or the empty check column that keeps labels aligned. */}}
107{{define "docs-more-row-lead"}}{{if .Row.Checkable}}<span estilo-menu-check aria-hidden="true">{{template "estilo-icon-check"}}</span>{{else if .Row.Icon}}<span estilo-menu-icon>{{template "docs-more-icon" .Row.Icon}}</span>{{else if .Checks}}<span estilo-menu-check aria-hidden="true"></span>{{end}}{{end}}
108
109{{/* docs-more-icon: the glyphs of ••• and its rows, Lucide (ISC,
110 brand/LICENSE.lucide): ellipsis, share, pencil, download, printer,
111 text, folder-open, file-text, circle-help, trash-2, chevron-down.
112 Decorative: every row and the button name themselves. */}}
113{{define "docs-more-icon"}}<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"{{if eq . "chevron"}} docs-more-chevron{{end}}>
114 {{- if eq . "more"}}<circle cx="12" cy="12" r="1.2" fill="currentColor"/><circle cx="5.5" cy="12" r="1.2" fill="currentColor"/><circle cx="18.5" cy="12" r="1.2" fill="currentColor"/>
115 {{- else if eq . "share"}}<path d="M12 3v12"/><path d="m8 7 4-4 4 4"/><path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-7"/>
116 {{- else if eq . "rename"}}<path d="M12 20h9"/><path d="M16.4 3.6a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z"/>
117 {{- else if eq . "download"}}<path d="M12 3v12"/><path d="m7 10 5 5 5-5"/><path d="M5 21h14"/>
118 {{- else if eq . "print"}}<path d="M6 9V3h12v6"/><rect x="4" y="9" width="16" height="8" rx="2"/><path d="M7 14h10v7H7z"/>
119 {{- else if eq . "count"}}<path d="M4 7V5h16v2"/><path d="M9 19h6"/><path d="M12 5v14"/>
120 {{- else if eq . "open"}}<path d="M4 20a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h5l2 2h7a1 1 0 0 1 1 1v3"/><path d="M4 20 7 11h15l-3 9z"/>
121 {{- else if eq . "report"}}<path d="M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8z"/><path d="M14 3v5h5"/><path d="M9 13h6M9 17h6"/>
122 {{- else if eq . "help"}}<circle cx="12" cy="12" r="9"/><path d="M9.1 9a3 3 0 0 1 5.8 1c0 2-3 3-3 3"/><path d="M12 17h.01"/>
123 {{- else if eq . "delete"}}<path d="M3 6h18"/><path d="M8 6V4h8v2"/><path d="M6 6l1 15h10l1-15"/><path d="M10 11v6M14 11v6"/>
124 {{- else if eq . "chevron"}}<path d="m6 9 6 6 6-6"/>
125 {{- end}}</svg>{{end}}
126
127{{/* docs-inline-title: the compact bar's inline title (estilo's
128 chrome.Compact.Title), shown once the large title has scrolled away
129 (brand/phone.js marks the bar estilo-bar-folded). aria-hidden: the
130 large title is the page's heading, and the state is said by its own
131 live region under it. The state comes first, in its tone, so a
132 failure is never the part an ellipsis cuts (Fable on #179, S2); the
133 editor drives it (fixtures/editor-entry.js). Data: inlineTitleView. */}}
134{{define "docs-inline-title"}}<div docs-inline-title aria-hidden="true"><b dir="auto">{{.Title}}</b><small docs-inline-sub><span docs-inline-state data-state="{{.Tone}}">{{.State}}</span>{{with .Shared}} · {{.}}{{end}}</small></div>{{end}}
135