diff --git a/docs/development/web-ui-verification.md b/docs/development/web-ui-verification.md index 1925e5e9b..9e91f458b 100644 --- a/docs/development/web-ui-verification.md +++ b/docs/development/web-ui-verification.md @@ -18,6 +18,8 @@ The core-screen sweep is committed and scripted — run it before you hand-roll The launcher builds `./mcpproxy` if needed, serves a throwaway instance on `127.0.0.1:18080` under a freshly generated throwaway API key (your own `MCPPROXY_API_KEY` is deliberately ignored — the key ends up in report URLs and traces), installs Chromium from the committed `e2e/web-ui-sweep/package-lock.json` via `npm ci`, and runs [`e2e/web-ui-sweep/web-ui-sweep.spec.ts`](https://github.com/smart-mcp-proxy/mcpproxy-go/blob/main/e2e/web-ui-sweep/web-ui-sweep.spec.ts) — servers list, server detail (+ security tab), tools page and search, activity log, settings — failing on uncaught page exceptions. Pass `MCPPROXY_FIXTURE_PATH=$(go build -o /tmp/mcpfixture ./cmd/mcpfixture && echo /tmp/mcpfixture)` to register a live stdio upstream so the server- and tool-dependent checks run instead of skipping. The HTML report lands in `tmp/web-smoke-artifacts/playwright-report/`. +Alongside it, [`e2e/web-ui-sweep/visual-a11y-sweep.spec.ts`](https://github.com/smart-mcp-proxy/mcpproxy-go/blob/main/e2e/web-ui-sweep/visual-a11y-sweep.spec.ts) guards the *appearance* contract that the 2026-08 UX audit found broken: it walks every visible text node on the main screens in both shipped themes, resolves the effective foreground/background through a canvas (theme tokens are `oklch()`, so a naive `rgb()` parse silently measures nothing) and fails anything below WCAG AA; it also checks the 390/820/1440px layouts, accessible names on every form control, the activity log's `aria-live` region and caption, the system-theme resolution, and that the header search button is not disabled at rest. Same launcher, same environment variables. + The release QA gate runs this exact script on every tag as its **advisory** `web-ui-sweep` job — see [Release Gate](release-gate.md#web-ui-sweep-t2--advisory). Extend the committed sweep when you add a screen worth guarding on releases; use the ad-hoc pattern below for the deeper, spec-specific verification that ships beside a spec. ## Ad-hoc, spec-specific verification diff --git a/e2e/web-ui-sweep/visual-a11y-sweep.spec.ts b/e2e/web-ui-sweep/visual-a11y-sweep.spec.ts new file mode 100644 index 000000000..935b9e283 --- /dev/null +++ b/e2e/web-ui-sweep/visual-a11y-sweep.spec.ts @@ -0,0 +1,524 @@ +// Visual / accessibility sweep — the regression net for the 2026-08 UX audit +// findings F9 (WCAG AA contrast), F14 (390px layout), F30 (accessible names, +// aria-live, table caption), F29 (system theme) and F32 (header search). +// +// It runs against the Web UI served by a REAL mcpproxy binary, exactly like +// web-ui-sweep.spec.ts, and it MEASURES rather than eyeballs: every visible +// text node is resolved to its effective foreground/background (walking up +// through transparent ancestors and applying opacity) and scored with the WCAG +// 2.1 contrast formula, the same method the audit used. +// +// Launcher: scripts/run-web-smoke.sh (see docs/development/web-ui-verification.md). +import { test, expect, Page } from '@playwright/test' + +const BASE = process.env.MCPPROXY_BASE_URL || 'http://127.0.0.1:18080' +const KEY = process.env.MCPPROXY_API_KEY || '' + +/** Themes the app ships as its light/dark defaults; `system` resolves to one. */ +const THEMES = ['corporate', 'dark'] as const + +const VIEWPORTS = [ + { name: 'desktop', width: 1440, height: 900 }, + { name: 'tablet', width: 820, height: 1180 }, + { name: 'mobile', width: 390, height: 844 }, +] as const + +const ROUTES = ['/', '/servers', '/activity', '/tools', '/sessions'] as const + +function url(route: string): string { + const sep = route.includes('?') ? '&' : '?' + return KEY ? `${BASE}/ui${route}${sep}apikey=${encodeURIComponent(KEY)}` : `${BASE}/ui${route}` +} + +/** + * Navigate, optionally pinning a theme first. + * + * The theme is written to localStorage and the page reloaded rather than + * registered with `addInitScript`: init scripts ACCUMULATE across calls on the + * same page, so a second theme would leave two setters racing on the next + * navigation. + */ +async function goto(page: Page, route: string, theme?: string) { + if (theme) { + // localStorage needs an origin, so land on the page once before writing. + if (new URL(page.url() || 'about:blank').origin !== new URL(BASE).origin) { + await page.goto(url(route)) + await page.waitForLoadState('domcontentloaded') + } + await page.evaluate((t) => window.localStorage.setItem('mcpproxy-theme', t), theme) + } + await page.goto(url(route)) + await page.waitForLoadState('domcontentloaded') + if (theme) { + await expect + .poll(() => page.evaluate(() => document.documentElement.getAttribute('data-theme'))) + .toBe(theme) + } + const closeWizard = page.locator('[data-test="close-wizard"]') + if (await closeWizard.isVisible().catch(() => false)) { + await closeWizard.click() + } + await page.locator('main').first().waitFor({ state: 'visible' }) + // Give SSE-driven content one tick to paint. + await page.waitForTimeout(750) +} + +interface ContrastFailure { + text: string + ratio: number + fg: string + bg: string + selector: string +} + +/** + * Walk every visible text node, resolve its effective colours and return the + * ones below the WCAG AA threshold for their size. + * + * Known limits, deliberately: the backdrop is taken from `background-color` + * only (a gradient or background image behind text is not sampled), and text + * over media is not evaluated. Both would need pixel sampling; the failures + * this catches are the palette ones the audit was about. It errs toward + * silence, never toward a false failure. + */ +async function contrastFailures(page: Page): Promise { + return page.evaluate(() => { + // Computed styles come back in the syntax they were authored in — the + // daisyUI themes are `oklch()`, and Chromium keeps them that way — so the + // only reliable reader is the browser's own colour pipeline. Painting the + // value onto a 1x1 canvas gives the sRGB bytes a user actually sees, which + // is exactly how the audit sampled its numbers. + const canvas = document.createElement('canvas') + canvas.width = canvas.height = 1 + const ctx = canvas.getContext('2d', { willReadFrequently: true })! + const cache = new Map() + const parse = (value: string): [number, number, number, number] => { + const hit = cache.get(value) + if (hit) return hit + ctx.clearRect(0, 0, 1, 1) + ctx.fillStyle = '#000000' + ctx.fillStyle = value + // An unparseable value leaves fillStyle at the previous colour; treat a + // literal `transparent` as fully transparent rather than opaque black. + if (/^(transparent|rgba?\(0,\s*0,\s*0,\s*0\))$/i.test(value.trim())) { + const clear: [number, number, number, number] = [0, 0, 0, 0] + cache.set(value, clear) + return clear + } + ctx.fillRect(0, 0, 1, 1) + const d = ctx.getImageData(0, 0, 1, 1).data + const out: [number, number, number, number] = [d[0], d[1], d[2], d[3] / 255] + cache.set(value, out) + return out + } + const lum = ([r, g, b]: number[]) => { + const f = (c: number) => { + const v = c / 255 + return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4) + } + return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b) + } + const ratio = (a: number[], b: number[]) => { + const [hi, lo] = lum(a) >= lum(b) ? [lum(a), lum(b)] : [lum(b), lum(a)] + return (hi + 0.05) / (lo + 0.05) + } + const over = (fg: number[], alpha: number, bg: number[]) => + [0, 1, 2].map((i) => fg[i] * alpha + bg[i] * (1 - alpha)) + + /** Composite every non-opaque background from the element up to . */ + const effectiveBackground = (el: Element): number[] => { + const stack: Array<[number[], number]> = [] + let node: Element | null = el + while (node) { + const cs = getComputedStyle(node) + const [r, g, b, a] = parse(cs.backgroundColor) + const alpha = a * Number(cs.opacity || '1') + if (alpha > 0) stack.push([[r, g, b], alpha]) + if (alpha >= 1) break + node = node.parentElement + } + let base = [255, 255, 255] + for (let i = stack.length - 1; i >= 0; i--) { + base = over(stack[i][0], stack[i][1], base) + } + return base + } + + const cumulativeOpacity = (el: Element): number => { + let o = 1 + let node: Element | null = el + while (node) { + o *= Number(getComputedStyle(node).opacity || '1') + node = node.parentElement + } + return o + } + + const describe = (el: Element): string => { + const cls = (el.className || '').toString().split(/\s+/).filter(Boolean).slice(0, 4) + return `${el.tagName.toLowerCase()}${cls.length ? '.' + cls.join('.') : ''}` + } + + const failures: Array<{ + text: string + ratio: number + fg: string + bg: string + selector: string + }> = [] + const seen = new Set() + + const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT) + let node: Node | null + while ((node = walker.nextNode())) { + const text = (node.textContent || '').trim() + if (!text) continue + const el = node.parentElement + if (!el || seen.has(el)) continue + seen.add(el) + // WCAG 1.4.3 exempts disabled controls and purely decorative text. + if ( + el.closest( + 'script, style, svg, [aria-hidden="true"], .sr-only, [disabled], .btn-disabled, .tab-disabled', + ) + ) { + continue + } + + const rect = el.getBoundingClientRect() + if (rect.width < 2 || rect.height < 2) continue + const cs = getComputedStyle(el) + if (cs.visibility === 'hidden' || cs.display === 'none') continue + + const [r, g, b, a] = parse(cs.color) + const alpha = a * cumulativeOpacity(el) + if (alpha <= 0.05) continue + const bg = effectiveBackground(el) + const fg = over([r, g, b], alpha, bg) + + const size = parseFloat(cs.fontSize) + const weight = Number(cs.fontWeight) || 400 + const large = size >= 24 || (size >= 18.66 && weight >= 700) + const threshold = large ? 3 : 4.5 + + const value = ratio(fg, bg) + if (value + 0.005 < threshold) { + failures.push({ + text: text.slice(0, 70), + ratio: Math.round(value * 100) / 100, + fg: `rgb(${fg.map((c) => Math.round(c)).join(' ')})`, + bg: `rgb(${bg.map((c) => Math.round(c)).join(' ')})`, + selector: describe(el), + }) + } + } + return failures + }) +} + +// --------------------------------------------------------------------------- +// F9 — WCAG AA contrast on every main screen, in both shipped themes. +// --------------------------------------------------------------------------- +for (const theme of THEMES) { + for (const route of ROUTES) { + test(`contrast AA: ${route} (${theme})`, async ({ page }) => { + await goto(page, route, theme) + const failures = await contrastFailures(page) + expect( + failures, + `WCAG AA contrast failures on ${route} (${theme}):\n` + + failures + .map((f) => ` ${f.ratio}:1 ${f.selector} ${f.fg} on ${f.bg} "${f.text}"`) + .join('\n'), + ).toEqual([]) + }) + } +} + +test('contrast AA: filled primary buttons in both themes', async ({ page }) => { + // Measured on the BUTTON elements directly. Filtering the generic walker's + // output by class would silently match nothing, because a button's label + // usually lives in a nested and that span is what the walker reports. + for (const theme of THEMES) { + await goto(page, '/servers', theme) + const measured = await page.evaluate(() => { + const canvas = document.createElement('canvas') + canvas.width = canvas.height = 1 + const ctx = canvas.getContext('2d', { willReadFrequently: true })! + const resolve = (value: string) => { + ctx.clearRect(0, 0, 1, 1) + ctx.fillStyle = '#000000' + ctx.fillStyle = value + ctx.fillRect(0, 0, 1, 1) + const d = ctx.getImageData(0, 0, 1, 1).data + return [d[0], d[1], d[2]] + } + const lum = (c: number[]) => + c + .map((v) => v / 255) + .map((v) => (v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4))) + .reduce((acc, v, i) => acc + v * [0.2126, 0.7152, 0.0722][i], 0) + + const out: Array<{ label: string; ratio: number }> = [] + document.querySelectorAll('.btn-primary').forEach((el) => { + const button = el as HTMLElement + if (button.hasAttribute('disabled') || button.classList.contains('btn-disabled')) return + const rect = button.getBoundingClientRect() + if (rect.width < 2 || rect.height < 2) return + const cs = getComputedStyle(button) + const fg = resolve(cs.color) + const bg = resolve(cs.backgroundColor) + const a = lum(fg) + const b = lum(bg) + const ratio = (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05) + out.push({ label: (button.textContent || '').trim().slice(0, 40), ratio }) + }) + return out + }) + + expect(measured.length, `no .btn-primary rendered in ${theme}`).toBeGreaterThan(0) + const failures = measured.filter((m) => m.ratio + 0.005 < 4.5) + expect( + failures, + `primary button contrast in ${theme}: ` + + failures.map((f) => `${f.ratio.toFixed(2)}:1 "${f.label}"`).join(', '), + ).toEqual([]) + } +}) + +test('contrast AA: buttons and links on a coloured alert, hovered', async ({ page }) => { + // daisyUI paints a base surface into `--btn-bg` on hover, which on a coloured + // alert dropped a ghost button to 3.47:1. Hover is only reachable with a real + // pointer, so it is measured here rather than in the unit test. + // + // Real elements only: injecting markup that uses a class the app never ships + // measures nothing meaningful, because Tailwind only compiles the classes it + // finds in the source — an injected `.btn-link` inherits plain `.btn` styling + // and reports a failure that cannot occur in the product. + const measured: Record = {} + for (const theme of THEMES) { + measured[theme] = 0 + for (const route of ['/', '/servers'] as const) { + await goto(page, route, theme) + const targets = page.locator( + ':is(.alert-info, .alert-success, .alert-warning, .alert-error) :is(.btn-ghost, a.link, .btn-link)', + ) + const count = await targets.count() + for (let i = 0; i < count; i++) { + const target = targets.nth(i) + if (!(await target.isVisible().catch(() => false))) continue + await target.hover() + const result = await target.evaluate((el) => { + const canvas = document.createElement('canvas') + canvas.width = canvas.height = 1 + const ctx = canvas.getContext('2d', { willReadFrequently: true })! + const resolve = (v: string) => { + ctx.clearRect(0, 0, 1, 1) + ctx.fillStyle = '#000000' + ctx.fillStyle = v + ctx.fillRect(0, 0, 1, 1) + const d = ctx.getImageData(0, 0, 1, 1).data + return [d[0], d[1], d[2], d[3] / 255] + } + const lum = (c: number[]) => + c + .slice(0, 3) + .map((v) => v / 255) + .map((v) => (v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4))) + .reduce((acc, v, i) => acc + v * [0.2126, 0.7152, 0.0722][i], 0) + const cs = getComputedStyle(el as HTMLElement) + const alertBg = resolve(getComputedStyle((el as HTMLElement).closest('.alert')!).backgroundColor) + const own = resolve(cs.backgroundColor) + const bg = [0, 1, 2].map((i) => own[i] * own[3] + alertBg[i] * (1 - own[3])) + const fg = resolve(cs.color) + const [hi, lo] = lum(fg) >= lum(bg) ? [lum(fg), lum(bg)] : [lum(bg), lum(fg)] + return { + ratio: Math.round(((hi + 0.05) / (lo + 0.05)) * 100) / 100, + label: (el.textContent || '').trim().slice(0, 30), + isGhost: (el as HTMLElement).classList.contains('btn-ghost'), + } + }) + if (result.isGhost) measured[theme]++ + expect( + result.ratio, + `${theme} ${route}: "${result.label}" inside a coloured alert measures ${result.ratio}:1 while hovered`, + ).toBeGreaterThanOrEqual(4.5 - 0.005) + } + } + } + // Per theme, and specifically a ghost button — the variant daisyUI repaints + // on hover. An ordinary link passing in one theme is not coverage. + for (const theme of THEMES) { + expect( + measured[theme], + `no hovered .btn-ghost inside a coloured alert was measured in ${theme}`, + ).toBeGreaterThan(0) + } +}) + +// --------------------------------------------------------------------------- +// F29 — "match system" theme. +// --------------------------------------------------------------------------- +test('system theme follows the OS colour scheme', async ({ browser }) => { + const dark = await browser.newPage({ colorScheme: 'dark' }) + await dark.goto(url('/')) + await dark.waitForLoadState('domcontentloaded') + await expect + .poll(() => dark.evaluate(() => document.documentElement.getAttribute('data-theme'))) + .toBe('dark') + await dark.close() + + const light = await browser.newPage({ colorScheme: 'light' }) + await light.goto(url('/')) + await light.waitForLoadState('domcontentloaded') + await expect + .poll(() => light.evaluate(() => document.documentElement.getAttribute('data-theme'))) + .toBe('corporate') + await light.close() +}) + +test('an explicit theme choice survives the OS preference', async ({ browser }) => { + const page = await browser.newPage({ colorScheme: 'dark' }) + await page.addInitScript(() => window.localStorage.setItem('mcpproxy-theme', 'corporate')) + await page.goto(url('/')) + await page.waitForLoadState('domcontentloaded') + await expect + .poll(() => page.evaluate(() => document.documentElement.getAttribute('data-theme'))) + .toBe('corporate') + await page.close() +}) + +// --------------------------------------------------------------------------- +// F14 — 390px layout: nothing clips, no horizontal page scroll, Status visible. +// --------------------------------------------------------------------------- +for (const vp of VIEWPORTS) { + test(`layout holds at ${vp.width}px (${vp.name})`, async ({ page }) => { + await page.setViewportSize({ width: vp.width, height: vp.height }) + for (const route of ROUTES) { + await goto(page, route) + const overflow = await page.evaluate( + () => document.documentElement.scrollWidth - document.documentElement.clientWidth, + ) + expect(overflow, `horizontal page overflow on ${route} at ${vp.width}px`).toBeLessThanOrEqual(1) + } + }) +} + +test('activity keeps the Status column on a phone', async ({ page }) => { + await page.setViewportSize({ width: 390, height: 844 }) + await goto(page, '/activity') + const rows = page.locator('[data-test="activity-row"]') + if ((await rows.count()) === 0) test.skip(true, 'no activity records on this instance') + const status = rows.first().locator('[data-test="activity-status"]') + await expect(status).toBeVisible() + const box = await status.boundingBox() + expect(box, 'status cell has no box').not.toBeNull() + expect(box!.x + box!.width, 'Status column is clipped off the right edge').toBeLessThanOrEqual(390) + // …and the label itself must not be cut off inside its own cell. + const clipped = await status.evaluate((el) => { + const cell = el.closest('td')! + return cell.scrollWidth - cell.clientWidth + }) + expect(clipped, 'Status label is clipped inside its cell').toBeLessThanOrEqual(1) +}) + +test('the footer never overlaps the page content', async ({ page }) => { + await page.setViewportSize({ width: 390, height: 844 }) + await goto(page, '/activity') + const overlap = await page.evaluate(() => { + const footer = document.querySelector('footer') + const main = document.querySelector('main') + if (!footer || !main) return 0 + return main.getBoundingClientRect().bottom - footer.getBoundingClientRect().top + }) + expect(overlap, 'main content bleeds under the footer').toBeLessThanOrEqual(1) +}) + +// --------------------------------------------------------------------------- +// F30 — accessible names, live region, table caption. +// --------------------------------------------------------------------------- +test('every form control on the main screens has an accessible name', async ({ page }) => { + for (const route of ROUTES) { + await goto(page, route) + const unnamed = await page.evaluate(() => { + const out: string[] = [] + const controls = document.querySelectorAll('input, select, textarea') + controls.forEach((el) => { + const c = el as HTMLInputElement + if (c.type === 'hidden') return + const rect = c.getBoundingClientRect() + if (rect.width < 2 || rect.height < 2) return + // An `aria-labelledby` only names a control if its target exists and + // actually has text, so it is resolved rather than trusted. + const labelledBy = (c.getAttribute('aria-labelledby') || '') + .split(/\s+/) + .filter(Boolean) + .map((id) => document.getElementById(id)) + .filter((n): n is HTMLElement => !!n && !!(n.textContent || '').trim()) + const labelled = + (c.getAttribute('aria-label') || '').trim() || + labelledBy.length > 0 || + (c.getAttribute('placeholder') || '').trim() || + (c.getAttribute('title') || '').trim() || + (c.id && document.querySelector(`label[for="${CSS.escape(c.id)}"]`)) || + c.closest('label') + if (!labelled) { + out.push(`${c.tagName.toLowerCase()}[type=${c.type}] .${c.className}`) + } + }) + return out + }) + expect(unnamed, `unnamed form controls on ${route}`).toEqual([]) + } +}) + +test('the activity table announces updates and carries a caption', async ({ page }) => { + await goto(page, '/activity') + // The live region reports the row count in every state, empty included, so + // this check does not depend on the instance having traffic. + await expect(page.locator('[data-test="activity-live-region"]')).toHaveCount(1) + await expect(page.locator('[data-test="activity-live-region"]')).toHaveAttribute( + 'aria-live', + 'polite', + ) + await expect(page.locator('[data-test="activity-live-region"]')).toContainText(/\d+ of \d+/) + + // The caption only exists when there is a table to caption. + if ((await page.locator('[data-test="activity-row"]').count()) > 0) { + const captions = await page.locator('table caption').count() + expect(captions, 'activity table has no ').toBeGreaterThan(0) + } +}) + +test('activity rows open their details from the keyboard, at every width', async ({ page }) => { + // Clicking the row is a shortcut; the per-row button is the real control, and + // it must survive the narrow layout (it used to be hidden below `sm`). + for (const width of [1440, 390]) { + await page.setViewportSize({ width, height: 844 }) + await goto(page, '/activity') + const rows = page.locator('[data-test="activity-row"]') + if ((await rows.count()) === 0) { + test.skip(true, 'no activity records on this instance') + } + const open = rows.first().locator('button[aria-label^="Open details"]') + await expect(open, `row button missing at ${width}px`).toBeVisible() + await open.focus() + await page.keyboard.press('Enter') + await expect(page.locator('#activity-detail-drawer')).toBeChecked() + await page.keyboard.press('Escape') + } +}) + +// --------------------------------------------------------------------------- +// F32 — the header search must not read as disabled at rest. +// --------------------------------------------------------------------------- +test('header search button is enabled with an empty box', async ({ page }) => { + await goto(page, '/') + const button = page.locator('[data-test="header-search-button"]') + await expect(button).toBeEnabled() + await expect(page.locator('[data-test="header-search-input"]')).toHaveValue('') + // Clicking with an empty query is a no-op, not a navigation. + await button.click() + await page.waitForTimeout(250) + expect(page.url()).not.toContain('/search') +}) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 48a436f43..cf6b639d6 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -12,8 +12,11 @@ - -
+ +
diff --git a/frontend/src/assets/main.css b/frontend/src/assets/main.css index 03130b052..8799f7954 100644 --- a/frontend/src/assets/main.css +++ b/frontend/src/assets/main.css @@ -10,6 +10,381 @@ coffee, winter, dim, nord, sunset; } +/* + * --------------------------------------------------------------------------- + * WCAG AA contrast tokens (UX audit F9) + * --------------------------------------------------------------------------- + * Two problems the stock daisyUI palettes have, both measured on a live page: + * + * 1. Semantic colours are *fills*, not text colours. `text-warning` on a + * `bg-warning/10` chip resolved to 1.28:1 in `corporate` — the worst + * offender was the "Docker isolation disabled" security warning itself. + * Fix: a parallel `--tone-*` ramp, dark enough (light themes) or light + * enough (dark themes) to clear 4.5:1 on base-100/200/300 and on their + * 10% tints. Only `text-*` / `link-*` are remapped; fills keep their token. + * + * 2. A few fill/content pairs fail on their own: white on `primary` was + * 4.13:1 in BOTH shipped themes (every filled primary button in the app), + * and white on corporate `success`/`info` was 3.30/3.73:1. Fix: one step + * darker on the fill, which buys AA everywhere those tokens are used. + * + * The values below are computed, not eyeballed: `frontend/src/utils/contrast.ts` + * implements the CSS colour maths and `frontend/tests/unit/contrast.spec.ts` + * parses THIS file plus the daisyUI theme files and fails if any audited pair + * drops below AA. Chroma/hue are preserved from the upstream token so the + * themes still look like themselves; only lightness moves. + */ +:root { + /* Generic fallback for the 13 non-default themes: bend the semantic colour + toward the theme's own text colour, which always increases contrast with + the theme's own surfaces regardless of whether the theme is light or dark. */ + --tone-primary: color-mix(in oklab, var(--color-primary) 62%, var(--color-base-content)); + --tone-secondary: color-mix(in oklab, var(--color-secondary) 62%, var(--color-base-content)); + --tone-accent: color-mix(in oklab, var(--color-accent) 62%, var(--color-base-content)); + --tone-info: color-mix(in oklab, var(--color-info) 62%, var(--color-base-content)); + --tone-success: color-mix(in oklab, var(--color-success) 62%, var(--color-base-content)); + --tone-warning: color-mix(in oklab, var(--color-warning) 62%, var(--color-base-content)); + --tone-error: color-mix(in oklab, var(--color-error) 62%, var(--color-base-content)); + /* Secondary/muted body text. `text-base-content/40` resolved to 2.51:1 on + white — AA has no "this text is less important" exemption, so the muted + ramp is a colour, not an alpha. */ + --tone-muted: color-mix(in oklab, var(--color-base-content) 78%, var(--color-base-100)); +} + +/* Light default. Worst-case ratios after the change are in the spec file. */ +[data-theme="corporate"] { + --color-primary: oklch(55% 0.158 241.966); /* white on primary 4.14 -> 4.66 */ + --color-success: oklch(53% 0.194 149.214); /* white on success 3.30 -> 4.66 */ + --color-info: oklch(54% 0.126 221.723); /* white on info 3.73 -> 4.70 */ + --color-accent: oklch(54% 0.118 184.704); /* white on accent 3.66 -> 4.61 */ + --color-secondary: oklch(46% 0.046 257.417); /* outline secondary 3.94 -> 5.79 */ + --tone-primary: oklch(42% 0.158 241.966); + --tone-secondary: oklch(43% 0.046 257.417); + --tone-accent: oklch(40% 0.118 184.704); + --tone-info: oklch(41% 0.126 221.723); + --tone-success: oklch(39% 0.194 149.214); + --tone-warning: oklch(45% 0.199 91.936); + --tone-error: oklch(46% 0.191 22.216); + --tone-muted: oklch(46% 0.031 278.072); /* base-content/40 2.51 -> 4.68 */ +} + +/* Dark default. */ +[data-theme="dark"] { + --color-primary: oklch(55% 0.233 277.117); /* primary-content on primary 4.14 -> 4.71 */ + --color-secondary: oklch(53% 0.241 354.308); /* secondary-content on secondary 3.05 -> 4.69 */ + --tone-primary: oklch(70% 0.233 277.117); + --tone-secondary: oklch(71% 0.241 354.308); + --tone-accent: oklch(66% 0.152 181.912); + --tone-info: oklch(67% 0.16 232.661); + --tone-success: oklch(66% 0.177 163.223); + --tone-warning: oklch(70% 0.189 84.429); + --tone-error: oklch(70% 0.194 13.428); + --tone-muted: oklch(64% 0.029 256.847); /* base-content/40 3.56 -> 4.71 */ +} + +/* + * Per-theme tone ramps for the other themes the picker offers. Generated the + * same way as the two blocks above — hue and chroma come straight from the + * upstream token, only lightness moves, until the colour clears 4.65:1 against + * base-100/200/300 and their 10% tints. The `:root` color-mix above stays as + * the fallback for any theme not listed here. + */ +[data-theme="light"] { + --tone-primary: oklch(51% 0.24 277.023); + --tone-secondary: oklch(50% 0.241 354.308); + --tone-accent: oklch(47% 0.152 181.912); + --tone-info: oklch(48% 0.16 232.661); + --tone-success: oklch(46% 0.177 163.223); + --tone-warning: oklch(51% 0.189 84.429); + --tone-error: oklch(52% 0.194 13.428); + --tone-muted: oklch(52% 0.006 285.885); +} /* worst 4.65:1 */ + +[data-theme="business"] { + --tone-primary: oklch(65% 0.099 251.473); + --tone-secondary: oklch(67% 0.027 229.389); + --tone-accent: oklch(69% 0.167 35.791); + --tone-info: oklch(66% 0.143 240.033); + --tone-success: oklch(67% 0.094 156.596); + --tone-warning: oklch(69% 0.115 81.519); + --tone-error: oklch(67% 0.146 29.674); + --tone-muted: oklch(63% 0.0 0.0); +} /* worst 4.66:1 */ + +[data-theme="emerald"] { + --tone-primary: oklch(43% 0.135 153.45); + --tone-secondary: oklch(45% 0.202 261.294); + --tone-accent: oklch(46% 0.149 33.2); + --tone-info: oklch(41% 0.191 231.6); + --tone-success: oklch(40% 0.15 160.0); + --tone-warning: oklch(45% 0.199 83.87); + --tone-error: oklch(43% 0.221 22.18); + --tone-muted: oklch(46% 0.032 262.988); +} /* worst 4.66:1 */ + +[data-theme="forest"] { + --tone-primary: oklch(63% 0.185 148.958); + --tone-secondary: oklch(63% 0.135 168.327); + --tone-accent: oklch(63% 0.119 185.713); + --tone-info: oklch(62% 0.191 231.6); + --tone-success: oklch(62% 0.15 160.0); + --tone-warning: oklch(66% 0.199 83.87); + --tone-error: oklch(67% 0.221 22.18); + --tone-muted: oklch(61% 0.001 17.911); +} /* worst 4.65:1 */ + +[data-theme="aqua"] { + --tone-primary: oklch(78% 0.144 198.645); + --tone-secondary: oklch(78% 0.108 309.782); + --tone-accent: oklch(81% 0.102 94.555); + --tone-info: oklch(80% 0.215 262.88); + --tone-success: oklch(75% 0.169 149.213); + --tone-warning: oklch(77% 0.157 58.318); + --tone-error: oklch(85% 0.19 27.33); + --tone-muted: oklch(74% 0.058 230.902); +} /* worst 4.67:1 */ + +[data-theme="lofi"] { + --tone-primary: oklch(46% 0.0 0.0); + --tone-secondary: oklch(47% 0.001 17.278); + --tone-accent: oklch(47% 0.0 0.0); + --tone-info: oklch(49% 0.103 205.9); + --tone-success: oklch(48% 0.153 164.14); + --tone-warning: oklch(51% 0.135 79.94); + --tone-error: oklch(52% 0.15 28.47); + --tone-muted: oklch(51% 0.0 0.0); +} /* worst 4.66:1 */ + +[data-theme="pastel"] { + --tone-primary: oklch(51% 0.063 306.703); + --tone-secondary: oklch(51% 0.058 10.001); + --tone-accent: oklch(49% 0.093 164.15); + --tone-info: oklch(47% 0.127 207.078); + --tone-success: oklch(47% 0.15 154.449); + --tone-warning: oklch(50% 0.128 66.29); + --tone-error: oklch(51% 0.114 19.571); + --tone-muted: oklch(50% 0.0 0.0); +} /* worst 4.66:1 */ + +[data-theme="fantasy"] { + --tone-primary: oklch(44% 0.189 325.02); + --tone-secondary: oklch(41% 0.162 241.36); + --tone-accent: oklch(46% 0.204 56.72); + --tone-info: oklch(41% 0.191 231.6); + --tone-success: oklch(40% 0.15 160.0); + --tone-warning: oklch(45% 0.199 83.87); + --tone-error: oklch(43% 0.221 22.18); + --tone-muted: oklch(46% 0.029 256.847); +} /* worst 4.65:1 */ + +[data-theme="wireframe"] { + --tone-primary: oklch(51% 0.0 0.0); + --tone-secondary: oklch(51% 0.0 0.0); + --tone-accent: oklch(51% 0.0 0.0); + --tone-info: oklch(48% 0.11 240.79); + --tone-success: oklch(47% 0.095 166.913); + --tone-warning: oklch(49% 0.137 46.201); + --tone-error: oklch(49% 0.177 26.899); + --tone-muted: oklch(51% 0.0 0.0); +} /* worst 4.65:1 */ + +[data-theme="luxury"] { + --tone-primary: oklch(70% 0.0 0.0); + --tone-secondary: oklch(63% 0.064 261.069); + --tone-accent: oklch(64% 0.051 338.825); + --tone-info: oklch(67% 0.121 237.133); + --tone-success: oklch(66% 0.192 132.154); + --tone-warning: oklch(68% 0.136 102.891); + --tone-error: oklch(68% 0.176 22.568); + --tone-muted: oklch(63% 0.123 76.89); +} /* worst 4.66:1 */ + +[data-theme="dracula"] { + --tone-primary: oklch(74% 0.183 346.812); + --tone-secondary: oklch(73% 0.148 301.883); + --tone-accent: oklch(73% 0.124 66.558); + --tone-info: oklch(73% 0.093 212.846); + --tone-success: oklch(71% 0.219 148.024); + --tone-warning: oklch(74% 0.134 112.757); + --tone-error: oklch(76% 0.206 24.43); + --tone-muted: oklch(67% 0.007 106.545); +} /* worst 4.67:1 */ + +[data-theme="synthwave"] { + --tone-primary: oklch(70% 0.202 349.761); + --tone-secondary: oklch(68% 0.111 230.318); + --tone-accent: oklch(68% 0.183 55.934); + --tone-info: oklch(66% 0.16 232.661); + --tone-success: oklch(65% 0.152 181.912); + --tone-warning: oklch(69% 0.182 98.111); + --tone-error: oklch(69% 0.121 32.639); + --tone-muted: oklch(64% 0.115 274.713); +} /* worst 4.70:1 */ + +[data-theme="cyberpunk"] { + --tone-primary: oklch(44% 0.209 6.35); + --tone-secondary: oklch(40% 0.184 204.72); + --tone-accent: oklch(47% 0.217 310.43); + --tone-info: oklch(41% 0.191 231.6); + --tone-success: oklch(40% 0.15 160.0); + --tone-warning: oklch(46% 0.199 83.87); + --tone-error: oklch(43% 0.221 22.18); + --tone-muted: oklch(45% 0.0 0.0); +} /* worst 4.66:1 */ + +@layer utilities { + /* Semantic text/link colours read from the AA-checked ramp. Fills + (`bg-*`, `badge-*`, `btn-*`, `alert-*`) deliberately keep `--color-*`. */ + .text-primary { color: var(--tone-primary); } + .text-secondary { color: var(--tone-secondary); } + .text-accent { color: var(--tone-accent); } + .text-info { color: var(--tone-info); } + .text-success { color: var(--tone-success); } + .text-warning { color: var(--tone-warning); } + .text-error { color: var(--tone-error); } + + .link-primary { color: var(--tone-primary); } + .link-secondary { color: var(--tone-secondary); } + .link-accent { color: var(--tone-accent); } + .link-info { color: var(--tone-info); } + .link-success { color: var(--tone-success); } + .link-warning { color: var(--tone-warning); } + .link-error { color: var(--tone-error); } + + /* Faded body text: /60 and below never cleared AA on base-200/300 (the + audit measured 2.51:1 for `/40` on white), so those steps resolve to the + muted colour. `/70` and up already pass and keep their own value, so the + "secondary" and "tertiary" levels stay visually distinct. */ + .text-base-content\/30, + .text-base-content\/40, + .text-base-content\/50, + .text-base-content\/60 { + color: var(--tone-muted); + } +} + +/* + * Unfilled variants paint the semantic colour as TEXT on a base surface, which + * is the same failure mode as `text-*` (a dark-theme outline secondary button + * measured 2.96:1). daisyUI exposes `--btn-rest-fg` for exactly this: it is + * read only in the rest state, so hover still flips to the filled fg/bg pair. + * + * Each value falls back THROUGH `--alert-fg`, which only exists inside a + * coloured alert: on that surface the on-colour foreground has to win, and a + * variable fallback settles it without a specificity duel with the alert rules + * further down (`.btn-link.btn-primary` would otherwise outrank them). + */ +:where(.btn-outline, .btn-dash, .btn-soft, .btn-ghost) { + &.btn-primary { --btn-rest-fg: var(--alert-fg, var(--tone-primary)); } + &.btn-secondary { --btn-rest-fg: var(--alert-fg, var(--tone-secondary)); } + &.btn-accent { --btn-rest-fg: var(--alert-fg, var(--tone-accent)); } + &.btn-info { --btn-rest-fg: var(--alert-fg, var(--tone-info)); } + &.btn-success { --btn-rest-fg: var(--alert-fg, var(--tone-success)); } + &.btn-warning { --btn-rest-fg: var(--alert-fg, var(--tone-warning)); } + &.btn-error { --btn-rest-fg: var(--alert-fg, var(--tone-error)); } +} + +/* `.btn-link` ignores `--btn-rest-fg` — daisyUI paints it straight from + `--btn-color` — so it needs the colour set directly. It has no fill in any + state, so there is no hover pair to preserve. */ +.btn-link { + &.btn-primary { color: var(--alert-fg, var(--tone-primary)); } + &.btn-secondary { color: var(--alert-fg, var(--tone-secondary)); } + &.btn-accent { color: var(--alert-fg, var(--tone-accent)); } + &.btn-info { color: var(--alert-fg, var(--tone-info)); } + &.btn-success { color: var(--alert-fg, var(--tone-success)); } + &.btn-warning { color: var(--alert-fg, var(--tone-warning)); } + &.btn-error { color: var(--alert-fg, var(--tone-error)); } +} +/* Uncoloured `.btn-link` defaults to `--color-primary`, i.e. a fill used as text. */ +.btn-link:not(.btn-primary, .btn-secondary, .btn-accent, .btn-info, .btn-success, .btn-warning, .btn-error) { + color: var(--alert-fg, var(--tone-primary)); +} + +/* Same story for unfilled badges, and the same `--alert-fg` escape hatch. */ +:where(.badge-outline, .badge-dash, .badge-soft) { + &.badge-primary { color: var(--alert-fg, var(--tone-primary)); } + &.badge-secondary { color: var(--alert-fg, var(--tone-secondary)); } + &.badge-accent { color: var(--alert-fg, var(--tone-accent)); } + &.badge-info { color: var(--alert-fg, var(--tone-info)); } + &.badge-success { color: var(--alert-fg, var(--tone-success)); } + &.badge-warning { color: var(--alert-fg, var(--tone-warning)); } + &.badge-error { color: var(--alert-fg, var(--tone-error)); } +} + +/* daisyUI paints these with `opacity` on base-content, which lands at ~4.2:1 + in corporate and ~3.6:1 in dark. Same intent, AA-checked colour instead. */ +.stat-title, +.stat-desc { + color: var(--tone-muted); + opacity: 1; +} + +.tabs .tab:not(.tab-active):not(.tab-disabled) { + color: var(--tone-muted); + opacity: 1; +} + +/* + * Inside a COLOURED alert the background is the semantic fill, so any tinted + * foreground on top of it is unreadable by construction: the audit measured + * 1.07:1 for the `dig ` remediation chip and 1.41:1 for the docs link. + * On such a surface the only guaranteed-AA foreground is the theme's own + * `*-content` colour, so links, ghost buttons and semantic text utilities all + * inherit it, and code chips invert into it. Unlayered so it beats daisyUI. + * Neutral `.alert` (base-200 surface) is untouched — tones are readable there. + */ +.alert-info { --alert-fg: var(--color-info-content); } +.alert-success { --alert-fg: var(--color-success-content); } +.alert-warning { --alert-fg: var(--color-warning-content); } +.alert-error { --alert-fg: var(--color-error-content); } + +/* `:not(.btn)` matters: a FILLED button inside an alert brings its own + background, so forcing the alert's foreground onto it would drop it to + 1.8:1 — the alert's rules apply to text, links and transparent buttons. */ +:where(.alert-info, .alert-success, .alert-warning, .alert-error) + :where(a:not(.btn), .link:not(.btn), .link-primary:not(.btn), .link-info:not(.btn), + .link-success:not(.btn), .link-warning:not(.btn), .link-error:not(.btn), + .btn-ghost, .btn-link, + .text-primary:not(.btn), .text-secondary:not(.btn), .text-accent:not(.btn), + .text-info:not(.btn), .text-success:not(.btn), .text-warning:not(.btn), + .text-error:not(.btn), .text-base-content\/30, .text-base-content\/40, + .text-base-content\/50, .text-base-content\/60, .text-base-content\/70) { + color: var(--alert-fg); + --btn-rest-fg: var(--alert-fg); +} + +:where(.alert-info, .alert-success, .alert-warning, .alert-error) + :where(a:not(.btn), .link:not(.btn)) { + text-decoration-line: underline; +} + +/* + * Hover/active on a transparent button inside a coloured alert. daisyUI paints + * `--btn-bg: var(--btn-color, var(--color-base-200))` in those states, i.e. a + * base surface dropped onto the alert's fill — measured 3.47:1 for a ghost + * button on a corporate info alert and 1.07:1 for a link button on a dark error + * alert. Any tint also erodes the pair (the fill/content ratio is only ~4.7:1 + * to begin with), so the background stays transparent and the affordance is a + * border plus an underline: the foreground keeps exactly its rest contrast. + */ +:where(.alert-info, .alert-success, .alert-warning, .alert-error) + :where(.btn-ghost, .btn-link):is(:hover, :focus-visible, :active) { + --btn-bg: #0000; + --btn-border: currentColor; + background-color: #0000; + color: var(--alert-fg); + text-decoration-line: underline; +} + +/* Code chips on a coloured alert: invert to the alert's own fill/content pair, + which every theme guarantees to be legible (>= 4.5:1 after the token fixes). */ +:where(.alert-info, .alert-success, .alert-warning, .alert-error) :where(code, kbd) { + background-color: var(--alert-fg); + color: var(--alert-color, var(--color-base-200)); + border-color: transparent; +} + /* Prevent horizontal scroll globally */ html, body { diff --git a/frontend/src/components/AddServerModal.vue b/frontend/src/components/AddServerModal.vue index 340889560..59429882e 100644 --- a/frontend/src/components/AddServerModal.vue +++ b/frontend/src/components/AddServerModal.vue @@ -114,7 +114,7 @@ - diff --git a/frontend/src/components/OnboardingWizard.vue b/frontend/src/components/OnboardingWizard.vue index 23e2c506b..c1597cf99 100644 --- a/frontend/src/components/OnboardingWizard.vue +++ b/frontend/src/components/OnboardingWizard.vue @@ -171,6 +171,7 @@ - Profile: + Profile: {{ activeLabel }} -
Active profile
+
Active profile