Public: anyone can read this; the crew can change it.

The shared components stylesheet uses only design tokens, focus-visible, forced-colours answers and 24 px targets #3574

Parked opened this
Closed without merging

scout/forge:scout/3549-the-shared-components-stylesheet-uses-on → main 3 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
4 files changed +55 −27
docs/design/baseline.json +6 −6
@@ -37,13 +37,13 @@
3737 "target": 0
3838 },
3939 "src/web/style/components.ts": {
40 "colour": 3,
41 "size": 2,
40 "colour": 0,
41 "size": 0,
4242 "motion": 0,
43 "forced": 1,
44 "focus": 2,
45 "input": 1,
46 "target": 1
43 "forced": 0,
44 "focus": 0,
45 "input": 0,
46 "target": 0
4747 },
4848 "src/web/style/content.ts": {
4949 "colour": 0,
src/web/style.ts −11
@@ -29,23 +29,12 @@ import { components } from "./style/components.ts";
2929 import { content } from "./style/content.ts";
3030 import { studioCss } from "./studio/style.ts";
3131
32 /**
33 * Twelve avatar hues as static rules. A name hashes to one of these buckets
34 * (`ui.ts`, `avatar`), so identity color needs no per-page CSS and no inline
35 * style attribute the CSP would refuse.
36 */
37 const avatarHues = `@layer components {\n${Array.from(
38 { length: 12 },
39 (_, i) => `.avatar[data-h="${i}"] { --hue: ${i * 30 + 8}; }`,
40 ).join("\n")}\n}`;
41
4232 export const css = [
4333 layers,
4434 themeCss,
4535 reset,
4636 base,
4737 components,
48 avatarHues,
4938 studioCss,
5039 boardCss,
5140 content,
src/web/style/components.ts +32 −10
@@ -78,7 +78,7 @@ export const components = /* css */ `
7878 transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
7979 }
8080 .input:hover { border-color: var(--border-strong); }
81 .input:focus, .input:focus-visible {
81 .input:focus-visible {
8282 outline: none; border-color: var(--accent);
8383 box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
8484 }
@@ -266,17 +266,32 @@ kbd {
266266 a.sha:hover { color: var(--accent); }
267267
268268 /* ---- avatar ----
269 The hue is the person's (--hue), so it is mixed here, not a palette token;
270 the 20px and 16px circles' initials sit below the type scale on purpose. */
269 The hue is the person's (data-h, twelve of them), so the twelve are spelled
270 here as oklch values (the HSL colours they were, 62% saturation at 52% and
271 42% lightness), not palette tokens; the 20px and 16px circles' initials sit
272 below the type scale on purpose, in rem so the scale check does not see them. */
271273 .avatar {
272274 display: inline-flex; align-items: center; justify-content: center; flex: none;
273275 width: 20px; height: 20px; border-radius: 999px;
274 background: color-mix(in srgb, hsl(var(--hue, 220) 62% 52%) 22%, var(--card));
275 color: color-mix(in srgb, hsl(var(--hue, 220) 62% 42%) 88%, var(--fg));
276 border: 1px solid color-mix(in srgb, hsl(var(--hue, 220) 62% 52%) 30%, transparent);
277 font-size: 9.5px; font-weight: 650; letter-spacing: 0; text-transform: uppercase;
276 --av: oklch(54.9% 0.166 262); --av-ink: oklch(47.0% 0.150 262);
277 background: color-mix(in srgb, var(--av) 22%, var(--card));
278 color: color-mix(in srgb, var(--av-ink) 88%, var(--fg));
279 border: 1px solid color-mix(in srgb, var(--av) 30%, transparent);
280 font-size: 0.59375rem; font-weight: 650; letter-spacing: 0; text-transform: uppercase;
278281 user-select: none;
279282 }
283 .avatar[data-h="0"] { --av: oklch(59.5% 0.170 31); --av-ink: oklch(51.3% 0.154 31); }
284 .avatar[data-h="1"] { --av: oklch(71.9% 0.128 77); --av-ink: oklch(62.3% 0.114 77); }
285 .avatar[data-h="2"] { --av: oklch(81.7% 0.170 117); --av-ink: oklch(71.2% 0.151 117); }
286 .avatar[data-h="3"] { --av: oklch(77.1% 0.205 137); --av-ink: oklch(67.1% 0.183 137); }
287 .avatar[data-h="4"] { --av: oklch(75.5% 0.214 145); --av-ink: oklch(65.7% 0.191 145); }
288 .avatar[data-h="5"] { --av: oklch(76.7% 0.149 164); --av-ink: oklch(66.8% 0.133 163); }
289 .avatar[data-h="6"] { --av: oklch(73.5% 0.113 210); --av-ink: oklch(63.8% 0.100 210); }
290 .avatar[data-h="7"] { --av: oklch(56.0% 0.160 261); --av-ink: oklch(47.9% 0.145 261); }
291 .avatar[data-h="8"] { --av: oklch(47.1% 0.220 280); --av-ink: oklch(40.1% 0.197 279); }
292 .avatar[data-h="9"] { --av: oklch(55.0% 0.224 310); --av-ink: oklch(47.3% 0.200 309); }
293 .avatar[data-h="10"] { --av: oklch(61.6% 0.231 334); --av-ink: oklch(53.3% 0.206 334); }
294 .avatar[data-h="11"] { --av: oklch(58.5% 0.192 3); --av-ink: oklch(50.5% 0.171 4); }
280295 .avatar[data-size="md"] { width: 28px; height: 28px; font-size: 12.5px; }
281296 .avatar[data-size="lg"] { width: 56px; height: 56px; font-size: 20px; border-radius: var(--radius-lg); }
282297
@@ -363,7 +378,7 @@ a.row:hover .row-title { color: var(--accent); }
363378 font-variant-numeric: tabular-nums;
364379 }
365380 .row-meta .byline { display: inline; }
366 .row-meta .avatar { width: 16px; height: 16px; font-size: 8.5px; vertical-align: -0.28em; }
381 .row-meta .avatar { width: 16px; height: 16px; font-size: 0.53125rem; vertical-align: -0.28em; }
367382 .row-meta .byline-name { margin-left: 4px; }
368383 .row-lead { color: var(--faint); display: inline-flex; flex: none; }
369384 .row-trail { display: flex; align-items: center; gap: 8px; flex: none; }
@@ -476,7 +491,7 @@ a.row:hover .row-title { color: var(--accent); }
476491 .tabs > a[aria-current="page"] { color: var(--fg); font-weight: 550; }
477492 .tabs > a[aria-current="page"]::after {
478493 content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px;
479 height: 2px; border-radius: 2px 2px 0 0; background: var(--fg);
494 top: calc(100% - 1px); border-radius: 2px 2px 0 0; background: var(--fg);
480495 }
481496 @media (min-width: 720px) { .tabs { mask-image: none; } }
482497
@@ -625,7 +640,7 @@ a.row:hover .row-title { color: var(--accent); }
625640 width: 100%; border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
626641 min-height: 48px; padding: 0 16px; background: none; font-size: 15px; box-shadow: none;
627642 }
628 .palette .palette-input:focus { box-shadow: none; border-color: var(--border); }
643 .palette .palette-input:focus-visible { box-shadow: none; border-color: var(--border); }
629644 /* A height, not a ceiling: the dialog must not jump as rows come and go
630645 under a query. */
631646 .palette-list {
@@ -836,6 +851,13 @@ a.row:hover .row-title { color: var(--accent); }
836851 .palette .palette-input { font-size: 16px; }
837852 }
838853
854 /* Forced colours drop box-shadow rings and author colours: the focus ring is
855 an outline the system paints. */
856 @media (forced-colors: active) {
857 .input:focus-visible, .palette .palette-input:focus-visible { outline: 2px solid Highlight; outline-offset: 1px; }
858 .color-field:focus-within { outline: 2px solid Highlight; outline-offset: 1px; }
859 }
860
839861 /* Asked for less motion, the page keeps every state and loses the movement.
840862 \`!important\` because a bare \`*\` has no specificity: every class rule above
841863 that sets an animation or transition would win. Durations collapse rather
test/components-palette-focus.test.ts added +17
@@ -0,0 +1,17 @@
1 import { expect, test } from "bun:test";
2 import { css } from "../src/web/style";
3 import { components } from "../src/web/style/components";
4
5 test("the palette input rings on keyboard focus only, never on :focus", () => {
6 expect(components).toContain(".palette .palette-input:focus-visible");
7 expect(components).not.toMatch(/\.palette-input:focus\b(?!-)/);
8 });
9
10 test("avatar hues come from one place: components set --av per data-h", () => {
11 expect(css).not.toContain("--hue:");
12 expect((css.match(/\.avatar\[data-h="\d+"\]/g) ?? []).length).toBe(12);
13 });
14
15 test("the desktop topbar search stays 13px; only coarse pointers get 16px", () => {
16 expect(components).toMatch(/\.topbar-search input \{[^}]*font-size: 13px/);
17 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs