oficina / estilo Public

The Colophon's reset outweighs an app's heading rule; its entries by the table; the chooser's resting state driven

Fable's review of colophon-drive-stack: M1, the reset at (0,2,0) so
Mapa's [estilo-credits] > h1 { margin } (0,1,1) cannot put 8px back
(the drive carries that rule and fails on the old reset with 16px); M2,
an open entry's blocks are anything else, --rst-sp-3, and a notice's
text --rst-sp-2 under its name; L3, an open entry audited from its own
root; L4, stale headers; L5, the resting chooser (status under Choose,
Cancel hidden) driven; L6, Cancel under Choose follows the door's rule
for a button under another action, said so; L7, README and CSS() say to
drop an app's own chooser rules and that the CSS has no hashed name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev bb6b065a1f986015dc9a97b40934b6afe20086d2 parent 147255c
7 files changed, +74 −34
  • chrome/rhythm.browser.mjs +5 −3
  • chrome/rhythm_browser_test.go +44 −18
  • credits/credits.css +8 −5
  • credits/credits_test.go +5 −3
  • googleimport/README.md +4 −1
  • googleimport/google-import.css +3 −2
  • googleimport/googleimport.go +5 −2

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.005s
ok  	amadan.net/oficina/estilo.git/chrome	4.684s
?   	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	2.558s
ok  	amadan.net/oficina/estilo.git/homeconnect	0.004s
ok  	amadan.net/oficina/estilo.git/internal/lint	0.006s
?   	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.113s
ok  	amadan.net/oficina/estilo.git/side	0.137s
ok  	amadan.net/oficina/estilo.git/sky	0.030s
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 36187c9..c690fb0 100644
--- a/chrome/rhythm.browser.mjs
+++ b/chrome/rhythm.browser.mjs
@@ -8,11 +8,13 @@
// node rhythm.browser.mjs <job JSON>
//
// 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:
+// 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
-// also saved there as <engine>-<viewport>-<page>.png.
+// sibling, or null where the page has no such element. With shots set
+// to a directory, each page is also saved there as
+// <engine>-<viewport>-<page>.png.
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
diff --git a/chrome/rhythm_browser_test.go b/chrome/rhythm_browser_test.go
index d1ac8a6..996b5d1 100644
--- a/chrome/rhythm_browser_test.go
+++ b/chrome/rhythm_browser_test.go
@@ -1,12 +1,17 @@
//go:build browser
// The door's rhythm, measured: Fiesta's rhythm audit (its check/rhythm,
-// v1.6.0, copied into testdata/rhythm.js because estilo does not require
+// v1.7.0, copied into testdata/rhythm.js because estilo does not require
// Fiesta; see the Makefile's test-spacing) over the card of every door
-// page, in real engines, on a desktop and a phone. It reports two blocks
-// whose gap is not a step of the spacing scale, text and a control less
-// than --rst-sp-2 apart, and a heading no closer to its content than to
-// what comes before it. Not part of `make test`: it needs Node 22+ and
+// page, the Colophon and the Google Drive chooser, in real engines, on a
+// desktop and a phone. It reports two blocks whose gap is not a step of
+// the spacing scale, text and a control less than --rst-sp-2 apart, a
+// heading no closer to its content than to what comes before it, and a
+// stack (rst-stack) bent out of its column or holding a fixed or
+// absolute child it does not pass over; none of these pages is an
+// rst-stack, so the last two have nothing to find here. It does not read
+// past a closed <details>' summary, nor into a list (a text block), so
+// an open Colophon entry is audited from its own root. Not part of `make test`: it needs Node 22+ and
// Playwright (ESTILO_PLAYWRIGHT, ESTILO_BROWSERS as for the title check).
// ESTILO_SHOTS=<dir> saves each page there to look at.
package chrome
@@ -115,7 +120,8 @@ var openGaps = map[string]float64{
// 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.
+// who opened them sees it. Closed, the page also carries an app's own
+// margin on the heading, which must not reach it.
func colophon(t *testing.T, open bool) string {
t.Helper()
tpl := template.Must(template.ParseFS(credits.Templates(), "templates/*.html"))
@@ -128,6 +134,11 @@ func colophon(t *testing.T, open bool) string {
t.Fatal(err)
}
html := out.String()
+ if !open {
+ // An app's own rule on the heading, as Mapa's frame.css wrote
+ // one before estilo spaced the Colophon: the stack outweighs it.
+ html = `<style>[estilo-credits] > h1 { margin: 0 0 var(--rst-sp-2); } [estilo-credits] > ul { margin: 0; }</style>` + html
+ }
if open {
html = strings.ReplaceAll(html, "<details>", "<details open>")
}
@@ -135,20 +146,21 @@ func colophon(t *testing.T, open bool) string {
}
// 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.
+// list --rst-sp-2 under its heading, and in an open entry its source
+// --rst-sp-3 under the summary, a notice's name --rst-sp-3 under what
+// is above it, and the notice's text --rst-sp-2 under its name.
var colophonGaps = map[string]float64{
"[estilo-credits] > ul": 8,
- "[estilo-credits] li:first-child details > p": 8,
+ "[estilo-credits] li:first-child details > p": 12,
"[estilo-credits] li:first-child details > pre": 8,
- "[estilo-credits] li:first-child details > p + pre + p": 8,
+ "[estilo-credits] li:first-child details > p + pre + p": 12,
}
// 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 {
+// ready, the Choose button shown and the status empty; idle, the status
+// saying something under Choose (a refusal, or what was imported);
+// busy, Cancel under Choose and the status saying what is happening.
+func chooser(t *testing.T, state string) string {
t.Helper()
tpl := template.Must(template.New("root").Parse(googleimport.Template()))
var out bytes.Buffer
@@ -157,9 +169,12 @@ func chooser(t *testing.T, busy bool) string {
t.Fatal(err)
}
html := strings.Replace(out.String(), "<span data-google-choose-wrap hidden>", "<span data-google-choose-wrap>", 1)
- if busy {
+ switch state {
+ case "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)
+ case "idle":
+ html = strings.Replace(html, `aria-live="polite"></p>`, `aria-live="polite">That file is too large to import.</p>`, 1)
}
return html
}
@@ -173,6 +188,13 @@ var chooserGaps = map[string]float64{
"[data-google-status]": 12,
}
+// chooserIdleGaps is the resting chooser: the status --rst-sp-3 under
+// Choose, past the hidden Cancel.
+var chooserIdleGaps = map[string]float64{
+ "[data-google-choose-wrap]": 16,
+ "[data-google-status]": 12,
+}
+
func openGapNames() []string {
var names []string
for _, gaps := range []map[string]float64{openGaps, colophonGaps, chooserGaps} {
@@ -186,8 +208,10 @@ func openGapNames() []string {
// pageGaps is the table each page is held to, by page.
var pageGaps = map[string]map[string]float64{
"open": openGaps,
+ "colophon": {"[estilo-credits] > ul": 8},
"colophon-open": colophonGaps,
"chooser-busy": chooserGaps,
+ "chooser-idle": chooserIdleGaps,
}
// doorPages is every page the door draws, with the states that change
@@ -218,8 +242,9 @@ func doorPages(t *testing.T) map[string]string {
// root (pageRoots).
"colophon": colophon(t, false),
"colophon-open": colophon(t, true),
- "chooser-ready": chooser(t, false),
- "chooser-busy": chooser(t, true),
+ "chooser-ready": chooser(t, "ready"),
+ "chooser-idle": chooser(t, "idle"),
+ "chooser-busy": chooser(t, "busy"),
}
}
@@ -227,7 +252,8 @@ func doorPages(t *testing.T) map[string]string {
// from; a door card is audited from [estilo-signin].
var pageRoots = map[string]string{
"colophon": "[estilo-credits]",
- "colophon-open": "[estilo-credits]",
+ "colophon-open": "[estilo-credits] li:first-child details",
+ "chooser-idle": "[estilo-google-import]",
"chooser-ready": "[estilo-google-import]",
"chooser-busy": "[estilo-google-import]",
}
diff --git a/credits/credits.css b/credits/credits.css
index 01b8044..72d6ab9 100644
--- a/credits/credits.css
+++ b/credits/credits.css
@@ -5,15 +5,18 @@
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. */
+ The reset weighs (0,2,0), so an app's own rule on the heading or the
+ list, such as h1 { margin } at (0,1,1), cannot put a margin back.
+ An open entry is spaced by the same table: its first block, its
+ source, and each notice's name are anything else, --rst-sp-3; a
+ notice's text is its name's content, --rst-sp-2 under 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] > :not([hidden]) { 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] details > :not(summary) { margin-block: var(--rst-sp-3) 0; }
+[estilo-credits] details > p + pre { margin-block-start: var(--rst-sp-2); }
[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 2c94504..397b559 100644
--- a/credits/credits_test.go
+++ b/credits/credits_test.go
@@ -70,15 +70,17 @@ func TestNoticeFormattingAndMissingLabel(t *testing.T) {
}
// 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.
+// whose children bring no margins, whatever an app's rule on its
+// heading says, and 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; }",
+ "[estilo-credits] > :not([hidden]) { margin-block: 0; }",
+ "[estilo-credits] details > :not(summary) { margin-block: var(--rst-sp-3) 0; }",
+ "[estilo-credits] details > p + pre { margin-block-start: var(--rst-sp-2); }",
} {
if !strings.Contains(css, rule) {
t.Errorf("credits.css lacks %q", rule)
diff --git a/googleimport/README.md b/googleimport/README.md
index c4c321c..5fb90a8 100644
--- a/googleimport/README.md
+++ b/googleimport/README.md
@@ -61,7 +61,10 @@ intact. The app owns permissions, CSRF, upload limits, conversion and reports.
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
+scale. Remove any `[estilo-google-import]` rules of the app's own when you link
+it: a column gap of the app's would add to its margins. It has no hashed name,
+so serve and cache it as the app serves its other estilo stylesheets; the
+immutable caching below is the script's. 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
diff --git a/googleimport/google-import.css b/googleimport/google-import.css
index 522a103..2fcc8a3 100644
--- a/googleimport/google-import.css
+++ b/googleimport/google-import.css
@@ -3,8 +3,9 @@
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
+ Choose while both show (a button under another action, as the
+ door's card has it, chrome.css), 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. */
diff --git a/googleimport/googleimport.go b/googleimport/googleimport.go
index 6e16928..ca00e59 100644
--- a/googleimport/googleimport.go
+++ b/googleimport/googleimport.go
@@ -71,8 +71,11 @@ 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.
+// script, and drops any [estilo-google-import] rules of its own, which
+// would add their gap to these margins. Without it the chooser's
+// paragraphs keep the browser's margins. It has no hashed name: serve
+// it under whatever path and cache policy the app gives its other
+// estilo stylesheets.
func CSS() []byte { return append([]byte(nil), stylesheet...) }
func JSName() string {
h := sha256.Sum256(javascript)