Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

slides: accent text reads in dark mode (--accent-ink, --accent-on) (#557)

nyblnetcc47c86a79a1
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7c6305e9..c975ef4a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1472,6 +1472,12 @@ jobs:
# the recorded floor, and every commonly typed formula renders. The
# check a fixed sample could not make, which is how #540 slipped by.
run: node scripts/test-maths-coverage.ts
+ - name: Accent contrast rig
+ # The accent as text reads in both themes: every --accent-ink text use
+ # is audited against the surface behind it and reaches 4.5:1; text on
+ # the orange fill uses --accent-on; labels drawn over the slide carry a
+ # surface halo. Dark --accent-ink was #3a2a00 on dark chrome — 1.09:1.
+ run: node scripts/test-slides-accent-contrast.ts
- name: Compact document rig
# The agent authoring form (#422): compactDoc/expandDoc are inverses
# on the starter deck, expansion equals the editor's insert helpers
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c9df3805..ddc393a9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,13 @@ pre-1.0.
## [Unreleased]
+- **Orange text can be read in dark mode again.** The armed comment tool, the
+ tick beside your language, your own name in a comment thread and the labels
+ on slide and point comments were drawn in a dark brown meant for text on the
+ orange, on dark panels where it all but vanished. They now use a lighter
+ gold, and the comment labels on a slide carry a soft halo so they read on
+ any slide, light or dark, in either theme.
+
## [1.2.4] — 2026-09-25
- **Formulas that stayed as raw text now render.** 1.2.0 replaced the maths
diff --git a/scripts/test-slides-accent-contrast.ts b/scripts/test-slides-accent-contrast.ts
new file mode 100644
index 00000000..a8e190dd
--- /dev/null
+++ b/scripts/test-slides-accent-contrast.ts
@@ -0,0 +1,122 @@
+#!/usr/bin/env node
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+// The accent as TEXT: every use reads, in both themes.
+//
+// node scripts/test-slides-accent-contrast.ts
+//
+// WHAT THIS PROVES. In dark theme `--accent-ink` was #3a2a00 — a colour meant
+// for text ON the orange fill — while every place that used it as text sat on
+// the dark chrome: the armed comment tool, the language menu's ✓, the comment
+// popover's name. Measured 1.09:1, i.e. invisible, and shipped (found by the
+// spaces chrome audit, working/design/chrome-unification.md). Now:
+//
+// --accent-ink accent-coloured text on the chrome's own surfaces (flips)
+// --accent-on text sitting on the solid --accent fill (does not flip)
+//
+// The rig reads the real tokens out of slides/src/styles.css and checks:
+// 1. every rule that sets `color: var(--accent-ink)` is on the AUDITED list
+// below, which names the surface it sits on — a new use goes red until
+// someone has looked at what is behind it;
+// 2. each audited use reaches 4.5:1 (WCAG AA, normal text) in both themes;
+// 3. text over the SLIDE (comment labels) carries the surface-coloured halo,
+// because the deck's background is nobody's token;
+// 4. text on the orange fill uses --accent-on, reaches 4.5:1 there, and no
+// rule hard-codes the old #3a28xx/#3a2axx any more;
+// 5. the focus outlines the kernel's toggle/menu draw from --accent-ink reach
+// 3:1 on the chrome (WCAG non-text contrast).
+
+import { readFileSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+import { dirname, join } from 'node:path'
+
+let failures = 0
+let checks = 0
+function ok(cond: boolean, msg: string) {
+ checks++
+ if (!cond) { failures++; console.log(` FAIL ${msg}`) }
+ else console.log(` ok ${msg}`)
+}
+const root = join(dirname(fileURLToPath(import.meta.url)), '..')
+const css = readFileSync(join(root, 'slides/src/styles.css'), 'utf8')
+
+// --- tokens -------------------------------------------------------------------
+const block = (sel: string) => {
+ const i = css.indexOf(sel + ' {')
+ if (i < 0) throw new Error('no block ' + sel)
+ return css.slice(i, css.indexOf('}', i))
+}
+const tokens = (b: string) => Object.fromEntries([...b.matchAll(/(--[a-z0-9-]+):\s*([^;]+);/g)].map((m) => [m[1], m[2].trim()]))
+const THEMES = {
+ light: tokens(block(':root, :root[data-theme="light"]')),
+ dark: tokens(block(':root[data-theme="dark"]')),
+} as Record<string, Record<string, string>>
+
+// --- colour maths (WCAG 2.x relative luminance) --------------------------------
+type RGB = [number, number, number]
+const hex = (h: string): RGB => { const s = h.replace('#', ''); const f = s.length === 3 ? s.split('').map((c) => c + c).join('') : s; return [0, 2, 4].map((i) => parseInt(f.slice(i, i + 2), 16)) as RGB }
+const lum = ([r, g, b]: RGB) => { const c = (v: number) => { const s = v / 255; return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4 }; return 0.2126 * c(r) + 0.7152 * c(g) + 0.0722 * c(b) }
+const contrast = (a: RGB, b: RGB) => { const [x, y] = [lum(a), lum(b)].sort((p, q) => q - p); return (x + 0.05) / (y + 0.05) }
+// color-mix(in srgb, A p%, transparent) painted over B
+const over = (a: RGB, p: number, b: RGB): RGB => a.map((v, i) => Math.round(v * p + b[i] * (1 - p))) as RGB
+
+// --- 1. every text use is audited --------------------------------------------
+type Bg = 'surface' | 'chrome-tint-22' | 'chrome-tint-30' | 'over-slide'
+const AUDITED: Record<string, Bg> = {
+ '.ed-btn-armed': 'chrome-tint-22', // the armed comment tool, on the topbar
+ '.ed-lang-on::after': 'surface', // the language menu's ✓
+ '.ed-comment-me:hover': 'surface', // your own name in a comment thread
+ '.ed-comment-hl.slide': 'over-slide', // "SLIDE" label on a whole-slide comment
+ '.ed-comment-hl.pin': 'over-slide', // coordinates beside a point comment
+}
+const rules = [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)].map((m) => ({ sel: m[1].trim().split('\n').pop()!.trim(), body: m[2] }))
+const inkText = rules.filter((r) => /(^|;|\s)color:\s*var\(--accent-ink\)/.test(r.body)).map((r) => r.sel)
+const unaudited = inkText.filter((s) => !(s in AUDITED))
+ok(unaudited.length === 0, `every accent-ink text use is audited (${inkText.length})${unaudited.length ? ' — new, look at its background: ' + unaudited.join(', ') : ''}`)
+ok(Object.keys(AUDITED).every((s) => inkText.includes(s)), 'and every audited use still exists (remove it from the list when it goes)')
+
+// --- 2 & 3. contrast of each use, both themes -------------------------------------
+for (const [theme, t] of Object.entries(THEMES)) {
+ const ink = hex(t['--accent-ink']), accent = hex(t['--accent'])
+ // (the topbar paints --surface — measured in Chrome, both themes — so the
+ // armed tool's 22%/30% accent tint sits over --surface, not --chrome)
+ const bgOf = (bg: Bg): RGB => bg === 'surface' || bg === 'over-slide' ? hex(t['--surface'])
+ : over(accent, bg === 'chrome-tint-22' ? 0.22 : 0.3, hex(t['--surface']))
+ for (const [sel, bg] of Object.entries(AUDITED)) {
+ const c = contrast(ink, bgOf(bg))
+ ok(c >= 4.5, `${theme}: ${sel} on ${bg === 'over-slide' ? 'its surface-coloured halo' : bg} — ${c.toFixed(2)}:1`)
+ }
+ // the armed tool's hover is a deeper tint of the same text
+ const hover = contrast(ink, bgOf('chrome-tint-30'))
+ ok(hover >= 4.5, `${theme}: .ed-btn-armed:hover — ${hover.toFixed(2)}:1`)
+ // 5. focus outlines (non-text) drawn from --accent-ink on the chrome
+ for (const bg of ['--chrome', '--surface']) {
+ const c = contrast(ink, hex(t[bg]))
+ ok(c >= 3, `${theme}: a focus outline in --accent-ink on ${bg} — ${c.toFixed(2)}:1 (non-text, ≥3)`)
+ }
+ // 4. text on the orange
+ const on = contrast(hex(t['--accent-on']), accent)
+ ok(on >= 4.5, `${theme}: --accent-on on the --accent fill — ${on.toFixed(2)}:1`)
+}
+for (const sel of Object.entries(AUDITED).filter(([, bg]) => bg === 'over-slide').map(([s]) => s)) {
+ const r = rules.find((x) => x.sel === sel)!
+ ok(/text-shadow:\s*var\(--over-slide-halo\)/.test(r.body), `${sel} carries the surface halo (the slide behind it is the deck's colour, not a token)`)
+}
+ok(/--over-slide-halo:[^;]*var\(--surface\)/.test(css), 'the halo is drawn in --surface, so it follows the theme')
+
+// --- 4. text on the fill uses the token -----------------------------------------
+// every rule that puts text on the solid fill must read on it: --accent-on in
+// the editor; the speaker view (its own popup document) spells a near-black
+const onFill = rules.filter((r) => /background:\s*var\(--accent\)\s*;/.test(r.body) && /(^|;|\s)color:/.test(r.body))
+for (const r of onFill) {
+ const c = /(?:^|;|\s)color:\s*([^;]+)/.exec(r.body)![1].trim()
+ const fg = c === 'var(--accent-on)' ? THEMES.dark['--accent-on'] : c
+ const ratio = /^#[0-9a-f]{3,6}$/i.test(fg) ? contrast(hex(fg), hex(THEMES.dark['--accent'])) : 0
+ ok(ratio >= 4.5, `${r.sel}: text on the accent fill (${c}) — ${ratio.toFixed(2)}:1`)
+}
+ok(['.ed-comment-chip', '.ed-step-badge.sel', '.ed-comment-marker'].every((s) => /color:\s*var\(--accent-on\)/.test(rules.find((r) => r.sel === s)?.body ?? '')), 'the editor\'s chips, badges and markers take --accent-on')
+const hard = rules.filter((r) => !r.sel.startsWith(':root') && /color:\s*#3a2[0-9a-f]00/i.test(r.body)).map((r) => r.sel)
+ok(hard.length === 0, `no rule hard-codes the old on-accent brown${hard.length ? ': ' + hard.join(', ') : ''}`)
+
+console.log(`\n${checks - failures}/${checks} checks passed`)
+process.exit(failures ? 1 : 0)
diff --git a/slides/src/styles.css b/slides/src/styles.css
index 3b6e5bf7..88ef3986 100644
--- a/slides/src/styles.css
+++ b/slides/src/styles.css
@@ -24,7 +24,8 @@
--line: #e3e8ef;
--muted: #5b6472;
--accent: #f7a600;
- --accent-ink: #7a5200;
+ --accent-ink: #7a5200; /* accent-coloured TEXT on the chrome's own surfaces */
+ --accent-on: #3a2a00; /* text sitting ON the solid --accent fill */
--blue: #5b8def;
--field: #ffffff; /* form-control surface — CHROME, not the slide */
--surface: #ffffff; /* panels, dialogs, menus */
@@ -43,7 +44,12 @@
--line: #333a45;
--muted: #8b95a4;
--accent: #f7a600;
- --accent-ink: #3a2a00; /* text ON the accent, so it flips */
+ /* accent-coloured TEXT on dark chrome: lifted, as spaces does. It used to
+ be #3a2a00 (meant for text ON the orange) and every text use sat on the
+ dark surfaces instead — 1.09:1, invisible (spaces' chrome audit, 2026-09).
+ Text on the orange fill has its own token, and it does not flip. */
+ --accent-ink: #f0b74e;
+ --accent-on: #3a2a00;
--blue: #7aa5f5; /* lifted: #5b8def is unreadable on dark chrome */
--field: #12151a;
--surface: #21262e;
@@ -56,6 +62,12 @@
:root {
--radius: 10px;
+ /* Chrome text drawn OVER THE SLIDE (the comment labels) sits on the deck's
+ background, not the chrome's, so neither theme's ink is safe on its own:
+ a dark slide hid the light theme's brown, a light slide would hide the
+ dark theme's gold. A halo in the chrome's surface colour gives the text
+ its own ground on any slide. */
+ --over-slide-halo: 0 0 2px var(--surface), 0 0 2px var(--surface), 0 0 4px var(--surface);
}
* { box-sizing: border-box; }
@@ -1269,7 +1281,7 @@ a.ed-btn { text-decoration: none; } /* the update block's "What's new" link is
z-index: 12;
pointer-events: none;
background: var(--accent);
- color: #3a2800;
+ color: var(--accent-on);
font: 700 10.5px/1 -apple-system, 'Segoe UI', system-ui, sans-serif;
padding: 5px 9px;
border-radius: 999px;
@@ -1288,11 +1300,13 @@ a.ed-btn { text-decoration: none; } /* the update block's "What's new" link is
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--accent-ink);
+ text-shadow: var(--over-slide-halo);
}
.ed-comment-hl.pin {
width: 0; height: 0;
font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
color: var(--accent-ink);
+ text-shadow: var(--over-slide-halo);
white-space: nowrap;
padding-left: 12px;
padding-top: 2px;
@@ -1335,7 +1349,7 @@ a.ed-btn { text-decoration: none; } /* the update block's "What's new" link is
cursor: pointer;
box-shadow: 0 1px 4px rgb(15 23 36 / 0.3);
}
-.ed-step-badge.sel { background: var(--accent); color: #3a2800; }
+.ed-step-badge.sel { background: var(--accent); color: var(--accent-on); }
.ed-step-badge:hover { transform: scale(1.15); }
.ed-comment-marker {
position: absolute;
@@ -1345,7 +1359,7 @@ a.ed-btn { text-decoration: none; } /* the update block's "What's new" link is
border: none;
border-radius: 50% 50% 50% 3px;
background: var(--accent);
- color: #3a2800;
+ color: var(--accent-on);
font: 700 10px/19px inherit;
font-family: inherit;
text-align: center;