@keystone-sites/marketing-design-system 1.0.16 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -26,6 +26,15 @@ files from their own `AGENTS.md`; they never copy them.
26
26
  - Never put `'use client'` on anything but a leaf island.
27
27
  - Never suppress a lint or type error. Never use `any` or `as` at a data boundary.
28
28
  - Never invent copy, a component API, or a file. Read it first; ask if unclear.
29
+ - Never let a component decide a product state. The package draws; the
30
+ consumer decides. Whether a control is live or disabled, a link or a
31
+ button, what it says, what it opens and who may use it comes in as a
32
+ prop (`href`, `onSelect`, `disabled`, `busy`, children, a slot) and is
33
+ drawn as given. No `locked`, `signedIn`, `account`, `plan` or other
34
+ product mode on a primitive, no baked-in ask, and no handler of the
35
+ package's own in place of the consumer's. A component may derive only
36
+ what is drawn (a grade's hue, a tier from a rank, a pager held at its
37
+ bound, "nothing to pick" in a filter), never what the reader is allowed.
29
38
  - Never commit, stage, or push unless asked in that turn.
30
39
 
31
40
  ## How the system is built
@@ -73,10 +82,13 @@ files from their own `AGENTS.md`; they never copy them.
73
82
  the type law plus a role color; a consumer styles `.copy[data-size]`, never
74
83
  a size class.
75
84
  - The Grader report's parts (Figma `ks-Grader`, "Components · Grader report &
76
- summary") are `primitives/report.tsx` (panel head, facts and chips, area
85
+ summary") are `primitives/report.tsx` (panel head, facts and chips, area
77
86
  cards, score and finding rows, stat cards), `primitives/report-nav.tsx`
78
87
  (the page switcher in the nav bar: chips from the first desktop anchor,
79
- a menu card below it), `primitives/keystone-score.tsx`
88
+ a menu card below it; each page is a link or the consumer's button, a
89
+ lock is a mark the consumer sets, and the card's foot is the consumer's
90
+ composition of `ReportNavWho`/`ReportNavControl`/`ReportNavAsk`),
91
+ `primitives/keystone-score.tsx`
80
92
  (the one arc: the Keystone Score) and, in `primitives/status.tsx`, the
