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
scout/forge:scout/3549-the-shared-components-stylesheet-uses-on → main 3 commits fork
4 files
changed +55
−27
docs/design/baseline.json +6 −6
| @@ -37,13 +37,13 @@ | ||
| 37 | 37 | "target": 0 |
| 38 | 38 | }, |
| 39 | 39 | "src/web/style/components.ts": { |
| 40 | "colour": 3, | |
| 41 | "size": 2, | |
| 40 | "colour": 0, | |
| 41 | "size": 0, | |
| 42 | 42 | "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 | |
| 47 | 47 | }, |
| 48 | 48 | "src/web/style/content.ts": { |
| 49 | 49 | "colour": 0, |
src/web/style.ts −11
| @@ -29,23 +29,12 @@ import { components } from "./style/components.ts"; | ||
| 29 | 29 | import { content } from "./style/content.ts"; |
| 30 | 30 | import { studioCss } from "./studio/style.ts"; |
| 31 | 31 | |
| 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 | ||
| 42 | 32 | export const css = [ |
| 43 | 33 | layers, |
| 44 | 34 | themeCss, |
| 45 | 35 | reset, |
| 46 | 36 | base, |
| 47 | 37 | components, |
| 48 | avatarHues, | |
| 49 | 38 | studioCss, |
| 50 | 39 | boardCss, |
| 51 | 40 | content, |
src/web/style/components.ts +32 −10
| @@ -78,7 +78,7 @@ export const components = /* css */ ` | ||
| 78 | 78 | transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease); |
| 79 | 79 | } |
| 80 | 80 | .input:hover { border-color: var(--border-strong); } |
| 81 | .input:focus, .input:focus-visible { | |
| 81 | .input:focus-visible { | |
| 82 | 82 | outline: none; border-color: var(--accent); |
| 83 | 83 | box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); |
| 84 | 84 | } |
| @@ -266,17 +266,32 @@ kbd { | ||
| 266 | 266 | a.sha:hover { color: var(--accent); } |
| 267 | 267 | |
| 268 | 268 | /* ---- 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. */ | |
| 271 | 273 | .avatar { |
| 272 | 274 | display: inline-flex; align-items: center; justify-content: center; flex: none; |
| 273 | 275 | 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; | |
| 278 | 281 | user-select: none; |
| 279 | 282 | } |
| 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); } | |
| 280 | 295 | .avatar[data-size="md"] { width: 28px; height: 28px; font-size: 12.5px; } |
| 281 | 296 | .avatar[data-size="lg"] { width: 56px; height: 56px; font-size: 20px; border-radius: var(--radius-lg); } |
| 282 | 297 | |
| @@ -363,7 +378,7 @@ a.row:hover .row-title { color: var(--accent); } | ||
| 363 | 378 | font-variant-numeric: tabular-nums; |
| 364 | 379 | } |
| 365 | 380 | .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; } | |
| 367 | 382 | .row-meta .byline-name { margin-left: 4px; } |
| 368 | 383 | .row-lead { color: var(--faint); display: inline-flex; flex: none; } |
| 369 | 384 | .row-trail { display: flex; align-items: center; gap: 8px; flex: none; } |
| @@ -476,7 +491,7 @@ a.row:hover .row-title { color: var(--accent); } | ||
| 476 | 491 | .tabs > a[aria-current="page"] { color: var(--fg); font-weight: 550; } |
| 477 | 492 | .tabs > a[aria-current="page"]::after { |
| 478 | 493 | 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); | |
| 480 | 495 | } |
| 481 | 496 | @media (min-width: 720px) { .tabs { mask-image: none; } } |
| 482 | 497 | |
| @@ -625,7 +640,7 @@ a.row:hover .row-title { color: var(--accent); } | ||
| 625 | 640 | width: 100%; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; |
| 626 | 641 | min-height: 48px; padding: 0 16px; background: none; font-size: 15px; box-shadow: none; |
| 627 | 642 | } |
| 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); } | |
| 629 | 644 | /* A height, not a ceiling: the dialog must not jump as rows come and go |
| 630 | 645 | under a query. */ |
| 631 | 646 | .palette-list { |
| @@ -836,6 +851,13 @@ a.row:hover .row-title { color: var(--accent); } | ||
| 836 | 851 | .palette .palette-input { font-size: 16px; } |
| 837 | 852 | } |
| 838 | 853 | |
| 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 | ||
| 839 | 861 | /* Asked for less motion, the page keeps every state and loses the movement. |
| 840 | 862 | \`!important\` because a bare \`*\` has no specificity: every class rule above |
| 841 | 863 | 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 | }); |
new above
offline