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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/16313-small-the-focus-ring-is-one-shape-on-eve → main 0 commits fork 5 threads · 5 unresolved

  • Merged. scout/16313-small-the-focus-ring-is-one-shape-on-eve was merged into main as c779af6.

Review

Sign in to review this change.
14 files changed +111 −28
docs/design/sections/2-tokens.md +2
@@ -2,6 +2,7 @@
22 order: 20
33 nest: 0
44 ---
5
56 ## 2. Tokens
67
78 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_:
1920 | `--border-strong` | a raised edge, and hover on a control. |
2021 | `--primary` / `--primary-fg` | the one filled button per page, and the live-activity pill. |
2122 | `--accent` / `--accent-fg` | interaction: focus ring, link hover, selection, the review-comment rail. |
outdated

The row is wider than the table and misaligned. Run prettier. Shorten the description too.

23 | `--ring` / `--ring-offset` | the one focus ring (`outline: var(--ring)`) on every control; `--ring-offset-tight` sits it on a bordered field. |
2224 | `--success` | open issue, mergeable pull, additions. |
2325 | `--danger` | closed, destructive, deletions. |
2426 | `--merged` | a merged pull. Purple, and only that. |
scripts/design-lint.ts +13 −1
@@ -70,6 +70,7 @@ import { join, relative } from "node:path";
7070 import { parseSection, renderSpine, stripSection } from "../src/view/design_spine.ts";
7171 import { dictateFindings } from "../src/design/dictate.ts";
7272 import { STRANGER_NEVER_SEES } from "../src/design/first_five_minutes.ts";
73 import { ringFindings } from "../src/design/ring.ts";
7374 import { contrastFindings } from "../src/design/contrast.ts";
7475 import { compareLayout, layoutCounts, scanLayout } from "../src/design/layout.ts";
7576 import { scanFeel, staleAllows } from "../src/design/feel.ts";
@@ -656,6 +657,17 @@ export function scanDictate(root: string): string[] {
656657 return dictateFindings(read("src/web/pages/talk.ts"), css).map((p) => `src/web/pages/talk.ts: ${p}`);
657658 }
658659
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
659671 const BASELINE = "docs/design/baseline.json";
660672 const DESIGN = "docs/DESIGN.md";
661673 const SECTIONS = "docs/design/sections";
@@ -672,7 +684,7 @@ if (import.meta.main) {
672684 } else {
673685 const base: Baseline = JSON.parse(readFileSync(join(root, BASELINE), "utf8"));
674686 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()];
676688 for (const p of problems) console.error(p);
677689 if (problems.length) process.exit(1);
678690 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*([^;}]+)/;
outdated

