From cd48bd423f3c26cd7595b79f299d8dcb93edca58 Mon Sep 17 00:00:00 2001 From: Luan Nguyen Date: Thu, 3 Dec 2026 23:24:22 +1100 Subject: [PATCH 1/2] fix(a11y): improve new note hint contrast --- web/src/styles/new-note.css | 2 -- 1 file changed, 2 deletions(-) diff --git a/web/src/styles/new-note.css b/web/src/styles/new-note.css index fd6c448..1d25433 100644 --- a/web/src/styles/new-note.css +++ b/web/src/styles/new-note.css @@ -110,7 +110,6 @@ } .new-note-hint { font-size: 14px; - color: var(--t4); margin: 6px 0 12px; } .new-note-tiles { @@ -312,7 +311,6 @@ } .new-note-hint { font-size: 14px; - color: var(--t4); margin: 6px 0 0; } .new-note-foot { From 598fc337ac9ae823efde15efd6ca4f357dae2c06 Mon Sep 17 00:00:00 2001 From: Luan Nguyen Date: Thu, 3 Dec 2026 23:47:43 +1100 Subject: [PATCH 2/2] fix(a11y): improve meeting starter prompt contrast --- web/src/styles/new-note.css | 2 +- .../integration/new-note-contrast-browser.mjs | 150 ++++++++++++++++++ 2 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 web/tests/integration/new-note-contrast-browser.mjs diff --git a/web/src/styles/new-note.css b/web/src/styles/new-note.css index 1d25433..32a5ef2 100644 --- a/web/src/styles/new-note.css +++ b/web/src/styles/new-note.css @@ -408,7 +408,7 @@ .new-note[data-starter="Meeting"] .tiptap p:has(> br:only-child)::before { position: absolute; pointer-events: none; - color: var(--t4); + color: var(--t3); } .quick-note-content textarea::placeholder { diff --git a/web/tests/integration/new-note-contrast-browser.mjs b/web/tests/integration/new-note-contrast-browser.mjs new file mode 100644 index 0000000..d81652a --- /dev/null +++ b/web/tests/integration/new-note-contrast-browser.mjs @@ -0,0 +1,150 @@ +import { chromium, expect } from "@playwright/test"; + +const browser = await chromium.launch({ + channel: process.env.NOTES_BROWSER_CHANNEL ?? "msedge", + headless: true, +}); +const base = process.env.NOTES_PREVIEW_URL ?? "http://127.0.0.1:5187"; + +try { + const page = await browser.newPage({ + viewport: { width: 1440, height: 1000 }, + serviceWorkers: "block", + }); + await page.addInitScript(() => + localStorage.setItem("orbyn-notes.local-only", "1"), + ); + await page.goto(base); + await page + .getByRole("button", { name: "New note", exact: true }) + .first() + .waitFor(); + const close = page.getByRole("button", { name: "Close setup" }); + if (await close.isVisible()) await close.click(); + await page + .getByRole("button", { name: "New note", exact: true }) + .first() + .click(); + const hint = page.locator(".new-note-hint"); + await expect(hint).toBeVisible(); + await page.evaluate(() => document.fonts.ready); + expect( + await page.evaluate(() => document.fonts.check('400 14px "Geist"')), + ).toBe(true); + for (const width of [1440, 390]) { + await page.setViewportSize({ width, height: 1000 }); + for (const theme of ["light", "dark", "dim"]) { + await page.evaluate((value) => { + document.documentElement.dataset.theme = value; + }, theme); + const measured = await hint.evaluate((element) => { + const parse = (value) => { + const numbers = value.match(/[\d.]+/g).map(Number); + return [numbers[0], numbers[1], numbers[2], numbers[3] ?? 1]; + }; + const composite = (front, back) => + front + .slice(0, 3) + .map((c, i) => c * front[3] + back[i] * (1 - front[3])); + let background = [255, 255, 255]; + const layers = []; + for (let node = element; node; node = node.parentElement) + layers.push(parse(getComputedStyle(node).backgroundColor)); + for (const layer of layers.reverse()) + background = composite(layer, background); + const style = getComputedStyle(element); + const foreground = parse(style.color); + const mixed = composite(foreground, background); + const luminance = (rgb) => + rgb + .map((c) => c / 255) + .map((c) => + c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4, + ) + .reduce((sum, c, i) => sum + c * [0.2126, 0.7152, 0.0722][i], 0); + const a = luminance(mixed), + b = luminance(background); + const rect = element.getBoundingClientRect(); + return { + color: style.color, + font: style.font, + background, + composited: mixed, + contrast: (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05), + rect: { + x: rect.x, + y: rect.y, + width: rect.width, + height: rect.height, + }, + viewport: innerWidth, + scrollWidth: document.documentElement.scrollWidth, + }; + }); + console.log(JSON.stringify({ theme, width, ...measured })); + expect(measured.contrast).toBeGreaterThanOrEqual(4.5); + expect(measured.rect.x).toBeGreaterThanOrEqual(0); + expect(measured.rect.x + measured.rect.width).toBeLessThanOrEqual( + width + 1, + ); + expect(measured.scrollWidth).toBeLessThanOrEqual(width + 1); + if (process.env.NOTES_EVIDENCE_DIR) { + await page.screenshot({ + path: `${process.env.NOTES_EVIDENCE_DIR}/hint-${theme}-${width}.png`, + }); + } + } + } + await page.setViewportSize({ width: 1440, height: 1000 }); + await page.getByRole("button", { name: /Meeting/ }).click(); + const prompts = page.locator('.new-note[data-starter="Meeting"] .tiptap p'); + await expect(prompts).toHaveCount(3); + for (const theme of ["light", "dark", "dim"]) { + await page.evaluate((value) => { + document.documentElement.dataset.theme = value; + }, theme); + const values = await prompts.evaluateAll((elements) => + elements.map((element) => { + const css = getComputedStyle(element, "::before"); + const parse = (value) => value.match(/[\d.]+/g).map(Number); + const foreground = parse(css.color); + const background = parse( + getComputedStyle(element.closest(".new-note")).backgroundColor, + ); + const mixed = background + .slice(0, 3) + .map( + (c, i) => foreground[i] * foreground[3] + c * (1 - foreground[3]), + ); + const luminance = (rgb) => + rgb + .map((c) => c / 255) + .map((c) => + c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4, + ) + .reduce((sum, c, i) => sum + c * [0.2126, 0.7152, 0.0722][i], 0); + const a = luminance(mixed), + b = luminance(background.slice(0, 3)); + return { + text: css.content, + font: css.fontSize, + color: css.color, + background: background.slice(0, 3), + composited: mixed, + contrast: (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05), + }; + }), + ); + console.log(JSON.stringify({ theme, meeting: values })); + expect(values.map((value) => value.text)).toEqual([ + '"Names"', + '"What was said"', + '"An action. Planner task links are Planned"', + ]); + for (const value of values) { + expect(value.contrast).toBeGreaterThanOrEqual(4.5); + } + } +} finally { + await browser.close(); +}