Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

Text takes the opposite colour to whatever it sits on (#353)

nyblnet5efe749301cf
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0cf45eb4..7d561224 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,15 @@ pre-1.0.
## [Unreleased]
+- **Fix: several buttons were unreadable in dark mode.** White text on a
+ near-white button — the main action in a dialog, the toast that confirms a
+ save, the active chip in a settings row, and the + between slides. The
+ colour of the text was fixed while the colour behind it followed the theme,
+ so what read cleanly in light turned into white-on-white as soon as the
+ interface went dark. The panel chevrons had a milder version of the same
+ thing. Text now always takes the opposite colour to whatever it sits on.
+
+
- **Fix: audio and video played in a show even with Autoplay switched off.**
Set a clip's *Autoplay* to Off and it still started the moment its slide came
up — every time, in a saved file, on any browser. The only way to stop it was
diff --git a/scripts/test-slides-theme.mjs b/scripts/test-slides-theme.mjs
index f3810cdf..d56be498 100644
--- a/scripts/test-slides-theme.mjs
+++ b/scripts/test-slides-theme.mjs
@@ -109,6 +109,41 @@ ok(whiteSurfaces.length === 0,
`every themed role is referenced by a rule${unused.length ? ` — defined but unused: ${unused.join(', ')}` : ''}`)
}
+// ---- 4b. a themed background never carries a literal foreground -----------
+// The pairing that breaks on a theme flip. `.ed-btn-primary` was
+// `background: var(--ink); color: #fff` — correct in light, and in dark the
+// background followed --ink to a light value while the text stayed white:
+// measured 1.21:1, unreadable, on six buttons across the app. It survived
+// review because the About dialog has its own override, so the one instance
+// anybody looked at was fine.
+//
+// Only tokens that ACTUALLY INVERT are an offence. `--accent` is the same
+// peach in both themes, so a literal foreground on it is stable and allowed —
+// flagging those would train people to ignore this check.
+{
+ const valuesIn = (body) => Object.fromEntries(
+ [...body.matchAll(/^\s*(--[a-z0-9-]+)\s*:\s*([^;]+);/gmi)].map((m) => [m[1], m[2].trim().toLowerCase()]))
+ const L = valuesIn(light ?? ''), D = valuesIn(dark ?? '')
+ const inverts = (tok) => L[tok] && D[tok] && L[tok] !== D[tok]
+
+ const offenders = []
+ for (const [, , sel, body] of rules) {
+ const bg = body.match(/background(?:-color)?\s*:\s*var\((--[a-z0-9-]+)/i)
+ if (!bg || !inverts(bg[1])) continue
+ // A literal colour, i.e. one that is not itself a token. Tested on the
+ // CAPTURED value rather than with a lookahead: `\s*(?!var\()` backtracks —
+ // it gives back a space and then happily matches ` var(--ink)`, which had
+ // this check reporting three false positives on its first run.
+ const fg = body.match(/(?:^|;)\s*color\s*:\s*([^;]+)/i)
+ if (!fg || /^var\(/.test(fg[1].trim())) continue
+ const s2 = sel.replace(/\/\*[\s\S]*?\*\//g, '').trim().split(',')[0].trim()
+ if (EXEMPT.test(s2)) continue
+ offenders.push(`${s2} — background ${bg[1]} inverts, but color is ${fg[1].trim()}`)
+ }
+ ok(offenders.length === 0,
+ `no rule pairs an inverting background token with a literal text colour${offenders.length ? `\n ${offenders.join('\n ')}` : ''}`)
+}
+
// ---- 5. the light palette has not forked from the suite -------------------
const SHARED = { '--ink': '#1e2a3a', '--ink-2': '#31445c', '--chrome': '#f5f7fa',
'--chrome-2': '#eceff4', '--line': '#e3e8ef', '--muted': '#5b6472',
diff --git a/slides/src/styles.css b/slides/src/styles.css
index 1a2cff72..e1a62c23 100644
--- a/slides/src/styles.css
+++ b/slides/src/styles.css
@@ -240,8 +240,16 @@ a.ed-btn { text-decoration: none; } /* the update block's "What's new" link is
.ed-btn svg { display: block; }
.ed-btn-primary {
+ /* The button is always the INVERSE of the surface it sits on, which is the
+ only pairing that survives a theme flip. `color: #fff` did not: the
+ background follows --ink, so in dark mode it turned light while the text
+ stayed white — measured at 1.21:1, the same ratio that made the panel
+ inputs unreadable before the theme tokens existed. It looked right in the
+ About dialog only because that has its own peach override, so the six
+ other primary buttons in the app were the ones nobody saw.
+ After: 14.51:1 light, 12.61:1 dark. */
background: var(--ink);
- color: #fff;
+ color: var(--surface);
padding: 6px 14px;
}
.ed-btn-primary:hover { background: var(--ink-2); }
@@ -461,7 +469,7 @@ a.ed-btn { text-decoration: none; } /* the update block's "What's new" link is
.ed-setchip:hover { background: var(--chrome-2); }
.ed-setchip.active {
background: var(--ink);
- color: #fff;
+ color: var(--surface);
}
/* ————— slide surface (shared by canvas, thumbs, present) ————— */
@@ -772,7 +780,7 @@ a.ed-btn { text-decoration: none; } /* the update block's "What's new" link is
bottom: 26px;
transform: translate(-50%, 12px);
background: var(--ink);
- color: #fff;
+ color: var(--surface);
font-size: 13px;
padding: 9px 16px;
border-radius: 999px;
@@ -1391,7 +1399,7 @@ a.ed-btn { text-decoration: none; } /* the update block's "What's new" link is
z-index: 1;
border: none;
background: var(--blue);
- color: #fff;
+ color: var(--surface);
border-radius: 50%;
width: 16px;
height: 16px;
@@ -2153,7 +2161,10 @@ body.ed-col-resizing { cursor: col-resize; user-select: none; }
border: 1px solid var(--line);
border-radius: 8px;
background: var(--surface);
- color: #5d6b80;
+ /* --muted, not a literal: the background follows --surface, so a fixed
+ grey-blue that read at 5.41:1 on white sat at 2.81:1 on the dark surface,
+ under the 4.5 floor. With the token it is 5.98:1 light, 5.02:1 dark. */
+ color: var(--muted);
font-size: 11px;
line-height: 1;
padding: 0;