@n1kname/components 0.21.0 → 0.23.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 +6 -4
- package/src/Diamonds.astro +385 -0
- package/src/FlowDiagram.astro +4 -4
- package/src/LoadFailed.astro +32 -0
- package/src/Phases.astro +363 -0
- package/src/Reveal.astro +2 -2
- package/src/SectionNav.astro +149 -0
- package/src/SidePanel.astro +1 -1
- package/src/SignIn.astro +372 -0
- package/src/Timeline.astro +4 -4
- package/src/hexmap.js +149 -0
- package/src/highlight.css +1 -1
- package/src/legend.js +4 -2
- package/src/loadfailed.js +18 -0
- package/src/yearcalendar.js +8 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n1kname/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -24,13 +24,15 @@
|
|
|
24
24
|
"./legend.js": "./src/legend.js",
|
|
25
25
|
"./sidepanel.js": "./src/sidepanel.js",
|
|
26
26
|
"./mapstage.js": "./src/mapstage.js",
|
|
27
|
-
"./match.css": "./src/match.css"
|
|
27
|
+
"./match.css": "./src/match.css",
|
|
28
|
+
"./loadfailed.js": "./src/loadfailed.js",
|
|
29
|
+
"./hexmap.js": "./src/hexmap.js"
|
|
28
30
|
},
|
|
29
31
|
"dependencies": {
|
|
30
|
-
"@n1kname/charts": "0.
|
|
32
|
+
"@n1kname/charts": "0.12.0"
|
|
31
33
|
},
|
|
32
34
|
"peerDependencies": {
|
|
33
|
-
"@n1kname/tokens": "^0.
|
|
35
|
+
"@n1kname/tokens": "^0.6.0",
|
|
34
36
|
"astro": "^7.4.4"
|
|
35
37
|
},
|
|
36
38
|
"publishConfig": {
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
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.
|
|
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.
|
|
11
|
+
*
|
|
12
|
+
* Once, as it comes into view, the parts arrive left to right. Nothing moves under reduced
|
|
13
|
+
* motion, and without script it is simply there.
|
|
14
|
+
*/
|
|
15
|
+
type Tone = 'cool' | 'accent' | 'sun';
|
|
16
|
+
|
|
17
|
+
interface Half {
|
|
18
|
+
/** Inside the half, such as "Discover". */
|
|
19
|
+
label: string;
|
|
20
|
+
/** Above the half: a short title ("Diverge") and the question it asks. */
|
|
21
|
+
note?: { title: string; text: string };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface Phase {
|
|
25
|
+
/** Under the diamond, such as "Discovery". */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Under the name, such as "Design the right thing". */
|
|
28
|
+
motto?: string;
|
|
29
|
+
tone?: Tone;
|
|
30
|
+
/** The two halves: opening out, then narrowing. Leave out with `repeat`. */
|
|
31
|
+
halves?: [Half, Half];
|
|
32
|
+
/** Smaller diamonds that fade out, for work that keeps going. */
|
|
33
|
+
repeat?: boolean;
|
|
34
|
+
/** Above a repeating phase, as a half's note is above a half. */
|
|
35
|
+
note?: { title: string; text: string };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface Props {
|
|
39
|
+
/** What the diagram is, for a screen reader: the list is named by it. */
|
|
40
|
+
title: string;
|
|
41
|
+
phases: Phase[];
|
|
42
|
+
/** The moment before each phase, in order: "Kick off", "Plan", "Launch". */
|
|
43
|
+
milestones?: (string | undefined)[];
|
|
44
|
+
caption?: string;
|
|
45
|
+
class?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { title, phases, milestones = [], caption, class: className } = Astro.props;
|
|
49
|
+
const tones: Tone[] = ['cool', 'accent', 'sun'];
|
|
50
|
+
const items = phases.flatMap((p, i) => {
|
|
51
|
+
const tone = p.tone ?? tones[i % tones.length];
|
|
52
|
+
return [...(milestones[i] ? [{ kind: 'moment' as const, label: milestones[i]!, tone }] : []), { kind: 'phase' as const, phase: p, tone }];
|
|
53
|
+
});
|
|
54
|
+
const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repeat ? 'minmax(0, 0.8fr)' : 'minmax(0, 1fr)')).join(' ');
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
<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>
|
|
103
|
+
))}
|
|
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>
|
|
117
|
+
{caption && <figcaption>{caption}</figcaption>}
|
|
118
|
+
</figure>
|
|
119
|
+
|
|
120
|
+
<script is:inline>
|
|
121
|
+
// Before the first paint, so parts waiting to arrive never show and then vanish.
|
|
122
|
+
(() => {
|
|
123
|
+
const all = document.querySelectorAll('[data-diamonds]:not(.arrive):not(.seen)');
|
|
124
|
+
const fig = all[all.length - 1];
|
|
125
|
+
if (fig && 'IntersectionObserver' in window && !matchMedia('(prefers-reduced-motion: reduce)').matches) fig.classList.add('arrive');
|
|
126
|
+
})();
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<style>
|
|
130
|
+
.diamonds {
|
|
131
|
+
min-width: 0;
|
|
132
|
+
margin: 0;
|
|
133
|
+
container-type: inline-size;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
[data-tone='cool'] {
|
|
137
|
+
--tone: var(--c-seq2-4);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
[data-tone='accent'] {
|
|
141
|
+
--tone: var(--c-accent);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
[data-tone='sun'] {
|
|
145
|
+
--tone: var(--c-heat-4);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.row {
|
|
149
|
+
display: grid;
|
|
150
|
+
grid-template-columns: var(--cols);
|
|
151
|
+
grid-template-rows: auto auto auto;
|
|
152
|
+
column-gap: var(--sp-1);
|
|
153
|
+
row-gap: var(--sp-3);
|
|
154
|
+
list-style: none;
|
|
155
|
+
margin: 0;
|
|
156
|
+
padding: 0;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.row > li {
|
|
160
|
+
display: grid;
|
|
161
|
+
grid-row: span 3;
|
|
162
|
+
grid-template-rows: subgrid;
|
|
163
|
+
min-width: 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* A moment on the line: a dot level with the diamonds' points, its name under it. */
|
|
167
|
+
.moment {
|
|
168
|
+
justify-items: center;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.dot {
|
|
172
|
+
grid-row: 2;
|
|
173
|
+
align-self: center;
|
|
174
|
+
width: 20px;
|
|
175
|
+
height: 20px;
|
|
176
|
+
border-radius: 50%;
|
|
177
|
+
background: var(--tone);
|
|
178
|
+
box-shadow: 0 0 0 4px var(--c-bg);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.moment-label {
|
|
182
|
+
grid-row: 3;
|
|
183
|
+
font-size: var(--text-caption);
|
|
184
|
+
font-weight: 600;
|
|
185
|
+
letter-spacing: var(--tracking-overline);
|
|
186
|
+
text-transform: uppercase;
|
|
187
|
+
color: var(--c-text-secondary);
|
|
188
|
+
white-space: nowrap;
|
|
189
|
+
}
|
|
190
|
+
|
|
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
|
+
.shape {
|
|
223
|
+
grid-row: 2;
|
|
224
|
+
align-self: center;
|
|
225
|
+
position: relative;
|
|
226
|
+
width: 100%;
|
|
227
|
+
aspect-ratio: 5 / 3;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.shape svg {
|
|
231
|
+
display: block;
|
|
232
|
+
width: 100%;
|
|
233
|
+
height: 100%;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/* Opening out in the tone itself; narrowing in a paler one. */
|
|
237
|
+
.open {
|
|
238
|
+
fill: var(--tone);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.close {
|
|
242
|
+
fill: color-mix(in oklab, var(--tone) 55%, #fff);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.halves {
|
|
246
|
+
position: absolute;
|
|
247
|
+
inset: 0;
|
|
248
|
+
display: grid;
|
|
249
|
+
grid-template-columns: 1fr 1fr;
|
|
250
|
+
align-items: center;
|
|
251
|
+
margin: 0;
|
|
252
|
+
color: var(--c-on-accent);
|
|
253
|
+
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;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/* Each label leans toward the middle, where its half is widest. */
|
|
261
|
+
.halves span:first-child {
|
|
262
|
+
justify-self: end;
|
|
263
|
+
padding-right: 10%;
|
|
264
|
+
text-align: right;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.halves span:last-child {
|
|
268
|
+
padding-left: 10%;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.name {
|
|
272
|
+
grid-row: 3;
|
|
273
|
+
margin: 0;
|
|
274
|
+
text-align: center;
|
|
275
|
+
font-family: var(--font-display);
|
|
276
|
+
font-weight: 600;
|
|
277
|
+
font-size: var(--text-h3);
|
|
278
|
+
line-height: var(--leading-h3);
|
|
279
|
+
color: var(--c-text);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.motto {
|
|
283
|
+
display: block;
|
|
284
|
+
margin-top: var(--sp-1);
|
|
285
|
+
font-family: var(--font-body);
|
|
286
|
+
font-weight: 400;
|
|
287
|
+
font-size: var(--text-body-sm);
|
|
288
|
+
color: var(--c-text-muted);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
figcaption {
|
|
292
|
+
margin-top: var(--sp-5);
|
|
293
|
+
font-size: var(--text-caption);
|
|
294
|
+
line-height: var(--leading-caption);
|
|
295
|
+
color: var(--c-text-muted);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* Too narrow for a row: the phases stack, each moment a dot and its name between them. */
|
|
299
|
+
@container (max-width: 560px) {
|
|
300
|
+
.row {
|
|
301
|
+
grid-template-columns: 1fr;
|
|
302
|
+
grid-template-rows: none;
|
|
303
|
+
row-gap: var(--sp-5);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.row > li {
|
|
307
|
+
grid-row: auto;
|
|
308
|
+
grid-template-rows: none;
|
|
309
|
+
row-gap: var(--sp-3);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.moment {
|
|
313
|
+
display: flex;
|
|
314
|
+
align-items: center;
|
|
315
|
+
justify-content: center;
|
|
316
|
+
gap: var(--sp-3);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.shape {
|
|
320
|
+
grid-row: auto;
|
|
321
|
+
width: min(100%, 420px);
|
|
322
|
+
justify-self: center;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.notes,
|
|
326
|
+
.name {
|
|
327
|
+
grid-row: auto;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.notes {
|
|
331
|
+
width: min(100%, 420px);
|
|
332
|
+
justify-self: center;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.halves {
|
|
336
|
+
font-size: var(--text-label);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
341
|
+
.arrive li {
|
|
342
|
+
opacity: 0;
|
|
343
|
+
translate: 0 8px;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.arrive.seen li {
|
|
347
|
+
opacity: 1;
|
|
348
|
+
translate: 0 0;
|
|
349
|
+
transition:
|
|
350
|
+
opacity var(--motion-base) var(--ease-out) calc(var(--i) * 80ms),
|
|
351
|
+
translate var(--motion-spring) var(--ease-spring) calc(var(--i) * 80ms);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
@media (forced-colors: active) {
|
|
356
|
+
.open,
|
|
357
|
+
.close {
|
|
358
|
+
fill: CanvasText;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.close {
|
|
362
|
+
fill-opacity: 0.6;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.halves {
|
|
366
|
+
color: Canvas;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
</style>
|
|
370
|
+
|
|
371
|
+
<script>
|
|
372
|
+
// Once, as it comes into view, the parts arrive left to right.
|
|
373
|
+
const seen = new IntersectionObserver(
|
|
374
|
+
(entries) => {
|
|
375
|
+
entries
|
|
376
|
+
.filter((e) => e.isIntersecting)
|
|
377
|
+
.forEach((e) => {
|
|
378
|
+
e.target.classList.add('seen');
|
|
379
|
+
seen.unobserve(e.target);
|
|
380
|
+
});
|
|
381
|
+
},
|
|
382
|
+
{ threshold: 0.3 },
|
|
383
|
+
);
|
|
384
|
+
document.querySelectorAll('[data-diamonds].arrive').forEach((fig) => seen.observe(fig));
|
|
385
|
+
</script>
|
package/src/FlowDiagram.astro
CHANGED
|
@@ -462,7 +462,7 @@ const lines = (label: string) => {
|
|
|
462
462
|
}
|
|
463
463
|
|
|
464
464
|
.in [data-step] {
|
|
465
|
-
animation: settle
|
|
465
|
+
animation: settle calc(var(--motion-grow, 700ms) * 0.8) var(--ease-spring) var(--d, 0ms) both;
|
|
466
466
|
}
|
|
467
467
|
|
|
468
468
|
.in .node,
|
|
@@ -477,17 +477,17 @@ const lines = (label: string) => {
|
|
|
477
477
|
}
|
|
478
478
|
|
|
479
479
|
.in .edge .line {
|
|
480
|
-
animation: draw 700ms cubic-bezier(0.3, 0, 0.2, 1) var(--d, 0ms) both;
|
|
480
|
+
animation: draw var(--motion-grow, 700ms) cubic-bezier(0.3, 0, 0.2, 1) var(--d, 0ms) both;
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
.in .edge .head,
|
|
484
484
|
.in .edge .edge-label {
|
|
485
|
-
animation: land
|
|
485
|
+
animation: land calc(var(--motion-grow, 700ms) * 0.45) var(--ease-out) calc(var(--d, 0ms) + var(--motion-grow, 700ms) * 0.8) both;
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
.in .ring {
|
|
489
489
|
animation-name: grow;
|
|
490
|
-
animation-duration:
|
|
490
|
+
animation-duration: var(--motion-reveal);
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
@keyframes settle {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* What a page says when it could not read its figures: an error empty state with a way to try
|
|
4
|
+
* again, hidden until a script shows it with showFailed() from ./loadfailed.js, which also hides
|
|
5
|
+
* the page's content so no half-drawn chart stays behind it.
|
|
6
|
+
*
|
|
7
|
+
* "Try again" is a link to the page itself (its path, so Button draws a link: an empty href would
|
|
8
|
+
* make it a button that does nothing), so it works without script and reads the figures from the
|
|
9
|
+
* start.
|
|
10
|
+
*/
|
|
11
|
+
import Button from './Button.astro';
|
|
12
|
+
import EmptyState from './EmptyState.astro';
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
id?: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
text?: string;
|
|
18
|
+
retry?: string;
|
|
19
|
+
}
|
|
20
|
+
const {
|
|
21
|
+
id = 'failed',
|
|
22
|
+
title = "There's nothing to show right now",
|
|
23
|
+
text = 'The page reads its figures when it opens, so trying again usually works.',
|
|
24
|
+
retry = 'Try again',
|
|
25
|
+
} = Astro.props;
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
<div id={id} class="load-failed" hidden data-load-failed>
|
|
29
|
+
<EmptyState kind="error" title={title} text={text}>
|
|
30
|
+
<Button href={Astro.url.pathname}>{retry}</Button>
|
|
31
|
+
</EmptyState>
|
|
32
|
+
</div>
|