@n1kname/components 0.55.0 → 0.56.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/ServiceBlueprint.astro +459 -0
package/package.json
CHANGED
|
@@ -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>
|