@n1kname/components 0.23.0 → 0.25.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n1kname/components",
3
- "version": "0.23.0",
3
+ "version": "0.25.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -0,0 +1,618 @@
1
+ ---
2
+ /**
3
+ * A career framework: the levels as a ladder you can pick from, forking where one level has two
4
+ * routes (a lead and a specialist at the same level, say), and for the level picked, what it is in
5
+ * one line, what it's responsible for, what changes from the level before (the promotion step),
6
+ * and what it does in each skill area. On request, every level side by side in one table.
7
+ *
8
+ * The ladder is a tab list: the arrow keys move along it and pick as they go, Home and End go to
9
+ * the ends. Picking changes the panel at once; it's an answer to a question, not a moment. Without
10
+ * script only the level given as `selected` shows, and the table still holds everything.
11
+ *
12
+ * Drawn in the diagrams' own style, on a sunken plate, as Flow diagram is. Below 640px wide the
13
+ * ladder becomes a list.
14
+ */
15
+ interface Level {
16
+ id: string;
17
+ /** Its place on the ladder, 1 first. Two levels with the same rank sit one above the other. */
18
+ rank: number;
19
+ title: string;
20
+ /** Above the title, small: "Level 3". */
21
+ label?: string;
22
+ /** The route it's on, where there's more than one: "Individual contributor". */
23
+ track?: string;
24
+ experience?: string;
25
+ scope?: string;
26
+ /** The level in one sentence. */
27
+ summary?: string;
28
+ /** What it's expected to do, by area id. */
29
+ skills?: Record<string, string>;
30
+ /** What changes from the level before: the few things a promotion to it rests on. */
31
+ changes?: string[];
32
+ }
33
+
34
+ interface Area {
35
+ id: string;
36
+ label: string;
37
+ /** The group it belongs to: "Craft", "Collaboration". */
38
+ theme?: string;
39
+ }
40
+
41
+ interface Props {
42
+ /** Names the ladder and the table for a screen reader. */
43
+ title: string;
44
+ levels: Level[];
45
+ areas?: Area[];
46
+ /** The level shown first. The first one by default. */
47
+ selected?: string;
48
+ /** Shows every level side by side in a table, under this label. None by default. */
49
+ compare?: string;
50
+ /** The panel's headings. */
51
+ scopeLabel?: string;
52
+ changesLabel?: string;
53
+ skillsLabel?: string;
54
+ caption?: string;
55
+ id?: string;
56
+ class?: string;
57
+ }
58
+
59
+ const {
60
+ title,
61
+ levels,
62
+ areas = [],
63
+ selected,
64
+ compare,
65
+ scopeLabel = 'Responsible for',
66
+ changesLabel = 'What changes from the level before',
67
+ skillsLabel = 'Skills',
68
+ caption,
69
+ class: className,
70
+ } = Astro.props;
71
+ let hash = 0;
72
+ for (const c of title) hash = (hash * 31 + c.charCodeAt(0)) | 0;
73
+ const uid = Astro.props.id ?? `career-${(hash >>> 0).toString(36)}`;
74
+ const current = selected ?? levels[0]?.id;
75
+
76
+ const ranks = [...new Set(levels.map((l) => l.rank))].sort((a, b) => a - b);
77
+ const at = (r: number) => levels.filter((l) => l.rank === r);
78
+ // The ladder's columns: a level (or two) per rank, a joint between ranks.
79
+ const columns = ranks.map(() => 'minmax(0, 1fr)').join(' var(--joint) ');
80
+ // A joint's shape: straight on, forking into two, joining from two, or two straight on.
81
+ const joint = (a: number, b: number) => {
82
+ const [from, to] = [at(a).length > 1, at(b).length > 1];
83
+ if (!from && !to) return 'M0 50 H28';
84
+ if (!from && to) return 'M0 50 H12 V25 H28 M12 50 V75 H28';
85
+ if (from && !to) return 'M0 25 H16 V50 H28 M0 75 H16 V50';
86
+ return 'M0 25 H28 M0 75 H28';
87
+ };
88
+
89
+ const themes = [...new Set(areas.map((a) => a.theme ?? ''))];
90
+ const byTheme = (t: string) => areas.filter((a) => (a.theme ?? '') === t);
91
+ const ordered = ranks.flatMap((r) => at(r));
92
+ ---
93
+
94
+ <figure class:list={['career-map', className]} data-career-map>
95
+ <div class="plate">
96
+ <div class="ladder" role="tablist" aria-label={title} style={`grid-template-columns: ${columns}`}>
97
+ {
98
+ ranks.map((r, k) => (
99
+ <>
100
+ {k > 0 && (
101
+ <svg class="joint" style={`grid-column: ${k * 2}`} viewBox="0 0 28 100" preserveAspectRatio="none" aria-hidden="true">
102
+ <path d={joint(ranks[k - 1], r)} vector-effect="non-scaling-stroke" />
103
+ </svg>
104
+ )}
105
+ {at(r).map((l, j, all) => (
106
+ <button
107
+ type="button"
108
+ role="tab"
109
+ class:list={['level', { fork: all.length > 1 }]}
110
+ id={`${uid}-tab-${l.id}`}
111
+ aria-selected={l.id === current ? 'true' : 'false'}
112
+ aria-controls={`${uid}-panel-${l.id}`}
113
+ tabindex={l.id === current ? 0 : -1}
114
+ data-level={l.id}
115
+ style={`grid-column: ${k * 2 + 1}; grid-row: ${all.length > 1 ? j + 1 : '1 / span 2'}`}
116
+ >
117
+ {l.label && <span class="level-label">{l.label}</span>}
118
+ <span class="level-title">{l.title}</span>
119
+ </button>
120
+ ))}
121
+ </>
122
+ ))
123
+ }
124
+ </div>
125
+
126
+ {
127
+ ordered.map((l) => (
128
+ <section class="panel" role="tabpanel" id={`${uid}-panel-${l.id}`} aria-labelledby={`${uid}-tab-${l.id}`} hidden={l.id !== current} tabindex="0">
129
+ <header class="panel-head">
130
+ <h3 class="panel-title">{l.title}</h3>
131
+ <p class="meta">{[l.label, l.track, l.experience].filter(Boolean).join(' · ')}</p>
132
+ {l.summary && <p class="summary">{l.summary}</p>}
133
+ </header>
134
+ <div class="cols">
135
+ <div class="main">
136
+ {l.scope && (
137
+ <>
138
+ <h4 class="part">{scopeLabel}</h4>
139
+ <p class="scope">{l.scope}</p>
140
+ </>
141
+ )}
142
+ {l.changes && l.changes.length > 0 && (
143
+ <>
144
+ <h4 class="part">{changesLabel}</h4>
145
+ <ul class="changes">
146
+ {l.changes.map((c) => (
147
+ <li>{c}</li>
148
+ ))}
149
+ </ul>
150
+ </>
151
+ )}
152
+ </div>
153
+ {l.skills && (
154
+ <div class="skills">
155
+ <h4 class="part">{skillsLabel}</h4>
156
+ {themes.map((t) => (
157
+ <div class="theme">
158
+ {t && <h5 class="theme-title">{t}</h5>}
159
+ <dl>
160
+ {byTheme(t)
161
+ .filter((a) => l.skills?.[a.id])
162
+ .map((a) => (
163
+ <div>
164
+ <dt>{a.label}</dt>
165
+ <dd>{l.skills![a.id]}</dd>
166
+ </div>
167
+ ))}
168
+ </dl>
169
+ </div>
170
+ ))}
171
+ </div>
172
+ )}
173
+ </div>
174
+ </section>
175
+ ))
176
+ }
177
+ </div>
178
+
179
+ {
180
+ compare && areas.length > 0 && (
181
+ <details class="compare">
182
+ <summary>{compare}</summary>
183
+ <div class="scroll" role="region" aria-label={`${title}: every level side by side`} tabindex="0">
184
+ <table>
185
+ <thead>
186
+ <tr>
187
+ <td />
188
+ {ordered.map((l) => (
189
+ <th scope="col">
190
+ {l.label && <span class="level-label">{l.label}</span>}
191
+ {l.title}
192
+ </th>
193
+ ))}
194
+ </tr>
195
+ </thead>
196
+ {themes.map((t) => (
197
+ <tbody>
198
+ {t && (
199
+ <tr class="theme-row">
200
+ <th scope="colgroup" colspan={ordered.length + 1}>
201
+ {t}
202
+ </th>
203
+ </tr>
204
+ )}
205
+ {byTheme(t).map((a) => (
206
+ <tr>
207
+ <th scope="row">{a.label}</th>
208
+ {ordered.map((l) => (
209
+ <td>{l.skills?.[a.id] ?? ''}</td>
210
+ ))}
211
+ </tr>
212
+ ))}
213
+ </tbody>
214
+ ))}
215
+ </table>
216
+ </div>
217
+ </details>
218
+ )
219
+ }
220
+ {caption && <figcaption>{caption}</figcaption>}
221
+ </figure>
222
+
223
+ <style>
224
+ .career-map {
225
+ --joint: 28px;
226
+ min-width: 0;
227
+ margin: 0;
228
+ }
229
+
230
+ .plate {
231
+ container-type: inline-size;
232
+ background: var(--c-surface-sunken);
233
+ border: 1px solid var(--c-border);
234
+ border-radius: var(--radius-lg);
235
+ padding: var(--sp-5);
236
+ }
237
+
238
+ /* The ladder: a level per rank, a joint between ranks, two levels stacked where it forks. */
239
+ .ladder {
240
+ display: grid;
241
+ grid-template-rows: auto auto;
242
+ align-items: center;
243
+ }
244
+
245
+ .joint {
246
+ grid-row: 1 / span 2;
247
+ align-self: stretch;
248
+ width: 100%;
249
+ height: 100%;
250
+ overflow: visible;
251
+ }
252
+
253
+ .joint path {
254
+ fill: none;
255
+ stroke: var(--c-diagram-line);
256
+ stroke-width: 1.75;
257
+ stroke-linejoin: round;
258
+ }
259
+
260
+ .level {
261
+ display: flex;
262
+ flex-direction: column;
263
+ align-items: center;
264
+ justify-content: center;
265
+ gap: 2px;
266
+ min-height: 56px;
267
+ margin-block: var(--sp-1);
268
+ padding: var(--sp-2) var(--sp-3);
269
+ border: 1.5px solid var(--c-diagram-edge);
270
+ border-radius: var(--radius-md);
271
+ background: var(--c-surface);
272
+ color: var(--c-text);
273
+ font: inherit;
274
+ text-align: center;
275
+ cursor: pointer;
276
+ transition: border-color var(--motion-hover) var(--ease-hover);
277
+ }
278
+
279
+ .level.fork {
280
+ background: var(--c-surface-tint);
281
+ border-color: var(--c-accent-edge);
282
+ }
283
+
284
+ .level:hover {
285
+ border-color: var(--c-border-strong);
286
+ }
287
+
288
+ .level.fork:hover {
289
+ border-color: var(--c-accent);
290
+ }
291
+
292
+ /* The level picked: the one solid node, as in Flow diagram. */
293
+ .level[aria-selected='true'] {
294
+ background: var(--c-accent);
295
+ border-color: var(--c-accent);
296
+ color: var(--c-on-accent);
297
+ }
298
+
299
+ .level:focus-visible {
300
+ outline: 2px solid var(--c-focus);
301
+ outline-offset: 2px;
302
+ }
303
+
304
+ .level-label {
305
+ display: block;
306
+ font-size: var(--text-caption);
307
+ line-height: var(--leading-caption);
308
+ color: var(--c-text-muted);
309
+ }
310
+
311
+ .level[aria-selected='true'] .level-label {
312
+ color: inherit;
313
+ }
314
+
315
+ .level-title {
316
+ font-size: var(--text-body-sm);
317
+ font-weight: 600;
318
+ line-height: 1.3;
319
+ text-wrap: balance;
320
+ }
321
+
322
+ /* The level picked. */
323
+ .panel {
324
+ margin-top: var(--sp-5);
325
+ padding: var(--sp-5);
326
+ border: 1px solid var(--c-border);
327
+ border-radius: var(--radius-md);
328
+ background: var(--c-surface);
329
+ }
330
+
331
+ .panel:focus-visible {
332
+ outline: 2px solid var(--c-focus);
333
+ outline-offset: 2px;
334
+ }
335
+
336
+ .panel-title {
337
+ margin: 0;
338
+ font-family: var(--font-display);
339
+ font-size: var(--text-h3);
340
+ line-height: var(--leading-h3);
341
+ }
342
+
343
+ .meta {
344
+ margin: var(--sp-1) 0 0;
345
+ font-size: var(--text-caption);
346
+ color: var(--c-text-muted);
347
+ }
348
+
349
+ .summary {
350
+ margin: var(--sp-4) 0 0;
351
+ font-family: var(--font-display);
352
+ font-size: var(--text-sub);
353
+ line-height: var(--leading-sub);
354
+ color: var(--c-text);
355
+ text-wrap: pretty;
356
+ }
357
+
358
+ /* What it's responsible for and what changes, beside its skills where there's room. */
359
+ .cols {
360
+ display: grid;
361
+ gap: var(--sp-5);
362
+ margin-top: var(--sp-5);
363
+ padding-top: var(--sp-5);
364
+ border-top: 1px solid var(--c-border);
365
+ }
366
+
367
+ @container (min-width: 760px) {
368
+ .cols {
369
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
370
+ gap: var(--sp-7);
371
+ }
372
+ }
373
+
374
+ .part {
375
+ margin: 0 0 var(--sp-2);
376
+ font-size: var(--text-overline);
377
+ line-height: var(--leading-overline);
378
+ letter-spacing: var(--tracking-overline);
379
+ text-transform: uppercase;
380
+ color: var(--c-text-accent);
381
+ }
382
+
383
+ .main > .part:not(:first-child) {
384
+ margin-top: var(--sp-5);
385
+ }
386
+
387
+ .scope {
388
+ margin: 0;
389
+ font-size: var(--text-body-sm);
390
+ line-height: var(--leading-body-sm);
391
+ color: var(--c-text-secondary);
392
+ }
393
+
394
+ .changes {
395
+ display: grid;
396
+ gap: var(--sp-2);
397
+ margin: 0;
398
+ padding: 0;
399
+ list-style: none;
400
+ font-size: var(--text-body-sm);
401
+ line-height: var(--leading-body-sm);
402
+ color: var(--c-text-secondary);
403
+ }
404
+
405
+ /* A small step up for each change: what the promotion adds. */
406
+ .changes li {
407
+ position: relative;
408
+ padding-left: var(--sp-5);
409
+ }
410
+
411
+ .changes li::before {
412
+ content: '';
413
+ position: absolute;
414
+ left: 2px;
415
+ top: 0.55em;
416
+ width: 8px;
417
+ height: 8px;
418
+ border-top: 1.75px solid var(--c-accent-edge);
419
+ border-right: 1.75px solid var(--c-accent-edge);
420
+ rotate: -45deg;
421
+ }
422
+
423
+ .theme + .theme {
424
+ margin-top: var(--sp-4);
425
+ }
426
+
427
+ .theme-title {
428
+ margin: 0 0 var(--sp-2);
429
+ font-size: var(--text-body-sm);
430
+ font-weight: 600;
431
+ color: var(--c-text);
432
+ }
433
+
434
+ dl {
435
+ display: grid;
436
+ gap: var(--sp-3);
437
+ margin: 0;
438
+ }
439
+
440
+ dl > div {
441
+ display: grid;
442
+ gap: 2px;
443
+ }
444
+
445
+ dt {
446
+ font-size: var(--text-body-sm);
447
+ font-weight: 600;
448
+ color: var(--c-text);
449
+ }
450
+
451
+ dd {
452
+ margin: 0;
453
+ font-size: var(--text-body-sm);
454
+ line-height: var(--leading-body-sm);
455
+ color: var(--c-text-secondary);
456
+ }
457
+
458
+ /* Every level side by side. */
459
+ .compare {
460
+ margin-top: var(--sp-4);
461
+ }
462
+
463
+ .compare summary {
464
+ display: inline-flex;
465
+ align-items: center;
466
+ gap: var(--sp-2);
467
+ padding: var(--sp-2) var(--sp-3);
468
+ border: 1px solid var(--c-border);
469
+ border-radius: var(--radius-full);
470
+ background: var(--c-surface);
471
+ font-size: var(--text-body-sm);
472
+ font-weight: 600;
473
+ cursor: pointer;
474
+ list-style: none;
475
+ }
476
+
477
+ .compare summary::-webkit-details-marker {
478
+ display: none;
479
+ }
480
+
481
+ .compare summary::after {
482
+ content: '';
483
+ width: 7px;
484
+ height: 7px;
485
+ border-right: 1.75px solid currentColor;
486
+ border-bottom: 1.75px solid currentColor;
487
+ rotate: 45deg;
488
+ translate: 0 -2px;
489
+ }
490
+
491
+ .compare[open] summary::after {
492
+ rotate: 225deg;
493
+ translate: 0 2px;
494
+ }
495
+
496
+ .compare summary:focus-visible,
497
+ .scroll:focus-visible {
498
+ outline: 2px solid var(--c-focus);
499
+ outline-offset: 2px;
500
+ }
501
+
502
+ .scroll {
503
+ margin-top: var(--sp-3);
504
+ overflow-x: auto;
505
+ border: 1px solid var(--c-border);
506
+ border-radius: var(--radius-md);
507
+ background: var(--c-surface);
508
+ }
509
+
510
+ table {
511
+ min-width: 1080px;
512
+ border-collapse: collapse;
513
+ font-size: var(--text-caption);
514
+ line-height: var(--leading-caption);
515
+ }
516
+
517
+ th,
518
+ td {
519
+ padding: var(--sp-3);
520
+ text-align: left;
521
+ vertical-align: top;
522
+ border-bottom: 1px solid var(--c-border);
523
+ }
524
+
525
+ td {
526
+ color: var(--c-text-secondary);
527
+ }
528
+
529
+ thead th {
530
+ position: sticky;
531
+ top: 0;
532
+ background: var(--c-surface);
533
+ font-weight: 600;
534
+ color: var(--c-text);
535
+ }
536
+
537
+ tbody th[scope='row'] {
538
+ width: 9rem;
539
+ font-weight: 600;
540
+ color: var(--c-text);
541
+ }
542
+
543
+ .theme-row th {
544
+ padding-top: var(--sp-4);
545
+ background: var(--c-surface-sunken);
546
+ font-size: var(--text-overline);
547
+ letter-spacing: var(--tracking-overline);
548
+ text-transform: uppercase;
549
+ color: var(--c-text-accent);
550
+ }
551
+
552
+ figcaption {
553
+ margin-top: var(--sp-3);
554
+ font-size: var(--text-caption);
555
+ line-height: var(--leading-caption);
556
+ color: var(--c-text-muted);
557
+ }
558
+
559
+ /* Too narrow for a ladder: a list, the routes marked in each level's label. */
560
+ @container (max-width: 640px) {
561
+ .ladder {
562
+ grid-template-columns: 1fr !important;
563
+ grid-template-rows: none;
564
+ gap: var(--sp-2);
565
+ }
566
+
567
+ .joint {
568
+ display: none;
569
+ }
570
+
571
+ .level {
572
+ grid-column: 1 !important;
573
+ grid-row: auto !important;
574
+ margin: 0;
575
+ min-height: 0;
576
+ }
577
+
578
+ .panel {
579
+ padding: var(--sp-4);
580
+ }
581
+ }
582
+
583
+ @media (forced-colors: active) {
584
+ .level[aria-selected='true'] {
585
+ forced-color-adjust: none;
586
+ background: Highlight;
587
+ color: HighlightText;
588
+ }
589
+ }
590
+ </style>
591
+
592
+ <script>
593
+ // Picking a level shows its panel. The arrow keys move along the ladder in reading order and pick
594
+ // as they go; Home and End go to the ends.
595
+ document.querySelectorAll<HTMLElement>('[data-career-map]').forEach((map) => {
596
+ const tabs = [...map.querySelectorAll<HTMLButtonElement>('[role="tab"]')];
597
+ // Reading order follows the ranks: the DOM already lists them so.
598
+ const pick = (tab: HTMLButtonElement, focus = false) => {
599
+ tabs.forEach((t) => {
600
+ const on = t === tab;
601
+ t.setAttribute('aria-selected', String(on));
602
+ t.tabIndex = on ? 0 : -1;
603
+ const panel = map.querySelector<HTMLElement>(`#${t.getAttribute('aria-controls')}`);
604
+ if (panel) panel.hidden = !on;
605
+ });
606
+ if (focus) tab.focus();
607
+ };
608
+ tabs.forEach((t, i) => {
609
+ t.addEventListener('click', () => pick(t));
610
+ t.addEventListener('keydown', (e) => {
611
+ const to = { ArrowRight: i + 1, ArrowDown: i + 1, ArrowLeft: i - 1, ArrowUp: i - 1, Home: 0, End: tabs.length - 1 }[e.key];
612
+ if (to === undefined) return;
613
+ e.preventDefault();
614
+ pick(tabs[(to + tabs.length) % tabs.length], true);
615
+ });
616
+ });
617
+ });
618
+ </script>
@@ -1,23 +1,23 @@
1
1
  ---
