Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): darken the light status text colours
Yudhi Armyndharis20184358ac1b
diff --git a/dashboard/src/App.css b/dashboard/src/App.cssindex 558e10066..1b798ec95 100644--- a/dashboard/src/App.css+++ b/dashboard/src/App.css@@ -2,11 +2,10 @@--primary: #25d366;/* The brand green as FOREGROUND is 1.98:1 on white, far under the 4.5:1 AA needs for text.It stays the fill colour; anything rendering it as text or an icon uses --primary-text, the same- hue darkened until it clears 4.5:1 on the three light backgrounds it lands on most: 4.95:1 on white,- 4.73:1 on --bg-light, and 4.52:1 on --primary-soft, which is the tightest of the three and the- one the active sidebar item uses. On the heavier green tints some badges paint (15 to 18 percent)- it measures 4.3 to 4.4:1. */- --primary-text: #17813e;+ hue darkened until it clears 4.5:1 on the light backgrounds it lands on: 5.28:1 on white, 5.04:1 on+ --bg-light, and 4.82:1 on --primary-soft (4.63:1 over --bg-light), the tint the active sidebar item+ uses. On the heaviest green tint a badge paints (18 percent over white) it measures 4.61:1. */+ --primary-text: #167c3b;--primary-hover: #1da851;--primary-soft: rgba(37, 211, 102, 0.12);--bg-light: #f8fafc;@@ -21,12 +20,12 @@--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 a 10 percent tint of its own hue. The heavier 12 to 22 percent tints that some badges- paint behind them do not all hold: the twins measure 4.29 to 4.46:1 there (error-text 4.29:1 on the- 15 percent red of the Failed pill, warning-text 4.34:1 on the 22 percent amber of Action required). */- --error-text: #c63838;- --success-text: #157c3b;- --warning-text: #986207;+ 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+ the 22 percent amber of Action required. A heavier tint needs a darker twin. */+ --error-text: #bf3535;+ --success-text: #157b3b;+ --warning-text: #935f06;--info: #2563eb; /* Blue 600 — info/permission/log badges + qr-ready pill */--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);@@ -91,7 +90,7 @@--success-text: var(--success);--warning-text: var(--warning);--primary-soft: color-mix(in srgb, var(--primary) 18%, transparent);- /* Must be restated here, not inherited: the light value (#17813e) measures 2.96:1 on Slate 800+ /* Must be restated here, not inherited: the light value (#167c3b) measures 2.77:1 on Slate 800and would fail worse than the brand green it replaced. On dark the brand green is 7.38:1. */--primary-text: var(--primary);--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);diff --git a/dashboard/src/error-text.test.ts b/dashboard/src/error-text.test.tsindex d8340a7c2..503e96fdb 100644--- a/dashboard/src/error-text.test.ts+++ b/dashboard/src/error-text.test.ts@@ -6,9 +6,9 @@ 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 a 10 percent tint over white (4.58:1), and-// measures 4.28 to 4.46:1 on the heavier tints of the banners and the Failed pill; in the dark theme it clears-// 4.5:1 on every tint. Foreground colours use --error-text.+// 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.+// Foreground colours use --error-text.const SRC = dirname(fileURLToPath(import.meta.url));diff --git a/dashboard/src/pages/Plugins.css b/dashboard/src/pages/Plugins.cssindex 086f837dc..d9d7a7248 100644--- a/dashboard/src/pages/Plugins.css+++ b/dashboard/src/pages/Plugins.css@@ -110,7 +110,7 @@padding: 0.0625rem 0.4375rem;font-size: 0.6875rem;font-weight: 600;- color: var(--primary-text, #17813e);+ color: var(--primary-text, #167c3b);background: color-mix(in srgb, var(--primary, #25d366) 12%, transparent);border: 1px solid color-mix(in srgb, var(--primary, #25d366) 35%, transparent);border-radius: 999px;@@ -1116,7 +1116,7 @@}.plugins-page .catalog-badge.update {- color: var(--primary-text, #17813e);+ color: var(--primary-text, #167c3b);}.plugins-page .catalog-row-action {diff --git a/dashboard/src/pages/Sessions.css b/dashboard/src/pages/Sessions.cssindex cf6b5fce3..7a66455cf 100644--- a/dashboard/src/pages/Sessions.css+++ b/dashboard/src/pages/Sessions.css@@ -684,7 +684,7 @@}/* The detail badge spells the status out beside its own label, so it takes the 10 percent tint of the other- badges: --warning-text is 4.76:1 on it, 4.34:1 on the pill's 22 percent. In the dialog it then differs from+ badges: --warning-text is 5.02:1 on it, 4.57:1 on the pill's 22 percent. In the dialog it then differs fromthe in-progress amber badges by hue only. */.sessions-page .status-badge.action_required {background: rgba(245, 158, 11, 0.1);diff --git a/dashboard/src/theme-contrast.test.ts b/dashboard/src/theme-contrast.test.tsindex 467c85162..849426615 100644--- a/dashboard/src/theme-contrast.test.ts+++ b/dashboard/src/theme-contrast.test.ts@@ -1,6 +1,6 @@import { test } from 'node:test';import assert from 'node:assert/strict';-import { readFileSync } from 'node:fs';+import { readFileSync, readdirSync } from 'node:fs';import { fileURLToPath } from 'node:url';import { dirname, join } from 'node:path';@@ -132,9 +132,8 @@ test('the action required pill clears 4.5:1 on its tint in the dark theme, with}});-// The detail modal repeats the status as a badge beside its own "Status" label. The 22 percent tint the card pill-// uses leaves --warning-text at 4.34:1 on white there, so the badge takes the 10 percent tint every other-// status badge has.+// The detail modal repeats the status as a badge beside its own "Status" label, on the 10 percent tint every other+// status badge has (--warning-text is 5.02:1 on it over white) rather than the card pill's 22 percent (4.57:1).test('the action required badge in the session details clears 4.5:1 on its tint in every theme', () => {const rule =/\.sessions-page \.status-badge\.action_required\s*\{[^}]*background:\s*rgba\(245,\s*158,\s*11,\s*([\d.]+)\)/.exec(@@ -151,6 +150,42 @@ test('the action required badge in the session details clears 4.5:1 on its tint}});+// A status badge, pill or hover state paints a translucent tint of its own hue behind a text twin. The twins have to hold+// on the heaviest tint any rule paints over white (error 15 percent, success 18, warning 22), not only on the 10+// percent one: a rule with a heavier tint needs a darker twin, or a lighter tint.+const cssFiles = (dir: string): string[] =>+ readdirSync(dir, { withFileTypes: true }).flatMap(entry => {+ const full = join(dir, entry.name);+ if (entry.isDirectory()) return cssFiles(full);+ return entry.name.endsWith('.css') ? [full] : [];+ });++test('every status text twin clears 4.5:1 on the translucent fill its own rule paints over white', () => {+ const root = dirname(fileURLToPath(import.meta.url));+ const light = blockAfter(LIGHT);+ const white = rgb(hexOf(light, '--bg-white'));+ let checked = 0;+ const offenders: string[] = [];+ for (const file of cssFiles(root)) {+ const css = readFileSync(file, 'utf8').replace(/\/\*[\s\S]*?\*\//g, '');+ for (const rule of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {+ const color = /(?:^|;)\s*color:\s*var\((--(?:error|success|warning|primary)-text)\)/.exec(rule[2]);+ const fill = /(?:^|;)\s*background(?:-color)?:\s*rgba\(\s*(\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)/.exec(rule[2]);+ if (!color || !fill) continue;+ checked++;+ const tint = mix([Number(fill[1]), Number(fill[2]), Number(fill[3])], Number(fill[4]), white);+ const ratio = contrast(rgb(hexOf(light, color[1])), tint);+ if (ratio < 4.5) {+ offenders.push(+ `${file.slice(root.length + 1)}: ${rule[1].trim()} ${color[1]} ${ratio.toFixed(2)}:1 on ${fill[4]}`,+ );+ }+ }+ }+ assert.ok(checked > 40, `the scan saw ${checked} rules`);+ assert.deepEqual(offenders, []);+});+test('the search match and the Number Checker highlight pill clear AA in both themes', () => {const search = readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'components/GlobalSearch.css'), 'utf8');const mark =