The lint only catches a removed outline. A hand-written outline: 2px solid var(--accent) on a focus rule (node_facts.ts:43, space_client.ts:57, map.ts:1247, feed_style.ts:17) passes, so the ring can drift again. Report any :focus-visible or :focus-within rule whose outline is not var(--ring) and not a forced-colours value.

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
4040 export const factsCss = /* css */ `
4141 .facts { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
4242 .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); }
4444 .facts summary:not(:focus-visible) { outline: 0; }
4545 @media (forced-colors: active) { .facts summary, .facts a:focus-visible { outline-color: Highlight; } }
4646 .facts dl, .facts dt, .facts dd { margin: 0; }
src/web/pages/map.ts +1 −1
@@ -1244,7 +1244,7 @@ export const mapCss = /* css */ `${factsCss}
12441244 @media (hover: hover) and (pointer: fine) { .map-node:hover .map-card { stroke: var(--border-strong); }
12451245 .map-node[data-state="working"]:hover .map-card { stroke: var(--accent); } }
12461246 .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; }
12481248 /* A soft outer ring, static: any animation inside a large inline SVG
12491249 repaints the whole drawing every frame, whatever property it touches. */
12501250 .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
5454 html.space-on .space-list, html.space-on .space-found { display: none; }
5555 .space-legend { padding: 0 1rem; font-size: .85rem; }
5656 .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); }
5858 .space-legend ul { list-style: none; padding: 0; margin: .4rem 0 0; }
5959 .space-legend li { margin: .25rem 0; }
6060 .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 */ `
1414 .feed-empty .empty { padding: 24px; }
1515 /* A timeline of the design system's cards; the card's own margin spaces them. */
1616 .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); }
1818 /* 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. */
1919 .new-posts { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 9; margin: 0; display: flex; justify-content: center; pointer-events: none; }
2020 .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 */ `
4747 --topbar-h: 56px;
4848 --page: 1120px;
4949 --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 */
5053 /* One strong curve for what enters and leaves (ease-out), one for a move
5154 on screen (ease-in-out); never ease-in. src/design/feel.ts holds it. */
5255 --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.
9194 h3 { font-size: 14px; font-weight: 600; line-height: 1.4; }
9295
9396 ::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; }
9598
9699 /* Anything anchorable clears the sticky topbar when it is scrolled to. */
97100 [id] { scroll-margin-top: calc(var(--topbar-h) + 12px); }
src/web/style/components.ts +9 −10
@@ -80,8 +80,7 @@ export const components = /* css */ `
8080 .input.input-num { width: 5rem; }
8181 @media (hover: hover) and (pointer: fine) { .input:hover { border-color: var(--border-strong); } }
8282 .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);
outdated

The literal outline-offset: 1px is repeated here, at components.ts:658 and :855, and at content.ts:1165. Give it a token next to --ring-offset so the ring's geometry lives in one place.

8584 }
8685 .input[aria-invalid="true"], .input:user-invalid {
8786 border-color: var(--danger);
@@ -147,9 +146,9 @@ select.input {
147146 .why > summary::-webkit-details-marker { display: none; }
148147 .why[open] > summary { border-color: var(--border-strong); color: var(--fg); }
149148 @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); }
151150 .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); }
153152 .files-list { margin: 4px 0 0; overflow-wrap: anywhere; }
154153 .why > p { margin: 6px 0 0; font-size: 12.5px; color: var(--muted-fg); overflow-wrap: anywhere; }
155154 @media (pointer: coarse) { .why > summary { width: 44px; height: 44px; } }
@@ -514,7 +513,7 @@ a.flow-row { min-height: 44px; }
514513 .row-children { list-style: none; margin: 0 0 0 22px; padding: 0; border-left: 1px solid var(--border); }
515514 .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); }
516515 @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; }
518517 .row-children > li { border-top: 1px solid var(--border); }
519518 @media (max-width: 719px) { .row-children { margin-left: 12px; } }
520519 /* 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); }
656655 border: 1px solid var(--border); border-radius: var(--radius-sm);
657656 background: var(--card);
658657 }
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); }
660659 .color-field input[type="color"] {
661660 appearance: none; -webkit-appearance: none; flex: none;
662661 width: 26px; height: 26px; padding: 0; border: 0; border-radius: 999px;
@@ -752,7 +751,7 @@ details[open] > summary.row > .row-lead { transform: rotate(90deg); }
752751 .seg > a[aria-current="page"], .seg > label:has(input:checked), .seg > button[aria-pressed="true"] {
753752 background: var(--card); color: var(--fg); box-shadow: var(--shadow-1);
754753 }
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; }
756755 @media (pointer: coarse) { .seg > a, .seg > label, .seg > button { min-height: 36px; } }
757756
758757 /* ---- menu (details; correct with zero JavaScript) ---- */
@@ -839,11 +838,11 @@ details[open] > summary.row > .row-lead { transform: rotate(90deg); }
839838 }
840839 .disclosure[open] > summary::before { transform: rotate(90deg); }
841840 @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); }
843842 /* A page's "? Help" (page_help.ts): a 44px target a thumb can hit, and a ring a keyboard can see. */
844843 .disclosure[data-page-help] > summary { width: fit-content; min-width: 44px; }
845844 .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); }
847846
848847 /* ---- topbar search (always a real form, so JS-off still searches) ---- */
849848 .topbar-search {
@@ -853,7 +852,7 @@ details[open] > summary.row > .row-lead { transform: rotate(90deg); }
853852 border: 1px solid var(--border); border-radius: var(--radius-sm);
854853 background: var(--card); color: var(--muted-fg);
855854 }
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); }
857856 .topbar-search input {
858857 flex: 1; min-width: 0; border: 0; background: none; outline: none;
859858 font-size: 16px; color: var(--fg);
src/web/style/content.ts +9 −9
@@ -321,9 +321,9 @@ form.inline { display: inline; margin-left: auto; }
321321 /* "Sort and time": a thumb-sized target; the line height is fixed so opening it moves only
322322 what is below. */
323323 .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); }
325325 .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); }
327327 .row-forks > .list { margin-left: 8px; }
328328 .explore-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
329329 .explore-pager .btn { min-height: 44px; }
@@ -546,7 +546,7 @@ img.img-box, .prose img.img-box, .tell-picture.img-box { display: block; width:
546546 .code tr.log-warn { background: color-mix(in srgb, var(--attn) 12%, transparent); }
547547 .log-jump { margin: 0 0 8px; min-height: 44px; display: flex; align-items: center; gap: 8px; }
548548 .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; }
550550 .ansi-b { font-weight: 700; }
551551 .ansi-u { text-decoration: underline; }
552552
@@ -624,20 +624,20 @@ img.img-box, .prose img.img-box, .tell-picture.img-box { display: block; width:
624624 .dxf-view { margin: 0; }
625625 .dxf-view svg { display: block; max-width: 100%; height: auto; margin: 0 auto; color: var(--fg); }
626626 .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); }
628628 .gerber-view { margin: 0; }
629629 .gerber-view svg { display: block; max-width: 100%; height: auto; margin: 0 auto; color: var(--fg); }
630630 .gerber-view .status-rows { margin-top: 12px; }
631631 .diagram-view { margin: 0; }
632632 .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); }
634634 .diagram-view svg { display: block; max-width: 100%; width: 100%; height: auto; margin: 0 auto; color: var(--fg); }
635635 .diagram-source pre { overflow-x: auto; }
636636 .diagram-source summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
637637 .gj-view { margin: 0; }
638638 .gj-view svg { display: block; max-width: 100%; height: auto; margin: 0 auto; color: var(--fg); }
639639 .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); }
641641 .gj-table table { width: 100%; font-size: 13px; }
642642 .gj-table th, .gj-table td { text-align: left; padding: 3px 8px; overflow-wrap: anywhere; }
643643 .font-view { padding: 16px 20px; }
@@ -723,7 +723,7 @@ img.img-box, .prose img.img-box, .tell-picture.img-box { display: block; width:
723723 radial-gradient(farthest-side at 100% 50%, var(--edge), transparent) right center / 10px 100% no-repeat scroll;
724724 }
725725 .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); }
727727 .prose table { width: max-content; min-width: 100%; max-width: none; font-size: 14px; }
728728 .prose th, .prose td { padding: 6px 10px; border: 1px solid var(--border); text-align: left; overflow-wrap: normal; }
729729 .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; }
11621162 background: color-mix(in srgb, var(--muted) 75%, transparent);
11631163 }
11641164 .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); }
11661166 /* Touch screens zoom a field set under 16px; the gutter, mirror and textarea share the size so they stay aligned. */
11671167 @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. */
outdated

Stale comment: the ring above is now an outline, not a shadow. Reword it. Also, content.ts:627 (.dxf-view svg:focus-visible) still hand-writes 2px solid var(--accent): use var(--ring).

11691169 @media (forced-colors: active) { .editor-wrap:focus-within { outline: 2px solid Highlight; outline-offset: 2px; } }
11701170 #editor-preview {
11711171 border: 1px solid var(--border); border-top: none;
test/a11y-landmarks.test.ts +1 −1
@@ -99,7 +99,7 @@ describe("the served stylesheet", () => {
9999 css = (await res.text()).replace(/\s+/g, " ");
100100 });
101101 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\)/);
103103 });
104104 test("keeps the skip link off-screen until focused, without moving layout", () => {
105105 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", () => {
outdated

Use an imported readFileSync instead of an inline require. Add a test case for a hand-written focus outline once the lint covers it.

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", () => {
5858
5959 test("the canvas has a visible focus ring of its own", async () => {
6060 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; }");
6262 });
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
110110 }
111111 expect(declared(".disclosure > summary")).toContain("min-height: 44px");
112112 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\)/);
114114 // Nothing anywhere, a narrow-screen block included, takes either back.
115115 const reaches = (selector: string): boolean =>
116116 /\bsummary\b/.test(selector) && (/^summary\b/.test(selector) || /disclosure|data-page-help/.test(selector));

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs