The Colophon and the Drive chooser on the spacing scale
- credits.css: the Colophon (estilo/credits, /help/open-source) is a stack on estilo's terms, as the door's card is: a column, children's block margins gone, the list --rst-sp-2 under its heading (was the browser's 18.8px), and an open entry's source, notice names and texts --rst-sp-2 apart (were 14px). - googleimport: the chooser gets a stylesheet of its own, CSS(): the disclosure, Choose --rst-sp-4 under it, Cancel --rst-sp-2 under Choose, the status --rst-sp-3 under the buttons; margins, so a hidden button or an empty status takes no space. Apps link it beside the script (README). - The rhythm drive audits both, from their own roots, closed and open, ready and busy, and holds their gaps; both fail on main's CSS. Its rhythm.js is Fiesta's next audit (closed details skipped).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 files changed,
+292
−38
chrome/rhythm.browser.mjs+4 −3chrome/rhythm_browser_test.go+103 −13chrome/testdata/rhythm.js+109 −20credits/credits.css+13 −1credits/credits_test.go+17 −0googleimport/README.md+4 −1googleimport/google-import.css+17 −0googleimport/googleimport.go+9 −0googleimport/googleimport_test.go+16 −0
CI passed — run details
CI log
=== modcache === all modules verified === vet === CGO_ENABLED=0 go vet ./... CGO_ENABLED=0 go vet -tags browser ./... === fmt === === build === CGO_ENABLED=0 go build -buildvcs=false ./... === go-test === CGO_ENABLED=0 go test -count=1 ./... ok amadan.net/oficina/estilo.git/base 0.004s ok amadan.net/oficina/estilo.git/brand 0.003s ok amadan.net/oficina/estilo.git/busy 0.009s ok amadan.net/oficina/estilo.git/callui 0.006s ok amadan.net/oficina/estilo.git/chrome 2.993s ? amadan.net/oficina/estilo.git/cmd/oficina-notices [no test files] ok amadan.net/oficina/estilo.git/colophon 0.021s ok amadan.net/oficina/estilo.git/credits 0.005s ok amadan.net/oficina/estilo.git/credits/catalog 0.004s ok amadan.net/oficina/estilo.git/desk 0.004s ok amadan.net/oficina/estilo.git/googleimport 1.028s ok amadan.net/oficina/estilo.git/homeconnect 0.006s ok amadan.net/oficina/estilo.git/internal/lint 0.007s ? amadan.net/oficina/estilo.git/internal/tokencheck [no test files] ok amadan.net/oficina/estilo.git/menu 0.010s ok amadan.net/oficina/estilo.git/savestatus 0.121s ok amadan.net/oficina/estilo.git/side 0.135s ok amadan.net/oficina/estilo.git/sky 0.032s ok amadan.net/oficina/estilo.git/theme 0.013s === spacing === go run amadan.net/rastrillo/fiesta/cmd/fiesta@v1.6.0 spacing .
diff --git a/chrome/rhythm.browser.mjs b/chrome/rhythm.browser.mjs| index c9d7c95..36187c9 100644 |
| --- a/chrome/rhythm.browser.mjs |
| +++ b/chrome/rhythm.browser.mjs |
| @@ -7,8 +7,8 @@ |
| // ESTILO_PLAYWRIGHT=<path to the playwright package> \ |
| // node rhythm.browser.mjs <job JSON> |
| // |
| -// Job: {origin, engines, viewports, pages, root, script, sizes, gaps, |
| -// shots}. Output: one entry per engine, {engine, version, error, pages: |
| +// Job: {origin, engines, viewports, pages, root, roots, script, sizes, |
| +// gaps, shots}; roots names a page's own root where it is not root. Output: one entry per engine, {engine, version, error, pages: |
| // [{page, viewport, findings, sizes, gaps}]}: sizes is each selector's |
| // [width, height] and gaps the space above it from its previous |
| // sibling, or null where the page has no such element. With shots set to a directory, each page is |
| @@ -31,7 +31,8 @@ for (const engine of job.engines) { |
| for (const name of job.pages) { |
| await page.goto(job.origin + '/' + name) |
| await page.evaluate(() => document.fonts.ready) |
| - const findings = await page.evaluate(([script, root]) => (0, eval)(script)(root, {}), [job.script, job.root]) |
| + const root = (job.roots && job.roots[name]) || job.root |
| + const findings = await page.evaluate(([script, root]) => (0, eval)(script)(root, {}), [job.script, root]) |
| const sizes = await page.evaluate((sels) => Object.fromEntries(sels.map((s) => { |
| const el = document.querySelector(s) |
| const r = el ? el.getBoundingClientRect() : null |
diff --git a/chrome/rhythm_browser_test.go b/chrome/rhythm_browser_test.go| index cd95bf3..d1ac8a6 100644 |
| --- a/chrome/rhythm_browser_test.go |
| +++ b/chrome/rhythm_browser_test.go |
| @@ -15,6 +15,7 @@ import ( |
| "bytes" |
| "encoding/json" |
| "fmt" |
| + "html/template" |
| "net/http" |
| "net/http/httptest" |
| "os" |
| @@ -23,6 +24,8 @@ import ( |
| "testing" |
| "amadan.net/oficina/estilo.git/base" |
| + "amadan.net/oficina/estilo.git/credits" |
| + "amadan.net/oficina/estilo.git/googleimport" |
| "amadan.net/oficina/estilo.git/theme" |
| "github.com/carlosframework/rastrillo/ui" |
| ) |
| @@ -37,6 +40,8 @@ const doorPage = `<!doctype html> |
| <link rel="stylesheet" href="/base.css"> |
| <link rel="stylesheet" href="/brand.css"> |
| <link rel="stylesheet" href="/chrome.css"> |
| +<link rel="stylesheet" href="/credits.css"> |
| +<link rel="stylesheet" href="/google-import.css"> |
| </head> |
| <body> |
| <main id="main" rst-page> |
| @@ -108,14 +113,83 @@ var openGaps = map[string]float64{ |
| "#door-button": 16, // before a button |
| } |
| +// colophon renders estilo's Colophon (credits) with two entries, one |
| +// with its source and notices; open, every entry is open, as a reader |
| +// who opened them sees it. |
| +func colophon(t *testing.T, open bool) string { |
| + t.Helper() |
| + tpl := template.Must(template.ParseFS(credits.Templates(), "templates/*.html")) |
| + var out bytes.Buffer |
| + data := credits.PageData{Title: "Open source", MissingNoticeLabel: "No notice was found.", Components: []credits.Component{ |
| + {Name: "example.org/first", Version: "v1.2.3", SourceURL: "https://example.org/first", Notices: []credits.Notice{{Name: "LICENSE", Text: "Copyright the authors.\nPermission is granted."}, {Name: "NOTICE", Text: "Built with care."}}}, |
| + {Name: "example.org/second"}, |
| + }} |
| + if err := tpl.ExecuteTemplate(&out, "estilo/credits", data); err != nil { |
| + t.Fatal(err) |
| + } |
| + html := out.String() |
| + if open { |
| + html = strings.ReplaceAll(html, "<details>", "<details open>") |
| + } |
| + return html |
| +} |
| + |
| +// colophonGaps is the space above each of the Colophon's blocks: the |
| +// list a step under its heading, and in an open entry its source, a |
| +// notice's name and its text a step apart, the first a step under the |
| +// summary. |
| +var colophonGaps = map[string]float64{ |
| + "[estilo-credits] > ul": 8, |
| + "[estilo-credits] li:first-child details > p": 8, |
| + "[estilo-credits] li:first-child details > pre": 8, |
| + "[estilo-credits] li:first-child details > p + pre + p": 8, |
| +} |
| + |
| +// chooser renders the Google Drive chooser as its script leaves it: |
| +// ready, the Choose button shown; busy, Cancel under it and the status |
| +// saying what is happening. |
| +func chooser(t *testing.T, busy bool) string { |
| + t.Helper() |
| + tpl := template.Must(template.New("root").Parse(googleimport.Template())) |
| + var out bytes.Buffer |
| + view := googleimport.View{Config: googleimport.Config{ClientID: "123456789-client.apps.googleusercontent.com", APIKey: "AIzaPublicBrowserKey123456789", AppID: "123456789"}, Kind: googleimport.Docs, FormID: "upload", InputID: "file", Labels: googleimport.Text("en")} |
| + if err := tpl.ExecuteTemplate(&out, "estilo-google-import", view); err != nil { |
| + t.Fatal(err) |
| + } |
| + html := strings.Replace(out.String(), "<span data-google-choose-wrap hidden>", "<span data-google-choose-wrap>", 1) |
| + if busy { |
| + html = strings.Replace(html, "<span data-google-cancel-wrap hidden>", "<span data-google-cancel-wrap>", 1) |
| + html = strings.Replace(html, `aria-live="polite"></p>`, `aria-live="polite">Connecting to Google…</p>`, 1) |
| + } |
| + return html |
| +} |
| + |
| +// chooserGaps is the space above each of the chooser's blocks: Choose |
| +// --rst-sp-4 under the disclosure, Cancel --rst-sp-2 under Choose, the |
| +// status --rst-sp-3 under the buttons. |
| +var chooserGaps = map[string]float64{ |
| + "[data-google-choose-wrap]": 16, |
| + "[data-google-cancel-wrap]": 8, |
| + "[data-google-status]": 12, |
| +} |
| + |
| func openGapNames() []string { |
| var names []string |
| - for id := range openGaps { |
| - names = append(names, id) |
| + for _, gaps := range []map[string]float64{openGaps, colophonGaps, chooserGaps} { |
| + for id := range gaps { |
| + names = append(names, id) |
| + } |
| } |
| return names |
| } |
| +// pageGaps is the table each page is held to, by page. |
| +var pageGaps = map[string]map[string]float64{ |
| + "open": openGaps, |
| + "colophon-open": colophonGaps, |
| + "chooser-busy": chooserGaps, |
| +} |
| + |
| // doorPages is every page the door draws, with the states that change |
| // what the card holds (a lede, an error, the notices), and an app's own |
| // card drawn through estilo-door-open, holding every relation of the |
| @@ -139,9 +213,25 @@ func doorPages(t *testing.T) map[string]string { |
| "sent": render(t, "estilo-signin-sent", sent), |
| "signed-out": render(t, "estilo-signed-out", out), |
| "open": openCard(t), |
| + // Not door pages, but chrome every app draws: the Colophon under |
| + // Help and the Google Drive chooser, each audited from its own |
| + // root (pageRoots). |
| + "colophon": colophon(t, false), |
| + "colophon-open": colophon(t, true), |
| + "chooser-ready": chooser(t, false), |
| + "chooser-busy": chooser(t, true), |
| } |
| } |
| +// pageRoots is the root each page that is not a door card is audited |
| +// from; a door card is audited from [estilo-signin]. |
| +var pageRoots = map[string]string{ |
| + "colophon": "[estilo-credits]", |
| + "colophon-open": "[estilo-credits]", |
| + "chooser-ready": "[estilo-google-import]", |
| + "chooser-busy": "[estilo-google-import]", |
| +} |
| + |
| func TestTheDoorKeepsTheRhythm(t *testing.T) { |
| if _, err := exec.LookPath("node"); err != nil { |
| t.Fatal("node is required (Node 22+)") |
| @@ -160,7 +250,7 @@ func TestTheDoorKeepsTheRhythm(t *testing.T) { |
| if err != nil { |
| t.Fatal(err) |
| } |
| - assets := map[string][]byte{"/tokens.css": ui.TokensCSS(), "/theme.css": theme.CSS(), "/base.css": base.CSS(), "/brand.css": brandCSS, "/chrome.css": CSS()} |
| + assets := map[string][]byte{"/tokens.css": ui.TokensCSS(), "/theme.css": theme.CSS(), "/base.css": base.CSS(), "/brand.css": brandCSS, "/chrome.css": CSS(), "/credits.css": credits.CSS(), "/google-import.css": googleimport.CSS()} |
| for path, body := range assets { |
| mux.HandleFunc("GET "+path, func(w http.ResponseWriter, r *http.Request) { |
| w.Header().Set("Content-Type", "text/css; charset=utf-8") |
| @@ -188,7 +278,7 @@ func TestTheDoorKeepsTheRhythm(t *testing.T) { |
| } |
| job, _ := json.Marshal(map[string]any{ |
| "origin": srv.URL, "engines": engines, "viewports": []int{1440, 390}, |
| - "pages": names, "root": "[estilo-signin]", "script": string(script), |
| + "pages": names, "root": "[estilo-signin]", "roots": pageRoots, "script": string(script), |
| "sizes": []string{"#door-img", "#door-button"}, |
| "gaps": openGapNames(), |
| "shots": os.Getenv("ESTILO_SHOTS"), |
| @@ -222,6 +312,15 @@ func TestTheDoorKeepsTheRhythm(t *testing.T) { |
| if report.Len() > 0 { |
| t.Errorf("%s %s, %s at %dpx:%s", r.Engine, r.Version, p.Page, p.Viewport, report.String()) |
| } |
| + for id, want := range pageGaps[p.Page] { |
| + got := p.Gaps[id] |
| + switch { |
| + case got == nil: |
| + t.Errorf("%s, %s's %s at %dpx: not measured", r.Engine, p.Page, id, p.Viewport) |
| + case *got < want-0.5 || *got > want+0.5: |
| + t.Errorf("%s, %s's %s at %dpx: %.1fpx above it, want %vpx", r.Engine, p.Page, id, p.Viewport, *got, want) |
| + } |
| + } |
| if p.Page != "open" { |
| continue |
| } |
| @@ -233,15 +332,6 @@ func TestTheDoorKeepsTheRhythm(t *testing.T) { |
| if b := p.Sizes["#door-button"]; len(b) != 2 || b[0] > 200 { |
| t.Errorf("%s, the card's lone button at %dpx is %v wide: stretched across the card", r.Engine, p.Viewport, b) |
| } |
| - for id, want := range openGaps { |
| - got := p.Gaps[id] |
| - switch { |
| - case got == nil: |
| - t.Errorf("%s, the card's %s at %dpx: not measured", r.Engine, id, p.Viewport) |
| - case *got < want-0.5 || *got > want+0.5: |
| - t.Errorf("%s, the card's %s at %dpx: %.1fpx above it, want %vpx", r.Engine, id, p.Viewport, *got, want) |
| - } |
| - } |
| } |
| } |
| } |
diff --git a/chrome/testdata/rhythm.js b/chrome/testdata/rhythm.js| index 7a6ce38..106c2a1 100644 |
| --- a/chrome/testdata/rhythm.js |
| +++ b/chrome/testdata/rhythm.js |
| @@ -1,16 +1,26 @@ |
| // Fiesta's rhythm audit: the runtime half of the spacing rule |
| -// (DESIGN.md, "Spacing"). It walks a page's content as the browser laid |
| -// it out and reports three things a reader sees and a stylesheet check |
| -// cannot: |
| +// (DESIGN.md, "Checking the rhythm"). It walks a page's content as the |
| +// browser laid it out and reports what a reader sees and a stylesheet |
| +// check cannot: |
| // |
| -// off-scale two blocks, one under the other, whose gap is not a |
| -// step of the spacing scale (0, or --rst-sp-1 to 6); |
| -// touching text directly above or below a control (a button, a |
| -// field, a disclosure) with less than --rst-sp-2 between, |
| -// unless the text is the control's own <label>; |
| -// heading a heading further from its own content than it is from |
| -// what comes before it, so it reads as belonging to the |
| -// block above. |
| +// off-scale two blocks, one under the other, whose gap is not a |
| +// step of the spacing scale (0, or --rst-sp-1 to 6); |
| +// touching text directly above or below a control (a button, a |
| +// field, a disclosure) with less than --rst-sp-2 |
| +// between, unless the text is the control's own <label>; |
| +// heading a heading further from its own content than it is |
| +// from what comes before it, so it reads as belonging to |
| +// the block above (a heading whose content opens with a |
| +// heading or a section is not held to it: the one that |
| +// follows takes its own opening, and is held instead); |
| +// bent a stack (rst-stack) that an app's own rule has made |
| +// something other than the stack's column: its display, |
| +// flex-direction, flex-wrap, align-items or gap is not |
| +// the stack's, which its margins are measured against; |
| +// out-of-flow a stack's child that is absolute or fixed and that the |
| +// stack does not pass over (rst-stack-out, the modal |
| +// overlay, a dialog, a popover), so the stack gives it a margin or |
| +// reads it as the block before the next. |
| // |
| // It is one function expression, evaluated in the page: the Go package |
| // beside it wraps it as rhythm.Expression for a chromedp drive, and |
| @@ -21,14 +31,24 @@ |
| // holds blocks, except Fiesta's components (an element carrying an |
| // rst- name other than the layout ones), whose insides are Fiesta's to |
| // space and its own gates to check, text blocks (p, headings, lists, |
| -// tables, pre), controls, and whatever options.skip names. |
| +// tables, pre), controls, whatever options.skip names, and the content |
| +// of a closed <details>, which shows only its summary. The two stack |
| +// checks read every stack under the root, components' included, but |
| +// none in a skipped region or a closed <details>. |
| +// |
| +// It returns the findings. With options.result true it returns |
| +// { findings, pairs, headings, stacks } instead: the findings and how |
| +// much it read, the pairs of neighbouring blocks it measured, the |
| +// headings it held to the heading rule and the stacks it checked, so a |
| +// test can tell a page that passed from one it barely saw. |
| (function fiestaRhythm(root, options) { |
| options = options || {}; |
| var tolerance = typeof options.tolerance === "number" && options.tolerance > 0 ? options.tolerance : 0.5; |
| var skip = options.skip || []; |
| var start = typeof root === "string" ? document.querySelector(root) : root; |
| if (!start) { |
| - return [{ kind: "missing", gap: 0, before: "", after: "", message: "no element matches " + root }]; |
| + var missing = [{ kind: "missing", gap: 0, before: "", after: "", message: "no element matches " + root }]; |
| + return options.result ? { findings: missing, pairs: 0, headings: 0, stacks: 0 } : missing; |
| } |
| var htmlStyle = getComputedStyle(document.documentElement); |
| @@ -92,6 +112,22 @@ |
| return !!headingTags[el.tagName] || el.getAttribute("role") === "heading"; |
| } |
| + function opensSection(el) { |
| + return el.hasAttribute("rst-section") || el.classList.contains("rst-section"); |
| + } |
| + |
| + // closed is a <details> that is shut: of its children only the |
| + // summary is shown, and the rest is not the page's to measure. |
| + function closed(el) { |
| + return el.tagName === "DETAILS" && !el.open; |
| + } |
| + |
| + // shows says whether a child of parent is drawn as far as a closed |
| + // <details> goes. |
| + function shows(parent, child) { |
| + return !closed(parent) || child.tagName === "SUMMARY"; |
| + } |
| + |
| function shown(el) { |
| var style = getComputedStyle(el); |
| if (style.display === "none" || style.visibility === "hidden") return false; |
| @@ -110,6 +146,7 @@ |
| function flow(container) { |
| var out = []; |
| for (var el = container.firstElementChild; el; el = el.nextElementSibling) { |
| + if (!shows(container, el)) continue; |
| var style = getComputedStyle(el); |
| if (style.display === "contents") { |
| if (skipped(el) || isComponent(el)) { |
| @@ -151,12 +188,12 @@ |
| for (var k = 0; k < nodes.length; k++) { |
| var node = nodes[first ? k : nodes.length - 1 - k]; |
| if (node.nodeType === 3) { |
| - if (node.textContent.trim() === "") continue; |
| + if (closed(el) || node.textContent.trim() === "") continue; |
| var box = lineBox(node); |
| if (box) return { kind: "text", node: node, box: box }; |
| continue; |
| } |
| - if (node.nodeType !== 1) continue; |
| + if (node.nodeType !== 1 || !shows(el, node)) continue; |
| var style = getComputedStyle(node); |
| if (style.display === "none" || style.visibility === "hidden") continue; |
| var found = edge(node, first); |
| @@ -213,7 +250,7 @@ |
| return { el: el, top: r.top, bottom: r.bottom }; |
| } |
| var text = !!textTags[el.tagName]; |
| - for (var n = el.firstChild; n && !text; n = n.nextSibling) { |
| + for (var n = el.firstChild; n && !text && !closed(el); n = n.nextSibling) { |
| if (n.nodeType === 3 && n.textContent.trim() !== "") text = true; |
| } |
| var kids = text ? [] : flow(el); |
| @@ -245,6 +282,8 @@ |
| var lastChildOf = new Map(); |
| var excludedBefore = new Set(); |
| var headings = []; |
| + var pairs = 0; |
| + var held = 0; |
| function walk(container) { |
| var kids = flow(container); |
| @@ -266,6 +305,7 @@ |
| var stacked = rb.top >= ra.bottom - tolerance && rb.left < ra.right && ra.left < rb.right; |
| if (!stacked || skipped(a) || skipped(b)) return; |
| var gap = rb.top - ra.bottom; |
| + pairs++; |
| gapBefore.set(b, { gap: gap, from: a }); |
| nextOf.set(a, b); |
| if (!onScale(gap)) { |
| @@ -309,12 +349,18 @@ |
| // after is the block a heading's content starts with and the space |
| // to it: its next block, or, when it ends a wrapper (a header |
| - // holding only the heading), the block after the wrapper. |
| + // holding only the heading), the block after the wrapper. It is null |
| + // when that content opens with a heading or a section: a heading or |
| + // a section after a heading takes its own opening (DESIGN.md, "The |
| + // stack"), and the heading that follows is held to its content. |
| function after(h) { |
| for (var at = h; at && at !== start; at = lastChildOf.get(at)) { |
| if (nextOf.has(at)) { |
| - var next = content(nextOf.get(at), true); |
| - return next ? { el: next.el, gap: next.top - h.getBoundingClientRect().bottom } : null; |
| + var block = nextOf.get(at); |
| + if (isHeading(block) || opensSection(block)) return null; |
| + var next = content(block, true); |
| + if (!next || isHeading(next.el)) return null; |
| + return { el: next.el, gap: next.top - h.getBoundingClientRect().bottom }; |
| } |
| if (!lastChildOf.has(at)) return null; |
| } |
| @@ -340,6 +386,7 @@ |
| if (open === null) return; |
| if (open === undefined) open = opening[h.tagName]; |
| if (open === undefined) return; |
| + held++; |
| if (next.gap >= open - tolerance) { |
| findings.push({ |
| kind: "heading", gap: round(next.gap), before: describe(h), after: describe(next.el), |
| @@ -348,5 +395,47 @@ |
| }); |
| } |
| }); |
| - return findings; |
| + |
| + // The stacks under the root, the root included, that are drawn and |
| + // the page's: none in a skipped region or a closed <details>. |
| + function outside(el) { |
| + if (el.closest("details:not([open]) > :not(summary)")) return true; |
| + for (var at = el; at; at = at === start ? null : at.parentElement) { |
| + if (skipped(at)) return true; |
| + } |
| + return false; |
| + } |
| + var stackSel = "[rst-stack], .rst-stack"; |
| + var stacks = Array.prototype.slice.call(start.querySelectorAll(stackSel)); |
| + if (start.matches(stackSel)) stacks.unshift(start); |
| + stacks = stacks.filter(function (el) { return el.getClientRects().length > 0 && !outside(el); }); |
| + |
| + // passedOver is what the stack's own rules pass over (tokens.css): |
| + // not drawn, or marked as out of the column. |
| + var passedOver = '[hidden], [type="hidden"], [rst-stack-out], .rst-stack-out, [rst-modal-overlay], .rst-modal-overlay, dialog, [popover], script, style, template'; |
| + stacks.forEach(function (stack) { |
| + var s = getComputedStyle(stack); |
| + var gap = parseFloat(s.rowGap); |
| + if (s.display !== "flex" || s.flexDirection !== "column" || s.flexWrap !== "nowrap" || |
| + (s.alignItems !== "normal" && s.alignItems !== "stretch") || !(Math.abs(gap - scale[2]) <= tolerance)) { |
| + findings.push({ |
| + kind: "bent", gap: isNaN(gap) ? 0 : round(gap), before: describe(stack), after: "", |
| + message: "a stack is " + s.display + ", " + s.flexDirection + ", " + s.flexWrap + ", align-items " + s.alignItems + |
| + ", gap " + s.rowGap + "; the stack is a flex column, nowrap, align-items normal, gap " + round(scale[2]) + |
| + "px: an app rule overrides it" |
| + }); |
| + } |
| + for (var child = stack.firstElementChild; child; child = child.nextElementSibling) { |
| + var cs = getComputedStyle(child); |
| + if (cs.display === "none" || (cs.position !== "absolute" && cs.position !== "fixed") || child.matches(passedOver)) continue; |
| + var margin = parseFloat(cs.marginBlockStart) || 0; |
| + findings.push({ |
| + kind: "out-of-flow", gap: round(margin), before: describe(child), after: "", |
| + message: "a stack's child is " + cs.position + " and the stack does not pass it over, so it takes a margin (" + |
| + round(margin) + "px) or stands for the block before the next; mark it rst-stack-out" |
| + }); |
| + } |
| + }); |
| + |
| + return options.result ? { findings: findings, pairs: pairs, headings: held, stacks: stacks.length } : findings; |
| }) |
diff --git a/credits/credits.css b/credits/credits.css| index 0d696f7..01b8044 100644 |
| --- a/credits/credits.css |
| +++ b/credits/credits.css |
| @@ -1,7 +1,19 @@ |
| -[estilo-credits] { min-inline-size: 0; overflow-wrap: anywhere; } |
| +/* credits/credits.css: the Colophon under Help (estilo/credits). The |
| + section is a stack on estilo's terms, as the door's card is |
| + (chrome.css): a column whose children bring no block margins of their |
| + own, spaced by the table Fiesta's rst-stack uses (DESIGN.md, "The |
| + stack"). It holds a heading and its list, and what follows a heading |
| + is --rst-sp-2 under it, the column's gap; so the browser's own |
| + margins (18.8px under the heading, 14px around the list) are gone. |
| + An open entry is spaced the same way: its source, each notice's name |
| + and its text --rst-sp-2 apart, the first --rst-sp-2 under the |
| + summary, never touching it. */ |
| +[estilo-credits] { display: flex; flex-direction: column; gap: var(--rst-sp-2); min-inline-size: 0; overflow-wrap: anywhere; } |
| +[estilo-credits] > * { margin-block: 0; } |
| [estilo-credits] > ul { list-style: none; padding: 0; } |
| [estilo-credits] > ul > li { border-block-end: 1px solid var(--rst-line); padding-block: var(--rst-sp-2); } |
| [estilo-credits] summary { min-block-size: 24px; padding-block: var(--rst-sp-2); cursor: pointer; } |
| +[estilo-credits] details > :not(summary) { margin-block: var(--rst-sp-2) 0; } |
| [estilo-credits] a { display: inline-block; min-block-size: 24px; max-inline-size: 100%; } |
| [estilo-credits] pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; } |
| [estilo-credits-version] { font-size: .875em; } |
diff --git a/credits/credits_test.go b/credits/credits_test.go| index 514a24e..2c94504 100644 |
| --- a/credits/credits_test.go |
| +++ b/credits/credits_test.go |
| @@ -68,3 +68,20 @@ func TestNoticeFormattingAndMissingLabel(t *testing.T) { |
| t.Fatal("missing-notice label lost, repeated or interpreted") |
| } |
| } |
| + |
| +// The Colophon is a stack on estilo's terms (credits.css): a column |
| +// whose children bring no margins, the list a step under its heading. |
| +// Before, the browser's margins put the list 18.8px under it. |
| +// chrome/rhythm_browser_test.go measures it in real engines. |
| +func TestTheColophonIsAStack(t *testing.T) { |
| + css := string(CSS()) |
| + for _, rule := range []string{ |
| + "[estilo-credits] { display: flex; flex-direction: column; gap: var(--rst-sp-2);", |
| + "[estilo-credits] > * { margin-block: 0; }", |
| + "[estilo-credits] details > :not(summary) { margin-block: var(--rst-sp-2) 0; }", |
| + } { |
| + if !strings.Contains(css, rule) { |
| + t.Errorf("credits.css lacks %q", rule) |
| + } |
| + } |
| +} |
diff --git a/googleimport/README.md b/googleimport/README.md| index 2da6d78..c4c321c 100644 |
| --- a/googleimport/README.md |
| +++ b/googleimport/README.md |
| @@ -59,7 +59,10 @@ Labels: Text(locale)}`. The file input must belong to the named same-origin |
| multipart POST form. Existing hidden fields, including creation tokens, remain |
| intact. The app owns permissions, CSRF, upload limits, conversion and reports. |
| -Serve `JS()` as JavaScript at `JSName()` and load it with a module script only |
| +Serve `CSS()` as a stylesheet and link it on the page that renders the |
| +chooser; it spaces the chooser's disclosure, buttons and status on the spacing |
| +scale, so the page needs no rules of its own for them. Serve `JS()` as |
| +JavaScript at `JSName()` and load it with a module script only |
| on configured import pages. The name contains the asset's hash and may be |
| cached as immutable. Call `Headers(w, ContentSecurityPolicy)` before rendering |
| the opted-in import page, including a refused POST's re-render. Handle errors |
diff --git a/googleimport/google-import.css b/googleimport/google-import.css| new file mode 100644 |
| index 0000000..522a103 |
| --- /dev/null |
| +++ b/googleimport/google-import.css |
| @@ -0,0 +1,17 @@ |
| +/* googleimport/google-import.css: the Google Drive chooser |
| + (estilo-google-import), on the spacing scale. Its blocks are spaced |
| + by the table Fiesta's rst-stack uses (DESIGN.md, "The stack"): the |
| + disclosure, then the Choose button --rst-sp-4 under it (text sits |
| + that far clear of the button under it), Cancel --rst-sp-2 under |
| + Choose while both show, and the status line --rst-sp-3 under |
| + whatever is above it. Margins, not a column gap: the script shows |
| + and hides the buttons and fills the status, and a hidden button or |
| + an empty status then takes no space at all, where a gap would still |
| + fall beside an empty one. The buttons keep their own width. */ |
| +[estilo-google-import] { display: flex; flex-direction: column; align-items: flex-start; } |
| +[estilo-google-import] > * { margin-block: 0; } |
| +[estilo-google-import] > noscript > p { margin-block: 0; } |
| +[estilo-google-import] > * + * { margin-block-start: var(--rst-sp-3); } |
| +[estilo-google-import] > * + [data-google-choose-wrap] { margin-block-start: var(--rst-sp-4); } |
| +[estilo-google-import] > [data-google-choose-wrap]:not([hidden]) + [data-google-cancel-wrap] { margin-block-start: var(--rst-sp-2); } |
| +[estilo-google-import] > [data-google-status]:empty { margin-block-start: 0; } |
diff --git a/googleimport/googleimport.go b/googleimport/googleimport.go| index f28f756..6e16928 100644 |
| --- a/googleimport/googleimport.go |
| +++ b/googleimport/googleimport.go |
| @@ -62,9 +62,18 @@ var templates embed.FS |
| //go:embed google-import.mjs |
| var javascript []byte |
| +//go:embed google-import.css |
| +var stylesheet []byte |
| + |
| func Templates() fs.FS { return templates } |
| func Template() string { b, _ := templates.ReadFile("templates/google-import.html"); return string(b) } |
| func JS() []byte { return append([]byte(nil), javascript...) } |
| + |
| +// CSS is the chooser's stylesheet: its blocks on the spacing scale. An |
| +// app links it on the page that renders the chooser, beside JSName's |
| +// script; without it the chooser's paragraphs keep the browser's |
| +// margins. |
| +func CSS() []byte { return append([]byte(nil), stylesheet...) } |
| func JSName() string { |
| h := sha256.Sum256(javascript) |
| return fmt.Sprintf("google-import.%x.mjs", h[:8]) |
diff --git a/googleimport/googleimport_test.go b/googleimport/googleimport_test.go| index a8f0794..956ae2e 100644 |
| --- a/googleimport/googleimport_test.go |
| +++ b/googleimport/googleimport_test.go |
| @@ -119,3 +119,19 @@ func TestBrowserModuleLogic(t *testing.T) { |
| t.Fatalf("node: %v\n%s", err, out) |
| } |
| } |
| + |
| +// The chooser brings its own spacing (google-import.css): before, it |
| +// had none, and Docs and Sheets each spaced it in their own CSS. |
| +// chrome/rhythm_browser_test.go measures it in real engines. |
| +func TestTheChooserHasItsSpacing(t *testing.T) { |
| + css := string(CSS()) |
| + for _, rule := range []string{ |
| + "[estilo-google-import] { display: flex; flex-direction: column; align-items: flex-start; }", |
| + "[estilo-google-import] > * + [data-google-choose-wrap] { margin-block-start: var(--rst-sp-4); }", |
| + "[estilo-google-import] > [data-google-status]:empty { margin-block-start: 0; }", |
| + } { |
| + if !strings.Contains(css, rule) { |
| + t.Errorf("google-import.css lacks %q", rule) |
| + } |
| + } |
| +} |