2
2
  /**
3
3
  * A design process as diamonds: each phase opens out (diverge) and narrows again (converge), with
4
- * the moments between them on the line, such as kick-off and launch. A last phase can repeat
5
- * instead, as smaller diamonds that fade out, for the work that goes on after launch.
4
+ * the moments between them as stops at the diamonds' points, such as kick-off and launch. A last phase can
5
+ * repeat instead, as smaller diamonds that fade out, for the work that goes on after launch.
6
6
  *
7
- * Drawn in HTML and SVG, so the words are text: they wrap, scale with the page, and are read out
8
- * in order (moment, phase, its two halves and their notes, its name). Below 560px wide the phases
9
- * stack. The halves use three fixed tones, the closing half paler, with the dark text on them, so
10
- * they read the same in either theme.
7
+ * Drawn in the diagrams' own style, on a sunken plate: tinted fills with a hairline edge and soft
8
+ * corners, as in Flow diagram, so it sits beside them. HTML and SVG, so the words are text: they wrap, scale with
9
+ * the page, and are read out in order (moment, phase, its two halves, its name, its notes). Below
10
+ * 560px wide the phases stack.
11
11
  *
12
12
  * Once, as it comes into view, the parts arrive left to right. Nothing moves under reduced
13
13
  * motion, and without script it is simply there.
14
14
  */
