Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

spaces: procedural covers for the home page and gallery cards (#448)

nyblnetb9bef7ee7f87
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md
index 52ffcc81..1e31e638 100644
--- a/docs/DECISIONS.md
+++ b/docs/DECISIONS.md
@@ -6696,6 +6696,63 @@ mapped, 1 correctly absent, run by bento-team-slides.
Claude-Session: https://claude.ai/code/session_01Jcfdy8A69nonyATtm8vRy8
+## 2026-09-12 — bento/spaces: procedural covers are a render-time default on two surfaces, and a document theme preset is not a thing this app can honestly offer
+
+**A page with no `cover` draws a generated one — never stored, never on paper,
+never in the thumbnail.** `spaces/src/procedural.ts` builds an SVG (gradient +
+one of six geometric figures) seeded by FNV-1a over the page id, so every reader
+of one file sees the same cover on the same page and a page keeps it across
+renames. Nothing is written: `cover` absent stays absent, an older build sees no
+cover, and a saved file does not change. A page with a usable cover of its own
+draws only that; a remote cover, which `coverSrc` already refuses, counts as
+none. The decision is one pure function (`proceduralCoverFor`) so the model
+rig pins every branch without a DOM; the browser pass is what proves the
+render.
+
+**Two surfaces, chosen structurally rather than by a field: the HOME page, and
+every coverless GALLERY card.** Not every page. A cover is a 150–320px
+full-bleed band that pushes the title down and lifts the icon into a disc; on a
+space of two hundred plain notes that is two hundred posters, and a journal
+entry under a banner is wrong however quiet the figure. The gallery already
+drew a procedural tint on its bare cards (the id-derived hue), so the card is a
+refinement of an accepted default; the home page is the one page the format
+itself names. A per-page opt-in would be a format field for a thing that is
+not document data — the reason the surfaces are structural.
+
+**Print and the preview draw nothing procedural.** Both pass `printing: true`
+and the decision returns '' under it: five centimetres of toner for artwork
+nobody chose, and the file-manager still is a render of the AUTHOR's document,
+which this is not in — and every saved file would otherwise grow by the SVG.
+
+**Restraint is by construction, and measured.** The gradient is the gallery's
+former CSS tint exactly (hue → hue+40°, 0.30/0.16 on a card; 0.44/0.26 on the
+page, where a white disc has to read against it); the figure sits on it at
+6–14% alpha at lightness 44. Everything is alpha over the surface's own ground
+(`--chrome-2`), which is how one SVG serves both themes. Rasterised over each
+ground across 400 ids: the card mark's worst case is 4.29:1 light / 3.28:1
+dark (from 6.55 / 4.13 with the tint alone — the figure costs about a point
+and stays above the 3:1 large-text line); the disc glyph is 9.94 / 9.30. The
+disc EDGE against the cover is 1.33–2.31 light and 1.91–3.53 dark; it was not
+chased to 3:1 because the only way there is a wash loud enough to be the thing
+this rule exists to refuse, and the glyph, not the boundary, is what identifies
+the control — the same bargain a real cover already makes over a pale photo.
+
+**Theme presets were asked for and NOT built, and the reason is the
+2026-08-22 entry above.** A preset would be a bundle of `doc.theme` values,
+and in this app `doc.theme.background/color/accent/fontFamily` are painted by
+NOTHING in the live app — only `preview.ts` reads the colours, only `measure`
+and `dir` reach the reading column. That was ruled, not forgotten: the reading
+surface is chrome and follows the reader, and "if it ever changes it changes
+with the FORMAT". So a "Dark" or "High contrast" document preset would change
+the thumbnail and nothing a reader can see, and a rig asserting "the preset
+wrote the resolved keys" would be green over a control that does nothing —
+the source-grep-over-a-dead-renderer failure this zone has recorded twice.
+Painting `doc.theme` onto the column reverses that ruling and pre-empts the
+open cross-app dark-mode question, and is not a change one app zone makes on
+its own. What is honest without a ruling is smaller and differently shaped:
+typography presets (`fontFamily`/`headingFamily`/`measure`, which ARE document
+data), which would first need the column to paint the font fields at all. Left
+for the ruling rather than shipped under the wrong name.
## 2026-09-09 — a derived column is never an independent axis, and a view that ignores the filter is worse than no view
**bento/dash keeps its 3D view.** The cut was proposed with numbers — 2,240
diff --git a/scripts/test-spaces-model.ts b/scripts/test-spaces-model.ts
index 8725147c..d5ffe71d 100644
--- a/scripts/test-spaces-model.ts
+++ b/scripts/test-spaces-model.ts
@@ -66,6 +66,7 @@ import type { Block, Page } from '../spaces/src/model.ts'
import {
buildGraph, layoutGraph, stepLayout, nodeRadius, graphBounds,
} from '../spaces/src/graph.ts'
+import { proceduralCoverSvg, proceduralCoverFor, hueOf, CARD_HUES } from '../spaces/src/procedural.ts'
let failures = 0
let checks = 0
@@ -687,6 +688,55 @@ for (const [label, input, err] of [
'…through the IMAGE pipeline: downscaled, content-addressed, and the same budget question')
ok(/delete p\.cover/.test(ed2), 'removing a cover DELETES the key rather than storing an empty string')
ok(/pickCover\(page\.id\)/.test(props2), 'the properties panel offers it, beside the icon')
+
+ // 6. PROCEDURAL COVERS (procedural.ts). A render-time default, never data:
+ // the properties below are the ones a reader would notice breaking, and
+ // every one is asserted on the OUTPUT, not on the source.
+ const same = proceduralCoverSvg('p-one') === proceduralCoverSvg('p-one')
+ ok(same, 'the same id yields the same SVG twice — a page keeps its cover across reloads and readers')
+ ok(proceduralCoverSvg('p-one') !== proceduralCoverSvg('p-two'),
+ 'two ids yield different SVGs — a gallery of coverless pages is a set of distinct things')
+ ok(new Set(Array.from({ length: 64 }, (_, i) => proceduralCoverSvg(`id${i}`))).size === 64,
+ '…sixty-four ids, sixty-four covers')
+ ok(CARD_HUES.includes(hueOf('p-one')) && hueOf('p-one') === hueOf('p-one'),
+ 'the hue is one of the curated stops, and stable')
+ // CODE lines only — the file's own commentary explains why it never does
+ const genSrc = fs.readFileSync(new URL('../spaces/src/procedural.ts', import.meta.url), 'utf8')
+ .split('\n').filter((l) => !/^\s*(\/\/|\*|\/\*)/.test(l)).join('\n')
+ ok(!/Math\.random|Date\.now|new Date/.test(genSrc), 'nothing in the generator reads a clock or a die')
+ const svg = proceduralCoverSvg('p-one', 'page')
+ ok(/^<svg /.test(svg) && /<\/svg>$/.test(svg) && /aria-hidden="true"/.test(svg),
+ 'the output is one decorative <svg> element')
+ ok(!/<script|on[a-z]+=|<foreignObject|href=/i.test(svg), 'and it carries nothing that could run, load or link')
+ ok(proceduralCoverSvg('p-one', 'page') !== proceduralCoverSvg('p-one', 'card')
+ && Buffer.byteLength(svg) < 2048,
+ 'the page wash is its own strength, and a cover costs under 2KB — and none of it is saved')
+ // the decision, as the renderer asks it
+ const pdoc = (parseDoc(doc({
+ home: 'h',
+ pages: [
+ { id: 'h', title: 'Home', blocks: [] },
+ { id: 'n', title: 'Note', blocks: [] },
+ { id: 'c', title: 'Covered', cover: 'data:image/png;base64,AAA', blocks: [] },
+ { id: 'r', title: 'Remote', cover: 'https://x/y.png', blocks: [] },
+ ],
+ })) as { doc: SpacesDoc }).doc
+ const pg = (id: string) => pdoc.pages.find((p) => p.id === id)!
+ ok(proceduralCoverFor(pg('h'), pdoc, false).length > 0, 'the home page gets a procedural cover')
+ ok(proceduralCoverFor(pg('n'), pdoc, false) === '',
+ '…and an ordinary page does NOT — two hundred notes are not two hundred posters')
+ ok(proceduralCoverFor(pg('h'), pdoc, true) === '', '…and nothing procedural under printing (paper, the thumbnail)')
+ pdoc.home = 'c'
+ ok(proceduralCoverFor(pg('c'), pdoc, false) === '', 'a page with a real cover draws no procedural one, home or not')
+ const c = pg('c')
+ delete (c as { cover?: unknown }).cover
+ ok(proceduralCoverFor(c, pdoc, false).length > 0, '…and a page whose cover is REMOVED gets its procedural one back')
+ pdoc.home = 'r'
+ ok(proceduralCoverFor(pg('r'), pdoc, false).length > 0,
+ 'a remote cover is refused (PLATFORM §1), so that page is coverless and gets the procedural one')
+ ok(/proceduralCoverFor\(page, doc, opts\.printing === true\)/.test(render)
+ && /proceduralCoverSvg\(r\.page\.id, 'card'\)/.test(render),
+ 'the renderer asks that decision for the page view and draws the card figure in the gallery')
}
diff --git a/spaces/CHANGELOG.md b/spaces/CHANGELOG.md
index b99adc26..92bc1ca9 100644
--- a/spaces/CHANGELOG.md
+++ b/spaces/CHANGELOG.md
@@ -486,6 +486,35 @@ Versions follow `0.MINOR.PATCH` while pre-1.0.
2026, from the same file. `bento.journal()` opens today's for an agent, and
`bento.journal('2026-08-06')` any day's.
+- **A page with no cover gets a procedural one — on the home page and on every
+ gallery card, and nowhere else.** A gradient plus a geometric figure (orbs,
+ bands, a dot lattice, rings, facets or waves), seeded from the page id, drawn
+ at render time and never written into the file: `cover` absent stays absent,
+ an older build sees no cover exactly as before, and a saved space does not
+ grow by a byte. The same id draws the same cover on every machine and every
+ reload; a page that gains a real cover shows that and nothing else, and a
+ page whose cover is removed gets its procedural one back. The gallery already
+ tinted its coverless cards on a hue from the id — this is that tint with a
+ figure on it, in the same two hues at the same alphas, over the theme's own
+ ground, so one SVG is right in light and in dark.
+
+ Home page and gallery only, on purpose. A cover is a full-bleed band that
+ pushes the title down and lifts the icon into a disc; on a space of two
+ hundred plain notes that is two hundred posters, and a journal entry under a
+ banner is wrong however restrained the artwork. The two surfaces chosen are
+ the two that already single a page out. Never on paper (5cm of toner for a
+ figure nobody chose) and never in the file-manager thumbnail (a still of the
+ author's document, and this is not in it).
+
+ Measured with real pixels, the SVG rasterised over the theme ground, across
+ 400 ids covering all eight hues and all six figures: the card's letter-mark
+ keeps at least 4.29:1 in light and 3.28:1 in dark (34px bold; the figure
+ costs about a point against the plain tint, which sat at 6.55 and 4.13);
+ the icon on the home page's disc reads at 9.94:1 light / 9.30:1 dark. The
+ disc's EDGE against the cover is 1.33–2.31:1 in light and 1.91–3.53:1 in
+ dark — the disc is white-on-a-wash by design, as it is over a pale
+ photograph, and its shadow carries the boundary; the glyph is what has to
+ read. Shell +1,412 B.
- **A finger can do the four things only a mouse could.** Reordering a block,
nesting a page in the tree, moving an issue card between columns and moving a
card on a canvas were all mouse-only: the first three are HTML5
diff --git a/spaces/src/procedural.ts b/spaces/src/procedural.ts
new file mode 100644
index 00000000..7aef1067
--- /dev/null
+++ b/spaces/src/procedural.ts
@@ -0,0 +1,223 @@
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+//
+// Procedural covers: what a page with no `cover` shows where a cover would go.
+//
+// A RENDER-TIME DEFAULT, NEVER DOCUMENT DATA. Nothing here is written into the
+// file: `page.cover` absent stays absent, an older build sees exactly what it
+// saw before (no cover), and the bytes of a saved space do not change by one.
+// The gallery already did this for its coverless cards — a tinted panel on a
+// hue derived from the page id — and this is that idea carried one step
+// further: a gradient plus a geometric figure, seeded from the same id.
+//
+// DETERMINISTIC FROM THE ID, for the reason the gallery hue is and the reason
+// repaired ids come from the id rather than from Math.random: every reader of
+// one file, on every machine, on every reload, sees the same cover on the same
+// page. A page keeps its cover when it is renamed and loses it only when it
+// gains a real one. Two calls with one id return the same string, byte for
+// byte; the model rig asserts it.
+//
+// WHERE IT DRAWS, AND WHERE IT DELIBERATELY DOES NOT. Two surfaces, both of
+// which already single a page out:
+// · every coverless card in a GALLERY — the surface that exists so a set of
+// pages reads as a set of distinct things, and the one that already drew a
+// procedural tint there;
+// · the HOME page in the page view — the one page the format itself names
+// (`doc.home`), the page a reader lands on, the front door.
+// NOT every page. A cover is a full-bleed band of 150–320px that pushes the
+// title down and lifts the icon into a disc; on a space of two hundred plain
+// notes that is two hundred posters, and a daily journal entry under a banner
+// is wrong in a way no restraint in the artwork fixes. The gallery hue was
+// accepted precisely because it is a card in a grid; the same figure at the
+// top of every note would be the loud default this rule exists to refuse.
+// Opt-in per page would need a field, which is a format change for a thing that
+// is not document data; so the surfaces are chosen structurally instead.
+//
+// NEVER ON PAPER, NEVER IN THE THUMBNAIL. Both go through `printing: true`
+// and the renderer draws nothing procedural under it. Print: 5cm of toner for
+// a figure nobody chose. The preview (preview.ts) is a still of the AUTHOR's
+// document for a file manager, and a default the app invents is not in that
+// document — the same reason the gallery's tint was never in it either, and
+// it keeps every saved file from growing by the SVG on each save.
+//
+// RESTRAINED BY CONSTRUCTION. The gradient is the gallery's existing tint
+// exactly (hue → hue+40°, at the same alphas) and the figure sits on it at
+// 6–14% alpha, in the same two hues. Everything is ALPHA over the surface's
+// own ground (`--chrome-2`), which is what makes one SVG right in both themes:
+// a pale wash on the light ground and a muted one on the dark, as the gallery
+// card already is. No hard edge in the figure exceeds the tint the card had.
+
+import { type SpacesDoc, type Page, coverSrc, homePage } from './model.ts'
+
+/** Eight stops, spaced around the wheel and chosen to be distinguishable at
+ * 30% alpha on both grounds — see `hueOf`. */
+export const CARD_HUES = [210, 265, 320, 8, 32, 48, 152, 186]
+
+/** FNV-1a over the id: the same cheap hash assets.ts falls back to. */
+export function hashId(id: string): number {
+ let h = 0x811c9dc5
+ for (let i = 0; i < id.length; i++) { h ^= id.charCodeAt(i); h = Math.imul(h, 0x01000193) >>> 0 }
+ return h >>> 0
+}
+
+/**
+ * A stable hue for a page with no cover.
+ *
+ * A CURATED SET, not 360 free hues. Free hue was measured drawing 61 and 54 in
+ * the same grid — the same dirty chartreuse twice — and five cards as
+ * peach/pink/pink/lavender/lavender: two near-duplicate pairs out of five. It
+ * also lands on olive and mustard, which no amount of alpha rescues, and goes
+ * muddy in the dark theme. Neighbours in a grid differ because the stops
+ * differ, not because the hash happened to spread.
+ */
+export function hueOf(id: string): number {
+ return CARD_HUES[hashId(id) % CARD_HUES.length]
+}
+
+/** mulberry32: a 32-bit seed in, the same sequence out on every engine. */
+function rng(seed: number): () => number {
+ let a = seed >>> 0
+ return () => {
+ a = (a + 0x6d2b79f5) >>> 0
+ let t = a
+ t = Math.imul(t ^ (t >>> 15), t | 1)
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61)
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296
+ }
+}
+
+/** Fixed-point to one decimal, so the string is short and never locale-shaped. */
+const n = (v: number): string => String(Math.round(v * 10) / 10)
+/** …and two for an alpha, where one decimal would flatten 0.07 and 0.14 alike. */
+const a = (v: number): string => String(Math.round(v * 100) / 100)
+
+/** `hsl(h,s%,l%)` — the comma form, which every SVG presentation attribute
+ * parser accepts; alpha travels separately as `fill-opacity`. */
+const hsl = (h: number, s: number, l: number): string => `hsl(${n(h)},${n(s)}%,${n(l)}%)`
+
+/** The two surfaces, and the one number that differs between them: the page
+ * cover is a larger, less busy field with a white disc riding its lower edge,
+ * so its wash is a step stronger than the card's — measured, not guessed
+ * (see the contrast numbers in the changelog). */
+export type CoverSurface = 'card' | 'page'
+
+export const VIEW_W = 600
+export const VIEW_H = 240
+
+/**
+ * The SVG for a page with no cover, as a string.
+ *
+ * A string rather than an element so the model rig can pin its properties in
+ * plain node, and so the renderer inserts it with one `innerHTML` on a wrapper
+ * it created itself. Nothing in the string comes from the document except the
+ * id, and the id only ever reaches it as a number.
+ */
+export function proceduralCoverSvg(id: string, surface: CoverSurface = 'card'): string {
+ const seed = hashId(id)
+ const h = hueOf(id)
+ const h2 = (h + 40) % 360
+ const r = rng(seed)
+ const page = surface === 'page'
+ // the gallery's own two stops, verbatim; the page wash one step stronger
+ const a1 = page ? 0.44 : 0.30
+ const a2 = page ? 0.26 : 0.16
+ const gid = `sp-g${seed.toString(36)}`
+
+ const parts: string[] = []
+ parts.push(
+ `<svg class="sp-gen" viewBox="0 0 ${VIEW_W} ${VIEW_H}" preserveAspectRatio="xMidYMid slice" ` +
+ `aria-hidden="true" focusable="false">`,
+ `<defs><linearGradient id="${gid}" x1="0" y1="0" x2="1" y2="1">` +
+ `<stop offset="0" stop-color="${hsl(h, 62, 62)}" stop-opacity="${a(a1)}"/>` +
+ `<stop offset="1" stop-color="${hsl(h2, 62, 58)}" stop-opacity="${a(a2)}"/>` +
+ `</linearGradient></defs>`,
+ `<rect width="${VIEW_W}" height="${VIEW_H}" fill="url(#${gid})"/>`,
+ )
+
+ // THE FIGURE. Six families; the seed picks one and then places it. Every
+ // figure is a handful of elements — a lattice goes through <pattern> so a
+ // field of dots costs two elements, not a hundred and sixty.
+ const ink = (i: number) => hsl(i % 2 ? h2 : h, 58, 44)
+ const fig = Math.floor(r() * 6)
+ const W = VIEW_W, H = VIEW_H
+ if (fig === 0) {
+ // orbs: three to five discs, large, overlapping the edges
+ const k = 3 + Math.floor(r() * 3)
+ for (let i = 0; i < k; i++) {
+ const cx = r() * W, cy = r() * H, rad = 50 + r() * 100
+ parts.push(`<circle cx="${n(cx)}" cy="${n(cy)}" r="${n(rad)}" fill="${ink(i)}" fill-opacity="${a(0.06 + r() * 0.06)}"/>`)
+ }
+ } else if (fig === 1) {
+ // bands: a rotated group of four to six stripes
+ const ang = -50 + r() * 100
+ const k = 4 + Math.floor(r() * 3)
+ parts.push(`<g transform="rotate(${n(ang)} ${W / 2} ${H / 2})">`)
+ let x = -W * 0.4 + r() * 80
+ for (let i = 0; i < k; i++) {
+ const w = 18 + r() * 60
+ parts.push(`<rect x="${n(x)}" y="-${H}" width="${n(w)}" height="${H * 3}" fill="${ink(i)}" fill-opacity="${a(0.07 + r() * 0.06)}"/>`)
+ x += w + 30 + r() * 90
+ }
+ parts.push('</g>')
+ } else if (fig === 2) {
+ // lattice: a dot field through <pattern>, and one disc to anchor it
+ const step = 22 + Math.floor(r() * 14)
+ const pid = `${gid}p`
+ parts.push(
+ `<defs><pattern id="${pid}" width="${step}" height="${step}" patternUnits="userSpaceOnUse">` +
+ `<circle cx="${step / 2}" cy="${step / 2}" r="${n(1.6 + r() * 1.6)}" fill="${ink(0)}" fill-opacity="0.2"/>` +
+ `</pattern></defs>`,
+ `<rect width="${W}" height="${H}" fill="url(#${pid})"/>`,
+ `<circle cx="${n(W * (0.55 + r() * 0.35))}" cy="${n(H * (0.2 + r() * 0.6))}" r="${n(60 + r() * 60)}" fill="${ink(1)}" fill-opacity="${a(0.08 + r() * 0.05)}"/>`,
+ )
+ } else if (fig === 3) {
+ // rings: concentric strokes from a point near one corner
+ const cx = r() < 0.5 ? r() * W * 0.3 : W - r() * W * 0.3
+ const cy = r() < 0.5 ? r() * H * 0.3 : H - r() * H * 0.3
+ const k = 4 + Math.floor(r() * 3)
+ const gap = 26 + r() * 22
+ for (let i = 0; i < k; i++) {
+ parts.push(`<circle cx="${n(cx)}" cy="${n(cy)}" r="${n(gap * (i + 1))}" fill="none" stroke="${ink(i)}" stroke-width="${n(6 + r() * 8)}" stroke-opacity="${a(0.08 + r() * 0.06)}"/>`)
+ }
+ } else if (fig === 4) {
+ // facets: three or four triangles fanned from the edges
+ const k = 3 + Math.floor(r() * 2)
+ for (let i = 0; i < k; i++) {
+ const x0 = r() * W, y0 = r() < 0.5 ? -20 : H + 20
+ const x1 = r() * W, y1 = r() * H
+ const x2 = r() * W, y2 = r() < 0.5 ? -20 : H + 20
+ parts.push(`<polygon points="${n(x0)},${n(y0)} ${n(x1)},${n(y1)} ${n(x2)},${n(y2)}" fill="${ink(i)}" fill-opacity="${a(0.06 + r() * 0.06)}"/>`)
+ }
+ } else {
+ // waves: three stacked curves filled to the bottom edge
+ const k = 3
+ for (let i = 0; i < k; i++) {
+ const base = H * (0.45 + i * 0.16) + r() * 20
+ const amp = 16 + r() * 26
+ const c1 = W * (0.2 + r() * 0.2), c2 = W * (0.6 + r() * 0.2)
+ parts.push(
+ `<path d="M0,${n(base)} C${n(c1)},${n(base - amp)} ${n(c2)},${n(base + amp)} ${W},${n(base - amp * 0.5)} ` +
+ `L${W},${H} L0,${H} Z" fill="${ink(i)}" fill-opacity="${a(0.07 + r() * 0.05)}"/>`,
+ )
+ }
+ }
+ parts.push('</svg>')
+ return parts.join('')
+}
+
+/**
+ * THE DECISION, as one pure function: the SVG for this page in the page view,
+ * or '' when it must draw nothing. render.ts asks this and nothing else, so
+ * the rig can pin every branch without a DOM:
+ * · a page with a usable cover of its own draws no procedural one;
+ * · only the home page gets one (the argument is at the top of this file);
+ * · nothing procedural under `printing` — paper and the thumbnail.
+ * A REMOTE cover counts as none: coverSrc refuses it (PLATFORM §1), so the
+ * page renders coverless today and is treated as coverless here.
+ */
+export function proceduralCoverFor(page: Page, doc: SpacesDoc, printing: boolean): string {
+ if (printing) return ''
+ if (coverSrc(page)) return ''
+ if (homePage(doc)?.id !== page.id) return ''
+ return proceduralCoverSvg(page.id, 'page')
+}
diff --git a/spaces/src/render.ts b/spaces/src/render.ts
index 37a30051..97a30eed 100644
--- a/spaces/src/render.ts
+++ b/spaces/src/render.ts
@@ -10,6 +10,7 @@
// one decision.
import { type SpacesDoc, type Page, type Block, loadsRemotely, assetValue, tableOf, linkCard, coverSrc } from './model'
+import { proceduralCoverSvg, proceduralCoverFor } from './procedural'
import { sanitizeInline, inertBody, esc } from './sanitize'
import { tokenize } from './highlight'
import { t, locale } from './i18n'
@@ -1048,6 +1049,19 @@ export function renderPage(page: Page, doc: SpacesDoc, opts: RenderOpts = {}): H
img.setAttribute('aria-hidden', 'true')
wrap.appendChild(img)
art.appendChild(wrap)
+ } else {
+ // NO COVER: the HOME page gets a procedural one — a figure seeded from its
+ // id, never written to the document. The home page only, and never on
+ // paper or in the thumbnail; procedural.ts decides and argues both. A page
+ // whose cover is removed lands here again, which is the "gets it back" half.
+ const gen = proceduralCoverFor(page, doc, opts.printing === true)
+ if (gen) {
+ art.classList.add('sp-has-cover')
+ const wrap = document.createElement('div')
+ wrap.className = 'sp-cover sp-cover-gen'
+ wrap.innerHTML = gen
+ art.appendChild(wrap)
+ }
}
const h = document.createElement('h1')
@@ -1139,29 +1153,6 @@ function shownValue(f: FieldSpec | undefined, value: unknown): string {
return String(value)
}
-/**
- * A stable hue for a page with no cover.
- *
- * FNV-1a over the id, which is the same cheap hash assets.ts falls back to:
- * every reader of one file computes the same colour, and a page keeps its
- * colour when it is renamed.
- *
- * A CURATED SET, not 360 free hues. Free hue was measured drawing 61 and 54 in
- * the same grid — the same dirty chartreuse twice — and five cards as
- * peach/pink/pink/lavender/lavender: two near-duplicate pairs out of five. It
- * also lands on olive and mustard, which no amount of alpha rescues, and goes
- * muddy in the dark theme. Eight stops spaced around the wheel and chosen to
- * be distinguishable at 30% alpha on both grounds; neighbours in a grid differ
- * because the stops differ, not because the hash happened to spread.
- */
-const CARD_HUES = [210, 265, 320, 8, 32, 48, 152, 186]
-
-function hueOf(id: string): number {
- let h = 0x811c9dc5
- for (let i = 0; i < id.length; i++) { h ^= id.charCodeAt(i); h = Math.imul(h, 0x01000193) >>> 0 }
- return CARD_HUES[h % CARD_HUES.length]
-}
-
/**
* What a coverless card shows: the page's icon, else the first character of
* its title.
@@ -1425,10 +1416,10 @@ function renderView(host: HTMLElement, b: Block, doc: SpacesDoc, opts: RenderOpt
shot.appendChild(img)
} else {
shot.classList.add('sp-gcard-bare')
- // deterministic, so a page keeps its colour across reloads, readers and
+ // deterministic, so a page keeps its cover across reloads, readers and
// machines — the same reason ids are repaired from the id and never
- // from Math.random
- shot.style.setProperty('--h', String(hueOf(r.page.id)))
+ // from Math.random. The figure is procedural.ts's; the mark rides on it.
+ shot.innerHTML = proceduralCoverSvg(r.page.id, 'card')
const mark = document.createElement('span')
mark.className = 'sp-gcard-mark'
pageMark(mark, r.page)
diff --git a/spaces/src/styles.css b/spaces/src/styles.css
index 25ad58f0..3f4d2823 100644
--- a/spaces/src/styles.css
+++ b/spaces/src/styles.css
@@ -2411,6 +2411,9 @@ button.sp-issue-set:hover { background: var(--chrome-2); border-color: var(--edg
box-shadow: inset 0 0 0 1px rgb(var(--shade) / .08);
}
.sp-cover-img { display: block; width: 100%; height: 100%; object-fit: cover; }
+/* A PROCEDURAL cover (procedural.ts): the figure fills the same box, over the
+ same ground — `slice` crops it to whatever the band's aspect is. */
+.sp-gen { display: block; width: 100%; height: 100%; }
/* The lift is what makes it read as a cover rather than as a banner sitting on
top of a document: the title rises INTO the picture's lower edge, which is
the arrangement everyone recognises. A scrim under the title would fight the
@@ -2469,14 +2472,14 @@ button.sp-issue-set:hover { background: var(--chrome-2); border-color: var(--edg
display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.sp-gcard-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
-/* A CARD WITH NO COVER IS NOT A HOLE. Its own hue, derived from the page id, so
- a gallery nobody has given pictures to still reads as a set of distinct
- things. `hsl` with an alpha keeps it a tint in both themes rather than a
- colour that glows on the dark one. */
-.sp-gcard-bare {
- background:
- linear-gradient(150deg, hsl(var(--h, 210) 62% 62% / .30), hsl(calc(var(--h, 210) * 1deg + 40deg) 62% 58% / .16));
-}
+/* A CARD WITH NO COVER IS NOT A HOLE. Its own figure, derived from the page id
+ (procedural.ts — the tint this rule used to draw, plus a pattern), so a
+ gallery nobody has given pictures to still reads as a set of distinct
+ things. Alpha over the ground keeps it a tint in both themes rather than a
+ colour that glows on the dark one. The mark sits above the figure. */
+.sp-gcard-bare { position: relative; }
+.sp-gcard-bare .sp-gen { position: absolute; inset: 0; }
+.sp-gcard-bare .sp-gcard-mark { position: relative; }
/* --ink-2, not --muted: a grey letter on a 30% tint was the same value as the
tint in the dark theme. */
.sp-gcard-mark { font-size: 34px; line-height: 1; color: var(--ink-2, var(--ink)); font-weight: 600; }