Editor: estilo at head with the desk part; Docs' grey desk
estilo moves from 260f98c to the local desk branch (origin/main 4d5b935 plus the desk commits) through a TEMPORARY replace in go.mod pointing at ../estilo-desk. The estilo branch is not pushed yet; the last task of the editor tidy swaps this replace for a real pin. - estilo's desk.css is served at static/estilo/desk.css and linked after chrome.css on every page the layout draws. - --slides-desk reads var(--estilo-desk) (Docs' #e3e7ee light, #0e1015 dark) instead of Slides' warm #ebe7e2 / #0e1014; its @property keeps initial value #e3e7ee. - The deck list's ground is plain var(--slides-desk): the radial wash of Slides' hue at the top is gone. - go run ./scripts/writeestilo re-vendored busy.js and rastrillo.js (theme.css and busy.css unchanged); scripts/credits.py updated their hashes in credits/assets.json. - TestSignInPageIsTheDoor accepts any sky version: estilo bumped the sky's image prefix from v1 to v2. Visible differences the bump brings, beyond the desk: - Account menu, Appearance: three equal segments with a sun, moon and display icon over each word, the current one raised and bold, instead of three rows with a check mark; choosing one switches the page in place (background POST, no reload, no busy hold). Scripts off it posts and redirects as before. - Busy rule (Fiesta 1.3.0's busy.js): a POST is still held 650ms; a GET form or link now goes at once and shows the busy state only after 500ms. - The sign-in door's sky images are served under /static/estilo/sky/v2/ (estilo redrew them). - The editor's own header uses none of the new stacked-bar parts (Menubar, Lead, controls), so its bar, menus and layout are unchanged; no Slides CSS needed fixing.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
11 files changed,
+455
−86
go.mod+4 −0go.sum+0 −2internal/slides/credits/assets.json+2 −2internal/slides/render.go+6 −2internal/slides/static/busy.js+154 −38internal/slides/static/decks.css+5 −13internal/slides/static/desk.css+7 −5internal/slides/static/rastrillo.js+197 −22internal/slides/templates/layout.html+2 −1internal/slidestest/editor_tidy_test.go+77 −0internal/slidestest/signin_door_test.go+1 −1
diff --git a/go.mod b/go.mod| index 7f702e6..856e759 100644 |
| --- a/go.mod |
| +++ b/go.mod |
| @@ -72,3 +72,7 @@ require ( |
| // a dependency that is real at go run time and invisible at tidy |
| // time. Deleting this line breaks the gate, not the app. |
| tool amadan.net/rastrillo/rastrillo/cmd/rastrillo |
| + |
| +// Temporary: estilo's desk part is on a local branch not yet pushed. |
| +// Replaced by a real pin in the last task of the editor tidy. |
| +replace amadan.net/oficina/estilo.git => ../estilo-desk |
diff --git a/go.sum b/go.sum| index a3a08b3..d3cde15 100644 |
| --- a/go.sum |
| +++ b/go.sum |
| @@ -1,7 +1,5 @@ |
| amadan.net/oficina/agent-access.git v0.0.0-20261024232549-8ed8ba826000 h1:L07nc+dmLI7c1PBkSkbnrjOK5f8p6OBbA/yTxznxCAw= |
| amadan.net/oficina/agent-access.git v0.0.0-20261024232549-8ed8ba826000/go.mod h1:Ph9PIa3VE1IEaUzZiQH6D+IQ6HThWWGfVr0ecMMgrFA= |
| -amadan.net/oficina/estilo.git v0.0.0-20261025200559-260f98c42e2d h1:p9+01xRdBD7s1viTINgQ6XoDD5ghOxYubD7FNcjhBTw= |
| -amadan.net/oficina/estilo.git v0.0.0-20261025200559-260f98c42e2d/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw= |
| amadan.net/oficina/home/connect v0.0.0-20261101223546-d82341cd9a0c h1:6NOvTeDLlctihXkIa/FCr1np3N3N4oKB0YS9x8VSfxI= |
| amadan.net/oficina/home/connect v0.0.0-20261101223546-d82341cd9a0c/go.mod h1:ix81eFV87yE9f2SXiRuxYCVM4lAgTRC5YoQMiH3+TDk= |
| amadan.net/oficina/home/dashboard v0.0.0-20261024234842-3774eb68f816 h1:AFDuOio0MxNxN9ZWVc3lul1QHkNjNUCO56kXpe/Fw3I= |
diff --git a/internal/slides/credits/assets.json b/internal/slides/credits/assets.json| index d132c0c..39c2818 100644 |
| --- a/internal/slides/credits/assets.json |
| +++ b/internal/slides/credits/assets.json |
| @@ -37,7 +37,7 @@ |
| "internal/slides/fonts/files/LiberationSerif-Italic.ttf": "de18fe26337e03241952dca46398d5b66f3c5738d080bfd284f66e67b926f597", |
| "internal/slides/fonts/files/LiberationSerif-Regular.ttf": "9caef765d2e891c10dd73658894f01e660fe0c1c83e0bda7d6edf561d8f623d4", |
| "internal/slides/pdfcore/testdata/slides_pdf.wasm": "78f7dcd8e7fabeb1eef2b857ae432e681b176661c8b58d6b82b38621a1cf356b", |
| - "internal/slides/static/busy.js": "b5be5c1c7239b066ec5d13e0c9a21a06c7c7a448542dc7d664a989f4589bae02", |
| + "internal/slides/static/busy.js": "b97dbe70effa06551d68a09e23cc81921f0076bb35c8d8590beb436938cdf1ff", |
| "internal/slides/static/calendar.js": "dfa06d84768b8e99d1e50d9dca81caadacf2412db74ac4e432d78c29680bbdd2", |
| "internal/slides/static/datetime.js": "5aea0521b14f9164c14b75fdcc1ff9a5429d2f51d8d78161a4eebba0e41a1ea1", |
| "internal/slides/static/editor.c3fbe7c9ae1c7c02.js": "c3fbe7c9ae1c7c02c8698dff7c2b8f8819802c259adf04368d64ce6e7005531c", |
| @@ -69,7 +69,7 @@ |
| "internal/slides/static/fontsgate.971e476eab8b8588.js": "971e476eab8b8588be520ac38eb823ab19beb2567db734555a7edc40d58567b2", |
| "internal/slides/static/fontshold.876f3d8d396da42f.js": "876f3d8d396da42f81954539f30b7200edfcde719d2920504707822f176a36ab", |
| "internal/slides/static/present.js": "046810f3116893a781471a721a7d4992df5e4dc312591501416ff4a2859f829e", |
| - "internal/slides/static/rastrillo.js": "b1eac44b25a98ca8144c59dc792ac6c5f66570b40b14f5b428c6838f88e137a3", |
| + "internal/slides/static/rastrillo.js": "13a8ca6fa9ac25833f6485ab50a521dff7bd811372025dc5141b96522b60098b", |
| "internal/slides/static/select.js": "e231bad4b964464addfacd52d2260d4bdc0a02938fc033a25fdd9cbeb3671be1", |
| "internal/slides/static/shell.js": "bdc4d635fb8f14ef7089f7f692290baea645b13543be36328e7667fe8aed2caf", |
| "rust-toolchain.toml": "88bc3a3493bc98cad9f5bc5b4f8948739e1a418d8367373bb9b854fecaf5edc6" |
diff --git a/internal/slides/render.go b/internal/slides/render.go| index 58a9acc..486dd46 100644 |
| --- a/internal/slides/render.go |
| +++ b/internal/slides/render.go |
| @@ -12,6 +12,7 @@ import ( |
| "amadan.net/oficina/estilo.git/base" |
| "amadan.net/oficina/estilo.git/chrome" |
| "amadan.net/oficina/estilo.git/credits" |
| + "amadan.net/oficina/estilo.git/desk" |
| estilomenu "amadan.net/oficina/estilo.git/menu" |
| "amadan.net/oficina/estilo.git/savestatus" |
| "amadan.net/oficina/home/connect" |
| @@ -50,8 +51,8 @@ const DefaultLocale = "en" |
| // the handler New mounts (app.go). |
| // |
| // The tree it serves is the app's own static/ plus estilo's shared |
| -// chrome, under static/estilo/: base.css, menu.css, chrome.css and the |
| -// optional chrome.js. Served from here rather than linked from estilo, |
| +// chrome, under static/estilo/: base.css, menu.css, chrome.css, desk.css |
| +// and the optional chrome.js. Served from here rather than linked from estilo, |
| // so they are fingerprinted like every other asset and a new estilo pin |
| // is a new URL. |
| var assets = rastrillo.NewAssets(staticFiles()) |
| @@ -75,6 +76,9 @@ func staticFiles() fs.FS { |
| files["static/estilo/base.css"] = &fstest.MapFile{Data: base.CSS()} |
| files["static/estilo/menu.css"] = &fstest.MapFile{Data: estilomenu.CSS()} |
| files["static/estilo/chrome.css"] = &fstest.MapFile{Data: chrome.CSS()} |
| + // The desk an editor sits on (--estilo-desk, Docs' grey) and the |
| + // floating card; static/desk.css reads the token. |
| + files["static/estilo/desk.css"] = &fstest.MapFile{Data: desk.CSS()} |
| // The sky behind the sign-in door (estilo sky); its images are |
| // served by sky.Handler. |
| files["static/estilo/sky.css"] = &fstest.MapFile{Data: sky.CSS()} |
diff --git a/internal/slides/static/busy.js b/internal/slides/static/busy.js| index 550a843..4f07a5a 100644 |
| --- a/internal/slides/static/busy.js |
| +++ b/internal/slides/static/busy.js |
| @@ -9,11 +9,26 @@ |
| What a submitted button does: its label gives way to a spinner (the |
| label stays, beside the spinner, under reduced motion or forced |
| colours — tokens.css), it goes aria-busy and then disabled, and its |
| - form refuses a second submit. The spinner shows for at least |
| - HOLD_MS: a response faster than that is held back until then, so a |
| - quick save reads as a deliberate beat rather than a flicker. Going |
| - Back to the page hands every busy form back, and a submit still being |
| - held when the page is left is dropped rather than sent later. |
| + form refuses a second submit. When depends on the method, the |
| + submitter's formmethod beating the form's: |
| + |
| + POST the spinner shows at once and for at least HOLD_MS: a |
| + response faster than that is held back until then, so a |
| + quick save reads as a deliberate beat rather than a flicker. |
| + A save changes something, and the beat says it happened. |
| + GET the submit goes at once, and the button shows nothing |
| + unless the page is still here SHOW_AFTER_MS later. A GET |
| + only looks something up (a search, a filter, a view): |
| + holding it made every look slower for a spinner nobody |
| + needed, and one that flashes on its way out is a glitch. |
| + The form refuses a second submit from the start. |
| + |
| + Going Back to the page hands every busy form back. A submit still |
| + being held when the page is left is dropped rather than sent |
| + later, and a GET's spinner still waiting is never shown. Left means |
| + a navigation has started, not that it has finished. A form pow.js |
| + protects is pow's to hold: this file arms only pow's re-send and |
| + never holds it. |
| Vocabulary: |
| data-busy="false" on a <form> or on one submit button: opt OUT |
| @@ -22,6 +37,10 @@ |
| included — changes nothing |
| data-busy-label="…" on the form or on the button: replacement |
| button text while it works |
| + data-live-form on a <form>: live.js's to send, and to show |
| + busy, whenever it claims the submit (marking |
| + the event e.liveForm); this file arms it only |
| + when live.js lets it go natively |
| A script that handles a submit itself (a fetch, say) cancels it in a |
| listener on the form or the document, as it would anyway: those run |
| @@ -34,10 +53,15 @@ |
| (function () { |
| "use strict"; |
| - // How long the spinner shows, at least. Long enough to read as an |
| - // answer to the click, short enough never to feel like waiting. |
| + // How long a POST's spinner shows, at least. Long enough to read as |
| + // an answer to the click, short enough never to feel like waiting. |
| var HOLD_MS = 650; |
| + // How long a GET may take before its button says it is working. |
| + // Under half a second a click and its answer read as one event; past |
| + // it, a still button reads as a missed click. |
| + var SHOW_AFTER_MS = 500; |
| + |
| // ── The busy rule ──────────────────────────────────────────────── |
| // |
| // A button that CHANGES something says so while it works; a button |
| @@ -71,6 +95,8 @@ |
| // Every busy element in the DOCUMENT, then the ownership test: a |
| // form="id" submit button is owned by a form it does not live in. |
| function busyOff(form) { |
| + clearTimeout(reveals.get(form)); |
| + reveals.delete(form); |
| form.removeAttribute("aria-busy"); |
| document.querySelectorAll('[aria-busy="true"]').forEach(function (b) { |
| if (b.form !== form && !form.contains(b)) return; |
| @@ -85,9 +111,25 @@ |
| }); |
| } |
| - function busySubmit(e) { |
| + function busySubmit(e, late) { |
| var form = e.target; |
| if (!form || form.tagName !== "FORM") return; |
| + // A swapping form is live.js's whenever live.js claims it: arming it |
| + // here too would hand it back a tick after live.js cancels the |
| + // submit, clearing live.js's busy state mid-request. Whether this |
| + // capture listener runs before live.js's is down to script order, so |
| + // it is armed late, from the window listener, and only if live.js |
| + // did not claim it (e.liveForm, set in live.js's capture listener) |
| + // and nobody cancelled it. One live.js leaves to the browser (a GET, |
| + // another origin, a page live.js is not running on) keeps the rule. |
| + if (form.hasAttribute("data-live-form") && !late) return; |
| + // pow.js owns every submit of a form it protects: it cancels it, |
| + // shows its own busy state (this file's vocabulary) while it waits, |
| + // and re-sends it marked data-pow-released. Arming here before that |
| + // would hand the form back a tick later and wipe pow's feedback, and |
| + // a guard armed here would refuse pow's re-send. Arm on the re-send |
| + // only. |
| + if (form.hasAttribute("data-pow-form") && !form.hasAttribute("data-pow-released")) return; |
| if (form.getAttribute("data-busy") === "false") return; |
| // The button the browser submitted with: the one clicked, or — for |
| // Enter in a field — the default one it implicitly clicked. Only |
| @@ -109,48 +151,91 @@ |
| // shadowable, and under strict mode assigning to a shadowed one throws. |
| var to = (btn && btn.getAttribute("formtarget")) || form.getAttribute("target"); |
| if (to && to !== "_self") return; |
| - if (/^dialog$/i.test(btn && btn.getAttribute("formmethod") || |
| - form.getAttribute("method"))) return; |
| + var method = btn && btn.getAttribute("formmethod") || form.getAttribute("method"); |
| + if (/^dialog$/i.test(method)) return; |
| if (form === releasing) return; // the hold sending the submit it held |
| if (form.getAttribute("aria-busy") === "true") { e.preventDefault(); return; } |
| form.setAttribute("aria-busy", "true"); |
| if (!btn || btn.getAttribute("data-busy") === "false") btn = null; |
| + // Anything but post is a GET: a missing method, and one HTML does |
| + // not know, both submit as one. Its button waits for the reveal, and |
| + // with no busy button the hold below leaves its submit alone. |
| var label = btn && (btn.getAttribute("data-busy-label") || |
| form.getAttribute("data-busy-label")); |
| - if (btn) { |
| - btn.setAttribute("aria-busy", "true"); |
| - if (btn.tagName === "BUTTON") { |
| - if (label) { |
| - btn.setAttribute("data-idle-label", btn.textContent); |
| - btn.textContent = label; |
| - } |
| - // A child element, not a pseudo-element: the shim has to be |
| - // able to take it away again. An <input type="submit"> has no |
| - // children, which is the one shape this cannot draw a spinner |
| - // on. tokens.css stops it rotating under reduced motion. |
| - var spin = document.createElement("span"); |
| - spin.setAttribute("rst-spin", ""); |
| - spin.setAttribute("aria-hidden", "true"); |
| - btn.insertBefore(spin, btn.firstChild); |
| - } |
| + if (!/^post$/i.test(method || "")) { |
| + if (btn) reveals.set(form, setTimeout(function () { reveal(form, btn, label); }, SHOW_AFTER_MS)); |
| + setTimeout(function () { |
| + // Cancelled downstream, as below: hand the form back, and |
| + // cancel the reveal with it. |
| + if (e.defaultPrevented) busyOff(form); |
| + }, 0); |
| + return; |
| } |
| + if (btn) dress(btn, label); |
| setTimeout(function () { |
| // Someone downstream cancelled the submit — an app handler doing |
| // the work itself, most likely. Nothing is on its way anywhere, |
| // so hand the form back, guard included, and let whoever took the |
| // job own the feedback too. |
| if (e.defaultPrevented && !held.has(e)) { busyOff(form); return; } |
| - if (!btn) return; |
| - if (label && btn.tagName === "INPUT") { |
| - btn.setAttribute("data-idle-label", btn.value); |
| - btn.value = label; |
| - } |
| - btn.disabled = true; |
| + if (btn) harden(btn, label); |
| }, 0); |
| } |
| + // The half of the busy state that cannot touch the payload. The |
| + // spinner is a child element, not a pseudo-element, so busyOff can |
| + // take it away again. An <input type="submit"> has no children, |
| + // which is the one shape this cannot draw a spinner on. tokens.css |
| + // stops it rotating under reduced motion. |
| + function dress(btn, label) { |
| + btn.setAttribute("aria-busy", "true"); |
| + if (btn.tagName !== "BUTTON") return; |
| + if (label) { |
| + btn.setAttribute("data-idle-label", btn.textContent); |
| + btn.textContent = label; |
| + } |
| + var spin = document.createElement("span"); |
| + spin.setAttribute("rst-spin", ""); |
| + spin.setAttribute("aria-hidden", "true"); |
| + btn.insertBefore(spin, btn.firstChild); |
| + } |
| + |
| + // The half that can: a disabled button drops its name and value, and |
| + // an <input type="submit">'s value is what it submits. |
| + function harden(btn, label) { |
| + if (label && btn.tagName === "INPUT") { |
| + btn.setAttribute("data-idle-label", btn.value); |
| + btn.value = label; |
| + } |
| + btn.disabled = true; |
| + } |
| + |
| document.addEventListener("submit", busySubmit, true); |
| + // ── The reveal ─────────────────────────────────────────────────── |
| + // |
| + // A GET's page is still here SHOW_AFTER_MS after the click, so the |
| + // answer is slow, and the button says so now: the busy state a POST |
| + // shows at once. Nothing here can change the payload any more; the |
| + // entry list was built long ago. A button that has left its form |
| + // meanwhile (a polled fragment replacing it, a form= changed) is not |
| + // the one working, and busyOff would never find it to hand it back. |
| + var reveals = new Map(); // form -> the timer that will reveal its button |
| + function reveal(form, btn, label) { |
| + reveals.delete(form); |
| + if (form.getAttribute("aria-busy") !== "true") return; |
| + if (!btn.isConnected || btn.form !== form) return; |
| + dress(btn, label); |
| + harden(btn, label); |
| + } |
| + |
| + // Every reveal still waiting is dropped. Not on beforeunload: a GET's |
| + // own navigation fires it, and a slow one is exactly when to show. |
| + function dropReveals() { |
| + reveals.forEach(function (timer) { clearTimeout(timer); }); |
| + reveals.clear(); |
| + } |
| + |
| // ── The hold ───────────────────────────────────────────────────── |
| // |
| // A spinner can only be promised a minimum time by holding the |
| @@ -174,6 +259,16 @@ |
| var form = e.target; |
| if (!form || form.tagName !== "FORM") return; |
| if (form === releasing) { releasing = null; return; } |
| + if (form.hasAttribute("data-live-form")) { |
| + if (e.defaultPrevented || e.liveForm) return; |
| + busySubmit(e, true); |
| + } |
| + // Never hold a pow form: pow has already held it while it solved, |
| + // and a second hold is a second wait for nothing. Worse, holding it |
| + // here and re-sending later would send it back through pow, which |
| + // would hold it again with busy.js's guard still armed, and the form |
| + // could never submit. |
| + if (form.hasAttribute("data-pow-form")) return; |
| if (e.defaultPrevented || form.getAttribute("aria-busy") !== "true") return; |
| // Only a submit with a spinner to show is held: the hold is for the |
| // spinner. A script's requestSubmit() with no submitter, or a button |
| @@ -184,6 +279,13 @@ |
| e.preventDefault(); |
| held.add(e); |
| pending.set(form, setTimeout(function () { release(form, btn); }, HOLD_MS)); |
| + // pagehide fires only once a navigation commits, and a slow |
| + // destination leaves the hold running until then: a held submit |
| + // released meanwhile replaces the navigation the visitor chose. |
| + // beforeunload fires as the navigation starts. Attached only while |
| + // something is held, so it keeps no page out of the back-forward |
| + // cache. |
| + if (pending.size === 1) window.addEventListener("beforeunload", dropHeld); |
| }); |
| // Send the held submit. The submitter goes with it, so its name and |
| @@ -195,6 +297,7 @@ |
| // must be handed back with its errors showing, not left spinning. |
| function release(form, btn) { |
| pending.delete(form); |
| + if (pending.size === 0) window.removeEventListener("beforeunload", dropHeld); |
| if (!form.isConnected) return; |
| var skip = form.hasAttribute("novalidate") || |
| (btn && btn.hasAttribute("formnovalidate")); |
| @@ -234,19 +337,32 @@ |
| } |
| } |
| + // A navigation started while a submit was held: drop every held |
| + // submit and hand the forms back, so a navigation that is then |
| + // cancelled (a download, a beforeunload prompt) leaves no form |
| + // spinning. |
| + function dropHeld() { |
| + pending.forEach(function (timer, form) { |
| + clearTimeout(timer); |
| + busyOff(form); |
| + }); |
| + pending.clear(); |
| + window.removeEventListener("beforeunload", dropHeld); |
| + } |
| + |
| // Leaving the page — a link, Back — while a submit is held drops it: |
| // the visitor has gone somewhere else, and a timer surviving into the |
| - // back/forward cache would otherwise send it on their return. |
| - window.addEventListener("pagehide", function () { |
| - pending.forEach(function (timer) { clearTimeout(timer); }); |
| - pending.clear(); |
| - }); |
| + // back/forward cache would otherwise send it on their return, or |
| + // dress a form they walked away from as busy. |
| + window.addEventListener("pagehide", function () { dropHeld(); dropReveals(); }); |
| // The back/forward cache restores a page's DOM exactly as it was left |
| // — busy buttons still disabled, still wearing the busy label and the |
| // spinner — so a visitor who navigates back finds a dead form. Hand |
| // every busy form back. |
| window.addEventListener("pageshow", function (e) { |
| - if (e.persisted) document.querySelectorAll("form[aria-busy]").forEach(busyOff); |
| + if (!e.persisted) return; |
| + document.querySelectorAll("form[aria-busy]").forEach(busyOff); |
| + dropReveals(); |
| }); |
| })(); |
diff --git a/internal/slides/static/decks.css b/internal/slides/static/decks.css| index d19f3e1..8d7f120 100644 |
| --- a/internal/slides/static/decks.css |
| +++ b/internal/slides/static/decks.css |
| @@ -3,20 +3,12 @@ |
| first slides lying on a desk, everything older as rows. The light on |
| them is brand/light.css's; this file is the still design. */ |
| -/* The desk. The page under the decks is lit from above by a wash of |
| - Slides' own hue (the icon's glow, estilo theme/apps.go hue 56, at the |
| - aurora's lightness). One hue only, as the app icons have; the suite's |
| - full aurora stays on Home. Painted on the body so it reaches the bar |
| - and the edges without anything here overflowing. Over the desk the |
| - editor and the viewer sit on too (static/desk.css), so going from the |
| - list into a deck never changes the room. */ |
| +/* The desk: the same grey the editor and the viewer sit on |
| + (static/desk.css, estilo's --estilo-desk), plain, so going from the |
| + list into a deck never changes the room. Painted on the body so it |
| + reaches the bar and the edges without anything here overflowing. */ |
| body:has([slides-decks]) { |
| - background: |
| - radial-gradient(ellipse 70rem 28rem at 50% -6rem, |
| - light-dark(oklch(0.88 0.06 56 / 0.5), oklch(0.42 0.08 56 / 0.14)), |
| - transparent 70%) |
| - no-repeat, |
| - var(--slides-desk, var(--rst-bg)); |
| + background: var(--slides-desk); |
| } |
| [slides-decks] { |
| padding-block: var(--rst-sp-4) var(--rst-sp-6); |
diff --git a/internal/slides/static/desk.css b/internal/slides/static/desk.css| index ca770f3..bb52c12 100644 |
| --- a/internal/slides/static/desk.css |
| +++ b/internal/slides/static/desk.css |
| @@ -1,17 +1,19 @@ |
| /* desk.css — the desk the slides sit on (I2, after Docs' editor): one |
| colour for the deck list, the viewer and the editor, so moving between |
| - them never changes the room. A warm grey from Slides' own hue in light, |
| - near-black in dark, so a slide reads as a lit page on a surface. |
| + them never changes the room. Docs' own cool grey in light, near-black |
| + in dark, so a slide reads as a lit page on a surface. The colour is |
| + estilo's (--estilo-desk, desk.css under static/estilo/), so Slides and |
| + Docs sit on the same desk; this file only names it for Slides. |
| - Registered as a <color> so light-dark() resolves on :root, in the |
| + Registered as a <color> so the token resolves on :root, in the |
| reader's scheme, and the resolved colour is what inherits. */ |
| @property --slides-desk { |
| syntax: "<color>"; |
| inherits: true; |
| - initial-value: #ebe7e2; |
| + initial-value: #e3e7ee; |
| } |
| :root { |
| - --slides-desk: light-dark(#ebe7e2, #0e1014); |
| + --slides-desk: var(--estilo-desk); |
| } |
| body:has(:is([slides-editor], [slides-viewer], [slides-decks])) { |
| background: var(--slides-desk); |
diff --git a/internal/slides/static/rastrillo.js b/internal/slides/static/rastrillo.js| index 2c9cd5a..d9a9063 100644 |
| --- a/internal/slides/static/rastrillo.js |
| +++ b/internal/slides/static/rastrillo.js |
| @@ -38,10 +38,16 @@ |
| direct navigation. Reserved: the framework's own handlers do not |
| read it today. |
| - Menus: an open <details rst-dropdown>, <details rst-row-menu> or a |
| - nested <details rst-menu-group> closes on an outside click and on |
| - Escape, in EITHER spelling, so upgrading this file before running |
| - `rastrillo markup` leaves no dead menus. Exclusivity stays native. |
| + Menus: an open <details rst-dropdown>, <details rst-row-menu>, a |
| + nested <details rst-menu-group>, or the topbar's and console's narrow |
| + <details rst-shell-menu> card (whose content is its next sibling, the |
| + tail) closes on an outside click and on Escape, in EITHER spelling, |
| + so upgrading this file before running `rastrillo markup` leaves no |
| + dead menus. Exclusivity stays native. (anchor.js, beside this file, |
| + keeps a dropdown's menu on the screen where CSS anchor positioning |
| + is missing.) A switch's knob can be dragged along its track, and |
| + snaps to the nearer end. The colour-scheme menu's forms apply in |
| + place and write the server's cookie, instead of posting. |
| A polled response may answer 204 with a Rastrillo-Location header |
| instead of a fragment; the shim navigates there, but only to a local |
| @@ -157,19 +163,51 @@ |
| // clicking elsewhere INSIDE the parent closing the submenu — the |
| // contains(except) test below already draws that line for free. |
| // |
| - // Shell chrome and the toggle-block are deliberately absent from |
| - // MENUS. A sidebar's disclosure strip and a settings switch are not |
| - // menus; closing them because a click landed elsewhere would fight the |
| - // user rather than help. |
| + // The old sidebar drawer and the toggle-block are deliberately absent |
| + // from MENUS: neither is a menu, and closing one because a click |
| + // landed elsewhere would fight the user. The topbar's and console's |
| + // narrow Menu IS in, since it became a floating card: an overlay, which |
| + // is what this list is for. It is not in the rst-menus name group, |
| + // which is document-wide; there, opening the account menu inside the |
| + // card would close the card around it. |
| var MENUS = "[rst-dropdown][open],[rst-menu-group][open],[rst-row-menu][open]"; |
| MENUS += "," + MENUS.replace(/\[(rst[-\w]+)\]/g, ".$1"); |
| + // Written out rather than derived: the class spelling of rst-shell-menu |
| + // is .rst-shell__menu, which the rewrite above would spell wrong. Only |
| + // in a topbar, or a console whose root names its view: a console |
| + // layout from before the phone index gates its RAIL on this [open], |
| + // and dismissing it there closed the whole navigation on a tap at a |
| + // group label. No :is(), so an older engine still parses the list. |
| + MENUS += ",[rst-shell-topbar] [rst-shell-menu][open],[rst-shell-console~=page] [rst-shell-menu][open],[rst-shell-console~=index] [rst-shell-menu][open]"; |
| + MENUS += ",.rst-shell-topbar .rst-shell__menu[open],.rst-shell-console--page .rst-shell__menu[open],.rst-shell-console--index .rst-shell__menu[open]"; |
| + var TAIL = "[rst-shell-tail],.rst-shell__tail"; |
| - // except is the clicked node: the menu containing it stays open, which |
| - // is what keeps a click on a menu item — or on the summary of a menu |
| - // being opened right now — from closing the thing being used. |
| + // menuAround is closest(MENUS) plus one logical parent. The card's |
| + // content (the tail) is the shell menu's next SIBLING, not its child, |
| + // so without this a click on the account menu inside the card would |
| + // close the card, and Escape from a plain nav link in it would find no |
| + // menu at all. Only while the Menu summary is rendered: at 800px and |
| + // up it is display: none, while a <details> opened at 390 and then |
| + // widened keeps [open], and climbing to it would hand focus to a |
| + // summary nobody can see. |
| + function menuAround(node) { |
| + var d = node.closest(MENUS), t, s; |
| + if (d) return d; |
| + t = node.closest(TAIL); |
| + d = t && t.previousElementSibling; |
| + s = d && d.matches(MENUS) && d.querySelector("summary"); |
| + return s && s.getClientRects().length ? d : null; |
| + } |
| + |
| + // except is the clicked node: every menu around it, directly or through |
| + // menuAround's climb, stays open, which is what keeps a click on a menu |
| + // item, or on the summary of a menu being opened right now, from |
| + // closing the thing being used. |
| function closeMenus(except) { |
| + var keep = [], m; |
| + for (m = except && except.closest && menuAround(except); m; m = m.parentElement && menuAround(m.parentElement)) keep.push(m); |
| document.querySelectorAll(MENUS).forEach(function (d) { |
| - if (!except || !d.contains(except)) d.open = false; |
| + if (keep.indexOf(d) < 0 && !(except && d.contains(except))) d.open = false; |
| }); |
| } |
| @@ -180,14 +218,14 @@ |
| // which strands a keyboard user at the top of the document. Hand it |
| // back to the summary that opened the menu. |
| var el = document.activeElement; |
| - var host = el && el.closest ? el.closest(MENUS) : null; |
| - // Climb to the OUTERMOST open menu around the focus. closest() finds |
| - // the innermost, which for focus inside a submenu is the submenu — |
| - // and its summary is inside the parent that is about to close too, so |
| - // focusing it would hand focus to something no longer rendered, which |
| - // is no hand-back at all. |
| - while (host && host.parentElement && host.parentElement.closest(MENUS)) { |
| - host = host.parentElement.closest(MENUS); |
| + var host = el && el.closest ? menuAround(el) : null; |
| + // Climb to the OUTERMOST open menu around the focus. menuAround |
| + // finds the innermost, which for focus inside a submenu is the |
| + // submenu, and for focus in the account menu inside the card is the |
| + // account menu: their summaries are inside the thing about to close, |
| + // so focusing one would hand focus to something no longer rendered. |
| + while (host && host.parentElement && menuAround(host.parentElement)) { |
| + host = menuAround(host.parentElement); |
| } |
| closeMenus(null); |
| if (host) { |
| @@ -199,13 +237,150 @@ |
| document.addEventListener("click", dismissMenus, true); |
| document.addEventListener("keydown", dismissMenus, true); |
| + // A switch slides. A press on its track that moves 4px drags the knob |
| + // (the CSS reads its share of the travel, --rst-switch-p, and the on |
| + // colour's share, --rst-switch-on, off the track) and on release the |
| + // knob goes to the nearer end (half way is on) with the firm release |
| + // curve, which the CSS keys off data-rst-settle on the label for the |
| + // 0.18s it takes and a little slack; if that end is the other state, |
| + // the checkbox is clicked, so input and change fire as for a tap. A |
| + // press that does not move is the label's, which toggles as it always |
| + // has; after a drag the label's own click is cancelled (never the |
| + // checkbox's, which Space and the drop above send), so nothing |
| + // toggles twice. The checkbox stays the state. |
| + var TRACK = "[rst-switch-track],.rst-switch__track", drag = null, after = null, settling = null, settleT = 0, releasing = false; |
| + function unsettle() { |
| + if (settling) settling.removeAttribute("data-rst-settle"); |
| + settling = null; |
| + clearTimeout(settleT); |
| + } |
| + function settle(l) { |
| + unsettle(); |
| + settling = l; |
| + l.setAttribute("data-rst-settle", ""); |
| + settleT = setTimeout(unsettle, 300); |
| + } |
| + // A toggle while a switch settles takes a toggle's own curve: the |
| + // mark goes on change, bar the release's own click. |
| + document.addEventListener("change", function (e) { if (settling && !releasing && settling.contains(e.target)) unsettle(); }, true); |
| + // One drag at a time: a second finger is ignored until the first |
| + // lifts, and a drag ends (cleaned up, committed only on pointerup) |
| + // however its pointer goes. A press by the same pointer means its |
| + // release was missed, so that drag is over. |
| + document.addEventListener("pointerdown", function (e) { |
| + if (drag && e.pointerId !== drag.id) return; |
| + // A toggle block's head is a switch too; its own input is first. |
| + var t = e.target.closest && e.target.closest(TRACK), l = t && t.closest("[rst-switch],.rst-switch,[rst-tblock-head],.rst-tblock__head"), box = l && l.querySelector("input"); |
| + if (drag) drop({ type: "lost", pointerId: drag.id }); |
| + after = null; |
| + // :disabled, not .disabled: a disabled fieldset disables the box |
| + // without setting its property, and a click on it does nothing. |
| + if (!box || box.matches(":disabled") || e.button) return; |
| + var r = t.getBoundingClientRect(), max = r.width - r.height; |
| + drag = { l: l, t: t, box: box, id: e.pointerId, x: e.clientX, max: max, at: box.checked ? max : 0, pos: -1, |
| + dir: getComputedStyle(t).direction === "rtl" ? -1 : 1 }; |
| + }); |
| + document.addEventListener("pointermove", function (e) { |
| + var g = drag, d; |
| + if (!g || e.pointerId !== g.id) return; |
| + d = (e.clientX - g.x) * g.dir; |
| + if (g.pos < 0) { |
| + if (Math.abs(d) < 4) return; |
| + // A drag on a settling switch takes over: no mark. |
| + if (settling === g.l) unsettle(); |
| + g.l.setAttribute("data-rst-drag", ""); |
| + g.t.setPointerCapture(e.pointerId); |
| + } |
| + g.pos = Math.min(g.max, Math.max(0, g.at + d)); |
| + d = g.pos / g.max; |
| + g.t.style.setProperty("--rst-switch-p", d); |
| + g.t.style.setProperty("--rst-switch-on", d * 100 + "%"); |
| + }); |
| + function drop(e) { |
| + var g = drag; |
| + if (!g || e.pointerId !== g.id) return; |
| + drag = null; |
| + if (g.pos < 0) return; |
| + g.l.removeAttribute("data-rst-drag"); |
| + settle(g.l); |
| + g.t.style.removeProperty("--rst-switch-p"); |
| + g.t.style.removeProperty("--rst-switch-on"); |
| + after = g.l; |
| + releasing = true; |
| + if (e.type === "pointerup" && !g.box.matches(":disabled") && g.pos >= g.max / 2 !== g.box.checked) g.box.click(); |
| + releasing = false; |
| + } |
| + document.addEventListener("pointerup", drop); |
| + document.addEventListener("pointercancel", drop); |
| + document.addEventListener("lostpointercapture", drop); |
| + document.addEventListener("click", function (e) { |
| + if (after && after.contains(e.target) && e.target.tagName !== "INPUT") { |
| + e.preventDefault(); |
| + after = null; |
| + } |
| + }, true); |
| + |
| + // iOS applies :active on a tap only when a touch listener exists. This |
| + // file owns the listener, not light.js, so an app that deletes |
| + // light.js keeps its pressed states. |
| + document.addEventListener("touchstart", function () {}, { passive: true }); |
| + |
| + // The colour-scheme switch's forms ([rst-scheme], POST /_theme) apply |
| + // here instead of round-tripping: data-theme on <html> is what the |
| + // themes read, and the cookie is the server's own (name, path, age, |
| + // SameSite), so the next render paints the same scheme first. System |
| + // is no attribute and no cookie, as on the server. |
| + document.addEventListener("submit", function (e) { |
| + var f = e.target, m = f.closest("[rst-scheme],.rst-scheme"), s = m && f.elements.scheme && f.elements.scheme.value, on = s === "light" || s === "dark"; |
| + if (!s) return; |
| + e.preventDefault(); |
| + if (on) document.documentElement.setAttribute("data-theme", s); else document.documentElement.removeAttribute("data-theme"); |
| + land(); |
| + document.cookie = "rastrillo_scheme=" + (on ? s + "; Max-Age=31536000" : "; Max-Age=0") + "; Path=/; SameSite=Lax" + (location.protocol === "https:" ? "; Secure" : ""); |
| + // Not toggleAttribute: aria-current="" reads as false. |
| + m.querySelectorAll("button").forEach(function (b) { if (b.form === f) b.setAttribute("aria-current", "true"); else b.removeAttribute("aria-current"); }); |
| + m.open = false; |
| + }, true); |
| + |
| + // A scheme change lands in the frame it happens in. The shipped |
| + // tints need no help: at rest nothing fades its background, and a |
| + // hovered row's, tile's or rail item's tint rides a registered |
| + // percentage, so a change of scheme re-resolves its colour at once. |
| + // What this lands is everything else still running: an app's own |
| + // colour transitions, or a switch track mid-toggle, which a change |
| + // of scheme would otherwise retarget while the text changes at |
| + // once. getAnimations() flushes style, which starts the transitions, |
| + // and cancelling one lands it on its end value. Transitions only, |
| + // told by transitionProperty: cancelling an animation would stop a |
| + // spinner for good. |
| + function land() { |
| + if (!document.getAnimations) return; |
| + document.getAnimations().forEach(function (a) { if (typeof a.transitionProperty === "string") a.cancel(); }); |
| + } |
| + |
| + // The OS flipping under a page on System is the same change with no |
| + // click: light-dark() repaints with no script involved. The change |
| + // event reaches script a frame after the style update that started |
| + // the fade, so this lands it a frame late rather than 200ms late. |
| + var osScheme = window.matchMedia && matchMedia("(prefers-color-scheme: dark)"); |
| + if (osScheme) osScheme.onchange = function () { if (!document.documentElement.hasAttribute("data-theme")) land(); }; |
| + |
| function scan() { |
| document.querySelectorAll("[data-poll]").forEach(poll); |
| } |
| + // A prerendered page runs this before anyone is looking at it, and |
| + // may never be shown: polling there would fetch on a timer, or hold an |
| + // EventSource open, for a page the reader only hovered a link to. It |
| + // starts when the page is activated instead. |
| + function start() { |
| + if (document.prerendering) document.addEventListener("prerenderingchange", scan, { once: true }); |
| + else scan(); |
| + } |
| + |
| if (document.readyState === "loading") { |
| - document.addEventListener("DOMContentLoaded", scan); |
| + document.addEventListener("DOMContentLoaded", start); |
| } else { |
| - scan(); |
| + start(); |
| } |
| })(); |
diff --git a/internal/slides/templates/layout.html b/internal/slides/templates/layout.html| index 0c07361..02f9bfc 100644 |
| --- a/internal/slides/templates/layout.html |
| +++ b/internal/slides/templates/layout.html |
| @@ -26,7 +26,7 @@ |
| <meta charset> comes first, before anything that could be read as |
| text. The stylesheets are in the suite's fixed order: tokens, theme, |
| - brand, then estilo's base, menu and chrome, then the page's own |
| + brand, then estilo's base, menu, chrome and desk, then the page's own |
| (page-head). */}} |
| <html lang="{{block "lang" .}}en{{end}}" dir="{{block "dir" .}}ltr{{end}}"{{with .Frame.Theme}} data-theme="{{.}}"{{end}}> |
| <head> |
| @@ -60,6 +60,7 @@ |
| <link rel="stylesheet" href="{{asset "static/estilo/base.css"}}"> |
| <link rel="stylesheet" href="{{asset "static/estilo/menu.css"}}"> |
| <link rel="stylesheet" href="{{asset "static/estilo/chrome.css"}}"> |
| +<link rel="stylesheet" href="{{asset "static/estilo/desk.css"}}"> |
| <link rel="stylesheet" href="{{asset "static/estilo/sky.css"}}"> |
| <script defer src="{{asset "static/rastrillo.js"}}"></script> |
| <script defer src="{{asset "static/busy.js"}}"></script> |
diff --git a/internal/slidestest/editor_tidy_test.go b/internal/slidestest/editor_tidy_test.go| new file mode 100644 |
| index 0000000..eac4121 |
| --- /dev/null |
| +++ b/internal/slidestest/editor_tidy_test.go |
| @@ -0,0 +1,77 @@ |
| +package slidestest |
| + |
| +import ( |
| + "net/http" |
| + "os" |
| + "path/filepath" |
| + "regexp" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +// The editor, tidied (docs/superpowers/specs/2026-11-16-editor-tidy-design.md). |
| + |
| +// deskLink is estilo's desk part as the layout links it: fingerprinted, |
| +// under static/estilo/. |
| +var deskLink = regexp.MustCompile(`/static/estilo/desk\.[0-9a-f]{16}\.css`) |
| + |
| +// TestEditorTidyServesEstiloDesk: estilo's desk part is served beside |
| +// its chrome, and the editor and the deck list both link it, so the |
| +// grey under a deck is estilo's token and not a copy of it. |
| +func TestEditorTidyServesEstiloDesk(t *testing.T) { |
| + a := newApp(t) |
| + |
| + css := mustGet(t, a, "/static/estilo/desk.css", http.StatusOK, nil).Body.String() |
| + if !strings.Contains(css, "--estilo-desk:") { |
| + t.Errorf("/static/estilo/desk.css defines no --estilo-desk:\n%s", css) |
| + } |
| + |
| + cookies := signedIn(t, a, allowedAddress) |
| + path := sampleDeck(t, a, cookies) |
| + for _, page := range []string{"/", path + "/edit"} { |
| + body := mustGet(t, a, page, http.StatusOK, cookies).Body.String() |
| + link := deskLink.FindString(body) |
| + if link == "" { |
| + t.Errorf("GET %s links no estilo desk.css:\n%s", page, body) |
| + continue |
| + } |
| + if got := mustGet(t, a, link, http.StatusOK, nil).Body.String(); got != css { |
| + t.Errorf("GET %s: %s is not the desk.css served unfingerprinted", page, link) |
| + } |
| + chrome := regexp.MustCompile(`/static/estilo/chrome\.[0-9a-f]{16}\.css`).FindStringIndex(body) |
| + if chrome == nil || strings.Index(body, link) < chrome[1] { |
| + t.Errorf("GET %s: desk.css is not linked after chrome.css", page) |
| + } |
| + } |
| +} |
| + |
| +// TestEditorTidyDeskIsEstilos: Slides' desk is estilo's grey, Docs' |
| +// own, not Slides' warm grey; and the deck list sits on that same desk, |
| +// with no wash of colour over it. |
| +func TestEditorTidyDeskIsEstilos(t *testing.T) { |
| + desk := readStatic(t, "desk.css") |
| + if !strings.Contains(desk, "var(--estilo-desk)") { |
| + t.Error("static/desk.css does not read var(--estilo-desk)") |
| + } |
| + if strings.Contains(desk, "#ebe7e2") { |
| + t.Error("static/desk.css still carries Slides' warm grey #ebe7e2") |
| + } |
| + |
| + decks := readStatic(t, "decks.css") |
| + rule := regexp.MustCompile(`body:has\(\[slides-decks\]\)\s*\{[^}]*\}`).FindString(decks) |
| + if rule == "" { |
| + t.Fatal("static/decks.css has no body:has([slides-decks]) rule") |
| + } |
| + if strings.Contains(rule, "gradient") { |
| + t.Errorf("the deck list's ground still has a gradient:\n%s", rule) |
| + } |
| +} |
| + |
| +func readStatic(t *testing.T, name string) string { |
| + t.Helper() |
| + b, err := os.ReadFile(filepath.Join("..", "slides", "static", name)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return string(b) |
| +} |
diff --git a/internal/slidestest/signin_door_test.go b/internal/slidestest/signin_door_test.go| index 52e88ce..bcd9793 100644 |
| --- a/internal/slidestest/signin_door_test.go |
| +++ b/internal/slidestest/signin_door_test.go |
| @@ -24,7 +24,7 @@ func TestSignInPageIsTheDoor(t *testing.T) { |
| if !regexp.MustCompile(`<img estilo-sky-layer="placeholder"[^>]*src="data:image/png;base64,`).MatchString(body) { |
| t.Error("sign-in page has no inline sky placeholder") |
| } |
| - layer := regexp.MustCompile(`<img estilo-sky-layer="[a-z]+"[^>]*src="(/static/estilo/sky/v1/[^"]+)"`).FindStringSubmatch(body) |
| + layer := regexp.MustCompile(`<img estilo-sky-layer="[a-z]+"[^>]*src="(/static/estilo/sky/v[0-9]+/[^"]+)"`).FindStringSubmatch(body) |
| if layer == nil { |
| t.Fatal("sign-in page links no served sky layer") |
| } |