15
- type Tone = 'cool' | 'accent' | 'sun';
15
+ type Tone = 'cool' | 'accent' | 'quiet';
16
16
 
17
17
  interface Half {
18
18
  /** Inside the half, such as "Discover". */
19
19
  label: string;
20
- /** Above the half: a short title ("Diverge") and the question it asks. */
20
+ /** Under the phase's name: a short title ("Diverge") and the question this half asks. */
21
21
  note?: { title: string; text: string };
22
22
  }
23
23
 
@@ -31,7 +31,7 @@ interface Phase {
31
31
  halves?: [Half, Half];
32
32
  /** Smaller diamonds that fade out, for work that keeps going. */
33
33
  repeat?: boolean;
34
- /** Above a repeating phase, as a half's note is above a half. */
34
+ /** Under a repeating phase's name, as a half's note is under a diamond. */
35
35
  note?: { title: string; text: string };
36
36
  }
37
37
 
@@ -46,74 +46,112 @@ interface Props {
46
46
  }
47
47
 
48
48
  const { title, phases, milestones = [], caption, class: className } = Astro.props;
49
- const tones: Tone[] = ['cool', 'accent', 'sun'];
49
+ const tones: Tone[] = ['cool', 'accent', 'quiet'];
50
50
  const items = phases.flatMap((p, i) => {
51
- const tone = p.tone ?? tones[i % tones.length];
51
+ const tone = p.tone ?? (p.repeat ? 'quiet' : tones[i % tones.length]);
52
52
  return [...(milestones[i] ? [{ kind: 'moment' as const, label: milestones[i]!, tone }] : []), { kind: 'phase' as const, phase: p, tone }];
53
53
  });
