Public: anyone can read this; the crew can change it.
small: the focus ring is one shape on every button, link and input, and design-lint fails on a control that removes it #16809
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/16313-small-the-focus-ring-is-one-shape-on-eve → main 0 commits fork 5 threads · 5 unresolved
14 files
changed +111
−28
- docs/design/sections/2-tokens.md
- scripts/design-lint.ts
- src/design/ring.ts
- src/web/node_facts.ts
- src/web/pages/map.ts
- src/web/space_client.ts
- src/web/studio/feed_style.ts
- src/web/style/base.ts
- src/web/style/components.ts
- src/web/style/content.ts
- test/a11y-landmarks.test.ts
- test/design-lint-ring.test.ts
- test/map-keys-pan.test.ts
- test/notes-ceiling.test.ts
docs/design/sections/2-tokens.md +2
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | order: 20 |
| 3 | 3 | nest: 0 |
| 4 | 4 | --- |
| 5 | ||
| 5 | 6 | ## 2. Tokens |
| 6 | 7 | |
| 7 | 8 | Palettes live in `src/design/themes.ts`; the stylesheet only ever reads |
| @@ -19,6 +20,7 @@ variables, so a theme is data. Six ship today. What each role _means_: | ||
| 19 | 20 | | `--border-strong` | a raised edge, and hover on a control. | |
| 20 | 21 | | `--primary` / `--primary-fg` | the one filled button per page, and the live-activity pill. | |
| 21 | 22 | | `--accent` / `--accent-fg` | interaction: focus ring, link hover, selection, the review-comment rail. | |
| 23 | | `--ring` / `--ring-offset` | the one focus ring (`outline: var(--ring)`) on every control; `--ring-offset-tight` sits it on a bordered field. | | |
| 22 | 24 | | `--success` | open issue, mergeable pull, additions. | |
| 23 | 25 | | `--danger` | closed, destructive, deletions. | |
| 24 | 26 | | `--merged` | a merged pull. Purple, and only that. | |
scripts/design-lint.ts +13 −1
| @@ -70,6 +70,7 @@ import { join, relative } from "node:path"; | ||
| 70 | 70 | import { parseSection, renderSpine, stripSection } from "../src/view/design_spine.ts"; |
| 71 | 71 | import { dictateFindings } from "../src/design/dictate.ts"; |
| 72 | 72 | import { STRANGER_NEVER_SEES } from "../src/design/first_five_minutes.ts"; |
| 73 | import { ringFindings } from "../src/design/ring.ts"; | |
| 73 | 74 | import { contrastFindings } from "../src/design/contrast.ts"; |
| 74 | 75 | import { compareLayout, layoutCounts, scanLayout } from "../src/design/layout.ts"; |
| 75 | 76 | import { scanFeel, staleAllows } from "../src/design/feel.ts"; |
| @@ -656,6 +657,17 @@ export function scanDictate(root: string): string[] { | ||
| 656 | 657 | return dictateFindings(read("src/web/pages/talk.ts"), css).map((p) => `src/web/pages/talk.ts: ${p}`); |
| 657 | 658 | } |
| 658 | 659 | |
| 660 | /** A rule that sets outline to none must ring the control another way (#16313). */ | |
| 661 | export function scanRing(root: string): string[] { | |
| 662 | const out: string[] = []; | |
| 663 | for (const f of sourceFiles(root)) { | |
| 664 | for (const css of cssBlocks(readFileSync(f, "utf8"))) { | |
| 665 | for (const m of ringFindings(css)) out.push(`${relative(root, f)}: ${m.selector} — outline removed with no replacement; keep var(--ring) (docs/DESIGN.md §2) or ring it with a box-shadow`); | |
| 666 | } | |
| 667 | } | |
| 668 | return out; | |
| 669 | } | |
| 670 | ||
| 659 | 671 | const BASELINE = "docs/design/baseline.json"; |
| 660 | 672 | const DESIGN = "docs/DESIGN.md"; |
| 661 | 673 | const SECTIONS = "docs/design/sections"; |
| @@ -672,7 +684,7 @@ if (import.meta.main) { | ||
| 672 | 684 | } else { |
| 673 | 685 | const base: Baseline = JSON.parse(readFileSync(join(root, BASELINE), "utf8")); |
| 674 | 686 | const debt: QuietDebt = JSON.parse(readFileSync(join(root, QUIET_DEBT), "utf8")); |
| 675 | const problems = [...compare(base, now, designText(root), areaFiles(root)), ...compareQuiet(debt, scanQuiet(root)), ...scanBanner(root), ...compareLayout(base.layout ?? {}, scanLayout(root)), ...scanOverlay(root), ...scanCards(root), ...scanStranger(root), ...scanMotion(root), ...scanFeel(root), ...staleAllows(root).map((a) => `${a.file}: ${a.rule} "${a.text}" is allowed in docs/design/feel-allow.json but no longer found: take it out`), ...scanWidth(root), ...scanDictate(root), ...contrastFindings()]; | |
| 687 | const problems = [...compare(base, now, designText(root), areaFiles(root)), ...compareQuiet(debt, scanQuiet(root)), ...scanBanner(root), ...compareLayout(base.layout ?? {}, scanLayout(root)), ...scanOverlay(root), ...scanCards(root), ...scanStranger(root), ...scanMotion(root), ...scanFeel(root), ...staleAllows(root).map((a) => `${a.file}: ${a.rule} "${a.text}" is allowed in docs/design/feel-allow.json but no longer found: take it out`), ...scanWidth(root), ...scanDictate(root), ...scanRing(root), ...contrastFindings()]; | |
| 676 | 688 | for (const p of problems) console.error(p); |
| 677 | 689 | if (problems.length) process.exit(1); |
| 678 | 690 | console.log("design: no colour, size or component added outside the system"); |
src/design/ring.ts added +37
| @@ -0,0 +1,37 @@ | ||
| 1 | /** | |
| 2 | * One focus ring (#16313): `--ring` and `--ring-offset` in the tokens draw it, and a rule that | |
| 3 | * turns the outline off must put something in its place — a box-shadow in the same rule, or | |
| 4 | * another rule in the sheet that rings the same control (its container's `:focus-within`, or the | |
| 5 | * same selector followed by a child). And a focus rule that draws an outline must draw | |
| 6 | * `var(--ring)`, not its own shape; a forced-colours rule (a system colour such as Highlight) is | |
| 7 | * the one exception. Plain data in (one sheet's text), plain findings out. | |
| 8 | */ | |
| 9 | ||
| 10 | export type RingFinding = { selector: string }; | |
| 11 | ||
| 12 | const strip = (css: string): string => css.replace(/\/\*[\s\S]*?\*\//g, ""); | |
| 13 | const OFF = /(?<![\w-])outline(?:-style)?\s*:\s*(?:none|0)\s*(?:!important\s*)?(?:;|$)/; | |
| 14 | const MARK = /(?<![\w-])(?:box-shadow\s*:\s*(?!none)|border-color\s*:|stroke\s*:|outline\s*:\s*(?!none|0\s*(?:;|$)))/; | |
| 15 | ||
| 16 | const OWN = /(?<![\w-])outline\s*:\s*([^;}]+)/; | |
The lint only catches a removed outline. A hand-written |
||
| 17 | const SYSTEM = /\b(?:Highlight|CanvasText|LinkText|ButtonText|AccentColor)\b/; | |
| 18 | ||
| 19 | export function ringFindings(css: string): RingFinding[] { | |
| 20 | const rules = [...strip(css).matchAll(/([^{}]+)\{([^{}]*)\}/g)].map((m) => ({ selector: m[1]!.replace(/^[\s;]+/, "").replace(/\s+/g, " ").trim(), body: m[2]! })); | |
| 21 | const out: RingFinding[] = []; | |
| 22 | for (const r of rules) { | |
| 23 | const own = OWN.exec(r.body)?.[1]?.trim(); | |
| 24 | if (own && /:focus-(?:visible|within)/.test(r.selector) && !/^(?:none|0)\b/.test(own) && !own.includes("var(--ring)") && !SYSTEM.test(own)) { | |
| 25 | out.push({ selector: r.selector }); | |
| 26 | continue; | |
| 27 | } | |
| 28 | if (r.selector.startsWith("@") || !OFF.test(r.body) || /box-shadow\s*:\s*(?!none)/.test(r.body)) continue; | |
| 29 | if (/:not\(:focus/.test(r.selector)) continue; // an outline off while NOT focused is no removal | |
| 30 | const cls = /\.[\w-]+/.exec(r.selector)?.[0] ?? r.selector; | |
| 31 | const replaced = rules.some( | |
| 32 | (o) => o !== r && MARK.test(o.body) && (o.selector.includes(r.selector) || (/:focus-within|:has\(/.test(o.selector) && o.selector.includes(cls))), | |
| 33 | ); | |
| 34 | if (!replaced) out.push({ selector: r.selector }); | |
| 35 | } | |
| 36 | return out; | |
| 37 | } |
src/web/node_facts.ts +1 −1
| @@ -40,7 +40,7 @@ export function factsList(name: string, facts: readonly Fact[], tabbable: boolea | ||
| 40 | 40 | export const factsCss = /* css */ ` |
| 41 | 41 | .facts { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } |
| 42 | 42 | .facts:focus-within { left: 8px; bottom: 8px; width: min(26rem, calc(100% - 1.5rem)); height: auto; max-height: 40vh; padding: 8px 12px; overflow: auto; clip: auto; white-space: normal; background: var(--muted); } |
| 43 | .facts summary, .facts a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } | |
| 43 | .facts summary:focus-visible, .facts a:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); } | |
| 44 | 44 | .facts summary:not(:focus-visible) { outline: 0; } |
| 45 | 45 | (forced-colors: active) { .facts summary, .facts a:focus-visible { outline-color: Highlight; } } |
| 46 | 46 | .facts dl, .facts dt, .facts dd { margin: 0; } |
src/web/pages/map.ts +1 −1
| @@ -1244,7 +1244,7 @@ export const mapCss = /* css */ `${factsCss} | ||
| 1244 | 1244 | @media (hover: hover) and (pointer: fine) { .map-node:hover .map-card { stroke: var(--border-strong); } |
| 1245 | 1245 | .map-node[data-state="working"]:hover .map-card { stroke: var(--accent); } } |
| 1246 | 1246 | .map-node:focus-visible .map-card { stroke: var(--accent); stroke-width: 2; } |
| 1247 | .map-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; } | |
| 1247 | .map-canvas:focus-visible { outline: var(--ring); outline-offset: -2px; } | |
| 1248 | 1248 | /* A soft outer ring, static: any animation inside a large inline SVG |
| 1249 | 1249 | repaints the whole drawing every frame, whatever property it touches. */ |
| 1250 | 1250 | .map-breath { fill: none; stroke: var(--accent); stroke-width: 1.5; opacity: .35; } |
src/web/space_client.ts +1 −1
| @@ -54,7 +54,7 @@ html.space-on .space-time { display: flex; gap: .6rem; align-items: center; padd | ||
| 54 | 54 | html.space-on .space-list, html.space-on .space-found { display: none; } |
| 55 | 55 | .space-legend { padding: 0 1rem; font-size: .85rem; } |
| 56 | 56 | .space-legend summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; } |
| 57 | .space-legend summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } | |
| 57 | .space-legend summary:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); } | |
| 58 | 58 | .space-legend ul { list-style: none; padding: 0; margin: .4rem 0 0; } |
| 59 | 59 | .space-legend li { margin: .25rem 0; } |
| 60 | 60 | .space-legend i { display: inline-block; width: .7rem; height: .7rem; margin-right: .4rem; background: currentColor; vertical-align: -.05rem; } |
src/web/studio/feed_style.ts +1 −1
| @@ -14,7 +14,7 @@ export const feedCss = /* css */ ` | ||
| 14 | 14 | .feed-empty .empty { padding: 24px; } |
| 15 | 15 | /* A timeline of the design system's cards; the card's own margin spaces them. */ |
| 16 | 16 | .feed { display: grid; gap: 0; } |
| 17 | .feed > .card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; } | |
| 17 | .feed > .card:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset-tight); } | |
| 18 | 18 | /* The held-posts button sticks under the topbar so it is in sight while the reader is down the feed; the paragraph is zero-high until the button shows. */ |
| 19 | 19 | .new-posts { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 9; margin: 0; display: flex; justify-content: center; pointer-events: none; } |
| 20 | 20 | .new-posts .btn { pointer-events: auto; min-height: 44px; box-shadow: var(--shadow-2); } |
src/web/style/base.ts +4 −1
| @@ -47,6 +47,9 @@ export const base = /* css */ ` | ||
| 47 | 47 | --topbar-h: 56px; |
| 48 | 48 | --page: 1120px; |
| 49 | 49 | --measure: 72ch; |
| 50 | --ring: 2px solid var(--accent); /* the one focus ring: buttons, links, inputs, summaries */ | |
| 51 | --ring-offset: 2px; | |
| 52 | --ring-offset-tight: 1px; /* the ring on a field that already has a border */ | |
| 50 | 53 | /* One strong curve for what enters and leaves (ease-out), one for a move |
| 51 | 54 | on screen (ease-in-out); never ease-in. src/design/feel.ts holds it. */ |
| 52 | 55 | --ease: cubic-bezier(.23, 1, .32, 1); |
| @@ -91,7 +94,7 @@ h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; line-height: 1. | ||
| 91 | 94 | h3 { font-size: 14px; font-weight: 600; line-height: 1.4; } |
| 92 | 95 | |
| 93 | 96 | ::selection { background: color-mix(in srgb, var(--accent) 26%, transparent); } |
| 94 | :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; } | |
| 97 | :focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); border-radius: 3px; } | |
| 95 | 98 | |
| 96 | 99 | /* Anything anchorable clears the sticky topbar when it is scrolled to. */ |
| 97 | 100 | [id] { scroll-margin-top: calc(var(--topbar-h) + 12px); } |
src/web/style/components.ts +9 −10
| @@ -80,8 +80,7 @@ export const components = /* css */ ` | ||
| 80 | 80 | .input.input-num { width: 5rem; } |
| 81 | 81 | @media (hover: hover) and (pointer: fine) { .input:hover { border-color: var(--border-strong); } } |
| 82 | 82 | .input:focus-visible { |
| 83 | outline: none; border-color: var(--accent); | |
| 84 | box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); | |
| 83 | outline: var(--ring); outline-offset: var(--ring-offset-tight); border-color: var(--accent); | |
| 85 | 84 | } |
| 86 | 85 | .input[aria-invalid="true"], .input:user-invalid { |
| 87 | 86 | border-color: var(--danger); |
| @@ -147,9 +146,9 @@ select.input { | ||
| 147 | 146 | .why > summary::-webkit-details-marker { display: none; } |
| 148 | 147 | .why[open] > summary { border-color: var(--border-strong); color: var(--fg); } |
| 149 | 148 | @media (hover: hover) and (pointer: fine) { .why > summary:hover { border-color: var(--border-strong); color: var(--fg); } } |
| 150 | .why > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } | |
| 149 | .why > summary:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); } | |
| 151 | 150 | .holds summary { cursor: pointer; min-height: 24px; } |
| 152 | .holds summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } | |
| 151 | .holds summary:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); } | |
| 153 | 152 | .files-list { margin: 4px 0 0; overflow-wrap: anywhere; } |
| 154 | 153 | .why > p { margin: 6px 0 0; font-size: 12.5px; color: var(--muted-fg); overflow-wrap: anywhere; } |
| 155 | 154 | @media (pointer: coarse) { .why > summary { width: 44px; height: 44px; } } |
| @@ -514,7 +513,7 @@ a.flow-row { min-height: 44px; } | ||
| 514 | 513 | .row-children { list-style: none; margin: 0 0 0 22px; padding: 0; border-left: 1px solid var(--border); } |
| 515 | 514 | .row-children > li[data-fold] > details > summary { display: flex; align-items: center; min-height: 44px; padding: 0 12px; cursor: pointer; color: var(--muted-fg, inherit); } |
| 516 | 515 | @media (hover: hover) and (pointer: fine) { .row-children > li[data-fold] > details > summary:hover { background: var(--muted); } } |
| 517 | .row-children > li[data-fold] > details > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; } | |
| 516 | .row-children > li[data-fold] > details > summary:focus-visible { outline: var(--ring); outline-offset: -2px; } | |
| 518 | 517 | .row-children > li { border-top: 1px solid var(--border); } |
| 519 | 518 | @media (max-width: 719px) { .row-children { margin-left: 12px; } } |
| 520 | 519 | /* A bare tree (/family, docs/design/areas/family.md): names and a line each; indentation is the only structure. */ |
| @@ -656,7 +655,7 @@ details[open] > summary.row > .row-lead { transform: rotate(90deg); } | ||
| 656 | 655 | border: 1px solid var(--border); border-radius: var(--radius-sm); |
| 657 | 656 | background: var(--card); |
| 658 | 657 | } |
| 659 | .color-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); } | |
| 658 | .color-field:focus-within { border-color: var(--accent); outline: var(--ring); outline-offset: var(--ring-offset-tight); } | |
| 660 | 659 | .color-field input[type="color"] { |
| 661 | 660 | appearance: none; -webkit-appearance: none; flex: none; |
| 662 | 661 | width: 26px; height: 26px; padding: 0; border: 0; border-radius: 999px; |
| @@ -752,7 +751,7 @@ details[open] > summary.row > .row-lead { transform: rotate(90deg); } | ||
| 752 | 751 | .seg > a[aria-current="page"], .seg > label:has(input:checked), .seg > button[aria-pressed="true"] { |
| 753 | 752 | background: var(--card); color: var(--fg); box-shadow: var(--shadow-1); |
| 754 | 753 | } |
| 755 | .seg > label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; } | |
| 754 | .seg > label:has(input:focus-visible) { outline: var(--ring); outline-offset: -2px; } | |
| 756 | 755 | @media (pointer: coarse) { .seg > a, .seg > label, .seg > button { min-height: 36px; } } |
| 757 | 756 | |
| 758 | 757 | /* ---- menu (details; correct with zero JavaScript) ---- */ |
| @@ -839,11 +838,11 @@ details[open] > summary.row > .row-lead { transform: rotate(90deg); } | ||
| 839 | 838 | } |
| 840 | 839 | .disclosure[open] > summary::before { transform: rotate(90deg); } |
| 841 | 840 | @media (hover: hover) and (pointer: fine) { .disclosure > summary:hover { color: var(--accent); } } |
| 842 | .disclosure > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); } | |
| 841 | .disclosure > summary:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); border-radius: var(--radius); } | |
| 843 | 842 | /* A page's "? Help" (page_help.ts): a 44px target a thumb can hit, and a ring a keyboard can see. */ |
| 844 | 843 | .disclosure[data-page-help] > summary { width: fit-content; min-width: 44px; } |
| 845 | 844 | .disclosure[data-page-help] > summary::before { content: none; } |
| 846 | .disclosure[data-page-help] > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); } | |
| 845 | .disclosure[data-page-help] > summary:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); border-radius: var(--radius); } | |
| 847 | 846 | |
| 848 | 847 | /* ---- topbar search (always a real form, so JS-off still searches) ---- */ |
| 849 | 848 | .topbar-search { |
| @@ -853,7 +852,7 @@ details[open] > summary.row > .row-lead { transform: rotate(90deg); } | ||
| 853 | 852 | border: 1px solid var(--border); border-radius: var(--radius-sm); |
| 854 | 853 | background: var(--card); color: var(--muted-fg); |
| 855 | 854 | } |
| 856 | .topbar-search:focus-within { border-color: var(--accent); } | |
| 855 | .topbar-search:focus-within { border-color: var(--accent); outline: var(--ring); outline-offset: var(--ring-offset-tight); } | |
| 857 | 856 | .topbar-search input { |
| 858 | 857 | flex: 1; min-width: 0; border: 0; background: none; outline: none; |
| 859 | 858 | font-size: 16px; color: var(--fg); |
src/web/style/content.ts +9 −9
| @@ -321,9 +321,9 @@ form.inline { display: inline; margin-left: auto; } | ||
| 321 | 321 | /* "Sort and time": a thumb-sized target; the line height is fixed so opening it moves only |
| 322 | 322 | what is below. */ |
| 323 | 323 | .sort-toggle { display: flex; align-items: center; min-height: 44px; padding: 0 4px; cursor: pointer; } |
| 324 | .sort-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); } | |
| 324 | .sort-toggle:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); border-radius: var(--radius-sm); } | |
| 325 | 325 | .row-forks > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; padding: 0 12px; } |
| 326 | .row-forks > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } | |
| 326 | .row-forks > summary:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); } | |
| 327 | 327 | .row-forks > .list { margin-left: 8px; } |
| 328 | 328 | .explore-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; } |
| 329 | 329 | .explore-pager .btn { min-height: 44px; } |
| @@ -546,7 +546,7 @@ img.img-box, .prose img.img-box, .tell-picture.img-box { display: block; width: | ||
| 546 | 546 | .code tr.log-warn { background: color-mix(in srgb, var(--attn) 12%, transparent); } |
| 547 | 547 | .log-jump { margin: 0 0 8px; min-height: 44px; display: flex; align-items: center; gap: 8px; } |
| 548 | 548 | .log-jump a { display: inline-block; padding: 12px 8px 12px 0; } |
| 549 | .log-jump a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; } | |
| 549 | .log-jump a:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); border-radius: 4px; } | |
| 550 | 550 | .ansi-b { font-weight: 700; } |
| 551 | 551 | .ansi-u { text-decoration: underline; } |
| 552 | 552 | |
| @@ -624,20 +624,20 @@ img.img-box, .prose img.img-box, .tell-picture.img-box { display: block; width: | ||
| 624 | 624 | .dxf-view { margin: 0; } |
| 625 | 625 | .dxf-view svg { display: block; max-width: 100%; height: auto; margin: 0 auto; color: var(--fg); } |
| 626 | 626 | .dxf-view .status-rows { margin-top: 12px; } |
| 627 | .dxf-view svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } | |
| 627 | .dxf-view svg:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); } | |
| 628 | 628 | .gerber-view { margin: 0; } |
| 629 | 629 | .gerber-view svg { display: block; max-width: 100%; height: auto; margin: 0 auto; color: var(--fg); } |
| 630 | 630 | .gerber-view .status-rows { margin-top: 12px; } |
| 631 | 631 | .diagram-view { margin: 0; } |
| 632 | 632 | .diagram-scroll { overflow-x: auto; max-width: 100%; } |
| 633 | .diagram-scroll:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; } | |
| 633 | .diagram-scroll:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); } | |
| 634 | 634 | .diagram-view svg { display: block; max-width: 100%; width: 100%; height: auto; margin: 0 auto; color: var(--fg); } |
| 635 | 635 | .diagram-source pre { overflow-x: auto; } |
| 636 | 636 | .diagram-source summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; } |
| 637 | 637 | .gj-view { margin: 0; } |
| 638 | 638 | .gj-view svg { display: block; max-width: 100%; height: auto; margin: 0 auto; color: var(--fg); } |
| 639 | 639 | .gj-table { overflow-x: auto; max-width: 100%; } |
| 640 | .gj-table:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; } | |
| 640 | .gj-table:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); } | |
| 641 | 641 | .gj-table table { width: 100%; font-size: 13px; } |
| 642 | 642 | .gj-table th, .gj-table td { text-align: left; padding: 3px 8px; overflow-wrap: anywhere; } |
| 643 | 643 | .font-view { padding: 16px 20px; } |
| @@ -723,7 +723,7 @@ img.img-box, .prose img.img-box, .tell-picture.img-box { display: block; width: | ||
| 723 | 723 | radial-gradient(farthest-side at 100% 50%, var(--edge), transparent) right center / 10px 100% no-repeat scroll; |
| 724 | 724 | } |
| 725 | 725 | .prose.prose-page .table-scroll { --cover: var(--bg); } |
| 726 | .prose .table-scroll:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; } | |
| 726 | .prose .table-scroll:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); } | |
| 727 | 727 | .prose table { width: max-content; min-width: 100%; max-width: none; font-size: 14px; } |
| 728 | 728 | .prose th, .prose td { padding: 6px 10px; border: 1px solid var(--border); text-align: left; overflow-wrap: normal; } |
| 729 | 729 | .prose th { background: color-mix(in srgb, var(--muted) 72%, transparent); font-weight: 600; white-space: nowrap; } |
| @@ -1162,10 +1162,10 @@ textarea.editor:focus-visible { outline: none; } | ||
| 1162 | 1162 | background: color-mix(in srgb, var(--muted) 75%, transparent); |
| 1163 | 1163 | } |
| 1164 | 1164 | .editor-wrap { --editor-fs: 12.5px; } |
| 1165 | .editor-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); } | |
| 1165 | .editor-wrap:focus-within { border-color: var(--accent); outline: var(--ring); outline-offset: var(--ring-offset-tight); } | |
| 1166 | 1166 | /* Touch screens zoom a field set under 16px; the gutter, mirror and textarea share the size so they stay aligned. */ |
| 1167 | 1167 | @media (pointer: coarse) { .editor-wrap { --editor-fs: 16px; } } |
| 1168 | /* The ring above is a shadow, which forced colours drop; the textarea's own outline is off, so draw one. */ | |
| 1168 | /* The ring above is an outline, which forced colours may recolour; the textarea's own outline is off, so draw one. */ | |
| 1169 | 1169 | @media (forced-colors: active) { .editor-wrap:focus-within { outline: 2px solid Highlight; outline-offset: 2px; } } |
| 1170 | 1170 | #editor-preview { |
| 1171 | 1171 | border: 1px solid var(--border); border-top: none; |
test/a11y-landmarks.test.ts +1 −1
| @@ -99,7 +99,7 @@ describe("the served stylesheet", () => { | ||
| 99 | 99 | css = (await res.text()).replace(/\s+/g, " "); |
| 100 | 100 | }); |
| 101 | 101 | test("draws a focus ring on every control", () => { |
| 102 | expect(css).toMatch(/(^|[}\s]):focus-visible\s*\{\s*outline:\s*2px solid var\(--accent\)/); | |
| 102 | expect(css).toMatch(/(^|[}\s]):focus-visible\s*\{\s*outline:\s*var\(--ring\)/); | |
| 103 | 103 | }); |
| 104 | 104 | test("keeps the skip link off-screen until focused, without moving layout", () => { |
| 105 | 105 | expect(css).toMatch(/\.skip\s*\{[^}]*position:\s*absolute[^}]*top:\s*-\d+px/); |
test/design-lint-ring.test.ts added +30
| @@ -0,0 +1,30 @@ | ||
| 1 | import { expect, test } from "bun:test"; | |
| 2 | import { readFileSync } from "node:fs"; | |
| 3 | import { ringFindings } from "../src/design/ring.ts"; | |
| 4 | import { scanRing } from "../scripts/design-lint.ts"; | |
| 5 | ||
| 6 | test("a rule that removes the outline with nothing in its place is found", () => { | |
| 7 | expect(ringFindings(".btn:focus-visible { outline: none; }")).toEqual([{ selector: ".btn:focus-visible" }]); | |
| 8 | expect(ringFindings("a:focus { outline: 0 }")).toHaveLength(1); | |
| 9 | }); | |
| 10 | ||
| 11 | test("a replacement in the rule, or on the container, passes", () => { | |
| 12 | expect(ringFindings(".i:focus-visible { outline: none; box-shadow: 0 0 0 2px red; }")).toEqual([]); | |
| 13 | expect(ringFindings(".bar input { outline: none; } .bar:focus-within { outline: var(--ring); }")).toEqual([]); | |
| 14 | expect(ringFindings(".c a:focus-visible { outline: none; } .c a:focus-visible > .x { stroke: red; }")).toEqual([]); | |
| 15 | expect(ringFindings(".f summary:not(:focus-visible) { outline: none; }")).toEqual([]); | |
| 16 | }); | |
| 17 | ||
| 18 | test("the shipped stylesheets have none, and the ring is one token", () => { | |
| 19 | expect(scanRing(process.cwd())).toEqual([]); | |
| 20 | const base = readFileSync("src/web/style/base.ts", "utf8"); | |
| 21 | expect(base).toContain("--ring: 2px solid var(--accent)"); | |
| 22 | }); | |
| 23 | ||
| 24 | test("a focus rule that hand-writes its outline is found; the token and a system colour pass", () => { | |
| 25 | expect(ringFindings(".a:focus-visible { outline: 2px solid var(--accent); }")).toEqual([{ selector: ".a:focus-visible" }]); | |
| 26 | expect(ringFindings(".b:focus-within { outline: 1px solid red; outline-offset: 1px; }")).toHaveLength(1); | |
| 27 | expect(ringFindings(".a:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset-tight); }")).toEqual([]); | |
| 28 | expect(ringFindings("@media (forced-colors: active) { .a:focus-visible { outline: 2px solid Highlight; } }")).toEqual([]); | |
| 29 | expect(ringFindings(".a:hover { outline: 2px solid red; }")).toEqual([]); | |
| 30 | }); |
test/map-keys-pan.test.ts +1 −1
| @@ -58,5 +58,5 @@ test("countInView counts overlapping rectangles; showingLine words it", () => { | ||
| 58 | 58 | |
| 59 | 59 | test("the canvas has a visible focus ring of its own", async () => { |
| 60 | 60 | const src = await Bun.file(new URL("../src/web/pages/map.ts", import.meta.url)).text(); |
| 61 | expect(src).toContain(".map-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }"); | |
| 61 | expect(src).toContain(".map-canvas:focus-visible { outline: var(--ring); outline-offset: -2px; }"); | |
| 62 | 62 | }); |
test/notes-ceiling.test.ts +1 −1
| @@ -110,7 +110,7 @@ test("the ? the pages render is a 44×44 px target with a visible focus ring, at | ||
| 110 | 110 | } |
| 111 | 111 | expect(declared(".disclosure > summary")).toContain("min-height: 44px"); |
| 112 | 112 | expect(declared(".disclosure[data-page-help] > summary")).toContain("min-width: 44px"); |
| 113 | expect(declared(".disclosure[data-page-help] > summary:focus-visible")).toMatch(/outline: 2px solid var\(--accent\)/); | |
| 113 | expect(declared(".disclosure[data-page-help] > summary:focus-visible")).toMatch(/outline: var\(--ring\)/); | |
| 114 | 114 | // Nothing anywhere, a narrow-screen block included, takes either back. |
| 115 | 115 | const reaches = (selector: string): boolean => |
| 116 | 116 | /\bsummary\b/.test(selector) && (/^summary\b/.test(selector) || /disclosure|data-page-help/.test(selector)); |
new above
offline
The row is wider than the table and misaligned. Run prettier. Shorten the description too.