Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): darken the error text for badges on a tinted card

Yudhi Armyndharise50444a2d97c
diff --git a/dashboard/src/App.css b/dashboard/src/App.css
index 5afcc4661..840c4e50a 100644
--- a/dashboard/src/App.css
+++ b/dashboard/src/App.css
@@ -25,10 +25,10 @@
--warning: #f59e0b;
/* Status colours as FOREGROUND fail AA on light: error 3.76:1, success 2.28:1, warning 2.15:1.
They stay the fill/border colours; text and icons use these darkened twins. Each clears 4.5:1 on
- white and on the heaviest tint of its own hue that a badge paints over white: error-text 4.57:1 on the
- 15 percent red of the Failed pill, success-text 4.58:1 on an 18 percent green and warning-text 4.57:1 on
+ white and on the heaviest tint of its own hue that a badge paints over white: error-text 4.84:1 on the
+ 15 percent red of the Failed pill (4.62:1 where a badge sits on the 4 percent red of its result card), success-text 4.58:1 on an 18 percent green and warning-text 4.57:1 on
the 22 percent amber of Action required. A heavier tint needs a darker twin. */
- --error-text: #bf3535;
+ --error-text: #b93232;
--success-text: #157b3b;
--warning-text: #935f06;
--info: #2563eb; /* Blue 600 — info/permission/log badges + qr-ready pill */
diff --git a/dashboard/src/error-text.test.ts b/dashboard/src/error-text.test.ts
index 503e96fdb..5150448a2 100644
--- a/dashboard/src/error-text.test.ts
+++ b/dashboard/src/error-text.test.ts
@@ -7,7 +7,7 @@ import { dirname, join } from 'node:path';
// --error is the fill and border red. As a text colour it measures 3.76:1 on white and 3.08:1 on the 12 percent
// error tint of a banner, under the 4.5:1 AA needs; --error-text is the same hue darkened (lightened in the
// dark theme). In the light theme it clears 4.5:1 on white and on the tints over white up to the 15 percent of the
-// Failed pill (4.88:1 at 10 percent, 4.57:1 at 15 percent); in the dark theme it clears 4.5:1 on every tint.
+// Failed pill (5.17:1 at 10 percent, 4.84:1 at 15 percent); in the dark theme it clears 4.5:1 on every tint.
// Foreground colours use --error-text.
const SRC = dirname(fileURLToPath(import.meta.url));
diff --git a/dashboard/src/theme-contrast.test.ts b/dashboard/src/theme-contrast.test.ts
index 81bc7f1f9..629357f83 100644
--- a/dashboard/src/theme-contrast.test.ts
+++ b/dashboard/src/theme-contrast.test.ts
@@ -192,6 +192,27 @@ test('every status text twin clears 4.5:1 on the translucent fill its own rule p
assert.deepEqual(offenders, []);
});
+// A badge inside a tinted card sits on both tints: the Not Registered badge paints 15 percent red over the 4 percent red
+// of its result card, which leaves --error-text at 4.38:1 where the pair over plain white measured 4.57:1.
+test('the Not Registered badge clears 4.5:1 on its tint over the tint of its result card', () => {
+ const css = read('NumberChecker.css').replace(/\/\*[\s\S]*?\*\//g, '');
+ const alphaOf = (selector: string): number => {
+ const rule = new RegExp(
+ `${selector.replace(/[.]/g, '\\.')}\\s*\\{[^}]*background:\\s*rgba\\(239,\\s*68,\\s*68,\\s*([\\d.]+)\\)`,
+ ).exec(css);
+ assert.ok(rule, `NumberChecker.css has no red tint for ${selector}`);
+ return Number(rule[1]);
+ };
+ const badge = alphaOf('.number-checker .nc-status-badge.unregistered');
+ const card = alphaOf('.number-checker .nc-result-card.not-found');
+ const light = blockAfter(LIGHT);
+ const red = rgb(hexOf(light, '--error'));
+ // The result card sits in .nc-card, which is --bg-white.
+ const tint = mix(red, badge, mix(red, card, rgb(hexOf(light, '--bg-white'))));
+ const ratio = contrast(rgb(hexOf(light, '--error-text')), tint);
+ assert.ok(ratio >= 4.5, `--error-text on the badge over the card is ${ratio.toFixed(2)}:1`);
+});
+
// WCAG 2.2 SC 1.4.11 asks 3:1 of a keyboard focus indicator against what it is drawn on: the page and card surfaces
// and the soft brand tint of a focused menu entry or search hit. The brand fill measured 1.98:1 on white.
test('the focus ring clears 3:1 on every surface it is drawn on, in both themes', () => {