Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): raise the contrast of avatar kind glyphs
Yudhi Armyndharis674379417843
diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.cssindex f19f43f47..fdcdfff02 100644--- a/dashboard/src/pages/Chats.css+++ b/dashboard/src/pages/Chats.css@@ -755,14 +755,16 @@display: block;}+/* The glyph shows the chat's kind, so each tone's colour holds the 3:1 of a graphic on its pastel and, in dark mode, on+ the 18 percent of itself mixed into the panel; theme-contrast.test.ts checks every tone in both. */.chats-page .avatar-tone-blue {background: #e3ebff;- color: #4a6bd6;+ color: #5070d7;}.chats-page .avatar-tone-orange {background: #fde8dc;- color: #d9773b;+ color: #cf6728;}.chats-page .avatar-tone-pink {@@ -777,12 +779,12 @@.chats-page .avatar-tone-violet {background: #ede4fb;- color: #8257d1;+ color: #875ed3;}.chats-page .avatar-tone-teal {background: #daf3ee;- color: #1f9a85;+ color: #1e9581;}[data-theme='dark'] .chats-page .chat-avatar[class*='avatar-tone-'] {diff --git a/dashboard/src/theme-contrast.test.ts b/dashboard/src/theme-contrast.test.tsindex daadf00ca..59581dd64 100644--- a/dashboard/src/theme-contrast.test.ts+++ b/dashboard/src/theme-contrast.test.ts@@ -268,6 +268,37 @@ test('the session status mark clears 3:1 against its ring in every theme and telassert.match(forced, /\.session-status-dot\.pending\s*\{[^}]*background:\s*Canvas;[^}]*inset 0 0 0 2px CanvasText/);});+// A picture-less avatar shows the chat's kind as a glyph in its tone (components/chats/ChatAvatar.tsx): in light mode+// on the tone's pastel, in dark mode on the tone mixed into the dark panel. Orange measured 2.67:1 on its pastel and+// violet 2.96:1 on its dark mix.+test('every avatar tone draws its glyph at 3:1 or more on its fill, in light and dark', () => {+ const avatar = readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'components/chats/ChatAvatar.tsx'), 'utf8');+ const tones = /AVATAR_TONES = \[([^\]]+)\]/.exec(avatar)?.[1].match(/[a-z]+/g) ?? [];+ assert.ok(tones.length >= 6, 'ChatAvatar.tsx no longer lists its tones');+ const darkMix = (anchor: string): [number, string] => {+ const rule = new RegExp(+ `${anchor.replace(/[.[\]()'*]/g, '\\$&')}[^{]*\\{[^}]*background:\\s*color-mix\\(in srgb, currentColor (\\d+)%, (#[0-9a-f]{6})\\)`,+ ).exec(CHATS_CSS);+ assert.ok(rule, `no dark tone fill under ${anchor}`);+ return [Number(rule[1]) / 100, rule[2]];+ };+ const darks = [+ darkMix("[data-theme='dark'] .chats-page .chat-avatar[class*='avatar-tone-']"),+ darkMix(":root:not([data-theme='light']) .chats-page .chat-avatar[class*='avatar-tone-']"),+ ];+ for (const tone of tones) {+ const rule = chatRule(`.chats-page .avatar-tone-${tone}`);+ const glyph = rgb(/color:\s*(#[0-9a-f]{6})/i.exec(rule)?.[1] ?? '');+ const pastel = rgb(/background:\s*(#[0-9a-f]{6})/i.exec(rule)?.[1] ?? '');+ const light = contrast(glyph, pastel);+ assert.ok(light >= 3, `${tone} glyph is ${light.toFixed(2)}:1 on its pastel`);+ for (const [alpha, panel] of darks) {+ const dark = contrast(glyph, mix(glyph, alpha, rgb(panel)));+ assert.ok(dark >= 3, `${tone} glyph is ${dark.toFixed(2)}:1 on its dark fill`);+ }+ }+});+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'],