54
- const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repeat ? 'minmax(0, 0.8fr)' : 'minmax(0, 1fr)')).join(' ');
54
+ // A diamond with soft corners: rounder at top and bottom, a little at the points. Drawn on a fixed
55
+ // viewBox the shape keeps, so the corners never stretch.
56
+ const rounded = (pts: [number, number][], radii: number[]) =>
57
+ pts
58
+ .map((p, i) => {
59
+ const prev = pts[(i + pts.length - 1) % pts.length];
60
+ const next = pts[(i + 1) % pts.length];
61
+ const cut = (to: [number, number]) => {
62
+ const [dx, dy] = [to[0] - p[0], to[1] - p[1]];
63
+ const len = Math.hypot(dx, dy);
64
+ return [p[0] + (dx / len) * radii[i], p[1] + (dy / len) * radii[i]].map((v) => +v.toFixed(2));
65
+ };
66
+ const [a, b] = [cut(prev), cut(next)];
67
+ return `${i ? 'L' : 'M'}${a[0]} ${a[1]} Q${p[0]} ${p[1]} ${b[0]} ${b[1]}`;
68
+ })
69
+ .join(' ') + ' Z';
70
+ const big = rounded([[1, 60], [100, 1], [199, 60], [100, 119]], [5, 16, 5, 16]);
71
+ const small = (x: number) => rounded([[x + 4, 50], [x + 50, 18], [x + 96, 50], [x + 50, 82]], [3, 9, 3, 9]);
72
+ let hash = 0;
73
+ for (const c of title) hash = (hash * 31 + c.charCodeAt(0)) | 0;
74
+ const uid = `dia-${(hash >>> 0).toString(36)}`;
75
+ const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repeat ? 'minmax(0, 0.75fr)' : 'minmax(0, 1fr)')).join(' ');
55
76
  ---
