Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): tell session states apart by shape and contrast

Yudhi Armyndharise56fbc02d4bb
diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.css
index fbd5327b1..91d9d02f4 100644
--- a/dashboard/src/pages/Chats.css
+++ b/dashboard/src/pages/Chats.css
@@ -236,6 +236,9 @@
border-style: solid;
}
+/* Ready, on its way and down differ in shape as well as in colour: a dot, a ring and a square. The colours are the
+ status text twins, which hold 3:1 against the panel-coloured ring around the mark in every theme (the base green
+ and amber were 2.28:1 and 2.15:1 on white). */
.chats-page .session-status-dot {
position: absolute;
top: -1px;
@@ -243,16 +246,34 @@
width: 12px;
height: 12px;
border-radius: 50%;
- background: var(--success);
+ background: var(--success-text);
border: 2px solid var(--chat-panel);
}
.chats-page .session-status-dot.pending {
- background: var(--warning);
+ background: var(--chat-panel);
+ box-shadow: inset 0 0 0 2px var(--warning-text);
}
.chats-page .session-status-dot.down {
- background: var(--error);
+ border-radius: 2px;
+ background: var(--error-text);
+}
+
+/* Forced colours paint each mark in the page colour and drop the inset ring, which would leave bare outlines; the marks
+ are drawn in the system colours instead. */
+@media (forced-colors: active) {
+ .chats-page .session-status-dot,
+ .chats-page .session-status-dot.down {
+ forced-color-adjust: none;
+ background: CanvasText;
+ border-color: Canvas;
+ }
+
+ .chats-page .session-status-dot.pending {
+ background: Canvas;
+ box-shadow: inset 0 0 0 2px CanvasText;
+ }
}
.chats-page .session-text {
diff --git a/dashboard/src/theme-contrast.test.ts b/dashboard/src/theme-contrast.test.ts
index a4143df5e..5af8f3343 100644
--- a/dashboard/src/theme-contrast.test.ts
+++ b/dashboard/src/theme-contrast.test.ts
@@ -226,6 +226,39 @@ test('time stamps and read ticks on the outgoing bubble clear their ratios in ev
}
});
+// The session status mark is the one sign in the switcher that the open session dropped. Against the panel-coloured
+// ring around it each state holds the 3:1 of a graphic (the base green and amber were 2.28:1 and 2.15:1 on white), and
+// the states differ in shape too, not by colour alone: a dot, a ring and a square. Forced colours keep the shapes.
+test('the session status mark clears 3:1 against its ring in every theme and tells its states apart by shape', () => {
+ const ready = chatRule('.chats-page .session-status-dot');
+ const pending = chatRule('.chats-page .session-status-dot.pending');
+ const down = chatRule('.chats-page .session-status-dot.down');
+ assert.match(ready, /border:\s*2px solid var\(--chat-panel\)/);
+ assert.match(ready, /border-radius:\s*50%/);
+ assert.match(pending, /background:\s*var\(--chat-panel\)/, 'the pending mark is not hollow');
+ assert.match(down, /border-radius:\s*[0-4]px/, 'the down mark is not square');
+ const marks = [
+ /background:\s*var\((--[\w-]+)\)/.exec(ready)?.[1],
+ /box-shadow:\s*inset 0 0 0 2px var\((--[\w-]+)\)/.exec(pending)?.[1],
+ /background:\s*var\((--[\w-]+)\)/.exec(down)?.[1],
+ ];
+ for (const [chatAnchor, appAnchor] of [
+ [CHAT_ANCHORS[0], LIGHT],
+ [CHAT_ANCHORS[1], DARK],
+ [CHAT_ANCHORS[2], DARK_MEDIA],
+ ]) {
+ const ring = rgb(chatToken(chatBlock(chatAnchor), '--chat-panel'));
+ for (const mark of marks) {
+ assert.ok(mark, 'a status mark is no longer drawn in a token');
+ const ratio = contrast(rgb(hexOf(blockAfter(appAnchor), mark)), ring);
+ assert.ok(ratio >= 3, `${chatAnchor} ${mark} is ${ratio.toFixed(2)}:1 against the ring`);
+ }
+ }
+ const forced = /@media \(forced-colors: active\)\s*\{([\s\S]*?)\n\}/.exec(CHATS_CSS)?.[1] ?? '';
+ assert.match(forced, /\.session-status-dot[^{]*\{[^}]*forced-color-adjust:\s*none[^}]*background:\s*CanvasText/);
+ assert.match(forced, /\.session-status-dot\.pending\s*\{[^}]*background:\s*Canvas;[^}]*inset 0 0 0 2px CanvasText/);
+});
+
test('the action required pill clears 4.5:1 on its tint in the dark theme, with one tint on both pages', () => {
const tints = [
['Sessions.css', '.sessions-page .status-pill.action_required'],