@n1kname/components 0.22.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 +1 -1
- package/src/Diamonds.astro +385 -0
- package/src/Phases.astro +363 -0
- package/src/SectionNav.astro +149 -0
package/package.json
CHANGED
|
@@ -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/Phases.astro
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* A way of working in phases: each phase a band that points on to the next, its steps as rings
|
|
4
|
+
* under it, and a short text on what happens in it. Below them, spans for what runs across
|
|
5
|
+
* phases, such as discovery that never quite stops.
|
|
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.
|
|
10
|
+
*
|
|
11
|
+
* Once, as it comes into view, the phases arrive left to right. Nothing moves under reduced
|
|
12
|
+
* motion, and without script it is simply there.
|
|
13
|
+
*/
|
|
14
|
+
type Tone = 'cool' | 'accent' | 'sun';
|
|
15
|
+
|
|
16
|
+
interface Phase {
|
|
17
|
+
/** On the band, such as "Define & validate". */
|
|
18
|
+
title: string;
|
|
19
|
+
/** Under the title on the band: what the phase is for. */
|
|
20
|
+
sub?: string;
|
|
21
|
+
/** The steps in it, as rings under the band. */
|
|
22
|
+
steps?: string[];
|
|
23
|
+
/** What happens in it, under the rings. */
|
|
24
|
+
text?: string;
|
|
25
|
+
tone?: Tone;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface Span {
|
|
29
|
+
label: string;
|
|
30
|
+
/** The first and last phase it runs across, 0 first. To the last phase by default. */
|
|
31
|
+
from: number;
|
|
32
|
+
to?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface Props {
|
|
36
|
+
/** What the diagram is, for a screen reader: the list is named by it. */
|
|
37
|
+
title: string;
|
|
38
|
+
phases: Phase[];
|
|
39
|
+
spans?: Span[];
|
|
40
|
+
caption?: string;
|
|
41
|
+
class?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const { title, phases, spans = [], caption, class: className } = Astro.props;
|
|
45
|
+
const tones: Tone[] = ['cool', 'accent', 'sun'];
|
|
46
|
+
const last = phases.length - 1;
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
<figure class:list={['phases', className]} data-phases>
|
|
50
|
+
<ol class="row" aria-label={title} style={`--n: ${phases.length}`}>
|
|
51
|
+
{
|
|
52
|
+
phases.map((p, i) => (
|
|
53
|
+
<li data-tone={p.tone ?? tones[i % tones.length]} style={`--i: ${i}`}>
|
|
54
|
+
<p class="band">
|
|
55
|
+
<strong>{p.title}</strong>
|
|
56
|
+
{p.sub && <span>{p.sub}</span>}
|
|
57
|
+
</p>
|
|
58
|
+
{p.steps && p.steps.length > 0 ? (
|
|
59
|
+
<ol class="steps">
|
|
60
|
+
{p.steps.map((s) => (
|
|
61
|
+
<li>
|
|
62
|
+
<span>{s}</span>
|
|
63
|
+
</li>
|
|
64
|
+
))}
|
|
65
|
+
</ol>
|
|
66
|
+
) : (
|
|
67
|
+
<span />
|
|
68
|
+
)}
|
|
69
|
+
{p.text ? <p class="text">{p.text}</p> : <span />}
|
|
70
|
+
</li>
|
|
71
|
+
))
|
|
72
|
+
}
|
|
73
|
+
</ol>
|
|
74
|
+
{
|
|
75
|
+
spans.length > 0 && (
|
|
76
|
+
<ul class="spans" style={`--n: ${phases.length}`}>
|
|
77
|
+
{spans.map((s) => {
|
|
78
|
+
const to = Math.min(s.to ?? last, last);
|
|
79
|
+
return (
|
|
80
|
+
<li style={`grid-column: ${s.from + 1} / ${to + 2}`}>
|
|
81
|
+
<span class="label">
|
|
82
|
+
{s.label}<span class="range">{`: ${phases[s.from].title}${to !== s.from ? ` to ${phases[to].title}` : ''}`}</span>
|
|
83
|
+
</span>
|
|
84
|
+
</li>
|
|
85
|
+
);
|
|
86
|
+
})}
|
|
87
|
+
</ul>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
{caption && <figcaption>{caption}</figcaption>}
|
|
91
|
+
</figure>
|
|
92
|
+
|
|
93
|
+
<script is:inline>
|
|
94
|
+
// Before the first paint, so phases waiting to arrive never show and then vanish.
|
|
95
|
+
(() => {
|
|
96
|
+
const all = document.querySelectorAll('[data-phases]:not(.arrive):not(.seen)');
|
|
97
|
+
const fig = all[all.length - 1];
|
|
98
|
+
if (fig && 'IntersectionObserver' in window && !matchMedia('(prefers-reduced-motion: reduce)').matches) fig.classList.add('arrive');
|
|
99
|
+
})();
|
|
100
|
+
</script>
|
|
101
|
+
|
|
102
|
+
<style>
|
|
103
|
+
.phases {
|
|
104
|
+
--notch: 22px;
|
|
105
|
+
min-width: 0;
|
|
106
|
+
margin: 0;
|
|
107
|
+
container-type: inline-size;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
[data-tone='cool'] {
|
|
111
|
+
--tone: var(--c-seq2-4);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
[data-tone='accent'] {
|
|
115
|
+
--tone: var(--c-accent);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
[data-tone='sun'] {
|
|
119
|
+
--tone: var(--c-heat-4);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.row {
|
|
123
|
+
display: grid;
|
|
124
|
+
grid-template-columns: repeat(var(--n), minmax(0, 1fr));
|
|
125
|
+
grid-template-rows: auto auto auto;
|
|
126
|
+
row-gap: var(--sp-4);
|
|
127
|
+
list-style: none;
|
|
128
|
+
margin: 0;
|
|
129
|
+
padding: 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.row > li {
|
|
133
|
+
display: grid;
|
|
134
|
+
grid-row: span 3;
|
|
135
|
+
grid-template-rows: subgrid;
|
|
136
|
+
min-width: 0;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* The band points on to the next; the next is cut to take the point, a hairline apart. */
|
|
140
|
+
.band {
|
|
141
|
+
display: flex;
|
|
142
|
+
flex-direction: column;
|
|
143
|
+
justify-content: center;
|
|
144
|
+
gap: 2px;
|
|
145
|
+
min-height: 64px;
|
|
146
|
+
margin: 0 calc(var(--notch) * -1 + 3px) 0 0;
|
|
147
|
+
padding: var(--sp-3) calc(var(--notch) + var(--sp-3));
|
|
148
|
+
background: var(--tone);
|
|
149
|
+
color: var(--c-on-accent);
|
|
150
|
+
text-align: center;
|
|
151
|
+
clip-path: polygon(0 0, calc(100% - var(--notch)) 0, 100% 50%, calc(100% - var(--notch)) 100%, 0 100%, var(--notch) 50%);
|
|
152
|
+
font-size: var(--text-body-sm);
|
|
153
|
+
line-height: var(--leading-body-sm);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.row > li:first-child .band {
|
|
157
|
+
clip-path: polygon(0 0, calc(100% - var(--notch)) 0, 100% 50%, calc(100% - var(--notch)) 100%, 0 100%);
|
|
158
|
+
border-radius: 999px 0 0 999px;
|
|
159
|
+
padding-left: var(--sp-5);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.row > li:last-child .band {
|
|
163
|
+
margin-right: 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.band strong {
|
|
167
|
+
color: inherit;
|
|
168
|
+
font-family: var(--font-display);
|
|
169
|
+
font-weight: 600;
|
|
170
|
+
font-size: var(--text-body);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.steps {
|
|
174
|
+
display: flex;
|
|
175
|
+
justify-content: center;
|
|
176
|
+
gap: var(--sp-3);
|
|
177
|
+
list-style: none;
|
|
178
|
+
margin: 0;
|
|
179
|
+
padding: 0 var(--sp-3);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.steps li {
|
|
183
|
+
flex: 0 1 132px;
|
|
184
|
+
min-width: 0;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.steps span {
|
|
188
|
+
display: grid;
|
|
189
|
+
place-items: center;
|
|
190
|
+
aspect-ratio: 1;
|
|
191
|
+
padding: var(--sp-3);
|
|
192
|
+
border: 5px solid var(--tone);
|
|
193
|
+
border-radius: 50%;
|
|
194
|
+
background: var(--c-surface);
|
|
195
|
+
color: var(--c-text);
|
|
196
|
+
font-size: var(--text-caption);
|
|
197
|
+
font-weight: 600;
|
|
198
|
+
line-height: 1.3;
|
|
199
|
+
text-align: center;
|
|
200
|
+
text-wrap: balance;
|
|
201
|
+
overflow-wrap: anywhere;
|
|
202
|
+
hyphens: auto;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.text {
|
|
206
|
+
margin: 0;
|
|
207
|
+
padding-inline: var(--sp-3) var(--sp-4);
|
|
208
|
+
font-size: var(--text-body-sm);
|
|
209
|
+
line-height: var(--leading-body-sm);
|
|
210
|
+
color: var(--c-text-secondary);
|
|
211
|
+
text-wrap: pretty;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/* What runs across phases: a dashed line from the first to the last, the label in the middle. */
|
|
215
|
+
.spans {
|
|
216
|
+
display: grid;
|
|
217
|
+
grid-template-columns: repeat(var(--n), minmax(0, 1fr));
|
|
218
|
+
gap: var(--sp-2) 0;
|
|
219
|
+
list-style: none;
|
|
220
|
+
margin: var(--sp-5) 0 0;
|
|
221
|
+
padding: 0;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.spans li {
|
|
225
|
+
display: flex;
|
|
226
|
+
align-items: center;
|
|
227
|
+
gap: var(--sp-3);
|
|
228
|
+
padding-inline: var(--sp-3);
|
|
229
|
+
font-size: var(--text-caption);
|
|
230
|
+
color: var(--c-text-muted);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.spans li::before,
|
|
234
|
+
.spans li::after {
|
|
235
|
+
content: '';
|
|
236
|
+
flex: 1;
|
|
237
|
+
border-top: 1.5px dashed var(--c-border-strong);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.spans li::before {
|
|
241
|
+
border-left: 1.5px solid var(--c-border-strong);
|
|
242
|
+
height: 8px;
|
|
243
|
+
margin-top: 8px;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.spans li::after {
|
|
247
|
+
border-right: 1.5px solid var(--c-border-strong);
|
|
248
|
+
height: 8px;
|
|
249
|
+
margin-top: 8px;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.label {
|
|
253
|
+
white-space: nowrap;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.range {
|
|
257
|
+
position: absolute;
|
|
258
|
+
width: 1px;
|
|
259
|
+
height: 1px;
|
|
260
|
+
overflow: hidden;
|
|
261
|
+
clip-path: inset(50%);
|
|
262
|
+
white-space: nowrap;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
figcaption {
|
|
266
|
+
margin-top: var(--sp-5);
|
|
267
|
+
font-size: var(--text-caption);
|
|
268
|
+
line-height: var(--leading-caption);
|
|
269
|
+
color: var(--c-text-muted);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
@container (max-width: 640px) {
|
|
273
|
+
.row {
|
|
274
|
+
grid-template-columns: 1fr;
|
|
275
|
+
grid-template-rows: none;
|
|
276
|
+
row-gap: var(--sp-6);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.row > li {
|
|
280
|
+
grid-row: auto;
|
|
281
|
+
grid-template-rows: none;
|
|
282
|
+
row-gap: var(--sp-4);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.band,
|
|
286
|
+
.row > li:first-child .band {
|
|
287
|
+
margin-right: 0;
|
|
288
|
+
clip-path: none;
|
|
289
|
+
border-radius: var(--radius-md);
|
|
290
|
+
padding-inline: var(--sp-4);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.spans {
|
|
294
|
+
grid-template-columns: 1fr;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.spans li {
|
|
298
|
+
grid-column: 1 !important;
|
|
299
|
+
padding: 0;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.spans li::before,
|
|
303
|
+
.spans li::after {
|
|
304
|
+
display: none;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.label {
|
|
308
|
+
white-space: normal;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.range {
|
|
312
|
+
position: static;
|
|
313
|
+
width: auto;
|
|
314
|
+
height: auto;
|
|
315
|
+
overflow: visible;
|
|
316
|
+
clip-path: none;
|
|
317
|
+
white-space: normal;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
322
|
+
.arrive .row > li {
|
|
323
|
+
opacity: 0;
|
|
324
|
+
translate: 0 8px;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.arrive.seen .row > li {
|
|
328
|
+
opacity: 1;
|
|
329
|
+
translate: 0 0;
|
|
330
|
+
transition:
|
|
331
|
+
opacity var(--motion-base) var(--ease-out) calc(var(--i) * 110ms),
|
|
332
|
+
translate var(--motion-spring) var(--ease-spring) calc(var(--i) * 110ms);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
@media (forced-colors: active) {
|
|
337
|
+
.band {
|
|
338
|
+
border: 1px solid CanvasText;
|
|
339
|
+
clip-path: none;
|
|
340
|
+
margin-right: 0;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.steps span {
|
|
344
|
+
border-color: CanvasText;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
</style>
|
|
348
|
+
|
|
349
|
+
<script>
|
|
350
|
+
// Once, as it comes into view, the phases arrive left to right.
|
|
351
|
+
const seen = new IntersectionObserver(
|
|
352
|
+
(entries) => {
|
|
353
|
+
entries
|
|
354
|
+
.filter((e) => e.isIntersecting)
|
|
355
|
+
.forEach((e) => {
|
|
356
|
+
e.target.classList.add('seen');
|
|
357
|
+
seen.unobserve(e.target);
|
|
358
|
+
});
|
|
359
|
+
},
|
|
360
|
+
{ threshold: 0.3 },
|
|
361
|
+
);
|
|
362
|
+
document.querySelectorAll('[data-phases].arrive').forEach((fig) => seen.observe(fig));
|
|
363
|
+
</script>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* The sections of one long page, as a list that stays in view beside the text: where you are is
|
|
4
|
+
* marked, and any section is one click or one Tab away. For a case study or a long read, in the
|
|
5
|
+
* margin beside the reading column.
|
|
6
|
+
*
|
|
7
|
+
* It finds where you are from the headings its links point to: the last one above the top third of
|
|
8
|
+
* the window is current, and its link gets `aria-current="location"`. That changes as you scroll,
|
|
9
|
+
* many times a minute, so it changes at once rather than gliding. Before the first heading nothing
|
|
10
|
+
* is current. Without script it is a plain list of links.
|
|
11
|
+
*
|
|
12
|
+
* The page places it: it is sticky inside whatever holds it, so give it a column or a margin that
|
|
13
|
+
* runs the length of the text. It never hides itself, so it is always in the tab order.
|
|
14
|
+
*/
|
|
15
|
+
interface Item {
|
|
16
|
+
/** The heading's id, with or without the #. */
|
|
17
|
+
href: string;
|
|
18
|
+
text: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Props {
|
|
22
|
+
items: Item[];
|
|
23
|
+
/** Names the navigation for a screen reader. */
|
|
24
|
+
label?: string;
|
|
25
|
+
/** A short visible title above the list, such as "Contents". None by default. */
|
|
26
|
+
title?: string;
|
|
27
|
+
id?: string;
|
|
28
|
+
class?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { items, label = 'Sections', title, id, class: className } = Astro.props;
|
|
32
|
+
const hash = (h: string) => (h.startsWith('#') ? h : `#${h}`);
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
<nav id={id} class:list={['section-nav', className]} aria-label={label} data-section-nav>
|
|
36
|
+
{title && <p class="title" aria-hidden="true">{title}</p>}
|
|
37
|
+
<ol>
|
|
38
|
+
{
|
|
39
|
+
items.map((item) => (
|
|
40
|
+
<li>
|
|
41
|
+
<a href={hash(item.href)}>{item.text}</a>
|
|
42
|
+
</li>
|
|
43
|
+
))
|
|
44
|
+
}
|
|
45
|
+
</ol>
|
|
46
|
+
</nav>
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
.section-nav {
|
|
50
|
+
position: sticky;
|
|
51
|
+
top: var(--section-nav-top, var(--sp-8));
|
|
52
|
+
max-height: calc(100dvh - var(--section-nav-top, var(--sp-8)) - var(--sp-5));
|
|
53
|
+
overflow-y: auto;
|
|
54
|
+
overscroll-behavior: contain;
|
|
55
|
+
font-size: var(--text-body-sm);
|
|
56
|
+
line-height: var(--leading-body-sm);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.title {
|
|
60
|
+
margin: 0 0 var(--sp-3);
|
|
61
|
+
font-size: var(--text-overline);
|
|
62
|
+
line-height: var(--leading-overline);
|
|
63
|
+
letter-spacing: var(--tracking-overline);
|
|
64
|
+
text-transform: uppercase;
|
|
65
|
+
color: var(--c-text-muted);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
ol {
|
|
69
|
+
list-style: none;
|
|
70
|
+
margin: 0;
|
|
71
|
+
padding: 0;
|
|
72
|
+
border-left: 1px solid var(--c-border);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
a {
|
|
76
|
+
display: block;
|
|
77
|
+
margin-left: -1px;
|
|
78
|
+
padding: var(--sp-1) 0 var(--sp-1) var(--sp-4);
|
|
79
|
+
border-left: 2px solid transparent;
|
|
80
|
+
background: none;
|
|
81
|
+
color: var(--c-text-muted);
|
|
82
|
+
text-decoration: none;
|
|
83
|
+
text-wrap: pretty;
|
|
84
|
+
transition: color var(--motion-hover) var(--ease-hover);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
a:hover {
|
|
88
|
+
color: var(--c-text);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Where you are: the text at full strength and the accent bar on the rule. */
|
|
92
|
+
a[aria-current] {
|
|
93
|
+
color: var(--c-text);
|
|
94
|
+
font-weight: 600;
|
|
95
|
+
border-left-color: var(--c-accent);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
a:focus-visible {
|
|
99
|
+
outline: 2px solid var(--c-focus);
|
|
100
|
+
outline-offset: 2px;
|
|
101
|
+
border-radius: var(--radius-sm);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@media (forced-colors: active) {
|
|
105
|
+
a[aria-current] {
|
|
106
|
+
border-left-color: CanvasText;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
</style>
|
|
110
|
+
|
|
111
|
+
<script>
|
|
112
|
+
document.querySelectorAll<HTMLElement>('[data-section-nav]').forEach((nav) => {
|
|
113
|
+
const links = [...nav.querySelectorAll<HTMLAnchorElement>('a[href^="#"]')];
|
|
114
|
+
const heads = links.map((a) => document.getElementById(decodeURIComponent(a.hash.slice(1))));
|
|
115
|
+
let current = -2;
|
|
116
|
+
const update = () => {
|
|
117
|
+
let now = -1;
|
|
118
|
+
heads.forEach((h, i) => {
|
|
119
|
+
if (h && h.getBoundingClientRect().top < innerHeight * 0.3) now = i;
|
|
120
|
+
});
|
|
121
|
+
if (now === current) return;
|
|
122
|
+
current = now;
|
|
123
|
+
links.forEach((a, i) => (i === now ? a.setAttribute('aria-current', 'location') : a.removeAttribute('aria-current')));
|
|
124
|
+
// Keep the current link in view when the list is taller than the window. The list scrolls
|
|
125
|
+
// itself; the page never moves for it.
|
|
126
|
+
const a = links[now];
|
|
127
|
+
if (a && nav.scrollHeight > nav.clientHeight) {
|
|
128
|
+
if (a.offsetTop < nav.scrollTop) nav.scrollTop = a.offsetTop - 8;
|
|
129
|
+
else if (a.offsetTop + a.offsetHeight > nav.scrollTop + nav.clientHeight) nav.scrollTop = a.offsetTop + a.offsetHeight - nav.clientHeight + 8;
|
|
130
|
+
}
|
|
131
|
+
nav.dispatchEvent(new CustomEvent('section-change', { detail: { index: now }, bubbles: true }));
|
|
132
|
+
};
|
|
133
|
+
let queued = false;
|
|
134
|
+
addEventListener(
|
|
135
|
+
'scroll',
|
|
136
|
+
() => {
|
|
137
|
+
if (queued) return;
|
|
138
|
+
queued = true;
|
|
139
|
+
requestAnimationFrame(() => {
|
|
140
|
+
queued = false;
|
|
141
|
+
update();
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
{ passive: true },
|
|
145
|
+
);
|
|
146
|
+
addEventListener('resize', update, { passive: true });
|
|
147
|
+
update();
|
|
148
|
+
});
|
|
149
|
+
</script>
|