56
77
 
57
78
  <figure class:list={['diamonds', className]} data-diamonds>
58
- <ol class="row" aria-label={title} style={`--cols: ${columns}`}>
59
- {
60
- items.map((it, i) =>
61
- it.kind === 'moment' ? (
62
- <li class="moment" data-tone={it.tone} style={`--i: ${i}`}>
63
- <span class="dot" aria-hidden="true" />
64
- <span class="moment-label">{it.label}</span>
65
- </li>
66
- ) : (
67
- <li class:list={['phase', { repeat: it.phase.repeat }]} data-tone={it.tone} style={`--i: ${i}`}>
68
- <div class="notes">
69
- {it.phase.repeat
70
- ? it.phase.note && (
71
- <p class="note wide">
72
- <strong>{it.phase.note.title}</strong> {it.phase.note.text}
73
- </p>
74
- )
75
- : it.phase.halves?.map(
76
- (h) =>
77
- h.note && (
78
- <p class="note">
79
- <strong>{h.note.title}</strong> {h.note.text}
80
- </p>
81
- ),
82
- )}
83
- </div>
84
- <div class="shape">
85
- {it.phase.repeat ? (
86
- <svg viewBox="0 0 300 120" preserveAspectRatio="xMidYMid meet" aria-hidden="true">
87
- {[0, 1, 2].map((k) => (
88
- <g opacity={[1, 0.55, 0.25][k]}>
89
- <polygon class="open" points={`${k * 100},60 ${k * 100 + 50},24 ${k * 100 + 50},96`} />
90
- <polygon class="close" points={`${k * 100 + 50},24 ${k * 100 + 100},60 ${k * 100 + 50},96`} />
91
- </g>
92
- ))}
93
- </svg>
94
- ) : (
95
- <>
96
- <svg viewBox="0 0 200 120" preserveAspectRatio="none" aria-hidden="true">
97
- <polygon class="open" points="0,60 100,0 100,120" />
98
- <polygon class="close" points="100,0 200,60 100,120" />
99
- </svg>
100
- <p class="halves">
101
- {it.phase.halves?.map((h) => (
102
- <span>{h.label}</span>
79
+ <div class="plate">
80
+ <ol class="row" aria-label={title} style={`--cols: ${columns}`}>
81
+ {
82
+ items.map((it, i) =>
83
+ it.kind === 'moment' ? (
84
+ <li class="moment" data-tone={it.tone} style={`--i: ${i}`}>
85
+ <span class="stop-cell">
86
+ <span class="stop" aria-hidden="true" />
87
+ <span class="moment-label">{it.label}</span>
88
+ </span>
89
+ </li>
90
+ ) : (
91
+ <li class:list={['phase', { repeat: it.phase.repeat }]} data-tone={it.tone} style={`--i: ${i}`}>
92
+ <div class="shape">
93
+ {it.phase.repeat ? (
94
+ <svg viewBox="0 0 300 100" aria-hidden="true">
95
+ {[0, 1, 2].map((k) => (
96
+ <g opacity={[1, 0.6, 0.32][k]}>
97
+ <clipPath id={`${uid}-${i}-${k}`}>
98
+ <path d={small(k * 100)} />
99
+ </clipPath>
100
+ <g clip-path={`url(#${uid}-${i}-${k})`}>
101
+ <rect class="open" x={k * 100} y="0" width="50" height="100" />
102
+ <rect class="close" x={k * 100 + 50} y="0" width="50" height="100" />
103
+ </g>
104
+ <path class="edge" d={small(k * 100)} vector-effect="non-scaling-stroke" />
105
+ </g>
103
106
  ))}
104
- </p>
105
- </>
106
- )}
107
- </div>
108
- <p class="name">
109
- {it.phase.name}
110
- {it.phase.motto && <span class="motto">{it.phase.motto}</span>}
111
- </p>
112
- </li>
113
- ),
114
- )
115
- }
116
- </ol>
107
+ </svg>
108
+ ) : (
109
+ <>
110
+ <svg viewBox="0 0 200 120" aria-hidden="true">
111
+ <clipPath id={`${uid}-${i}`}>
112
+ <path d={big} />
113
+ </clipPath>
114
+ <g clip-path={`url(#${uid}-${i})`}>
115
+ <rect class="open" x="0" y="0" width="100" height="120" />
116
+ <rect class="close" x="100" y="0" width="100" height="120" />
117
+ <line class="split" x1="100" y1="0" x2="100" y2="120" vector-effect="non-scaling-stroke" />
118
+ </g>
119
+ <path class="edge" d={big} vector-effect="non-scaling-stroke" />
120
+ </svg>
121
+ <p class="halves">
122
+ {it.phase.halves?.map((h) => (
123
+ <span>{h.label}</span>
124
+ ))}
125
+ </p>
126
+ </>
127
+ )}
128
+ </div>
129
+ <p class="name">
130
+ {it.phase.name}
131
+ {it.phase.motto && <span class="motto">{it.phase.motto}</span>}
132
+ </p>
133
+ <div class:list={['notes', { one: it.phase.repeat }]}>
134
+ {it.phase.repeat
135
+ ? it.phase.note && (
136
+ <p class="note">
137
+ <strong>{it.phase.note.title}</strong> {it.phase.note.text}
138
+ </p>
139
+ )
140
+ : it.phase.halves?.map(
141
+ (h) =>
142
+ h.note && (
143
+ <p class="note">
144
+ <strong>{h.note.title}</strong> {h.note.text}
145
+ </p>
146
+ ),
147
+ )}
148
+ </div>
149
+ </li>
150
+ ),
151
+ )
152
+ }
153
+ </ol>
154
+ </div>
117
155
  {caption && <figcaption>{caption}</figcaption>}
118
156
  </figure>
119
157
 
@@ -130,27 +168,41 @@ const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repe
130
168
  .diamonds {
131
169
  min-width: 0;
132
170
  margin: 0;
171
+ }
172
+
173
+ .plate {
133
174
  container-type: inline-size;
175
+ background: var(--c-surface-sunken);
176
+ border: 1px solid var(--c-border);
177
+ border-radius: var(--radius-lg);
178
+ padding: var(--sp-6) var(--sp-5) var(--sp-5);
134
179
  }
135
180
 
181
+ /* The diagrams' tones: a tint and an edge, never a saturated slab. The opening half carries a
182
+ * little more of the tone than the narrowing one. */
136
183
  [data-tone='cool'] {
137
- --tone: var(--c-seq2-4);
184
+ --edge: color-mix(in oklab, var(--c-tag-cool-text) 55%, transparent);
185
+ --soft: var(--c-tag-cool-bg);
186
+ --mark: var(--c-tag-cool-text);
138
187
  }
139
188
 
140
189
  [data-tone='accent'] {
141
- --tone: var(--c-accent);
190
+ --edge: var(--c-accent-edge);
191
+ --soft: var(--c-surface-tint);
192
+ --mark: var(--c-accent);
142
193
  }
143
194
 
144
- [data-tone='sun'] {
145
- --tone: var(--c-heat-4);
195
+ [data-tone='quiet'] {
196
+ --edge: var(--c-diagram-edge);
197
+ --soft: var(--c-surface);
198
+ --mark: var(--c-diagram-edge);
146
199
  }
147
200
 
148
201
  .row {
149
202
  display: grid;
150
203
  grid-template-columns: var(--cols);
151
204
  grid-template-rows: auto auto auto;
152
- column-gap: var(--sp-1);
153
- row-gap: var(--sp-3);
205
+ column-gap: var(--sp-2);
154
206
  list-style: none;
155
207
  margin: 0;
156
208
  padding: 0;
@@ -163,139 +215,162 @@ const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repe
163
215
  min-width: 0;
164
216
  }
165
217
 
166
- /* A moment on the line: a dot level with the diamonds' points, its name under it. */
167
- .moment {
168
- justify-items: center;
218
+ /* A moment: a stop level with the diamonds' points, its name just under it. */
219
+ .stop-cell {
220
+ position: relative;
221
+ grid-row: 1;
222
+ display: grid;
223
+ place-items: center;
169
224
  }
170
225
 
171
- .dot {
172
- grid-row: 2;
173
- align-self: center;
174
- width: 20px;
175
- height: 20px;
226
+ .stop {
227
+ width: 12px;
228
+ height: 12px;
176
229
  border-radius: 50%;
177
- background: var(--tone);
178
- box-shadow: 0 0 0 4px var(--c-bg);
230
+ background: var(--c-surface);
231
+ border: 2px solid var(--mark);
179
232
  }
180
233
 
181
234
  .moment-label {
182
- grid-row: 3;
183
- font-size: var(--text-caption);
235
+ position: absolute;
236
+ top: calc(50% + 16px);
237
+ font-size: 13px;
184
238
  font-weight: 600;
185
- letter-spacing: var(--tracking-overline);
186
- text-transform: uppercase;
187
- color: var(--c-text-secondary);
239
+ color: var(--c-text-muted);
188
240
  white-space: nowrap;
189
241
  }
190
242
 
191
- .notes {
192
- grid-row: 1;
193
- align-self: end;
194
- display: grid;
195
- grid-template-columns: 1fr 1fr;
196
- gap: var(--sp-3);
197
- }
198
-
199
- .note {
200
- margin: 0;
201
- font-size: var(--text-caption);
202
- line-height: var(--leading-caption);
203
- color: var(--c-text-secondary);
204
- text-wrap: pretty;
205
- }
206
-
207
- .note strong {
208
- display: block;
209
- font-weight: 600;
210
- letter-spacing: var(--tracking-overline);
211
- text-transform: uppercase;
212
- color: var(--c-text);
213
- }
214
-
215
- .note.wide {
216
- grid-column: 1 / -1;
217
- text-align: center;
218
- }
219
-
220
- /* Its width is the column's and its height follows, so a narrower phase is a smaller diamond,
221
- * centred on the line. */
222
243
  .shape {
223
- grid-row: 2;
244
+ grid-row: 1;
224
245
  align-self: center;
225
246
  position: relative;
226
247
  width: 100%;
227
248
  aspect-ratio: 5 / 3;
228
249
  }
229
250
 
251
+ .repeat .shape {
252
+ aspect-ratio: 3 / 1;
253
+ }
254
+
230
255
  .shape svg {
231
256
  display: block;
232
257
  width: 100%;
233
258
  height: 100%;
259
+ overflow: visible;
234
260
  }
235
261
 
236
- /* Opening out in the tone itself; narrowing in a paler one. */
262
+ /* The opening half: its tint with a little of its edge colour in it, in either theme. */
237
263
  .open {
238
- fill: var(--tone);
264
+ fill: color-mix(in oklab, var(--soft), var(--mark) 20%);
239
265
  }
240
266
 
241
267
  .close {
242
- fill: color-mix(in oklab, var(--tone) 55%, #fff);
268
+ fill: var(--soft);
269
+ }
270
+
271
+ .edge,
272
+ .split {
273
+ fill: none;
274
+ stroke: var(--edge);
275
+ stroke-width: 1.5;
276
+ stroke-linejoin: round;
243
277
  }
244
278
 
279
+ .split {
280
+ stroke-width: 1;
281
+ opacity: 0.6;
282
+ }
283
+
284
+ .repeat .edge {
285
+ stroke-dasharray: 3 4;
286
+ }
287
+
288
+ /* Each label centred on its half's own middle, a third of the way in from its point, at one
289
+ * size wherever the diamond is drawn. */
245
290
  .halves {
246
291
  position: absolute;
247
292
  inset: 0;
248
- display: grid;
249
- grid-template-columns: 1fr 1fr;
250
- align-items: center;
251
293
  margin: 0;
252
- color: var(--c-on-accent);
294
+ color: var(--c-text);
253
295
  font-weight: 600;
254
- font-size: clamp(0.6875rem, 2.4cqi, var(--text-label));
255
- letter-spacing: 0.04em;
256
- text-transform: uppercase;
257
- line-height: 1.2;
296
+ font-size: var(--text-body-sm);
297
+ line-height: 1.25;
298
+ text-align: center;
299
+ }
300
+
301
+ .halves span {
302
+ position: absolute;
303
+ top: 50%;
304
+ width: 30%;
305
+ translate: -50% -50%;
306
+ text-wrap: balance;
258
307
  }
259
308
 
260
- /* Each label leans toward the middle, where its half is widest. */
261
309
  .halves span:first-child {
262
- justify-self: end;
263
- padding-right: 10%;
264
- text-align: right;
310
+ left: 34%;
265
311
  }
266
312
 
267
313
  .halves span:last-child {
268
- padding-left: 10%;
314
+ left: 66%;
269
315
  }
270
316
 
271
317
  .name {
272
- grid-row: 3;
273
- margin: 0;
318
+ grid-row: 2;
319
+ margin: var(--sp-4) 0 0;
274
320
  text-align: center;
275
321
  font-family: var(--font-display);
276
322
  font-weight: 600;
277
- font-size: var(--text-h3);
278
- line-height: var(--leading-h3);
323
+ font-size: var(--text-sub);
324
+ line-height: var(--leading-sub);
279
325
  color: var(--c-text);
280
326
  }
281
327
 
282
328
  .motto {
283
329
  display: block;
284
- margin-top: var(--sp-1);
285
330
  font-family: var(--font-body);
286
331
  font-weight: 400;
287
- font-size: var(--text-body-sm);
332
+ font-size: var(--text-caption);
333
+ color: var(--c-text-muted);
334
+ }
335
+
336
+ .notes {
337
+ grid-row: 3;
338
+ display: grid;
339
+ grid-template-columns: 1fr 1fr;
340
+ align-content: start;
341
+ gap: var(--sp-3);
342
+ margin-top: var(--sp-4);
343
+ padding-top: var(--sp-3);
344
+ border-top: 1px solid var(--c-border);
345
+ }
346
+
347
+ .notes.one {
348
+ grid-template-columns: 1fr;
349
+ text-align: center;
350
+ }
351
+
352
+ .note {
353
+ margin: 0;
354
+ font-size: var(--text-caption);
355
+ line-height: var(--leading-caption);
288
356
  color: var(--c-text-muted);
357
+ text-wrap: pretty;
358
+ }
359
+
360
+ .note strong {
361
+ display: block;
362
+ font-weight: 600;
363
+ color: var(--c-text);
289
364
  }
290
365
 
291
366
  figcaption {
292
- margin-top: var(--sp-5);
367
+ margin-top: var(--sp-3);
293
368
  font-size: var(--text-caption);
294
369
  line-height: var(--leading-caption);
295
370
  color: var(--c-text-muted);
296
371
  }
297
372
 
298
- /* Too narrow for a row: the phases stack, each moment a dot and its name between them. */
373
+ /* Too narrow for a row: the phases stack, each moment a stop and its name between them. */
299
374
  @container (max-width: 560px) {
300
375
  .row {
301
376
  grid-template-columns: 1fr;
@@ -306,44 +381,43 @@ const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repe
306
381
  .row > li {
307
382
  grid-row: auto;
308
383
  grid-template-rows: none;
309
- row-gap: var(--sp-3);
310
384
  }
311
385
 
312
- .moment {
386
+ .stop-cell {
313
387
  display: flex;
314
- align-items: center;
315
388
  justify-content: center;
316
389
  gap: var(--sp-3);
317
390
  }
318
391
 
319
- .shape {
320
- grid-row: auto;
321
- width: min(100%, 420px);
322
- justify-self: center;
392
+ .moment-label {
393
+ position: static;
323
394
  }
324
395
 
325
- .notes,
326
- .name {
396
+ .shape,
397
+ .name,
398
+ .notes {
327
399
  grid-row: auto;
328
400
  }
329
401
 
402
+ .shape {
403
+ width: min(100%, 360px);
404
+ justify-self: center;
405
+ }
406
+
330
407
  .notes {
331
408
  width: min(100%, 420px);
332
409
  justify-self: center;
333
410
  }
334
411
 
335
- .halves {
336
- font-size: var(--text-label);
337
- }
338
412
  }
339
413
 
340
414
  @media (prefers-reduced-motion: no-preference) {
341
- .arrive li {
415
+ .arrive .row > li {
342
416
  opacity: 0;
343
417
  translate: 0 8px;
344
418
  }
345
419
 
346
- .arrive.seen li {
420
+ .arrive.seen .row > li {
347
421
  opacity: 1;
348
422
  translate: 0 0;
349
423
  transition:
@@ -353,17 +427,14 @@ const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repe
353
427
  }
354
428
 
355
429
  @media (forced-colors: active) {
356
- .open,
357
- .close {
358
- fill: CanvasText;
430
+ .edge,
431
+ .split {
432
+ stroke: CanvasText;
359
433
  }
360
434
 
435
+ .open,
361
436
  .close {
362
- fill-opacity: 0.6;
363
- }
364
-
365
- .halves {
366
- color: Canvas;
437
+ fill: Canvas;
367
438
  }
368
439
  }
369
440
  </style>
package/src/Phases.astro CHANGED
@@ -4,14 +4,14 @@
4
4
  * under it, and a short text on what happens in it. Below them, spans for what runs across
5
5
  * phases, such as discovery that never quite stops.
6
6
  *
7
- * Drawn in HTML, so the words are text that wraps and is read out in order. Below 640px wide the
8
- * phases stack and each span says which phases it runs across in words. The bands use three
9
- * fixed tones with the dark text on them, so they read the same in either theme.
7
+ * Drawn in the diagrams' own style, on a sunken plate with tinted bands and hairline rings, as in
8
+ * Flow diagram and Diamonds. HTML, so the words are text that wraps and is read out in order.
9
+ * Below 640px wide the phases stack and each span says which phases it runs across in words.
10
10
  *
11
11
  * Once, as it comes into view, the phases arrive left to right. Nothing moves under reduced
12
12
  * motion, and without script it is simply there.
13
13
  */
14
- type Tone = 'cool' | 'accent' | 'sun';
14
+ type Tone = 'cool' | 'accent' | 'quiet';
15
15
 
16
16
  interface Phase {
17
17
  /** On the band, such as "Define & validate". */
@@ -42,11 +42,12 @@ interface Props {
42
42
  }
43
43
 
44
44
  const { title, phases, spans = [], caption, class: className } = Astro.props;
45
- const tones: Tone[] = ['cool', 'accent', 'sun'];
45
+ const tones: Tone[] = ['cool', 'accent', 'quiet'];
46
46
  const last = phases.length - 1;
47
47
  ---
48
48
 
49
49
  <figure class:list={['phases', className]} data-phases>
50
+ <div class="plate">
50
51
  <ol class="row" aria-label={title} style={`--n: ${phases.length}`}>
51
52
  {
52
53
  phases.map((p, i) => (
@@ -87,6 +88,7 @@ const last = phases.length - 1;
87
88
  </ul>
88
89
  )
89
90
  }
91
+ </div>
90
92
  {caption && <figcaption>{caption}</figcaption>}
91
93
  </figure>
92
94
 
@@ -101,22 +103,33 @@ const last = phases.length - 1;
101
103
 
102
104
  <style>
103
105
  .phases {
104
- --notch: 22px;
106
+ --notch: 20px;
105
107
  min-width: 0;
106
108
  margin: 0;
109
+ }
110
+
111
+ .plate {
107
112
  container-type: inline-size;
113
+ background: var(--c-surface-sunken);
114
+ border: 1px solid var(--c-border);
115
+ border-radius: var(--radius-lg);
116
+ padding: var(--sp-6) var(--sp-5) var(--sp-5);
108
117
  }
109
118
 
119
+ /* The diagrams' tones: a tint for the band, the edge colour for the rings. */
110
120
  [data-tone='cool'] {
111
- --tone: var(--c-seq2-4);
121
+ --fill: var(--c-tag-cool-bg);
122
+ --mark: color-mix(in oklab, var(--c-tag-cool-text) 70%, transparent);
112
123
  }
113
124
 
114
125
  [data-tone='accent'] {
115
- --tone: var(--c-accent);
126
+ --fill: color-mix(in oklab, var(--c-accent) 16%, var(--c-surface));
127
+ --mark: var(--c-accent-edge);
116
128
  }
117
129
 
118
- [data-tone='sun'] {
119
- --tone: var(--c-heat-4);
130
+ [data-tone='quiet'] {
131
+ --fill: var(--c-surface);
132
+ --mark: var(--c-diagram-edge);
120
133
  }
121
134
 
122
135
  .row {
@@ -145,8 +158,8 @@ const last = phases.length - 1;
145
158
  min-height: 64px;
146
159
  margin: 0 calc(var(--notch) * -1 + 3px) 0 0;
147
160
  padding: var(--sp-3) calc(var(--notch) + var(--sp-3));
148
- background: var(--tone);
149
- color: var(--c-on-accent);
161
+ background: var(--fill);
162
+ color: var(--c-text-secondary);
150
163
  text-align: center;
151
164
  clip-path: polygon(0 0, calc(100% - var(--notch)) 0, 100% 50%, calc(100% - var(--notch)) 100%, 0 100%, var(--notch) 50%);
152
165
  font-size: var(--text-body-sm);
@@ -164,7 +177,7 @@ const last = phases.length - 1;
164
177
  }
165
178
 
166
179
  .band strong {
167
- color: inherit;
180
+ color: var(--c-text);
168
181
  font-family: var(--font-display);
169
182
  font-weight: 600;
170
183
  font-size: var(--text-body);
@@ -189,7 +202,7 @@ const last = phases.length - 1;
189
202
  place-items: center;
190
203
  aspect-ratio: 1;
191
204
  padding: var(--sp-3);
192
- border: 5px solid var(--tone);
205
+ border: 2px solid var(--mark);
193
206
  border-radius: 50%;
194
207
  background: var(--c-surface);
195
208
  color: var(--c-text);
@@ -234,17 +247,17 @@ const last = phases.length - 1;
234
247
  .spans li::after {
235
248
  content: '';
236
249
  flex: 1;
237
- border-top: 1.5px dashed var(--c-border-strong);
250
+ border-top: 1.5px dashed var(--c-diagram-line);
238
251
  }
239
252
 
240
253
  .spans li::before {
241
- border-left: 1.5px solid var(--c-border-strong);
254
+ border-left: 1.5px solid var(--c-diagram-line);
242
255
  height: 8px;
243
256
  margin-top: 8px;
244
257
  }
245
258
 
246
259
  .spans li::after {
247
- border-right: 1.5px solid var(--c-border-strong);
260
+ border-right: 1.5px solid var(--c-diagram-line);
248
261
  height: 8px;
249
262
  margin-top: 8px;
250
263
  }
@@ -263,7 +276,7 @@ const last = phases.length - 1;
263
276
  }
264
277
 
265
278
  figcaption {
266
- margin-top: var(--sp-5);
279
+ margin-top: var(--sp-3);
267
280
  font-size: var(--text-caption);
268
281
  line-height: var(--leading-caption);
269
282
  color: var(--c-text-muted);