81
93
  grade `Pill` and `ScoreRing` (an area's score is a ring, never an arc).
82
94
  Grades come from the model as `poor | fair | good | neutral`; a null value
@@ -8,8 +8,12 @@
8
8
  import { useEffect, useMemo, useState } from "react";
9
9
  import { fetchGraderGroup, type GraderSearchGroup, type GraderSuggestion } from "./grader";
10
10
 
11
- /** Keystroke settle time before a request goes out. */
12
- const DEBOUNCE_MS = 200;
11
+ /** Keystroke settle time before a request goes out: long enough that a
12
+ * name typed at speed is one or two searches, not one per letter. */
13
+ const DEBOUNCE_MS = 350;
14
+ /** Letters before a search is worth asking for — a single one matches
15
+ * everything and nothing. */
16
+ const MIN_QUERY = 2;
13
17
  /** Rows offered per group. */
14
18
  const MAX: Record<GraderSearchGroup, number> = { places: 5, web: 3 };
15
19
  const GROUPS: GraderSearchGroup[] = ["places", "web"];
@@ -88,9 +92,11 @@ function state(
88
92
  }
89
93
 
90
94
  /** `enabled` false parks the search (no fetch, `idle`) — the island uses
91
- * it once a business is chosen, so the chosen name is never looked up. */
95
+ * it once a business is chosen, so the chosen name is never looked up. A
96
+ * query shorter than `MIN_QUERY` is idle too. */
92
97
  export function useGraderSearch(query: string, enabled = true): GraderSearchState {
93
- const q = enabled ? query.trim() : "";
98
+ const trimmed = query.trim();
99
+ const q = enabled && trimmed.length >= MIN_QUERY ? trimmed : "";
94
100
  const [answer, setAnswer] = useState<Answer>(EMPTY_ANSWER);
95
101
 
96
102
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keystone-sites/marketing-design-system",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "Keystone's marketing design system: tokens, the tick grid, type, primitives, site chrome, and the landing kit. Source-shipped CSS and TSX for Next.js consumers.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -335,8 +335,15 @@
335
335
  /* The clipped circle hides the arrow's pass-through travel. */
336
336
  overflow: clip;
337
337
  }
338
- /* The body carries the size the control's --btn-size selects. */
338
+ /* The body carries the size the control's --btn-size selects; the glyph
339
+ box inside it is the square the arrows travel through. */
339
340
  .btn-arrow-body {
341
+ display: inline-flex;
342
+ align-items: center;
343
+ justify-content: center;
344
+ height: var(--_d);
345
+ }
346
+ .btn-arrow-glyph {
340
347
  display: grid;
341
348
  place-items: center;
342
349
  width: var(--_d);
@@ -404,6 +411,73 @@
404
411
  --_glyph-loading: var(--color-brown-700);
405
412
  --loading-track: var(--color-brown-300);
406
413
  }
414
+ /* Ink: the dark block inside the Grader's boxed field (ks-Grader
415
+ 224:7780); its words and glyph are the page's ground. */
416
+ .btn-arrow[data-chrome="ink"] {
417
+ --_bg: var(--color-text-100);
418
+ --_bg-hover: var(--color-text-000);
419
+ --_bg-disabled: var(--color-bg-300);
420
+ --_bg-loading: var(--color-text-200);
421
+ --_glyph: var(--color-bg-000);
422
+ --_glyph-disabled: var(--color-text-600);
423
+ --_glyph-loading: var(--color-bg-000);
424
+ }
425
+
426
+ /* The box (ks-Grader 224:7780 · 226:7820 · 226:7834): square corners on
427
+ radius/xs, the 24 glyph with its padding setting the height — the name
428
+ drawn before it at lg (48 tall, 12 around) and md (40, 8 around), the
429
+ glyph alone at sm (40, 8 around). The glyph box is the glyph's own
430
+ square, so the pass-through clips there and never crosses the words. */
431
+ .btn-arrow[data-shape="box"] {
432
+ border-radius: var(--radius-xs);
433
+ }
434
+ .btn-arrow[data-shape="box"] .btn-arrow-body {
435
+ box-sizing: border-box;
436
+ gap: var(--space-md);
437
+ height: var(--_box-h);
438
+ padding-inline: var(--_box-pl) var(--_box-pr);
439
+ --_d: 24px;
440
+ --_g: 24px;
441
+ }
442
+ .btn-arrow[data-shape="box"] .btn-arrow-glyph {
443
+ overflow: clip;
444
+ }
445
+ /* Above the hover fill, as the glyph is. */
446
+ .btn-arrow-words {
447
+ position: relative;
448
+ z-index: 1;
449
+ white-space: nowrap;
450
+ }
451
+ @container style(--btn-size: lg) {
452
+ .btn-arrow[data-shape="box"] .btn-arrow-body {
453
+ --_box-h: 48px;
454
+ --_box-pl: var(--space-2xl);
455
+ --_box-pr: var(--space-xl);
456
+ --font: var(--ts-text-xl-regular-font);
457
+ --ls: var(--ts-text-xl-regular-ls);
458
+ --opsz: var(--ts-text-xl-regular-opsz);
459
+ }
460
+ }
461
+ @container style(--btn-size: md) {
462
+ .btn-arrow[data-shape="box"] .btn-arrow-body {
463
+ --_box-h: 40px;
464
+ --_box-pl: var(--space-xl);
465
+ --_box-pr: var(--space-lg);
466
+ --font: var(--ts-text-lg-regular-font);
467
+ --ls: var(--ts-text-lg-regular-ls);
468
+ --opsz: var(--ts-text-lg-regular-opsz);
469
+ }
470
+ }
471
+ @container style(--btn-size: sm) {
472
+ .btn-arrow[data-shape="box"] .btn-arrow-body {
473
+ --_box-h: 40px;
474
+ --_box-pl: var(--space-md);
475
+ --_box-pr: var(--space-md);
476
+ }
477
+ .btn-arrow[data-shape="box"] .btn-arrow-words {
478
+ display: none;
479
+ }
480
+ }
407
481
 
408
482
  @media (hover: hover) {
409
483
  .btn-arrow:not(:disabled):not([data-state="disabled"]):not([data-loading]):hover::before {
@@ -223,13 +223,16 @@ export function ButtonGhost({
223
223
 
224
224
  interface ButtonArrowProps {
225
225
  size?: "lg" | "md" | "sm" | "inherit";
226
- chrome?: "teal" | "gray" | "brown";
226
+ chrome?: "teal" | "gray" | "brown" | "ink";
227
+ /** The round control, or the square-cornered block that draws its
228
+ * name before the glyph (at lg and md; sm shows the glyph alone). */
229
+ shape?: "pill" | "box";
227
230
  /** A URL renders link chrome; null renders disabled non-link chrome. */
228
231
  href?: string | null;
229
232
  disabled?: boolean;
230
233
  loading?: boolean;
231
234
  forceState?: ForceableState | "disabled";
232
- /** The control is icon-only; the name is mandatory. */
235
+ /** The control's name: spoken on the pill, drawn on the box. */
233
236
  label: string;
234
237
  type?: "button" | "submit";
235
238
  onClick?: MouseEventHandler<HTMLElement>;
@@ -239,6 +242,7 @@ interface ButtonArrowProps {
239
242
  export function ButtonArrow({
240
243
  size = "lg",
241
244
  chrome = "teal",
245
+ shape = "pill",
242
246
  href,
243
247
  disabled = false,
244
248
  loading = false,
@@ -250,15 +254,18 @@ export function ButtonArrow({
250
254
  }: ButtonArrowProps) {
251
255
  const glyph = (
252
256
  <span className="btn-arrow-body">
253
- {loading ? (
254
- <IconLoadingCircle />
255
- ) : (
256
- <>
257
- {/* Stacked glyphs create the hover pass-through. */}
258
- <IconArrowRight className="btn-arrow-main" />
259
- <IconArrowRight className="btn-arrow-ghost" />
260
- </>
261
- )}
257
+ {shape === "box" && <span className="type type-fixed btn-arrow-words">{label}</span>}
258
+ <span className="btn-arrow-glyph">
259
+ {loading ? (
260
+ <IconLoadingCircle />
261
+ ) : (
262
+ <>
263
+ {/* Stacked glyphs create the hover pass-through. */}
264
+ <IconArrowRight className="btn-arrow-main" />
265
+ <IconArrowRight className="btn-arrow-ghost" />
266
+ </>
267
+ )}
268
+ </span>
262
269
  </span>
263
270
  );
264
271
  if (typeof href === "string") {
@@ -268,6 +275,7 @@ export function ButtonArrow({
268
275
  className="btn-arrow"
269
276
  data-size={sizeAttr(size)}
270
277
  data-chrome={chrome}
278
+ data-shape={shape}
271
279
  data-state={forceState}
272
280
  aria-label={label}
273
281
  >
@@ -281,6 +289,7 @@ export function ButtonArrow({
281
289
  className="btn-arrow"
282
290
  data-size={sizeAttr(size)}
283
291
  data-chrome={chrome}
292
+ data-shape={shape}
284
293
  data-state="disabled"
285
294
  aria-disabled="true"
286
295
  aria-label={label}
@@ -295,6 +304,7 @@ export function ButtonArrow({
295
304
  className="btn-arrow"
296
305
  data-size={sizeAttr(size)}
297
306
  data-chrome={chrome}
307
+ data-shape={shape}
298
308
  data-state={forceState}
299
309
  data-loading={loading || undefined}
300
310
  disabled={disabled}
@@ -181,6 +181,50 @@
181
181
  pointer-events: auto;
182
182
  }
183
183
 
184
+ /* The box (ks-Grader 64:5612, Index/Search): the field on radius/md, the
185
+ ink submit a block inside its 4px inset. lg and md are the pill's
186
+ heights (56 · 48); sm is 48 too, the glyph-only submit (226:7862) at
187
+ the same 40 as md's — the phone's size, where the words would crowd
188
+ the field. The placeholder reads text/lg at md and sm where the pill's
189
+ md reads text/md. The design draws the submit in ink while the field
190
+ is empty, so the box keeps its chrome there and only stays inert; its
191
+ resting hover is bg/300's ring on the resting border, and focus and
192
+ filled are the pill's. */
193
+ .grader[data-shape="box"] .grader-field {
194
+ border-radius: var(--radius-md);
195
+ padding-inline: var(--space-lg) var(--space-xs);
196
+ }
197
+ @container style(--grader-size: md) {
198
+ .grader[data-shape="box"] .grader-field {
199
+ --font: var(--ts-text-lg-light-font);
200
+ --ls: var(--ts-text-lg-light-ls);
201
+ --opsz: var(--ts-text-lg-light-opsz);
202
+ }
203
+ }
204
+ @container style(--grader-size: sm) {
205
+ .grader[data-shape="box"] .grader-field {
206
+ height: 48px;
207
+ --font: var(--ts-text-lg-light-font);
208
+ --ls: var(--ts-text-lg-light-ls);
209
+ --opsz: var(--ts-text-lg-light-opsz);
210
+ }
211
+ }
212
+ @media (hover: hover) {
213
+ .grader[data-shape="box"]:not([data-error])
214
+ .grader-field:not(:focus-within):has(input:placeholder-shown):hover {
215
+ --_border: var(--color-border-000);
216
+ --_ring: var(--color-bg-300);
217
+ }
218
+ }
219
+ .grader[data-shape="box"][data-state="hover"]:not([data-error]) .grader-field {
220
+ --_border: var(--color-border-000);
221
+ --_ring: var(--color-bg-300);
222
+ }
223
+ .grader[data-shape="box"] .grader-field .btn-arrow:not(:disabled):not([data-loading]) {
224
+ background: var(--_bg);
225
+ color: var(--_glyph);
226
+ }
227
+
184
228
  /* The suggestion menu overlays following content without shifting layout.
185
229
  It fits its rows; the search hook already caps how many each group shows.
186
230
  Sections are their own stacking contexts (grid/engine.css), so the one
@@ -22,9 +22,12 @@ const GROUP_LABELS: GraderMenuLabels = { places: "Google Places", web: "Websites
22
22
  interface GraderInputProps {
23
23
  size?: "lg" | "md" | "sm" | "inherit";
24
24
  chrome?: "teal" | "brown";
25
+ /** The pill with its round arrow, or the box (ks-Grader 64:5612) whose
26
+ * ink submit draws the submit label as its words from md up. */
27
+ shape?: "pill" | "box";
25
28
  label?: string;
26
29
  placeholder?: string;
27
- /** The submit control's accessible name. */
30
+ /** The submit control's name: spoken on the pill, drawn on the box. */
28
31
  submitLabel?: string;
29
32
  /** The suggestion listbox's accessible name. */
30
33
  menuLabel?: string;
@@ -47,6 +50,7 @@ interface ActiveRow {
47
50
  export function GraderInput({
48
51
  size = "lg",
49
52
  chrome = "teal",
53
+ shape = "pill",
50
54
  label = "Your business name",
51
55
  placeholder = "Your business name",
52
56
  submitLabel = "Grade my site",
@@ -211,6 +215,7 @@ export function GraderInput({
211
215
  className="grader"
212
216
  data-size={size === "inherit" ? undefined : size}
213
217
  data-chrome={chrome}
218
+ data-shape={shape}
214
219
  data-error={error ? "" : undefined}
215
220
  data-state={forceState}
216
221
  data-open={open || undefined}
@@ -256,7 +261,9 @@ export function GraderInput({
256
261
  <ButtonArrow
257
262
  type="submit"
258
263
  size="inherit"
259
- chrome={error ? "gray" : chrome}
264
+ shape={shape}
265
+ // The box's submit is ink in every state; the pill's goes gray on error.
266
+ chrome={shape === "box" ? "ink" : error ? "gray" : chrome}
260
267
  // Show loading during search and deferred hand-off.
261
268
  loading={pending || searching}
262
269
  label={submitLabel}
@@ -1,12 +1,15 @@
1
1
  /* The report nav (ks-Grader grader-nav 64:8505): the page switcher in
2
- the nav bar once a report is unlocked. From the first desktop anchor
3
- the pages are chips in the bar, the current one on white. Below it
4
- the current page's name and a menu button open a card under the bar:
5
- the pages as rows with their score rings, the current one muted, and
6
- the account at the foot. The card hangs from the bar it is mounted
7
- in — the host is the positioned ancestor — spanning it inside
8
- `--rnav-card-inset` on the phone and standing under the controls at
9
- its own width from the tablet anchor. */
2
+ the nav bar once a report is read. From the first desktop anchor the
3
+ pages are chips in the bar, the current one on white, each area's
4
+ with its score ring after its name from the second. Below it the
5
+ menu button alone opens a card under the bar: the pages as rows
6
+ with their score rings, the current one muted, and the
7
+ account at the foot. Locked (205:21968, 245:12939), a lock stands
8
+ where an area's ring was and the chips wait for the second desktop
9
+ anchor. The card hangs from the bar it is mounted in — the host is
10
+ the positioned ancestor — spanning it inside `--rnav-card-inset` on
11
+ the phone and standing under the controls at its own width from the
12
+ tablet anchor. */
10
13
 
11
14
  /* Designed constants for this file. */
12
15
  :root {
@@ -14,6 +17,10 @@
14
17
  --rnav-row-h: 64px;
15
18
  --rnav-foot-h: 80px;
16
19
  --rnav-card-w: 350px;
20
+ /* The lock where a ring stood: 16 on a chip (205:21968), the ring's
21
+ 32 box on a card row (256:15675). */
22
+ --rnav-lock: 16px;
23
+ --rnav-lock-row: 32px;
17
24
  }
18
25
 
19
26
  /* ---- the chips (rd1 and up) ---- */
@@ -35,14 +42,19 @@
35
42
  .rnav-chip {
36
43
  display: inline-flex;
37
44
  align-items: center;
45
+ gap: var(--space-md);
38
46
  box-sizing: border-box;
39
47
  height: var(--rnav-control-h);
48
+ margin: var(--space-none);
49
+ padding-block: var(--space-none);
40
50
  padding-inline: var(--space-lg);
51
+ border: 0;
41
52
  border-radius: var(--radius-xs);
42
53
  background: var(--color-bg-200);
43
54
  color: var(--color-text-300);
44
55
  text-decoration: none;
45
56
  white-space: nowrap;
57
+ cursor: pointer;
46
58
  transition:
47
59
  background-color var(--motion-hover-duration) var(--motion-hover-ease),
48
60
  color var(--motion-hover-duration) var(--motion-hover-ease);
@@ -61,6 +73,19 @@
61
73
  box-shadow: 0 0 0 var(--ring-w) var(--color-border-200);
62
74
  }
63
75
 
76
+ /* The nav's rings carry no grade colour (64:8505, 214:27889): the sweep
77
+ in border/400 on a border/100 track, the number in text/200, on a
78
+ chip and in the card alike. The grade stays on the ring as data. */
79
+ .rnav-chip .score-ring,
80
+ .rnav-page .score-ring {
81
+ --_dot: var(--color-border-400);
82
+ color: var(--color-text-200);
83
+ }
84
+ .rnav-chip .score-ring .arc-track,
85
+ .rnav-page .score-ring .arc-track {
86
+ stroke: var(--color-border-100);
87
+ }
88
+
64
89
  /* ---- the menu (below rd1) ---- */
65
90
 
66
91
  /* The controls stand at the bar's end, whatever precedes them. */
@@ -71,37 +96,6 @@
71
96
  margin-inline-start: auto;
72
97
  }
73
98
 
74
- /* The current page: its name and the chevron, which turns while the
75
- card is open. */
76
- .rnav-current {
77
- appearance: none;
78
- display: inline-flex;
79
- align-items: center;
80
- gap: var(--fitem-gap);
81
- box-sizing: border-box;
82
- height: var(--rnav-control-h);
83
- margin: var(--space-none);
84
- padding-inline: var(--space-lg);
85
- border: 0;
86
- border-radius: var(--radius-xs);
87
- background: var(--color-bg-200);
88
- color: var(--color-text-300);
89
- white-space: nowrap;
90
- cursor: pointer;
91
- transition:
92
- background-color var(--motion-hover-duration) var(--motion-hover-ease),
93
- color var(--motion-hover-duration) var(--motion-hover-ease);
94
- }
95
- .rnav-current-tick {
96
- flex: none;
97
- color: var(--color-border-400);
98
- transition: rotate var(--motion-drawer-duration) var(--motion-drawer-ease);
99
- }
100
- .rnav-menu[data-open] .rnav-current-tick {
101
- rotate: 180deg;
102
- transition: rotate var(--motion-drawer-duration) var(--motion-drawer-ease-open);
103
- }
104
-
105
99
  /* The menu button (grader/nav-toggle 214:22707): the glyph swaps for
106
100
  the close while the card is open and the ground deepens a step. */
107
101
  .rnav-toggle {
@@ -147,15 +141,10 @@
147
141
  scale: 1;
148
142
  }
149
143
  @media (hover: hover) {
150
- .rnav-current:hover {
151
- background: var(--color-bg-300);
152
- color: var(--color-text-100);
153
- }
154
144
  .rnav-toggle:hover {
155
145
  background: var(--color-bg-300);
156
146
  }
157
147
  }
158
- .rnav-current:focus-visible,
159
148
  .rnav-toggle:focus-visible {
160
149
  outline: none;
161
150
  box-shadow: 0 0 0 var(--ring-w) var(--color-border-200);
@@ -218,10 +207,16 @@
218
207
  justify-content: space-between;
219
208
  gap: var(--space-lg);
220
209
  box-sizing: border-box;
210
+ width: 100%;
221
211
  min-height: var(--rnav-row-h);
212
+ margin: var(--space-none);
222
213
  padding-inline: var(--space-xl);
214
+ border: 0;
215
+ background: none;
223
216
  color: var(--color-text-300);
217
+ text-align: start;
224
218
  text-decoration: none;
219
+ cursor: pointer;
225
220
  transition: color var(--motion-hover-duration) var(--motion-hover-ease);
226
221
  }
227
222
  .rnav-page[aria-current="page"] {
@@ -230,6 +225,20 @@
230
225
  .rnav-page-label {
231
226
  min-width: 0;
232
227
  }
228
+ /* The lock where a ring stood (205:21968 at 16 on a chip, 256:15675 at
229
+ 20 inside the row's 32). */
230
+ .rnav-lock {
231
+ display: grid;
232
+ place-items: center;
233
+ flex: none;
234
+ width: var(--rnav-lock-row);
235
+ height: var(--rnav-lock-row);
236
+ color: var(--color-border-400);
237
+ }
238
+ .rnav-chip .rnav-lock {
239
+ width: var(--rnav-lock);
240
+ height: var(--rnav-lock);
241
+ }
233
242
  @media (hover: hover) {
234
243
  .rnav-page:not([aria-current="page"]):hover {
235
244
  color: var(--color-text-100);
@@ -300,6 +309,31 @@
300
309
  outline: none;
301
310
  box-shadow: 0 0 0 var(--ring-w) var(--color-border-200);
302
311
  }
312
+ /* The locked card's ask (256:15675): the dark control, across the foot. */
313
+ .rnav-ask {
314
+ appearance: none;
315
+ width: 100%;
316
+ height: var(--rnav-control-h);
317
+ margin: var(--space-none);
318
+ padding-inline: var(--space-xl);
319
+ border: 0;
320
+ border-radius: var(--radius-xs);
321
+ background: var(--color-text-200);
322
+ color: var(--color-bg-200);
323
+ cursor: pointer;
324
+ transition:
325
+ background-color var(--motion-hover-duration) var(--motion-hover-ease),
326
+ color var(--motion-hover-duration) var(--motion-hover-ease);
327
+ }
328
+ @media (hover: hover) {
329
+ .rnav-ask:hover {
330
+ color: var(--color-bg-000);
331
+ }
332
+ }
333
+ .rnav-ask:focus-visible {
334
+ outline: none;
335
+ box-shadow: 0 0 0 var(--ring-w) var(--color-border-200);
336
+ }
303
337
 
304
338
  /* From the tablet anchor the card stands under the controls at its own
305
339
  width, flush with the bar's end. */
@@ -311,7 +345,13 @@
311
345
  }
312
346
  }
313
347
 
314
- /* From the first desktop anchor the chips take the menu's place. */
348
+ /* From the first desktop anchor the chips take the menu's place, by
349
+ name alone: the first desktop band has no room for five ringed chips
350
+ beside the control that shares the bar. The rings join from the
351
+ second anchor (64:8505 is drawn at 1344). A locked report's chips
352
+ carry locks instead, and those five plus the control fit only from
353
+ the same anchor, so below it the menu stands on the phone and the
354
+ tablet alike (245:12939). */
315
355
  @container (--rd1) {
316
356
  .rnav-chips {
317
357
  display: flex;
@@ -319,4 +359,24 @@
319
359
  .rnav-menu {
320
360
  display: none;
321
361
  }
362
+ .rnav-chips[data-locked] {
363
+ display: none;
364
+ }
365
+ .rnav-menu[data-locked] {
366
+ display: flex;
367
+ }
368
+ .rnav-chip .score-ring {
369
+ display: none;
370
+ }
371
+ }
372
+ @container (--rd2) {
373
+ .rnav-chip .score-ring {
374
+ display: inline-grid;
375
+ }
376
+ .rnav-chips[data-locked] {
377
+ display: flex;
378
+ }
379
+ .rnav-menu[data-locked] {
380
+ display: none;
381
+ }
322
382
  }
@@ -1,17 +1,28 @@
1
1
  "use client";
2
2
 
3
3
  /** The report's page switcher (ks-Grader grader-nav, 64:8505), standing
4
- * in the nav bar once a report is unlocked. From the first desktop
5
- * anchor the pages are chips in the bar (`ReportNavChips`): names only,
6
- * the current one on white. Below it the bar holds the current page's
7
- * name with a chevron and a menu button (`ReportNavMenu`); either opens
8
- * a card under the bar with the pages as rows, each with its score as a
9
- * small ring — an unscored page an empty ring with a dash, never a
10
- * number — the current one muted, ending in who is signed in and the
11
- * way out. The card hangs from the bar it is mounted in: the host is
12
- * the positioned ancestor, and sets `--rnav-card-inset` to its gutter
13
- * so the card spans the phone inside the margins. Picking a page, the
14
- * close button, a tap outside, Escape or focus leaving put the card
4
+ * in the nav bar once a report is read. From the first desktop anchor
5
+ * the pages are chips in the bar (`ReportNavChips`), the current one on
6
+ * white; from the second each area's carries its score as a small ring
7
+ * after its name, the whole report's page staying name alone. Below it
8
+ * the bar holds the menu button alone (`ReportNavMenu`, 214:27280,
9
+ * 214:27670); it opens a card under the bar with the pages as rows, each
10
+ * with its score as a small ring — an unscored page an empty ring with a
11
+ * dash, never a number — the current one muted, ending in whatever foot
12
+ * the host gives it.
13
+ *
14
+ * This draws; the host decides. A page is a link (`href`) or a button
15
+ * (`onSelect`) — what a page the reader may not open yet does is the
16
+ * host's call. A page marked `lock` draws a lock where its ring would be
17
+ * (205:21968, 245:12939) and the stylesheet holds the chips for the
18
+ * second desktop anchor; nothing here knows why it is locked. The foot
19
+ * is the host's: `ReportNavWho`, `ReportNavControl` and `ReportNavAsk`
20
+ * are the parts it is drawn from.
21
+ *
22
+ * The card hangs from the bar it is mounted in: the host is the
23
+ * positioned ancestor, and sets `--rnav-card-inset` to its gutter so the
24
+ * card spans the phone inside the margins. Picking anything in the card,
25
+ * the close button, a tap outside, Escape or focus leaving put the card
15
26
  * away; focus goes into the card on open and back to the opener on
16
27
  * close. Styles in report-nav.css (`rnav-`). */
17
28
 
@@ -22,19 +33,30 @@ import {
22
33
  type FocusEvent,
23
34
  type KeyboardEvent,
24
35
  type MouseEvent,
36
+ type ReactNode,
25
37
  } from "react";
26
- import { IconNavMenu, IconNavTrigger } from "../icons";
38
+ import { IconLock, IconNavMenu } from "../icons";
27
39
  import { usePopover } from "../lib/use-popover";
28
40
  import { ScoreRing, type Grade } from "./status";
29
41
 
30
42
  export interface ReportNavPage<Id extends string> {
31
43
  id: Id;
32
44
  label: string;
33
- href: string;
45
+ /** The page as a link; without one the control is a button calling
46
+ * `onSelect`. */
47
+ href?: string;
48
+ onSelect?: () => void;
34
49
  /** The page's score on 100; null where it could not be scored. */
35
50
  score: number | null;
36
51
  grade: Grade;
37
- /** Attributes the host adds to the link (tracking). */
52
+ /** The whole report's page: its chip carries its name alone where an
53
+ * area's carries a ring (64:8505); the card's row rings it like the
54
+ * rest. */
55
+ overview?: boolean;
56
+ /** Set, a lock stands where the ring would, and the control is named
57
+ * after the label with this: "Website, Locked". */
58
+ lock?: string;
59
+ /** Attributes the host adds to the control (tracking, a hand-off). */
38
60
  attrs?: Record<string, string>;
39
61
  }
40
62
 
@@ -49,65 +71,147 @@ export interface ReportNavCopy {
49
71
  unscored: string;
50
72
  }
51
73
 
52
- export interface ReportNavAccount {
53
- /** The line over the name: "Signed in as". */
54
- label: string;
55
- who: string;
56
- signOut: string;
57
- onSignOut: () => void;
58
- /** The sign-out is under way; the control waits. */
59
- busy?: boolean;
74
+ /** The lock's size where a ring stood (205:21968 the chip's 16, 256:15675
75
+ * the card row's 20 inside the ring's 32). */
76
+ const LOCK_CHIP = 16;
77
+ const LOCK_ROW = 20;
78
+
79
+ /** Marks a control in the card that puts the card away when picked. */
80
+ const DISMISS = "data-rnav-dismiss";
81
+ const dismiss = { [DISMISS]: "" };
82
+
83
+ function LockMark({ size }: { size: number }) {
84
+ return (
85
+ <span className="rnav-lock" aria-hidden="true">
86
+ <IconLock size={size} />
87
+ </span>
88
+ );
60
89
  }
61
90
 
62
- /** The pages as chips in the bar, from the first desktop anchor. */
91
+ /** One page as its control: a link or a button, named after its lock
92
+ * when it has one, carrying the host's attributes. */
93
+ function PageControl<Id extends string>({
94
+ page,
95
+ current,
96
+ className,
97
+ children,
98
+ }: {
99
+ page: ReportNavPage<Id>;
100
+ current: Id;
101
+ className: string;
102
+ children: ReactNode;
103
+ }) {
104
+ const name = page.lock ? `${page.label}, ${page.lock}` : undefined;
105
+ if (page.href) {
106
+ return (
107
+ <a
108
+ className={className}
109
+ href={page.href}
110
+ aria-label={name}
111
+ aria-current={page.id === current ? "page" : undefined}
112
+ {...dismiss}
113
+ {...page.attrs}
114
+ >
115
+ {children}
116
+ </a>
117
+ );
118
+ }
119
+ return (
120
+ <button
121
+ type="button"
122
+ className={className}
123
+ aria-label={name}
124
+ onClick={page.onSelect}
125
+ {...dismiss}
126
+ {...page.attrs}
127
+ >
128
+ {children}
129
+ </button>
130
+ );
131
+ }
132
+
133
+ /** After a page's name: its ring, or its lock. */
134
+ function PageMark<Id extends string>({
135
+ page,
136
+ size,
137
+ lock,
138
+ copy,
139
+ }: {
140
+ page: ReportNavPage<Id>;
141
+ size: "xs" | "sm";
142
+ lock: number;
143
+ copy: Pick<ReportNavCopy, "score" | "unscored">;
144
+ }) {
145
+ if (page.lock) return <LockMark size={lock} />;
146
+ return (
147
+ <ScoreRing
148
+ value={page.score}
149
+ grade={page.grade}
150
+ size={size}
151
+ label={page.score == null ? copy.unscored : copy.score}
152
+ >
153
+ —
154
+ </ScoreRing>
155
+ );
156
+ }
157
+
158
+ /** The pages as chips in the bar, from the first desktop anchor: an
159
+ * area's name with its score ring (a dash where it could not be
160
+ * scored; the stylesheet shows it from the second anchor) or its lock,
161
+ * the overview's name alone. With any page locked the list is marked
162
+ * and the stylesheet holds it for the second desktop anchor. */
63
163
  export function ReportNavChips<Id extends string>({
64
164
  pages,
65
165
  current,
66
- label,
166
+ copy,
67
167
  }: {
68
168
  pages: readonly ReportNavPage<Id>[];
69
169
  current: Id;
70
- /** Accessible name of the list. */
71
- label: string;
170
+ copy: Pick<ReportNavCopy, "pages" | "score" | "unscored">;
72
171
  }) {
172
+ const locked = pages.some((p) => p.lock);
73
173
  return (
74
- <ul className="rnav-chips" aria-label={label}>
174
+ <ul className="rnav-chips" aria-label={copy.pages} data-locked={locked ? "" : undefined}>
75
175
  {pages.map((page) => (
76
176
  <li key={page.id} className="rnav-chips-item">
77
- <a
177
+ <PageControl
178
+ page={page}
179
+ current={current}
78
180
  className="type type-fixed ts-text-md-medium rnav-chip"
79
- href={page.href}
80
- aria-current={page.id === current ? "page" : undefined}
81
- {...page.attrs}
82
181
  >
83
- {page.label}
84
- </a>
182
+ <span aria-hidden={page.lock ? true : undefined}>{page.label}</span>
183
+ {(!page.overview || page.lock) && (
184
+ <PageMark page={page} size="xs" lock={LOCK_CHIP} copy={copy} />
185
+ )}
186
+ </PageControl>
85
187
  </li>
86
188
  ))}
87
189
  </ul>
88
190
  );
89
191
  }
90
192
 
91
- /** The current page and the menu button, below the first desktop
92
- * anchor, and the card they open. `account` is the signed-in reader's
93
- * foot — who, and the way out; a reader with no session has no foot. */
193
+ /** The menu button below the first desktop anchor, and the card it
194
+ * opens (214:27280, 214:27670): a row per page, each with its ring or
195
+ * lock, and the host's `foot` under them when there is one. With any
196
+ * page locked the menu is marked and the stylesheet keeps it through
197
+ * the first desktop anchor, where the chips would otherwise take over. */
94
198
  export function ReportNavMenu<Id extends string>({
95
199
  pages,
96
200
  current,
97
201
  copy,
98
- account,
202
+ foot,
99
203
  }: {
100
204
  pages: readonly ReportNavPage<Id>[];
101
205
  current: Id;
102
206
  copy: ReportNavCopy;
103
- account?: ReportNavAccount;
207
+ foot?: ReactNode;
104
208
  }) {
105
209
  const { open, setOpen, rootRef } = usePopover<HTMLDivElement>();
106
210
  const cardRef = useRef<HTMLDivElement>(null);
107
211
  /* The control that opened the card takes focus back when it closes. */
108
212
  const openerRef = useRef<HTMLButtonElement | null>(null);
109
213
  const cardId = useId();
110
- const page = pages.find((p) => p.id === current);
214
+ const locked = pages.some((p) => p.lock);
111
215
 
112
216
  useEffect(() => {
113
217
  if (open) cardRef.current?.focus({ preventScroll: true });
@@ -132,9 +236,11 @@ export function ReportNavMenu<Id extends string>({
132
236
  const next = event.relatedTarget;
133
237
  if (open && (!(next instanceof Node) || !event.currentTarget.contains(next))) setOpen(false);
134
238
  };
135
- /* A page picked: the link navigates; the card does not wait for it. */
239
+ /* A page picked, or the foot's ask made, puts the card away: a link
240
+ navigates and the card does not wait for it; a hand-off opens
241
+ elsewhere. A control that waits (`ReportNavControl`) keeps the card. */
136
242
  const onCardClick = (event: MouseEvent<HTMLDivElement>) => {
137
- if (event.target instanceof Element && event.target.closest("a")) setOpen(false);
243
+ if (event.target instanceof Element && event.target.closest(`[${DISMISS}]`)) setOpen(false);
138
244
  };
139
245
 
140
246
  return (
@@ -142,19 +248,10 @@ export function ReportNavMenu<Id extends string>({
142
248
  ref={rootRef}
143
249
  className="rnav-menu"
144
250
  data-open={open || undefined}
251
+ data-locked={locked ? "" : undefined}
145
252
  onKeyDown={onKeyDown}
146
253
  onBlur={onBlur}
147
254
  >
148
- <button
149
- type="button"
150
- className="type type-fixed ts-text-md-medium rnav-current"
151
- aria-expanded={open}
152
- aria-controls={cardId}
153
- onClick={toggle}
154
- >
155
- {page?.label}
156
- <IconNavTrigger className="rnav-current-tick" variant="chevron" />
157
- </button>
158
255
  <button
159
256
  type="button"
160
257
  className="rnav-toggle"
@@ -179,46 +276,78 @@ export function ReportNavMenu<Id extends string>({
179
276
  <ul className="rnav-pages" aria-label={copy.pages}>
180
277
  {pages.map((p) => (
181
278
  <li key={p.id} className="rnav-row">
182
- <a
279
+ <PageControl
280
+ page={p}
281
+ current={current}
183
282
  className="type type-fixed ts-text-md-medium rnav-page"
184
- href={p.href}
185
- aria-current={p.id === current ? "page" : undefined}
186
- {...p.attrs}
187
283
  >
188
- <span className="rnav-page-label">{p.label}</span>
189
- <ScoreRing
190
- value={p.score}
191
- grade={p.grade}
192
- size="sm"
193
- label={p.score == null ? copy.unscored : copy.score}
194
- >
195
- —
196
- </ScoreRing>
197
- </a>
284
+ <span className="rnav-page-label" aria-hidden={p.lock ? true : undefined}>
285
+ {p.label}
286
+ </span>
287
+ <PageMark page={p} size="sm" lock={LOCK_ROW} copy={copy} />
288
+ </PageControl>
198
289
  </li>
199
290
  ))}
200
291
  </ul>
201
- {account && (
202
- <div className="rnav-foot">
203
- <span className="rnav-who">
204
- <span className="type type-fixed ts-text-xs-regular rnav-who-label">
205
- {account.label}
206
- </span>
207
- <span className="type type-fixed ts-text-sm-regular rnav-who-name">
208
- {account.who}
209
- </span>
210
- </span>
211
- <button
212
- type="button"
213
- className="type type-fixed ts-text-sm-medium rnav-signout"
214
- disabled={account.busy}
215
- onClick={account.onSignOut}
216
- >
217
- {account.signOut}
218
- </button>
219
- </div>
220
- )}
292
+ {foot && <div className="rnav-foot">{foot}</div>}
221
293
  </div>
222
294
  </div>
223
295
  );
224
296
  }
297
+
298
+ /** The foot's two lines: a label over a name ("Signed in as" / who). */
299
+ export function ReportNavWho({ label, who }: { label: string; who: string }) {
300
+ return (
301
+ <span className="rnav-who">
302
+ <span className="type type-fixed ts-text-xs-regular rnav-who-label">{label}</span>
303
+ <span className="type type-fixed ts-text-sm-regular rnav-who-name">{who}</span>
304
+ </span>
305
+ );
306
+ }
307
+
308
+ /** The foot's muted control, beside the lines (214:27848). `busy` holds
309
+ * it while the host's action runs. */
310
+ export function ReportNavControl({
311
+ busy = false,
312
+ onClick,
313
+ children,
314
+ }: {
315
+ busy?: boolean;
316
+ onClick: () => void;
317
+ children: ReactNode;
318
+ }) {
319
+ return (
320
+ <button
321
+ type="button"
322
+ className="type type-fixed ts-text-sm-medium rnav-signout"
323
+ disabled={busy}
324
+ onClick={onClick}
325
+ >
326
+ {children}
327
+ </button>
328
+ );
329
+ }
330
+
331
+ /** The foot's dark control across its width (256:15675). */
332
+ export function ReportNavAsk({
333
+ onClick,
334
+ attrs,
335
+ children,
336
+ }: {
337
+ onClick: () => void;
338
+ /** The host's hand-off, when the control opens one directly. */
339
+ attrs?: Record<string, string>;
340
+ children: ReactNode;
341
+ }) {
342
+ return (
343
+ <button
344
+ type="button"
345
+ className="type type-fixed ts-text-sm-medium rnav-ask"
346
+ onClick={onClick}
347
+ {...dismiss}
348
+ {...attrs}
349
+ >
350
+ {children}
351
+ </button>
352
+ );
353
+ }
@@ -10,6 +10,10 @@
10
10
  --status-meter-reveal-dur: 1s;
11
11
  --status-arc-dur: 200ms;
12
12
  --status-arc-reveal-dur: 1.4s;
13
+ /* The score ring's stroke in px: the cards' and the hero's, and the
14
+ nav's thinner one on its 28 and 32 rings. */
15
+ --status-ring-stroke: 3;
16
+ --status-ring-stroke-nav: 1.5;
13
17
  }
14
18
 
15
19
  /* Hue ramps. */
@@ -331,11 +335,16 @@
331
335
 
332
336
  /* Score ring (ks-Grader grader/score-ring): an area's score as a thin
333
337
  ring in its grade's accent on a bg/300 track, the number centred in
334
- the serif. md is 60 (56 on a phone), lg is 76 (64), sm is 32. The
338
+ the serif. md is 60 (56 on a phone), lg is 76 (64), sm 32, xs 28. The
335
339
  number's type steps with the size; the ring has no motion so a card
336
340
  of four lands settled. */
337
341
  .score-ring {
338
- --_size: 60px;
342
+ --_n: 60;
343
+ --_stroke: var(--status-ring-stroke);
344
+ --_size: calc(var(--_n) * 1px);
345
+ /* The stroke as the share of the box that is --_stroke px at this
346
+ size: a percentage resolves against the box. */
347
+ --_sw: calc(var(--_stroke) * 100% / var(--_n));
339
348
  position: relative;
340
349
  display: inline-grid;
341
350
  place-items: center;
@@ -344,9 +353,16 @@
344
353
  height: var(--_size);
345
354
  color: var(--color-text-000);
346
355
  }
347
- /* The ring is drawn in a 100-unit box and scaled by the size; the stroke
348
- stays 3px at every size, so at any size under 100 its outer edge
349
- lands past the box: the svg paints it rather than clipping it. */
356
+ /* The ring is drawn in a 100-unit box and scaled by the size (--_n, the
357
+ size as a number), its stroke written in the box's units from the
358
+ pixels it should be, so the fill's dash, measured along the path,
359
+ keeps the score's share of the circle at every size and in every
360
+ engine; a stroke that does not scale measures its dash in pixels
361
+ instead and overruns a ring drawn under the box's size. The radius
362
+ puts the stroke's outer edge on the box, as Figma's ellipse does; the
363
+ markup's radius stands in where an engine does not size a circle from
364
+ the stylesheet, and there the edge lands past the box, which the svg
365
+ paints rather than clips. */
350
366
  .score-ring .arc {
351
367
  width: 100%;
352
368
  height: 100%;
@@ -354,7 +370,8 @@
354
370
  }
355
371
  .score-ring .arc-track,
356
372
  .score-ring .arc-fill {
357
- vector-effect: non-scaling-stroke;
373
+ stroke-width: var(--_sw);
374
+ r: calc(50% - var(--_sw) / 2);
358
375
  }
359
376
  .score-ring .arc-track {
360
377
  stroke: var(--color-bg-300);
@@ -370,18 +387,26 @@
370
387
  font-variant-numeric: tabular-nums;
371
388
  }
372
389
  .score-ring[data-size="lg"] {
373
- --_size: 76px;
390
+ --_n: 76;
374
391
  }
375
- /* sm (grader-nav 214:27889) is 32 at every size: a list row's mark. */
392
+ /* sm (grader-nav 214:27889) is 32 at every size: a list row's mark. xs
393
+ (grader-nav 64:8505) is 28: a chip's. Both take the nav's thinner
394
+ stroke: the chip's ring is drawn at 1.5; the row's is that ring
395
+ scaled to 32 (1.71), built as the 1.5 it scales from. */
376
396
  .score-ring[data-size="sm"] {
377
- --_size: 32px;
397
+ --_n: 32;
398
+ --_stroke: var(--status-ring-stroke-nav);
399
+ }
400
+ .score-ring[data-size="xs"] {
401
+ --_n: 28;
402
+ --_stroke: var(--status-ring-stroke-nav);
378
403
  }
379
404
  @container (--below-rt) {
380
- .score-ring:not([data-size="sm"]) {
381
- --_size: 56px;
405
+ .score-ring:not([data-size="sm"]):not([data-size="xs"]) {
406
+ --_n: 56;
382
407
  }
383
408
  .score-ring[data-size="lg"] {
384
- --_size: 64px;
409
+ --_n: 64;
385
410
  }
386
411
  }
387
412
 
@@ -195,12 +195,19 @@ export function Ring({
195
195
  );
196
196
  }
197
197
 
198
- /** The score ring's drawing box; the stroke is pinned to 3px in CSS so
199
- * the ring reads the same at every size (ks-Grader grader/score-ring). */
198
+ /** The score ring's drawing box (ks-Grader grader/score-ring). The
199
+ * stroke and the radius are the stylesheet's, which knows the size; the
200
+ * radius here is the fallback for an engine that does not size a circle
201
+ * from CSS, keeping a 3-unit stroke's centreline inside the box. The
202
+ * fill's dash is measured along a path normalised to 100, as the gauge's
203
+ * is (keystone-score.tsx), so the offset is the score's complement
204
+ * whatever the circumference. */
200
205
  const SCORE_RING_BOX = 100;
201
- const SCORE_RING_STROKE = 3;
206
+ const SCORE_RING_INSET = 3;
207
+ const SCORE_RING_PATH = 100;
202
208
 
203
209
  const SCORE_RING_TYPE = {
210
+ xs: "ts-display-serif-4xs-medium",
204
211
  sm: "ts-display-serif-3xs-regular",
205
212
  md: "ts-display-serif-xs-light",
206
213
  lg: "ts-display-serif-xs-plus-extralight",
@@ -208,10 +215,10 @@ const SCORE_RING_TYPE = {
208
215
 
209
216
  /** Score ring: an area's 0–100 score as a thin ring in its grade's
210
217
  * accent, the number centred. `md` is the overview card's 60 (56 on a
211
- * phone); `lg` the report hero's 76 (64); `sm` the report nav's 32 at
212
- * every size. A score that was not measured passes `value={null}`: the
213
- * ring stays a track and the centre shows the children (a dash, a
214
- * skeleton) instead of a number. */
218
+ * phone); `lg` the report hero's 76 (64); `sm` the report nav card's 32
219
+ * and `xs` its chips' 28, each at every size. A score that was not
220
+ * measured passes `value={null}`: the ring stays a track and the centre
221
+ * shows the children (a dash, a skeleton) instead of a number. */
215
222
  export function ScoreRing({
216
223
  value,
217
224
  grade,
@@ -226,8 +233,7 @@ export function ScoreRing({
226
233
  label: string;
227
234
  children?: ReactNode;
228
235
  }) {
229
- const r = (SCORE_RING_BOX - SCORE_RING_STROKE) / 2;
230
- const c = 2 * Math.PI * r;
236
+ const r = (SCORE_RING_BOX - SCORE_RING_INSET) / 2;
231
237
  const clamped = value == null ? 0 : Math.min(1, Math.max(0, value / 100));
232
238
  const step = SCORE_RING_TYPE[size];
233
239
  return (
@@ -250,7 +256,6 @@ export function ScoreRing({
250
256
  cy={SCORE_RING_BOX / 2}
251
257
  r={r}
252
258
  fill="none"
253
- strokeWidth={SCORE_RING_STROKE}
254
259
  />
255
260
  {value != null && (
256
261
  <circle
@@ -259,9 +264,9 @@ export function ScoreRing({
259
264
  cy={SCORE_RING_BOX / 2}
260
265
  r={r}
261
266
  fill="none"
262
- strokeWidth={SCORE_RING_STROKE}
263
- strokeDasharray={c}
264
- strokeDashoffset={c * (1 - clamped)}
267
+ pathLength={SCORE_RING_PATH}
268
+ strokeDasharray={SCORE_RING_PATH}
269
+ strokeDashoffset={SCORE_RING_PATH * (1 - clamped)}
265
270
  />
266
271
  )}
267
272
  </svg>