@n1kname/components 0.55.0 → 0.57.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 +1 -1
- package/src/CompareCards.astro +329 -0
- package/src/FlowDiagram.astro +52 -10
- package/src/ServiceBlueprint.astro +459 -0
- package/src/icons.ts +3 -0
package/package.json
CHANGED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* A few things side by side as cards, each with an icon disc and a name, and short labelled notes
|
|
4
|
+
* under it. A note can say what something gives (a check), what it misses (a crossed-out eye, in a
|
|
5
|
+
* dashed box), or a before and an after with an arrow between them. For the comparisons a table
|
|
6
|
+
* would otherwise carry: sources of evidence, a problem and the rule it became, one thing split in
|
|
7
|
+
* three.
|
|
8
|
+
*
|
|
9
|
+
* Drawn in the diagrams' style: tinted icon discs with an edge, as in Flow diagram, on surface
|
|
10
|
+
* cards. A list of cards, each a description list, so it reads in order. Two columns by default;
|
|
11
|
+
* below 560px wide the cards stack.
|
|
12
|
+
*
|
|
13
|
+
* Once, as it comes into view, the cards rise in one after another. Nothing moves under reduced
|
|
14
|
+
* motion, and without script it is simply there.
|
|
15
|
+
*/
|
|
16
|
+
import Icon from './Icon.astro';
|
|
17
|
+
import type { IconName } from './icons';
|
|
18
|
+
|
|
19
|
+
type Tone = 'accent' | 'cool' | 'quiet';
|
|
20
|
+
type Mark = 'gain' | 'gap' | 'before' | 'after' | 'plain';
|
|
21
|
+
|
|
22
|
+
interface Note {
|
|
23
|
+
/** "What it gave us". */
|
|
24
|
+
label: string;
|
|
25
|
+
text: string;
|
|
26
|
+
/** How the note is drawn. Plain by default. */
|
|
27
|
+
mark?: Mark;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface Card {
|
|
31
|
+
title: string;
|
|
32
|
+
/** Under the title, a few words. */
|
|
33
|
+
kicker?: string;
|
|
34
|
+
icon?: IconName;
|
|
35
|
+
tone?: Tone;
|
|
36
|
+
notes: Note[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface Props {
|
|
40
|
+
/** What the cards compare, for a screen reader: the list is named by it. */
|
|
41
|
+
title: string;
|
|
42
|
+
cards: Card[];
|
|
43
|
+
/** Cards per row where there is room: 1 to 4. */
|
|
44
|
+
columns?: number;
|
|
45
|
+
caption?: string;
|
|
46
|
+
class?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const { title, cards, columns = 2, caption, class: className } = Astro.props;
|
|
50
|
+
const tones: Tone[] = ['accent', 'cool'];
|
|
51
|
+
const markIcon: Partial<Record<Mark, IconName>> = { gain: 'circle-check', gap: 'eye-off' };
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
<figure class:list={['compare-cards', className]} data-compare-cards>
|
|
55
|
+
<ul class="cards" aria-label={title} style={`--cols: ${Math.min(4, Math.max(1, columns))}`}>
|
|
56
|
+
{
|
|
57
|
+
cards.map((card, i) => (
|
|
58
|
+
<li class="card" data-tone={card.tone ?? tones[i % tones.length]} style={`--i: ${i}`}>
|
|
59
|
+
<div class="head">
|
|
60
|
+
<span class="disc" aria-hidden="true">
|
|
61
|
+
{card.icon ? <Icon name={card.icon} size={22} /> : <span class="num">{i + 1}</span>}
|
|
62
|
+
</span>
|
|
63
|
+
<div>
|
|
64
|
+
<h3 class="title">{card.title}</h3>
|
|
65
|
+
{card.kicker && <p class="kicker">{card.kicker}</p>}
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
<dl>
|
|
69
|
+
{card.notes.map((n, k) => {
|
|
70
|
+
const mark = n.mark ?? 'plain';
|
|
71
|
+
const icon = markIcon[mark];
|
|
72
|
+
const turn = mark === 'after' && card.notes[k - 1]?.mark === 'before';
|
|
73
|
+
return (
|
|
74
|
+
<div class:list={['note', mark, { turn }]}>
|
|
75
|
+
<dt>
|
|
76
|
+
{icon && <Icon name={icon} size={15} />}
|
|
77
|
+
{n.label}
|
|
78
|
+
</dt>
|
|
79
|
+
<dd>{n.text}</dd>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
})}
|
|
83
|
+
</dl>
|
|
84
|
+
</li>
|
|
85
|
+
))
|
|
86
|
+
}
|
|
87
|
+
</ul>
|
|
88
|
+
{caption && <figcaption>{caption}</figcaption>}
|
|
89
|
+
</figure>
|
|
90
|
+
|
|
91
|
+
<script is:inline>
|
|
92
|
+
// Before the first paint, so cards waiting to arrive never show and then vanish.
|
|
93
|
+
(() => {
|
|
94
|
+
const all = document.querySelectorAll('[data-compare-cards]:not(.arrive)');
|
|
95
|
+
const fig = all[all.length - 1];
|
|
96
|
+
if (!fig || !('IntersectionObserver' in window) || matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
|
97
|
+
fig.classList.add('arrive');
|
|
98
|
+
const io = new IntersectionObserver(
|
|
99
|
+
(entries) => {
|
|
100
|
+
for (const e of entries) {
|
|
101
|
+
if (!e.isIntersecting) continue;
|
|
102
|
+
e.target.classList.add('in');
|
|
103
|
+
io.unobserve(e.target);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{ rootMargin: '0px 0px -15% 0px' },
|
|
107
|
+
);
|
|
108
|
+
io.observe(fig);
|
|
109
|
+
})();
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
<style>
|
|
113
|
+
.compare-cards {
|
|
114
|
+
min-width: 0;
|
|
115
|
+
margin: var(--sp-7) 0;
|
|
116
|
+
container-type: inline-size;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
[data-tone='accent'] {
|
|
120
|
+
--edge: var(--c-accent-edge);
|
|
121
|
+
--soft: var(--c-surface-tint);
|
|
122
|
+
--mark: var(--c-accent);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
[data-tone='cool'] {
|
|
126
|
+
--edge: color-mix(in oklab, var(--c-tag-cool-text) 55%, transparent);
|
|
127
|
+
--soft: var(--c-tag-cool-bg);
|
|
128
|
+
--mark: var(--c-tag-cool-text);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
[data-tone='quiet'] {
|
|
132
|
+
--edge: var(--c-diagram-edge);
|
|
133
|
+
--soft: var(--c-surface);
|
|
134
|
+
--mark: var(--c-text-secondary);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.cards {
|
|
138
|
+
display: grid;
|
|
139
|
+
grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
|
|
140
|
+
gap: var(--sp-4);
|
|
141
|
+
margin: 0;
|
|
142
|
+
padding: 0;
|
|
143
|
+
list-style: none;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@container (max-width: 560px) {
|
|
147
|
+
.cards {
|
|
148
|
+
grid-template-columns: minmax(0, 1fr);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.card {
|
|
153
|
+
display: flex;
|
|
154
|
+
flex-direction: column;
|
|
155
|
+
gap: var(--sp-4);
|
|
156
|
+
min-width: 0;
|
|
157
|
+
margin: 0;
|
|
158
|
+
padding: var(--sp-5);
|
|
159
|
+
background: var(--c-surface);
|
|
160
|
+
border: 1px solid var(--c-border);
|
|
161
|
+
border-radius: var(--radius-lg);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.head {
|
|
165
|
+
display: flex;
|
|
166
|
+
gap: var(--sp-3);
|
|
167
|
+
align-items: center;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.disc {
|
|
171
|
+
flex: none;
|
|
172
|
+
display: grid;
|
|
173
|
+
place-items: center;
|
|
174
|
+
width: 44px;
|
|
175
|
+
height: 44px;
|
|
176
|
+
border-radius: 50%;
|
|
177
|
+
background: var(--soft);
|
|
178
|
+
border: 1.5px solid var(--edge);
|
|
179
|
+
color: var(--mark);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.num {
|
|
183
|
+
font-weight: 600;
|
|
184
|
+
font-size: var(--text-body);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.title {
|
|
188
|
+
margin: 0;
|
|
189
|
+
font-family: var(--font-display);
|
|
190
|
+
font-weight: 600;
|
|
191
|
+
font-size: var(--text-sub);
|
|
192
|
+
line-height: var(--leading-sub);
|
|
193
|
+
color: var(--c-text);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.kicker {
|
|
197
|
+
margin: 0;
|
|
198
|
+
font-size: var(--text-caption);
|
|
199
|
+
color: var(--c-text-muted);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
dl {
|
|
203
|
+
display: flex;
|
|
204
|
+
flex-direction: column;
|
|
205
|
+
gap: var(--sp-3);
|
|
206
|
+
margin: 0;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.note {
|
|
210
|
+
position: relative;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
dt {
|
|
214
|
+
display: flex;
|
|
215
|
+
gap: 6px;
|
|
216
|
+
align-items: center;
|
|
217
|
+
margin-bottom: 2px;
|
|
218
|
+
font-size: var(--text-caption);
|
|
219
|
+
font-weight: 600;
|
|
220
|
+
color: var(--c-text-secondary);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
dd {
|
|
224
|
+
margin: 0;
|
|
225
|
+
font-size: var(--text-body-sm);
|
|
226
|
+
line-height: var(--leading-body-sm);
|
|
227
|
+
color: var(--c-text);
|
|
228
|
+
text-wrap: pretty;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* What a source gives: a tinted box with a check, against the dashed box of what it misses. */
|
|
232
|
+
.gain {
|
|
233
|
+
padding: var(--sp-2) var(--sp-3);
|
|
234
|
+
background: color-mix(in oklab, var(--soft) 60%, var(--c-surface));
|
|
235
|
+
border: 1px solid var(--edge);
|
|
236
|
+
border-radius: var(--radius-md);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.gain dt :global(svg) {
|
|
240
|
+
color: var(--mark);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* What a source can't see: a dashed box, the text a step quieter. */
|
|
244
|
+
.gap {
|
|
245
|
+
padding: var(--sp-2) var(--sp-3);
|
|
246
|
+
border: 1px dashed var(--c-border-strong);
|
|
247
|
+
border-radius: var(--radius-md);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.gap dd {
|
|
251
|
+
color: var(--c-text-secondary);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/* A before and an after: two tinted boxes with an arrow down between them. */
|
|
255
|
+
.before,
|
|
256
|
+
.after {
|
|
257
|
+
padding: var(--sp-2) var(--sp-3);
|
|
258
|
+
border-radius: var(--radius-md);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.before {
|
|
262
|
+
background: color-mix(in oklab, var(--c-status-critical) 10%, var(--c-surface));
|
|
263
|
+
border: 1px solid color-mix(in oklab, var(--c-status-critical) 40%, transparent);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.after {
|
|
267
|
+
background: var(--soft);
|
|
268
|
+
border: 1px solid var(--edge);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.turn {
|
|
272
|
+
margin-top: var(--sp-3);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.turn::before {
|
|
276
|
+
content: '';
|
|
277
|
+
position: absolute;
|
|
278
|
+
left: var(--sp-4);
|
|
279
|
+
top: calc(-1 * var(--sp-3) - var(--sp-3));
|
|
280
|
+
width: 1.5px;
|
|
281
|
+
height: calc(var(--sp-3) * 2);
|
|
282
|
+
background: var(--c-diagram-line);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.turn::after {
|
|
286
|
+
content: '';
|
|
287
|
+
position: absolute;
|
|
288
|
+
left: calc(var(--sp-4) - 3.25px);
|
|
289
|
+
top: -10px;
|
|
290
|
+
width: 7px;
|
|
291
|
+
height: 7px;
|
|
292
|
+
border-right: 1.5px solid var(--c-diagram-line);
|
|
293
|
+
border-bottom: 1.5px solid var(--c-diagram-line);
|
|
294
|
+
rotate: 45deg;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
figcaption {
|
|
298
|
+
margin-top: var(--sp-3);
|
|
299
|
+
font-size: var(--text-caption);
|
|
300
|
+
line-height: var(--leading-caption);
|
|
301
|
+
color: var(--c-text-muted);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/* Arriving: the cards rise in, 90ms apart. */
|
|
305
|
+
.arrive .card {
|
|
306
|
+
opacity: 0;
|
|
307
|
+
translate: 0 12px;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.arrive.in .card {
|
|
311
|
+
opacity: 1;
|
|
312
|
+
translate: 0 0;
|
|
313
|
+
transition:
|
|
314
|
+
opacity var(--motion-reveal, 500ms) var(--ease-out),
|
|
315
|
+
translate var(--motion-reveal, 500ms) var(--ease-out);
|
|
316
|
+
transition-delay: calc(var(--i) * 90ms);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
@media (forced-colors: active) {
|
|
320
|
+
.disc,
|
|
321
|
+
.card,
|
|
322
|
+
.before,
|
|
323
|
+
.after,
|
|
324
|
+
.gain,
|
|
325
|
+
.gap {
|
|
326
|
+
border-color: CanvasText;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
</style>
|
package/src/FlowDiagram.astro
CHANGED
|
@@ -170,7 +170,8 @@ const longest = (pts: [number, number][]): [number, number] => {
|
|
|
170
170
|
const len = Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]);
|
|
171
171
|
if (len > best) {
|
|
172
172
|
best = len;
|
|
173
|
-
|
|
173
|
+
// On the line: the label's pill is centred on it (the text's baseline sits 4.5px below).
|
|
174
|
+
at = [(pts[i][0] + pts[i - 1][0]) / 2, (pts[i][1] + pts[i - 1][1]) / 2 + 4.5];
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
177
|
return at;
|
|
@@ -205,6 +206,10 @@ const views = [
|
|
|
205
206
|
: []),
|
|
206
207
|
];
|
|
207
208
|
|
|
209
|
+
// A label's pill: wide enough for its text at 13px semibold, with room either side. Measured
|
|
210
|
+
// from the font's average glyph, so it never needs the page to lay out first.
|
|
211
|
+
const chipWidth = (label: string) => Math.round(label.length * 7.1 + 20);
|
|
212
|
+
|
|
208
213
|
// Label lines for a circle: break at the space nearest the middle when it is long.
|
|
209
214
|
const lines = (label: string) => {
|
|
210
215
|
if (label.length <= 10 || !label.includes(' ')) return [label];
|
|
@@ -238,11 +243,6 @@ const lines = (label: string) => {
|
|
|
238
243
|
<g class:list={['edge', e.tone]} data-step={e.step}>
|
|
239
244
|
<path class="line" d={e.d} pathLength="1" />
|
|
240
245
|
<path class="head" d={e.head} />
|
|
241
|
-
{e.label && (
|
|
242
|
-
<text class="edge-label" x={e.at[0]} y={e.at[1]}>
|
|
243
|
-
{e.label}
|
|
244
|
-
</text>
|
|
245
|
-
)}
|
|
246
246
|
{e.flow && (
|
|
247
247
|
<circle class="pulse" r="3.5">
|
|
248
248
|
<animateMotion dur="2.8s" begin="indefinite" repeatCount="indefinite" keyPoints="0;1;1" keyTimes="0;0.7;1" calcMode="linear" path={e.d} />
|
|
@@ -253,6 +253,23 @@ const lines = (label: string) => {
|
|
|
253
253
|
}
|
|
254
254
|
</g>
|
|
255
255
|
|
|
256
|
+
{/* Labels above every line, so no line or pulse crosses a label's pill. */}
|
|
257
|
+
<g class="labels">
|
|
258
|
+
{
|
|
259
|
+
drawn.map(
|
|
260
|
+
(e) =>
|
|
261
|
+
e.label && (
|
|
262
|
+
<g class:list={['edge-label', e.tone]} data-step={e.step}>
|
|
263
|
+
<rect class="chip" x={e.at[0] - chipWidth(e.label) / 2} y={e.at[1] - 15.5} width={chipWidth(e.label)} height="22" rx="11" />
|
|
264
|
+
<text x={e.at[0]} y={e.at[1]}>
|
|
265
|
+
{e.label}
|
|
266
|
+
</text>
|
|
267
|
+
</g>
|
|
268
|
+
),
|
|
269
|
+
)
|
|
270
|
+
}
|
|
271
|
+
</g>
|
|
272
|
+
|
|
256
273
|
{
|
|
257
274
|
nodes.map((n) => {
|
|
258
275
|
const { w, h } = size(n);
|
|
@@ -475,20 +492,38 @@ const lines = (label: string) => {
|
|
|
475
492
|
stroke: var(--c-tag-cool-text);
|
|
476
493
|
}
|
|
477
494
|
|
|
478
|
-
|
|
495
|
+
/* An edge's label sits in a pill on its line, so the line runs under it, never through the
|
|
496
|
+
* words. The pill is the page's background with a little of the line's colour in it. */
|
|
497
|
+
.edge-label text {
|
|
479
498
|
font-size: 13px;
|
|
480
499
|
font-weight: 600;
|
|
481
500
|
fill: var(--c-text-muted);
|
|
482
501
|
}
|
|
483
502
|
|
|
484
|
-
.
|
|
503
|
+
.chip {
|
|
504
|
+
fill: color-mix(in oklab, var(--c-diagram-line) 10%, var(--c-bg));
|
|
505
|
+
stroke: color-mix(in oklab, var(--c-diagram-line) 45%, transparent);
|
|
506
|
+
stroke-width: 1;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
.edge-label.accent text {
|
|
485
510
|
fill: var(--c-text-accent);
|
|
486
511
|
}
|
|
487
512
|
|
|
488
|
-
.edge.
|
|
513
|
+
.edge-label.accent .chip {
|
|
514
|
+
fill: color-mix(in oklab, var(--c-accent) 12%, var(--c-bg));
|
|
515
|
+
stroke: var(--c-accent-edge);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
.edge-label.cool text {
|
|
489
519
|
fill: var(--c-tag-cool-text);
|
|
490
520
|
}
|
|
491
521
|
|
|
522
|
+
.edge-label.cool .chip {
|
|
523
|
+
fill: color-mix(in oklab, var(--c-tag-cool-text) 12%, var(--c-bg));
|
|
524
|
+
stroke: color-mix(in oklab, var(--c-tag-cool-text) 45%, transparent);
|
|
525
|
+
}
|
|
526
|
+
|
|
492
527
|
.pulse {
|
|
493
528
|
fill: var(--c-diagram-line);
|
|
494
529
|
opacity: 0;
|
|
@@ -551,7 +586,7 @@ const lines = (label: string) => {
|
|
|
551
586
|
}
|
|
552
587
|
|
|
553
588
|
.in .edge .head,
|
|
554
|
-
.in .edge
|
|
589
|
+
.in .edge-label {
|
|
555
590
|
animation: land calc(var(--motion-grow, 700ms) * 0.45) var(--ease-out) calc(var(--d, 0ms) + var(--motion-grow, 700ms) * 0.8) both;
|
|
556
591
|
}
|
|
557
592
|
|
|
@@ -603,4 +638,11 @@ const lines = (label: string) => {
|
|
|
603
638
|
color: var(--c-text-muted);
|
|
604
639
|
max-width: var(--layout-measure);
|
|
605
640
|
}
|
|
641
|
+
|
|
642
|
+
@media (forced-colors: active) {
|
|
643
|
+
.chip {
|
|
644
|
+
fill: Canvas;
|
|
645
|
+
stroke: CanvasText;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
606
648
|
</style>
|
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* A service blueprint: the stages of a journey left to right, and lanes under them for what the
|
|
4
|
+
* customer does, thinks and sees, what happens behind the scenes, where it goes wrong, and what
|
|
5
|
+
* support hears about it. Lines across, such as the line of visibility, split what the customer
|
|
6
|
+
* sees from what they don't.
|
|
7
|
+
*
|
|
8
|
+
* HTML, so every word is text: a list of stages, each a list of its lanes, read in journey order.
|
|
9
|
+
* Wide, it is a grid that scrolls sideways with the lane names pinned on the left. Below 640px wide
|
|
10
|
+
* each stage becomes a card in a row you swipe through, with its lanes named inside it.
|
|
11
|
+
*
|
|
12
|
+
* Nothing moves.
|
|
13
|
+
*/
|
|
14
|
+
type Kind = 'doing' | 'feeling' | 'front' | 'back' | 'pain' | 'signal' | 'plain';
|
|
15
|
+
|
|
16
|
+
interface Lane {
|
|
17
|
+
/** The key stages use for this lane's cells, such as "doing". */
|
|
18
|
+
key: string;
|
|
19
|
+
/** "Doing", "Front stage". */
|
|
20
|
+
label: string;
|
|
21
|
+
/** Under the label, such as "what they see". */
|
|
22
|
+
hint?: string;
|
|
23
|
+
/** Sets the lane's colour. Defaults to the key when it names a kind, plain otherwise. */
|
|
24
|
+
kind?: Kind;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A cell: plain text, or a figure (such as "716 tickets") in bold ahead of the text. */
|
|
28
|
+
type Cell = string | { figure: string; text?: string };
|
|
29
|
+
|
|
30
|
+
interface Stage {
|
|
31
|
+
/** "Employer sets up the driver". */
|
|
32
|
+
label: string;
|
|
33
|
+
/** One cell per lane, by the lane's key. A lane left out stays empty for this stage. */
|
|
34
|
+
cells: Record<string, Cell | undefined>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface Props {
|
|
38
|
+
/** What the blueprint shows, for a screen reader and the scroll area's name. */
|
|
39
|
+
title: string;
|
|
40
|
+
lanes: Lane[];
|
|
41
|
+
stages: Stage[];
|
|
42
|
+
/** Lines across, drawn above the lane they name: { before: 'back', label: 'Line of visibility' }. */
|
|
43
|
+
lines?: { before: string; label: string }[];
|
|
44
|
+
caption?: string;
|
|
45
|
+
class?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { title, lanes, stages, lines = [], caption, class: className } = Astro.props;
|
|
49
|
+
const kinds: Kind[] = ['doing', 'feeling', 'front', 'back', 'pain', 'signal', 'plain'];
|
|
50
|
+
const kindOf = (l: Lane): Kind => l.kind ?? (kinds.includes(l.key as Kind) ? (l.key as Kind) : 'plain');
|
|
51
|
+
|
|
52
|
+
// Grid rows: the stage names first, then each lane, with a row of its own for a line above it.
|
|
53
|
+
let row = 2;
|
|
54
|
+
const laneRow: Record<string, number> = {};
|
|
55
|
+
const lineRows: { row: number; label: string }[] = [];
|
|
56
|
+
for (const lane of lanes) {
|
|
57
|
+
const line = lines.find((l) => l.before === lane.key);
|
|
58
|
+
if (line) lineRows.push({ row: row++, label: line.label });
|
|
59
|
+
laneRow[lane.key] = row++;
|
|
60
|
+
}
|
|
61
|
+
const rows = row - 1;
|
|
62
|
+
|
|
63
|
+
// On a card, a line shows above the first filled cell at or below it.
|
|
64
|
+
const lineAbove = (stage: Stage, laneIndex: number) => {
|
|
65
|
+
for (const line of lines) {
|
|
66
|
+
const start = lanes.findIndex((l) => l.key === line.before);
|
|
67
|
+
if (start < 0 || laneIndex < start) continue;
|
|
68
|
+
const first = lanes.findIndex((l, i) => i >= start && stage.cells[l.key] !== undefined);
|
|
69
|
+
if (first === laneIndex) return line.label;
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
};
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
<figure class:list={['service-blueprint', className]} data-service-blueprint>
|
|
76
|
+
<div class="plate">
|
|
77
|
+
<div class="scroller" tabindex="0" role="region" aria-label={title}>
|
|
78
|
+
<div class="grid" style={`--stages: ${stages.length}; --rows: ${rows}`}>
|
|
79
|
+
<div class="rail" aria-hidden="true">
|
|
80
|
+
{
|
|
81
|
+
lanes.map((lane) => (
|
|
82
|
+
<div class="lane-name" data-kind={kindOf(lane)} style={`--r: ${laneRow[lane.key]}`}>
|
|
83
|
+
<span class="swatch" />
|
|
84
|
+
<span>
|
|
85
|
+
{lane.label}
|
|
86
|
+
{lane.hint && <span class="hint">{lane.hint}</span>}
|
|
87
|
+
</span>
|
|
88
|
+
</div>
|
|
89
|
+
))
|
|
90
|
+
}
|
|
91
|
+
{
|
|
92
|
+
lineRows.map((l) => (
|
|
93
|
+
<div class="line" style={`--r: ${l.row}`}>
|
|
94
|
+
<span>{l.label}</span>
|
|
95
|
+
</div>
|
|
96
|
+
))
|
|
97
|
+
}
|
|
98
|
+
</div>
|
|
99
|
+
<ol class="stages" role="list">
|
|
100
|
+
{
|
|
101
|
+
stages.map((stage, s) => (
|
|
102
|
+
<li class="stage" role="listitem" style={`--c: ${s + 2}`}>
|
|
103
|
+
<div class="stage-name">
|
|
104
|
+
<span class="num" aria-hidden="true">
|
|
105
|
+
{s + 1}
|
|
106
|
+
</span>
|
|
107
|
+
<span>{stage.label}</span>
|
|
108
|
+
</div>
|
|
109
|
+
<dl>
|
|
110
|
+
{lanes.map((lane, i) => {
|
|
111
|
+
const cell = stage.cells[lane.key];
|
|
112
|
+
if (cell === undefined) return null;
|
|
113
|
+
const line = lineAbove(stage, i);
|
|
114
|
+
return (
|
|
115
|
+
<div class="cell" data-kind={kindOf(lane)} data-line={line} style={`--r: ${laneRow[lane.key]}`}>
|
|
116
|
+
<dt>{lane.label}</dt>
|
|
117
|
+
<dd>
|
|
118
|
+
{typeof cell === 'string' ? (
|
|
119
|
+
cell
|
|
120
|
+
) : (
|
|
121
|
+
<>
|
|
122
|
+
<strong class="figure">{cell.figure}</strong>
|
|
123
|
+
{cell.text && <> {cell.text}</>}
|
|
124
|
+
</>
|
|
125
|
+
)}
|
|
126
|
+
</dd>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
})}
|
|
130
|
+
</dl>
|
|
131
|
+
</li>
|
|
132
|
+
))
|
|
133
|
+
}
|
|
134
|
+
</ol>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
{caption && <figcaption>{caption}</figcaption>}
|
|
139
|
+
</figure>
|
|
140
|
+
|
|
141
|
+
<style>
|
|
142
|
+
.service-blueprint {
|
|
143
|
+
min-width: 0;
|
|
144
|
+
margin: 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.plate {
|
|
148
|
+
container-type: inline-size;
|
|
149
|
+
background: var(--c-surface-sunken);
|
|
150
|
+
border: 1px solid var(--c-border);
|
|
151
|
+
border-radius: var(--radius-lg);
|
|
152
|
+
overflow: hidden;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.scroller {
|
|
156
|
+
overflow-x: auto;
|
|
157
|
+
overscroll-behavior-x: contain;
|
|
158
|
+
padding: var(--sp-5) var(--sp-5) var(--sp-5) 0;
|
|
159
|
+
scrollbar-width: thin;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.scroller:focus-visible {
|
|
163
|
+
outline: 2px solid var(--c-focus);
|
|
164
|
+
outline-offset: -2px;
|
|
165
|
+
border-radius: var(--radius-lg);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/* The lanes' colours: a tint mixed into the surface and an edge, so text on them keeps its
|
|
169
|
+
* contrast in either theme. Customer lanes in the accent, a lavender and the cool teal; pain and
|
|
170
|
+
* support signal in the status colours, with a heavier left edge so they read as warnings. */
|
|
171
|
+
[data-kind='doing'] {
|
|
172
|
+
--edge: var(--c-accent-edge);
|
|
173
|
+
--soft: color-mix(in oklab, var(--c-accent) 14%, var(--c-surface));
|
|
174
|
+
--mark: var(--c-accent);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
[data-kind='feeling'] {
|
|
178
|
+
--edge: color-mix(in oklab, var(--c-chart-6) 50%, transparent);
|
|
179
|
+
--soft: color-mix(in oklab, var(--c-chart-6) 14%, var(--c-surface));
|
|
180
|
+
--mark: var(--c-chart-6);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
[data-kind='front'] {
|
|
184
|
+
--edge: color-mix(in oklab, var(--c-tag-cool-text) 50%, transparent);
|
|
185
|
+
--soft: var(--c-tag-cool-bg);
|
|
186
|
+
--mark: var(--c-tag-cool-text);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
[data-kind='back'],
|
|
190
|
+
[data-kind='plain'] {
|
|
191
|
+
--edge: var(--c-diagram-edge);
|
|
192
|
+
--soft: var(--c-surface);
|
|
193
|
+
--mark: var(--c-diagram-edge);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
[data-kind='pain'] {
|
|
197
|
+
--edge: color-mix(in oklab, var(--c-status-critical) 55%, transparent);
|
|
198
|
+
--soft: color-mix(in oklab, var(--c-status-critical) 13%, var(--c-surface));
|
|
199
|
+
--mark: var(--c-status-critical);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
[data-kind='signal'] {
|
|
203
|
+
--edge: color-mix(in oklab, var(--c-status-warning) 60%, transparent);
|
|
204
|
+
--soft: color-mix(in oklab, var(--c-status-warning) 14%, var(--c-surface));
|
|
205
|
+
--mark: var(--c-status-warning);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* Wide: one grid for the rail, the stage names and every cell, so a lane lines up across all
|
|
209
|
+
* stages however much text a cell holds. The rail and the stage lists step aside (contents)
|
|
210
|
+
* and their items take their place in it. */
|
|
211
|
+
.grid {
|
|
212
|
+
display: grid;
|
|
213
|
+
grid-template-columns: 9.5rem repeat(var(--stages), minmax(12rem, 1fr));
|
|
214
|
+
grid-template-rows: auto;
|
|
215
|
+
gap: var(--sp-2);
|
|
216
|
+
/* Each stage at least 12rem, so long notes wrap instead of widening their stage. */
|
|
217
|
+
width: max(100%, calc(9.5rem + var(--stages) * (12rem + var(--sp-2))));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.rail,
|
|
221
|
+
.stages,
|
|
222
|
+
.stage,
|
|
223
|
+
dl {
|
|
224
|
+
display: contents;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.stages {
|
|
228
|
+
list-style: none;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.lane-name {
|
|
232
|
+
grid-column: 1;
|
|
233
|
+
grid-row: var(--r);
|
|
234
|
+
position: sticky;
|
|
235
|
+
left: 0;
|
|
236
|
+
z-index: 2;
|
|
237
|
+
display: flex;
|
|
238
|
+
gap: var(--sp-2);
|
|
239
|
+
align-items: flex-start;
|
|
240
|
+
margin: 0;
|
|
241
|
+
padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-5);
|
|
242
|
+
background: var(--c-surface-sunken);
|
|
243
|
+
font-size: var(--text-body-sm);
|
|
244
|
+
font-weight: 600;
|
|
245
|
+
line-height: 1.25;
|
|
246
|
+
color: var(--c-text);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.swatch {
|
|
250
|
+
flex: none;
|
|
251
|
+
width: 10px;
|
|
252
|
+
height: 10px;
|
|
253
|
+
margin-top: 0.25em;
|
|
254
|
+
border-radius: 3px;
|
|
255
|
+
background: var(--soft);
|
|
256
|
+
border: 1.5px solid var(--mark);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.hint {
|
|
260
|
+
display: block;
|
|
261
|
+
font-weight: 400;
|
|
262
|
+
font-size: var(--text-caption);
|
|
263
|
+
color: var(--c-text-muted);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/* A line across every stage, its name pinned on the left with the lane names. */
|
|
267
|
+
.line {
|
|
268
|
+
grid-column: 1 / -1;
|
|
269
|
+
grid-row: var(--r);
|
|
270
|
+
position: relative;
|
|
271
|
+
margin: var(--sp-1) 0;
|
|
272
|
+
height: 0;
|
|
273
|
+
border-top: 1.5px dashed var(--c-diagram-line);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.line span {
|
|
277
|
+
position: sticky;
|
|
278
|
+
left: 0;
|
|
279
|
+
display: inline-block;
|
|
280
|
+
translate: 0 -50%;
|
|
281
|
+
padding: 0 var(--sp-2) 0 var(--sp-5);
|
|
282
|
+
background: var(--c-surface-sunken);
|
|
283
|
+
font-size: var(--text-caption);
|
|
284
|
+
font-weight: 600;
|
|
285
|
+
color: var(--c-text-muted);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.stage-name {
|
|
289
|
+
grid-column: var(--c);
|
|
290
|
+
grid-row: 1;
|
|
291
|
+
display: flex;
|
|
292
|
+
gap: var(--sp-2);
|
|
293
|
+
align-items: flex-start;
|
|
294
|
+
margin: 0 0 var(--sp-1);
|
|
295
|
+
padding-bottom: var(--sp-2);
|
|
296
|
+
border-bottom: 2px solid var(--c-border-strong);
|
|
297
|
+
font-family: var(--font-display);
|
|
298
|
+
font-weight: 600;
|
|
299
|
+
font-size: var(--text-body);
|
|
300
|
+
line-height: 1.25;
|
|
301
|
+
color: var(--c-text);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.num {
|
|
305
|
+
flex: none;
|
|
306
|
+
display: inline-grid;
|
|
307
|
+
place-items: center;
|
|
308
|
+
min-width: 1.5rem;
|
|
309
|
+
height: 1.5rem;
|
|
310
|
+
border-radius: var(--radius-full);
|
|
311
|
+
background: var(--c-surface);
|
|
312
|
+
border: 1px solid var(--c-border-strong);
|
|
313
|
+
font-family: var(--font-body);
|
|
314
|
+
font-size: var(--text-caption);
|
|
315
|
+
color: var(--c-text-secondary);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.cell {
|
|
319
|
+
grid-column: var(--c);
|
|
320
|
+
grid-row: var(--r);
|
|
321
|
+
min-width: 0;
|
|
322
|
+
padding: var(--sp-2) var(--sp-3);
|
|
323
|
+
background: var(--soft);
|
|
324
|
+
border: 1px solid var(--edge);
|
|
325
|
+
border-radius: var(--radius-md);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.cell[data-kind='back'] {
|
|
329
|
+
background: transparent;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.cell:is([data-kind='pain'], [data-kind='signal']) {
|
|
333
|
+
border-left: 3px solid var(--mark);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
dt {
|
|
337
|
+
position: absolute;
|
|
338
|
+
width: 1px;
|
|
339
|
+
height: 1px;
|
|
340
|
+
overflow: hidden;
|
|
341
|
+
clip-path: inset(50%);
|
|
342
|
+
white-space: nowrap;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
dd {
|
|
346
|
+
margin: 0;
|
|
347
|
+
font-size: var(--text-body-sm);
|
|
348
|
+
line-height: var(--leading-body-sm);
|
|
349
|
+
color: var(--c-text);
|
|
350
|
+
text-wrap: pretty;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.figure {
|
|
354
|
+
font-weight: 600;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
[data-kind='feeling'] dd {
|
|
358
|
+
font-style: italic;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/* Narrow: each stage is a card in a row you swipe through, its lanes named inside it, and a
|
|
362
|
+
* line shown above the first cell under it. */
|
|
363
|
+
@container (max-width: 640px) {
|
|
364
|
+
.scroller {
|
|
365
|
+
padding: var(--sp-4);
|
|
366
|
+
scroll-snap-type: x mandatory;
|
|
367
|
+
scroll-padding-inline: var(--sp-4);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.grid {
|
|
371
|
+
display: block;
|
|
372
|
+
width: auto;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.rail {
|
|
376
|
+
display: none;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.stages {
|
|
380
|
+
display: flex;
|
|
381
|
+
gap: var(--sp-3);
|
|
382
|
+
margin: 0;
|
|
383
|
+
padding: 0;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.stage {
|
|
387
|
+
display: block;
|
|
388
|
+
flex: 0 0 min(85%, 20rem);
|
|
389
|
+
scroll-snap-align: start;
|
|
390
|
+
padding: var(--sp-4);
|
|
391
|
+
background: var(--c-surface);
|
|
392
|
+
border: 1px solid var(--c-border);
|
|
393
|
+
border-radius: var(--radius-lg);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.stage-name {
|
|
397
|
+
margin-bottom: var(--sp-3);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
dl {
|
|
401
|
+
display: grid;
|
|
402
|
+
gap: var(--sp-2);
|
|
403
|
+
margin: 0;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
dt {
|
|
407
|
+
position: static;
|
|
408
|
+
width: auto;
|
|
409
|
+
height: auto;
|
|
410
|
+
overflow: visible;
|
|
411
|
+
clip-path: none;
|
|
412
|
+
margin-bottom: 2px;
|
|
413
|
+
font-size: var(--text-caption);
|
|
414
|
+
font-weight: 600;
|
|
415
|
+
color: var(--c-text-secondary);
|
|
416
|
+
white-space: normal;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.cell[data-line] {
|
|
420
|
+
position: relative;
|
|
421
|
+
margin-top: var(--sp-5);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.cell[data-line]::before {
|
|
425
|
+
content: attr(data-line);
|
|
426
|
+
position: absolute;
|
|
427
|
+
left: 0;
|
|
428
|
+
right: 0;
|
|
429
|
+
top: calc(-1 * var(--sp-4));
|
|
430
|
+
border-top: 1.5px dashed var(--c-diagram-line);
|
|
431
|
+
padding-top: 2px;
|
|
432
|
+
font-size: var(--text-caption);
|
|
433
|
+
font-weight: 600;
|
|
434
|
+
color: var(--c-text-muted);
|
|
435
|
+
line-height: 1;
|
|
436
|
+
translate: 0 -2px;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
figcaption {
|
|
441
|
+
margin-top: var(--sp-3);
|
|
442
|
+
font-size: var(--text-caption);
|
|
443
|
+
line-height: var(--leading-caption);
|
|
444
|
+
color: var(--c-text-muted);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
@media (forced-colors: active) {
|
|
448
|
+
.cell,
|
|
449
|
+
.swatch,
|
|
450
|
+
.num {
|
|
451
|
+
border-color: CanvasText;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
.line,
|
|
455
|
+
.cell[data-line]::before {
|
|
456
|
+
border-color: CanvasText;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
</style>
|
package/src/icons.ts
CHANGED
|
@@ -29,6 +29,9 @@ export const ICONS = {
|
|
|
29
29
|
headphones:
|
|
30
30
|
'<path d="M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3"/>',
|
|
31
31
|
search: '<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',
|
|
32
|
+
// What a source can't see, in Compare cards.
|
|
33
|
+
'eye-off':
|
|
34
|
+
'<path d="M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"/><path d="M14.084 14.158a3 3 0 0 1-4.242-4.242"/><path d="M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"/><path d="m2 2 20 20"/>',
|
|
32
35
|
'trending-up':
|
|
33
36
|
'<polyline points="22 7 13.5 15.5 8.5 10.5 2 17"/><polyline points="16 7 22 7 22 13"/>',
|
|
34
37
|
'shield-check':
|