Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): draw glyphs on the chat accent fill in dark ink
Yudhi Armyndharisa2140acad9ad
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f6d9c48f5..630048c28 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Read the dashboard Chats page's session list again when the page is shown, so a session deleted elsewhere no longer stays open.- Draw group sender names in dashboard chat threads in colours that clear 4.5:1 on the incoming bubble in light and dark themes.- Draw links inside a quoted dashboard chat message in the chat link colours, which clear 4.5:1 on the quote in light and dark themes.+- Draw the selection check in the dashboard New group list dark on its green fill, where white measured under 3:1.## [0.26.0] - 2026-10-28diff --git a/dashboard/src/contrast-pairs.test.ts b/dashboard/src/contrast-pairs.test.tsindex fe569a0d5..7b8120398 100644--- a/dashboard/src/contrast-pairs.test.ts+++ b/dashboard/src/contrast-pairs.test.ts@@ -42,11 +42,32 @@ const WHITE = /^(?:#fff|#ffffff|white)$/i;const LIGHT_FILL =/^(?:var\(--(?:primary|chat-accent)(?:-hover)?(?:,[^)]*)?\)|var\(--warning(?:,[^)]*)?\)|#25d366|#1da851|#16a34a|#f59e0b|#d97706|#00a884|#008f6f)$/i;+// A gradient is a light fill when one of its stops is: `linear-gradient(135deg, #5fd17b, var(--chat-accent))`.+function fillStops(r: Rule): string[] {+ const fill = r.decl.background ?? r.decl['background-color'] ?? '';+ const gradient = /^linear-gradient\((.*)\)$/.exec(fill);+ return gradient ? (gradient[1].match(/(?:[^,(]|\([^)]*\))+/g) ?? []).map(stop => stop.trim().split(' ')[0]) : [fill];+}++// The colour a selector draws in: its own rule's, else the one of the rule it refines, so a state rule that only paints+// the fill (`.select-check.checked`) is paired with the white its base rule (`.select-check`) sets.+function colourOf(all: Rule[], selector: string): string {+ let at = selector;+ while (at && !/\s$/.test(at)) {+ const colour = all.find(r => r.selectors.split(/,\s*/).includes(at) && r.decl.color)?.decl.color;+ if (colour) return colour;+ const base = at.replace(/(?:\.[\w-]+|:[\w-]+(?:\([^)]*\))?)$/, '');+ if (base === at) break;+ at = base;+ }+ return '';+}+test('no rule sets white text on the brand green or amber fill', () => {- const offenders = rules()- .filter(- r => WHITE.test(r.decl.color ?? '') && LIGHT_FILL.test(r.decl.background ?? r.decl['background-color'] ?? ''),- )+ const all = rules();+ const offenders = all+ .filter(r => fillStops(r).some(stop => LIGHT_FILL.test(stop)))+ .filter(r => r.selectors.split(/,\s*/).some(selector => WHITE.test(colourOf(all, selector)))).map(r => `${r.at}: ${r.selectors}`);assert.deepEqual(offenders, []);});diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.cssindex cd515fcca..3c7d6d512 100644--- a/dashboard/src/pages/Chats.css+++ b/dashboard/src/pages/Chats.css@@ -1225,7 +1225,8 @@height: 52px;border-radius: 14px;background: linear-gradient(135deg, #5fd17b, var(--chat-accent));- color: #fff;+ /* Dark on both ends of the green: white was 1.93:1 on the light one. */+ color: #0f172a;display: flex;align-items: center;justify-content: center;@@ -1560,12 +1561,13 @@align-items: center;justify-content: center;flex-shrink: 0;- color: #fff;}+/* Content on the accent fill is dark: white on it is 3.03:1 (see contrast-pairs.test.ts). */.chats-page .select-check.checked {background: var(--chat-accent);border-color: var(--chat-accent);+ color: #0f172a;}.chats-page .new-group-fields {diff --git a/dashboard/src/theme-contrast.test.ts b/dashboard/src/theme-contrast.test.tsindex 8ed1a9679..abd078b78 100644--- a/dashboard/src/theme-contrast.test.ts+++ b/dashboard/src/theme-contrast.test.ts@@ -122,6 +122,28 @@ test('the outgoing bubble draws its links in their own token, and a quote its liassert.match(chatRule('.chats-page .message-bubble.outgoing .quote-body a'), /color:\s*var\(--chat-link-out\)/);});+// The accent fill is one green in every theme. The New group check mark sits on it, and the group dialog's tile draws+// its glyph on a gradient from a lighter green into it: as graphics each needs 3:1 on every colour under it.+test('the glyphs drawn on the accent fill clear 3:1 on it, and on both ends of the group tile gradient', () => {+ const accent = rgb(chatToken(chatBlock('.chats-page {'), '--chat-accent'));+ const check = chatRule('.chats-page .select-check.checked');+ assert.match(check, /background:\s*var\(--chat-accent\)/);+ const tile = chatRule('.chats-page .group-info-tile');+ const light = /background:\s*linear-gradient\(135deg, (#[0-9a-f]{6}), var\(--chat-accent\)\)/.exec(tile)?.[1];+ assert.ok(light, 'the group tile is no longer the gradient this test measures');+ for (const [name, rule, fills] of [+ ['check mark', check, [accent]],+ ['group tile', tile, [rgb(light), accent]],+ ] as const) {+ const glyph = /(?:^|;)\s*color:\s*(#[0-9a-f]{6})/.exec(rule)?.[1];+ assert.ok(glyph, `the ${name} sets no glyph colour of its own`);+ for (const fill of fills) {+ const ratio = contrast(rgb(glyph), fill);+ assert.ok(ratio >= 3, `the ${name} glyph is ${ratio.toFixed(2)}:1 on its fill`);+ }+ }+});+// The muted lines a bubble holds are --chat-meta in an incoming one. On the dark outgoing green that token is 3.27:1,// and 2.87:1 on a quote there, so each line has an outgoing rule in --chat-meta-out, which the tests above measure.const BUBBLE_META = [