oficina / docs Public

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

Plain git — no account needed to clone.

Download

Download this file

1# Docs editor, layout I2: stacked header, floating inspector, share popover
2
3Status: revision 2, 2026-11-11, after Claude Fable 5.1's review (oficina/docs #105: CHANGES REQUIRED). The section "Revision 2: decisions from the review" at the end overrides anything above it that it contradicts.
4Branch: `design/richer-ui` (Docs) plus a new estilo branch, `bar-stack`.
5Mock-up: `design/editor-looks`, local only (`../docs-editor-looks`, `brand/looks.js` and `looks.css`).
6It is the reference for every measurement here and is never merged.
7It moves the chrome with script at load. The build must render it server-side.
8
9## Why
10
11Paul asked on 2026-11-07 for Docs to feel "rich, inviting, assertive", and "less Docs clone, definitely not Word clone".
12He then worked through five layouts and four riffs on one of them in the live mock-up, and chose I2.
13Every ruling quoted below is his, from that session.
14
15## What I2 is
16
17### Header: one 56px block
18
19- **Icon:** 32px, 12px from the inline start. The app name is dropped beside it.
20- **Title and menus:** stacked to the right of the icon.
21 - The title row is 24px: 16px type, weight 600, letter-spacing -0.01em.
22 - The menu row is 20px: 13px type, muted.
23 - Both start on one edge at 56px (12px padding, 32px icon, 12px gap).
24- **Optical balance, measured at 2x in WebKit:**
25 - The title's capitals start at the icon's top (11px). The title row sits 2.5px below its box.
26 - The menu row sits low in the header (1px offset). Its 24px highlight pill stops 3px above the header's bottom edge.
27 - An open menu's panel starts 1px above that edge, hanging from it.
28 - Rulings: "the top of the menu should hug the bottom of the header", then "a smidge", then "1px up and 1px down".
29- **Menu bar:**
30 - estilo's 32px minimum height is dropped.
31 - Menu titles get `cursor: pointer`.
32 - The highlight is a 24px pill, 6px radius, made by 2px negative block margins so it takes no room.
33 - Panels have 28px rows, 13px type, muted shortcut keys, 4px padding and a 10px radius.
34- **Title field:**
35 - As wide as its title, never full width ("It should grow according to the title, not start out full-width").
36 - Sized from the field's own `scrollWidth` at zero width, plus its end padding and border. `field-sizing: content`, a canvas and a mirror span all came up short in WebKit.
37 - Re-measured on input, on resize, after load and on `document.fonts.ready`.
38- **Rename:** shown only while the title is being edited. It is a 22px accent-soft pill inside the title row, not estilo's 2rem button.
39
40### Header controls: one set
41
42- **Sizing:** all 28px tall, pill-shaped, 13px type at weight 600, 8px apart.
43- **Order:** undo/redo, Format, Share, then a divider, then the avatar.
44- **Undo/redo:** one grey pill holding two 24px icon buttons, with a hairline between them.
45 - It is lit from the top: a gradient, a 1px inner highlight and a contact shadow.
46 - A hovered button lifts within it.
47 - These are the editor's own undo/redo buttons, so they need the toolbar's command binding (below).
48- **Format:** a quiet pill that toggles the inspector.
49 - It is accent-soft with accent text while the inspector is open.
50 - It has `aria-pressed` and a pencil icon.
51- **Share:** the one filled pill, the page's main action.
52 - It has a 1px top highlight and an accent-tinted shadow (`0 5px 12px -5px`), the index's New document at header scale.
53- **Avatar:** a 28px circle and nothing else ("It should just highlight the circle").
54 - Hover darkens the circle. While its menu is open it gets a 2px ring.
55- **Divider before the avatar:**
56 - A 1px line, 20px tall, with 12px either side.
57 - Only when actions precede it: there is none on the index ("We don't need the divider if there are no other header buttons").
58- **Depth:** everything follows the index's treatment ("should they get something of the 3D / highlight treatment").
59
60### Inspector, replacing the formatting bar on wide screens
61
62- **Panel:**
63 - 248px wide, floating 12px below the header and 12px from the inline end.
64 - 12px radius, glass background (backdrop blur), 12px padding.
65 - Its sections sit 14px apart. Section labels are 11px, weight 650, muted.
66- **Sections:**
67 - **Style:** the paragraph style picker full width, then font and size on one row (size column 64px).
68 - **Text:** bold, italic and code.
69 - **Alignment:** left, centre and right.
70 - **Lists:** bulleted, numbered and quote.
71 - Text, Alignment and Lists are joined segmented rows of 28px buttons. Undo/redo moved to the header ("History buttons probably should stay in the main header").
72- **Light:**
73 - It is a rastrillo card, lit by `light.js`: a rim and wash near the pointer.
74 - The glow is drawn from a reshaped `--rst-card-lit`, `max(0, lit × 1.43 − 0.43)`, so it disappears about 0.5s after the pointer leaves, not about 2s ("taking slightly too long").
75 - The rim is accent 70% mixed into the line colour (30% in dark). The wash is accent 9% (4% in dark).
76- **Back-lit hover:** a hovered control brightens to the surface with an accent halo:
77 - `0 0 0 1px accent 22%, 0 0 12px 1px accent 26%`, lower in dark.
78 - It sits above its segment neighbours.
79 - Ruling: "need a sort of back-light hover state to compensate for the background glow".
80- **Format toggle:**
81 - The open/closed state persists in a cookie and is rendered server-side.
82 - First paint is already right. No flash, the same rule `docs-view` follows.
83- **The sheet stays centred unless the inspector needs the room:**
84 - `padding-inline-end: max(16px, 16px + 816px + 2R − 100vw)`, where R is the inspector width plus 12px margin plus a 16px gap. Measured at 1800px, 1440px and 1280px.
85 - Ruling: "the inspector shouldn't push the sheet to the left unless there's not enough space".
86 - With the inspector closed, the sheet is plainly centred.
87- **Below 64rem:** no inspector. The existing toolbar strip and its phone rules stand, with undo/redo back in the strip, because the header controls collapse there.
88
89### Share as a popover
90
91- **Opening:** Share… opens a popover anchored under its button (`top`: header bottom + 6px; `right`: the button's end), 420px wide.
92 - No-JS fallback: the share page as it is now.
93- **Contents, composed server-side as a fragment of the share page** (a new GET variant, for example `/d/{sqid}/share?panel=1`, rendering only the panel):
94 - **Head:** "Share “title”" and a close button.
95 - **Invite row:** one rounded field holding the email input ("Add people by email"), a compact Can read / Can edit select and an Invite button.
96 - **People with access:** the owner first ("(you)", Owner), then each grant with an initial avatar, its access, and an × to remove it.
97 - **General access:** two rows with an icon, a one-line state and a rastrillo `rst-switch`. The switches are real checkboxes: click, drag (rastrillo.js) or Space.
98 - **Your team:** private or team.
99 - **Anyone with the link:** published or not. When just published it shows the one-time URL, a Copy link button and "Copy it now: the link is shown only this once". Later it offers "Make a new link".
100 - **Errors:** a negative callout under the head. Only the page's own error; the link's once-only warning lives with the link.
101- **Actions:** every one posts to the existing endpoints with fetch, and the panel is redrawn from the fragment the 303 lands on.
102- **Dismissal:**
103 - The popover is `manual`, with its own dismissal: a pointerdown outside it closes it, except on Share.
104 - Share while open does nothing ("should do nothing. It's causing a flash").
105 - Esc closes it and returns focus to Share.
106- **Phones:** below 36rem it is a full-width sheet from the top, with focus kept inside it.
107- Owners only, as the share page is.
108
109### Appearance: three-way selector, switched in place
110
111- **In estilo's account menu:** Light, Dark and System as three equal segments in one well, an icon (sun, moon, display) over each word. The current one is raised (surface, or #2f333d in dark), with an accent icon.
112- **Switching:**
113 - The page switches at once (`data-theme`, as `chrome.ThemeAttr` writes it) and saves the choice by POSTing `/appearance` in the background.
114 - No busy spinner, no reload ("They're not doing an action ... they should just switch immediately").
115 - Without script, the form posts and redirects as now.
116
117### Dark mode
118
119Every glow is far fainter in dark ("a lot more subtle"). Landed on the branch: 489163a. The inspector, halo and Share values above follow it.
120
121## Where each piece lives
122
123The shared pieces go to estilo once, so every app gets them; that is Paul's stated direction.
124
125**estilo, branch `bar-stack`:**
1261. `chrome.Bar` gains a stacked variant: a template slot under the title for the app's menu bar.
127 - Docs passes its menubar markup, rendered by `estilo-menubar` from Docs' `menuView` as now.
128 - When the slot is filled, the bar draws the 56px stacked header above; otherwise the one-row bar is unchanged.
129 - The 52px public `--estilo-bar-block-size` becomes 56px in the stacked variant, and is published as such.
1302. Bar actions accept an app-rendered leading slot (the undo/redo pill). Docs fills it with its `data-docs-command` buttons, which the editor's toolbar plugin must bind (below).
1313. The controls-set styling, the avatar circle highlight and the conditional divider.
1324. Menu bar title pointer cursor, the highlight pill, and the tighter menu panel inside the stacked bar.
1335. The title field's sizing script (in `chrome.js`) and the compact Rename.
1346. Appearance as the segmented selector, switched in place (`chrome.js`), with the form marked `data-busy="false"`.
1357. Upstream note, not this branch: rastrillo's `scheme-menu` could take the same selector.
136
137**Docs, on `design/richer-ui`:**
1381. Pin the estilo `bar-stack` branch. Pass the menubar into the bar's slot and the undo/redo buttons into the actions slot.
1392. **Toolbar binding:** `fixtures/toolbar.mjs` binds buttons found under `[docs-toolbar]` at mount.
140 - It must also bind the header's undo/redo, by `data-docs-command` under the bar's slot, and keep them in `sync`.
141 - The roving tab stop covers only the inspector or strip, not the header pair.
1423. **Inspector markup** in `show.html`: an `<aside>` holding the toolbar's groups as labelled sections, each section a `role="group"` with an accessible name.
143 - The groups stay inside one `role="toolbar"` so the existing plugin, roving focus and tests bind unchanged.
144 - The strip toolbar and the inspector are the same element, laid out by width: a column in the aside at 64rem and above, the strip below.
1454. Format toggle: a cookie (`docs-inspector`), server-rendered state, and the pressed button state.
1465. The share panel fragment route and template, the popover script (a new bundle or brand script; no inline script, under the CSP), and the share page unchanged for no-JS.
1476. The sheet centring rule and the inspector's light and back-lit hover (`brand/light.css`, `show.html`).
1487. Serve rastrillo's current `ui.ShimJS()` in place of estilo's older `busy.ShimJS()`. It is busy-less too and adds the switch drag the share switches need.
149 - Check first that nothing in Docs depends on the old shim's behaviour.
150 - Better: estilo re-vendors the shim from Fiesta 1.3.0's rastrillo, and Docs keeps taking it from estilo.
151
152## Constraints that already bind, and how I2 meets them
153
154- **No layout shift on load.** The inspector and the strip are server-rendered at their final size. The Format state is server-rendered. The title width is set before first paint where possible (initial width from the server's measurement is not possible, so the field starts at `max-content` via CSS and the script corrects by a few pixels at most).
155 - `TestFontTheFirstRevealIsTheFinalLayout` and the CLS checks must stay green.
156- **Never FOUT** (Paul, 2026-10-24). The header and inspector use the system UI face. The style list's previews use the chrome face, already landed.
157- **SC 1.4.10 at 320px.** Below 64rem nothing changes from today. The popover becomes a sheet.
158- **Touch targets.** Header controls are 28px and segmented buttons 28px: above 24px.
159- **Keyboard and accessibility:**
160 - The popover gives focus to the email field on open, Esc returns focus, and Tab stays inside it on phones.
161 - Switches are checkboxes with names.
162 - Appearance buttons keep `aria-pressed`.
163 - The Format toggle has `aria-pressed` and `aria-controls` on the aside.
164- **Busy rule:** POST actions keep the 650ms hold. Appearance and Format are view switches with no request held. Share's fetches carry no busy spinner unless slow, which is the GET rule's shape (landing in Fiesta 1.3.0).
165
166## Tests
167
168- **Go:** the stacked bar renders the slot and keeps the one-row bar when empty (estilo); the share fragment route is owner-only and 404s for others, as the page does; the Format cookie is rendered (Docs).
169- **Browser (Chromium and WebKit):**
170 - header measurements: the edges at 56px and the 28px controls;
171 - the inspector at 64rem and above versus the strip below;
172 - sheet centring at three widths;
173 - popover: open, invite, both switches, remove, Share-while-open does nothing, Esc;
174 - Appearance switches in place with no navigation;
175 - undo/redo from the header stay current (130eeeb);
176 - the existing toolbar, font and zoom suites.
177
178## Out of scope
179
180- Sheets, Slides and other apps: they take the estilo pieces when they re-pin. Their own passes follow.
181- The share email notification: offered, not yet asked for.
182
183## Revision 2: decisions from the review (#105)
184
185These override the sections above.
186
187### P1.1: the one-time link reaches the person who sees it
188
189- **Redirect:** a share POST sent from the popover carries `panel=1` (a hidden field). When it is present, the handler's 303 goes to `/d/{sqid}/share?panel=1`, not to the full page.
190 - So the render that calls `oneShots.take` is the fragment the popover shows.
191- **Rendering:** the fragment goes through `renderShare`, so it keeps the `Cache-Control: no-store` rule whenever it carries the URL. It uses a fragment template in place of the page.
192- **Direct navigation:** a request for `?panel=1` with `Sec-Fetch-Dest: document`, or with no `Sec-Fetch-*` at all, gets the full page.
193 - So a typed or reloaded URL is never a bare fragment, and a fetch never gets a page.
194- **Test:** after a publish from the popover, the URL appears in exactly one response body: the fragment. A following GET of the page or the fragment does not show it.
195
196### P1.2: one undo/redo pair, outside the toolbar
197
198- **Placement:** undo and redo leave `[docs-toolbar]` at every width. The strip loses its History group. There is one pair, in the bar's lead slot, visible at every width the editor is.
199 - The lead slot does not collapse into estilo's Menu sheet (see P1.3).
200- **Binding:** `fixtures/toolbar.mjs` binds the pair separately by `data-docs-command` under the bar's lead slot. They are bound and kept in `sync` like the rest, but are not in `setupRoving`'s controls: they are two ordinary tab stops.
201 - `fixtures/browser-drive.mjs` and every test that clicks the strip's undo move to the header pair.
202- **Inspector keyboard:** the inspector's `role="toolbar"` stays the one roving toolbar, with `aria-orientation="horizontal"`. Left and Right move as today.
203 - The vertical layout is visual only: its order is the reading order, so Left/Right still walk it.
204 - Up/Down are not claimed.
205
206### P1.3: breakpoints aligned with estilo's
207
208| Width | Lead slot (undo/redo) | Actions (Format, Share) | Formatting |
209|---|---|---|---|
210| 1024px and wider | visible | shown | inspector; Format toggles it |
211| 800–1023px | visible | Share only; Format is not rendered visible (no inspector to toggle) | today's strip under the header |
212| Below 800px | visible, before Menu | Share is a row in estilo's Menu sheet (estilo's existing rule) | today's strip |
213
214- **Share below 800px:** the popover script listens on every Share link in the bar, the sheet's row included. Below 36rem it opens as a full-width sheet.
215- **Format:** the toggle is an estilo action. Docs gives it `data-wide-only`, and estilo hides wide-only actions below 1024px in the bar and omits them from the sheet.
216
217### P2 decisions
218
219- **estilo slot API, as data:**
220 - `Bar.Menubar template.HTML` is rendered under the title and makes the bar `[estilo-bar~="stacked"]`.
221 - `Bar.Lead template.HTML` is rendered before the actions, at every width.
222 - Both are rendered by Docs from `views/` partials, so `TestOurTemplatesUseTheAttributeGrammar` and the markup tests still see them.
223 - In the stacked variant the bar's height is published as `--estilo-bar-block-size` (56px) through `:root:has([estilo-bar~="stacked"])`.
224 - No template redefinition.
225- **Title width:**
226 - The server renders the input with a `size` attribute derived from the title's length, as a first approximation that cannot shift layout by more than a few pixels. Script corrects it.
227 - It is capped at the space between the brand and the bar's end.
228 - A title longer than the cap scrolls inside the field, as today.
229- **Font wait:** the header pair and Format join `setInert`'s set (`editor-entry.js:521`), and `fonts_browser_test.go`'s inert checks extend to them.
230- **Busy rule in the popover:** the popover's script cancels each submit and does its own feedback. A request taking more than 500ms puts a spinner on the pressed control, mirroring the GET rule.
231 - It does not depend on Fiesta's busy.js.
232- **Shim:** estilo re-vendors rastrillo's current `ui.ShimJS()` (busy-less, with the switch drag) into `busy/rastrillo.js` with provenance, in the `bar-stack` branch or its own. Docs keeps taking it from estilo, and `TestBusyRuleIsLinkedAndServed` follows.
233- **Format toggle:**
234 - The cookie `docs-inspector` defaults to open.
235 - Without script, the button is rendered `disabled` and the inspector stays open, since a disabled control cannot claim to toggle.
236 - It uses `aria-expanded` and `aria-controls`, not `aria-pressed`: it shows and hides a region.
237
238### P3 notes for implementation
239
240- **Popover:**
241 - Position with logical insets, so RTL mirrors it.
242 - Use CSS anchor positioning where supported, with the script's placement as the fallback.
243 - On phones, use a modal `<dialog>` rather than a hand-made focus trap.
244 - Honour `defaultPrevented` after chrome.js's capture-phase Esc.
245- **Print:** the inspector and popover are hidden.
246- **Inspector light and back-lit hover:** under `(hover: hover)`, and with no transition under reduced motion.
247- **Sheet centring:** use the container's width (a container query unit or `100%` of the canvas), not `100vw`, which counts a classic scrollbar (show.html's own warning).
248- **Coarse pointers:** header controls and segments rise to 32px.
249- **Appearance:** if the background POST fails, the page stays switched for the visit and the selector says nothing. The next load shows the saved choice. Acceptable for a view preference; noted, not solved.
250- **Native wrappers** (`native/`) are unaffected: they render the same pages.
251
252### Reference values, not requirements
253
254The sub-pixel optical offsets, shadow strings, the glow-fade curve, glow percentages, icon drawings and the title-measuring technique above are the mock-up's values. They are references to match by screenshot comparison against `design/editor-looks`, not mechanisms to copy.
255
256### Revision 2.1: from the re-review (#105, APPROVED WITH CHANGES)
257
258- **C1, Format's home:** estilo's `Action` gains two things. `WideOnly` hides the action below 64rem in the bar and omits it from the Menu sheet. A `Toggle` kind renders a `<button aria-expanded aria-controls>` that is `disabled` until script binds it.
259 - Format is a `WideOnly` toggle. Sheets will want the same.
260 - estilo states its breakpoints in rem (64rem), not px.
261- **C2, the closed inspector:** at 64rem and above with the inspector closed, every toolbar control is hidden but is still in the roving set.
262 - `toolbar-roving.mjs`'s `reachable()` filters on `checkVisibility()`, not only `disabled`, and re-runs on resize.
263 - `focusStop()` returns false when nothing is visible, so Escape in the editor (editor-entry.js:824) stays put.
264- **C3:** `docs-inspector=closed` hides only the inspector at 64rem and above. Below that the strip shows regardless. There is a test at 1000px.
265- **C4, Share from the Menu sheet:** opening the popover closes `<details estilo-bar-more>`. Esc returns focus to the Menu trigger, not to the row inside the closed sheet.
266- **C5, the busy shape of popover actions:** awaiting Paul's ruling.
267 - Either way, the script refuses a second in-flight submit and holds a switch at its new position until its request settles. If the request fails, the switch reverts with the error.
268- **C6, decided by measurement (2026-11-11, WebKit, phone rules applied):** the stacked header does not fit a phone, with or without the pair.
269 - File–Help needs 261px. Beside the icon, the title, Menu and the avatar, 125px is left at 390px and 55px at 320px, and the title falls to "U…".
270 - **Below 800px:** today's layout stands. The one-row bar (no `Bar.Menubar` stacking), the menu row in `[docs-chrome]`, and the strip with undo/redo in it.
271 - **From 800px:** the stacked header and the header pair. The pair lives in the strip's markup at every width, and CSS shows exactly one of the two homes: the strip's group below 800px, `Bar.Lead` from 800px. Both stay out of roving.
272 - `Bar.Menubar`'s stacking is therefore wide-only too: estilo draws the one-row bar below 800px, and the app keeps its own menu row there.
273 - The 320px `scrollWidth` check covers the bar.
274- **Test notes:**
275 - Go tests of the fragment set `Sec-Fetch-Dest: empty`.
276 - `sharePost`'s empty-address 400 path (share.go:273-282) also renders the fragment when `panel=1` is in the body.
277 - `TestToolbarOptionValuesMatchTheBundle` widens to the lead and inspector partials.
278 - `TestTheOwnerGetsAShareControlInTheBar` is rewritten for the new actions order.
279 - The `size` claim is that nothing after the title moves.
280 - The shim is re-vendored from the rastrillo version Docs pins (v0.29.1-0.20261027164201-054787952dd2), so the drag script and the switch CSS come from one tree.
281
282### Revision 2.2: from the estilo bar-stack review (oficina/estilo #34, APPROVED WITH CHANGES)
283
284- **One menu bar below 800px:** the menubar is one piece of markup, `Bar.Menubar`, at every width. estilo draws it under the title from 800px and as the header's second row below 800px. Docs drops its own menu row in `[docs-chrome]`. This replaces C6's "the app keeps its own menu row there"; Claude Fable judged the change sound and better.
285- **The bar's height below 800px is not a constant:** it is 85px, or more when the menus wrap, and chrome.js publishes the real height. Docs reads `--estilo-bar-block-size` and never a number.
286- **Format's state** lives in the `docs-inspector` cookie: open by default, closed only for an exact `closed`, rendered server-side onto the inspector and into the toggle's `aria-expanded`.
287