Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): use dark text on the brand green and amber fills

Yudhi Armyndhariscfd15b1cc657
diff --git a/dashboard/src/components/FilterBuilder.css b/dashboard/src/components/FilterBuilder.css
index efba972f0..4b9af9003 100644
--- a/dashboard/src/components/FilterBuilder.css
+++ b/dashboard/src/components/FilterBuilder.css
@@ -191,7 +191,7 @@
.enum-tag.selected {
background: var(--primary);
border-color: var(--primary);
- color: #fff;
+ color: #0f172a;
}
/* Chips input with autocomplete */
diff --git a/dashboard/src/components/Layout.css b/dashboard/src/components/Layout.css
index 05a3fe31a..2dfab2133 100644
--- a/dashboard/src/components/Layout.css
+++ b/dashboard/src/components/Layout.css
@@ -113,7 +113,7 @@
.collapse-toggle:hover {
background: var(--primary);
border-color: var(--primary);
- color: white;
+ color: #0f172a;
box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}
diff --git a/dashboard/src/contrast-pairs.test.ts b/dashboard/src/contrast-pairs.test.ts
new file mode 100644
index 000000000..325cc5221
--- /dev/null
+++ b/dashboard/src/contrast-pairs.test.ts
@@ -0,0 +1,64 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { readFileSync, readdirSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
+import { dirname, join } from 'node:path';
+
+// The brand green (#25d366) and the amber warning fill are light colours: white on them is 1.98:1 and 2.15:1,
+// far under the 4.5:1 AA needs, and the green as text on white is the same 1.98:1. Text and icons on those fills are
+// dark (#0f172a, 9.0:1 on the green, as .btn-primary has it), and the brand green as text is --primary-text.
+
+const SRC = dirname(fileURLToPath(import.meta.url));
+
+function filesUnder(dir: string, extensions: string[]): string[] {
+ return readdirSync(dir, { withFileTypes: true }).flatMap(entry => {
+ const full = join(dir, entry.name);
+ if (entry.isDirectory()) return filesUnder(full, extensions);
+ return extensions.some(ext => entry.name.endsWith(ext)) && !entry.name.endsWith('.test.ts') ? [full] : [];
+ });
+}
+
+interface Rule {
+ at: string;
+ selectors: string;
+ decl: Record<string, string>;
+}
+
+function rules(): Rule[] {
+ return filesUnder(SRC, ['.css']).flatMap(full => {
+ const css = readFileSync(full, 'utf8').replace(/\/\*[\s\S]*?\*\//g, comment => comment.replace(/[^\n]/g, ''));
+ return [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)].map(m => ({
+ at: `${full.slice(SRC.length + 1)}:${css.slice(0, m.index + m[1].length).split('\n').length}`,
+ selectors: m[1].trim().replace(/\s+/g, ' '),
+ decl: Object.fromEntries([...m[2].matchAll(/(?:^|;)\s*([\w-]+)\s*:\s*([^;]+)/g)].map(d => [d[1], d[2].trim()])),
+ }));
+ });
+}
+
+const WHITE = /^(?:#fff|#ffffff|white)$/i;
+// Solid fills only: a translucent tint (rgba, color-mix) is a different pair and is checked by its own ratio.
+const LIGHT_FILL =
+ /^(?:var\(--primary(?:-hover)?(?:,[^)]*)?\)|var\(--warning(?:,[^)]*)?\)|#25d366|#1da851|#16a34a|#f59e0b|#d97706)$/i;
+
+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'] ?? ''),
+ )
+ .map(r => `${r.at}: ${r.selectors}`);
+ assert.deepEqual(offenders, []);
+});
+
+test('the brand green is never used as a text colour', () => {
+ const css = rules()
+ .filter(r => /^(?:var\(--primary(?:,[^)]*)?\)|#25d366)$/i.test(r.decl.color ?? ''))
+ .map(r => `${r.at}: ${r.selectors}`);
+ const inline = filesUnder(SRC, ['.tsx']).flatMap(full =>
+ readFileSync(full, 'utf8')
+ .split('\n')
+ .map((line, i) => ({ line, at: `${full.slice(SRC.length + 1)}:${i + 1}` }))
+ .filter(({ line }) => /(?<![\w-])color:\s*['"](?:var\(--primary\)|#25d366)['"]/.test(line))
+ .map(({ at }) => at),
+ );
+ assert.deepEqual([...css, ...inline], []);
+});
diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.css
index c802e9819..39e12659c 100644
--- a/dashboard/src/pages/Chats.css
+++ b/dashboard/src/pages/Chats.css
@@ -277,7 +277,7 @@
min-width: 20px;
padding: 0 6px;
background: var(--primary);
- color: white;
+ color: #0f172a;
font-size: 0.75rem;
font-weight: 700;
line-height: 1;
@@ -818,7 +818,7 @@
background: var(--primary);
border: none;
border-radius: 50%;
- color: white;
+ color: #0f172a;
cursor: pointer;
transition:
background 0.2s,
@@ -836,7 +836,7 @@
/* Keep the brand silhouette readable while clearly inactive — a bare gray-on-gray glyph
reads as "no button here" rather than "send, disabled". */
background: var(--primary);
- color: #fff;
+ color: #0f172a;
opacity: 0.55;
cursor: not-allowed;
box-shadow: none;
@@ -1463,7 +1463,7 @@
border: 1px solid var(--border);
border-radius: 8px;
background: var(--bg-white);
- color: var(--primary);
+ color: var(--primary-text);
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
@@ -1744,7 +1744,7 @@
.chats-page .status-compose-modal .compose-type-toggle button.active {
background: var(--primary);
- color: white;
+ color: #0f172a;
}
.chats-page .status-compose-modal .compose-field {
@@ -2240,7 +2240,7 @@
.chats-page .chat-avatar.action-avatar {
background: var(--primary);
border-color: var(--primary);
- color: #fff;
+ color: #0f172a;
}
.chats-page .select-check {
@@ -2339,7 +2339,7 @@
border: none;
border-radius: var(--radius, 8px);
background: var(--primary);
- color: #fff;
+ color: #0f172a;
font-weight: 600;
cursor: pointer;
}
@@ -2365,7 +2365,7 @@
height: 44px;
border-radius: 12px;
background: var(--primary);
- color: #fff;
+ color: #0f172a;
display: flex;
align-items: center;
justify-content: center;
diff --git a/dashboard/src/pages/Login.css b/dashboard/src/pages/Login.css
index 7ee9a0849..534283887 100644
--- a/dashboard/src/pages/Login.css
+++ b/dashboard/src/pages/Login.css
@@ -148,7 +148,7 @@
padding: 0.875rem 1.5rem;
font-size: 1rem;
font-weight: 600;
- color: white;
+ color: #0f172a;
background: var(--primary);
border: none;
border-radius: var(--radius);
diff --git a/dashboard/src/pages/Logs.css b/dashboard/src/pages/Logs.css
index 38172c7e6..8e22049d6 100644
--- a/dashboard/src/pages/Logs.css
+++ b/dashboard/src/pages/Logs.css
@@ -207,7 +207,7 @@
.logs-page .page-numbers button.active {
background: var(--primary);
border-color: var(--primary);
- color: white;
+ color: #0f172a;
}
/* Empty Table State */
diff --git a/dashboard/src/pages/MessageTester.css b/dashboard/src/pages/MessageTester.css
index c6aa0b7ee..11eece6b0 100644
--- a/dashboard/src/pages/MessageTester.css
+++ b/dashboard/src/pages/MessageTester.css
@@ -107,7 +107,7 @@
.message-tester .toggle-group button.active {
background: var(--primary);
- color: white;
+ color: #0f172a;
}
.message-tester .send-btn {
@@ -119,7 +119,7 @@
padding: 0.875rem 1.5rem;
font-size: 1rem;
font-weight: 600;
- color: white;
+ color: #0f172a;
background: var(--primary);
border: none;
border-radius: var(--radius);
diff --git a/dashboard/src/pages/NumberChecker.css b/dashboard/src/pages/NumberChecker.css
index b96b7abad..e2483e0ec 100644
--- a/dashboard/src/pages/NumberChecker.css
+++ b/dashboard/src/pages/NumberChecker.css
@@ -52,7 +52,7 @@
padding: 0.5rem 1rem;
border-radius: 6px;
background: var(--primary);
- color: #fff;
+ color: #0f172a;
border: none;
font-size: 0.875rem;
font-weight: 600;
@@ -226,7 +226,7 @@
.number-checker .nc-btn-primary {
background: var(--primary);
- color: #fff;
+ color: #0f172a;
}
.number-checker .nc-btn-primary:hover:not(:disabled) {
@@ -537,7 +537,7 @@
.number-checker .nc-filter-btn.active {
background: var(--primary);
- color: #fff;
+ color: #0f172a;
border-color: var(--primary);
}
diff --git a/dashboard/src/pages/NumberChecker.tsx b/dashboard/src/pages/NumberChecker.tsx
index 7834d15ba..125eacf68 100644
--- a/dashboard/src/pages/NumberChecker.tsx
+++ b/dashboard/src/pages/NumberChecker.tsx
@@ -561,7 +561,7 @@ export function NumberChecker() {
{isCheckingSingle ? (
<div className="nc-result-placeholder">
- <Loader2 size={36} className="animate-spin" style={{ color: 'var(--primary)' }} />
+ <Loader2 size={36} className="animate-spin" style={{ color: 'var(--primary-text)' }} />
<span>{t('numberChecker.single.querying')}</span>
</div>
) : singleResult ? (
diff --git a/dashboard/src/pages/Plugins.css b/dashboard/src/pages/Plugins.css
index d51b857a2..9c03d40dc 100644
--- a/dashboard/src/pages/Plugins.css
+++ b/dashboard/src/pages/Plugins.css
@@ -132,7 +132,9 @@
margin-inline-start: 6px;
font-size: 0.6875rem;
font-weight: 700;
- color: var(--primary-text, #17813e);
+ /* On the brand green Install button in both themes: dark text, as on .btn-primary. The brand-coloured text
+ this had was 2.49:1 on it in light and the same colour as the button in dark (invisible). */
+ color: #0f172a;
background: color-mix(in srgb, var(--primary, #25d366) 18%, transparent);
border-radius: 999px;
}
@@ -265,7 +267,7 @@
.plugins-page .btn-toggle.enable {
background: var(--primary, #25d366);
border: 1px solid var(--primary, #25d366);
- color: #fff;
+ color: #0f172a;
}
.plugins-page .btn-toggle.enable:hover {
@@ -592,7 +594,7 @@
.plugins-page .btn-update {
padding: 0.75rem 1.5rem;
background: #f59e0b;
- color: white;
+ color: #0f172a;
border: none;
border-radius: 8px;
font-size: 0.9375rem;
@@ -929,7 +931,7 @@
.plugins-page .install-tab.active,
.plugins-page .config-modal .modal-tab.active {
background: var(--primary);
- color: #fff;
+ color: #0f172a;
}
/* Keep the inactive tabs legible against the pill's light track and give them a hover affordance so
diff --git a/dashboard/src/pages/Sessions.css b/dashboard/src/pages/Sessions.css
index 76c511da6..eaa2cb55e 100644
--- a/dashboard/src/pages/Sessions.css
+++ b/dashboard/src/pages/Sessions.css
@@ -703,7 +703,7 @@
font-size: 0.8125rem;
font-weight: 600;
background: var(--primary);
- color: white;
+ color: #0f172a;
border: none;
border-radius: 6px;
cursor: pointer;
diff --git a/dashboard/src/pages/Webhooks.css b/dashboard/src/pages/Webhooks.css
index 3af4ddc84..1c11638f6 100644
--- a/dashboard/src/pages/Webhooks.css
+++ b/dashboard/src/pages/Webhooks.css
@@ -263,7 +263,7 @@
.webhooks-page .modal-body .event-tag.selected {
background: var(--primary);
- color: white;
+ color: #0f172a;
border-color: var(--primary);
}
@@ -289,7 +289,7 @@
[data-theme='dark'] .webhooks-page .modal-body .event-tag.selected,
:root:not([data-theme='light']) .webhooks-page .modal-body .event-tag.selected {
background: var(--primary);
- color: white;
+ color: #0f172a;
border-color: var(--primary);
}