Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): use the error text token for error text

Yudhi Armyndhariscaa9c92a2a6d
diff --git a/dashboard/src/components/ErrorBoundary.tsx b/dashboard/src/components/ErrorBoundary.tsx
index 8e021ad61..4f97630ae 100644
--- a/dashboard/src/components/ErrorBoundary.tsx
+++ b/dashboard/src/components/ErrorBoundary.tsx
@@ -44,7 +44,7 @@ export class ErrorBoundary extends Component<Props, State> {
color: 'var(--text-primary)',
}}
>
- <AlertCircle size={48} style={{ color: 'var(--error)', marginBottom: '1rem' }} />
+ <AlertCircle size={48} style={{ color: 'var(--error-text)', marginBottom: '1rem' }} />
<h1 style={{ fontSize: '1.5rem', marginBottom: '0.5rem' }}>{i18n.t('errorBoundary.title')}</h1>
<p style={{ color: 'var(--text-muted)', marginBottom: '1.5rem', textAlign: 'center' }}>
{i18n.t('errorBoundary.description')}
diff --git a/dashboard/src/error-text.test.ts b/dashboard/src/error-text.test.ts
new file mode 100644
index 000000000..84c5d3ee9
--- /dev/null
+++ b/dashboard/src/error-text.test.ts
@@ -0,0 +1,32 @@
+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';
+
+// --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) until it clears the darkest tint it lands on. Foreground colours use --error-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] : [];
+ });
+}
+
+test('no stylesheet or inline style colours text or an icon with the raw --error token', () => {
+ const offenders = filesUnder(SRC, ['.css', '.tsx']).flatMap(full => {
+ const source = readFileSync(full, 'utf8').replace(/\/\*[\s\S]*?\*\//g, comment => comment.replace(/[^\n]/g, ''));
+ // The property must be `color` itself: border-color, background and stroke keep the fill red on purpose.
+ return source
+ .split('\n')
+ .map((line, i) => ({ line, at: `${full.slice(SRC.length + 1)}:${i + 1}` }))
+ .filter(({ line }) => /(?<![\w-])color:\s*['"]?var\(--error\)/.test(line))
+ .map(({ line, at }) => `${at}: ${line.trim()}`);
+ });
+ assert.deepEqual(offenders, []);
+});
diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.css
index 173ac10e3..c802e9819 100644
--- a/dashboard/src/pages/Chats.css
+++ b/dashboard/src/pages/Chats.css
@@ -2449,7 +2449,7 @@
}
.chats-page .group-info-field .required {
- color: var(--error);
+ color: var(--error-text);
}
.chats-page .group-info-field input,
diff --git a/dashboard/src/pages/Dashboard.tsx b/dashboard/src/pages/Dashboard.tsx
index 88f6d2873..813b62290 100644
--- a/dashboard/src/pages/Dashboard.tsx
+++ b/dashboard/src/pages/Dashboard.tsx
@@ -96,7 +96,12 @@ export function Dashboard() {
return (
<div className="dashboard" style={{ padding: '2rem' }}>
<div
- style={{ background: 'rgba(239, 68, 68, 0.12)', padding: '1rem', borderRadius: '8px', color: 'var(--error)' }}
+ style={{
+ background: 'rgba(239, 68, 68, 0.12)',
+ padding: '1rem',
+ borderRadius: '8px',
+ color: 'var(--error-text)',
+ }}
>
{t('dashboard.errorPrefix', { message: error })}
</div>
diff --git a/dashboard/src/pages/MessageTester.css b/dashboard/src/pages/MessageTester.css
index 7c19b4e07..c6aa0b7ee 100644
--- a/dashboard/src/pages/MessageTester.css
+++ b/dashboard/src/pages/MessageTester.css
@@ -479,7 +479,7 @@
margin: 0;
padding: 0;
list-style: none;
- color: var(--error);
+ color: var(--error-text);
text-align: end;
}
diff --git a/dashboard/src/pages/MessageTester.tsx b/dashboard/src/pages/MessageTester.tsx
index 3444b7a7a..56a83b346 100644
--- a/dashboard/src/pages/MessageTester.tsx
+++ b/dashboard/src/pages/MessageTester.tsx
@@ -1260,7 +1260,7 @@ export function MessageTester() {
{response.error && (
<div className="detail-row">
<span className="detail-label">{t('messageTester.response.error')}</span>
- <span className="detail-value" style={{ color: 'var(--error)' }}>
+ <span className="detail-value" style={{ color: 'var(--error-text)' }}>
{response.error}
</span>
</div>
diff --git a/dashboard/src/pages/Sessions.tsx b/dashboard/src/pages/Sessions.tsx
index 02ae8e33f..7bc69695d 100644
--- a/dashboard/src/pages/Sessions.tsx
+++ b/dashboard/src/pages/Sessions.tsx
@@ -728,7 +728,7 @@ export function Sessions() {
background: 'rgba(239, 68, 68, 0.12)',
padding: '1rem',
borderRadius: '8px',
- color: 'var(--error)',
+ color: 'var(--error-text)',
marginBottom: '1rem',
}}
>