@n1kname/components 0.59.0 → 0.60.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/Tracks.astro +371 -0
- package/src/icons.ts +2 -0
package/package.json
CHANGED
package/src/Tracks.astro
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* The same few steps, taken on parallel tracks: each track a row, its name on the left, then its
|
|
4
|
+
* steps as bands that point on to the next. For one question answered several ways, such as three
|
|
5
|
+
* countries and how each sets a price and what the design does about it, where cards would box
|
|
6
|
+
* up what is really a flow.
|
|
7
|
+
*
|
|
8
|
+
* Drawn as Phases is, on a sunken plate with tinted bands, so a page with both reads as one
|
|
9
|
+
* family. The step names sit once over the columns; each band holds a sentence. A list of tracks,
|
|
10
|
+
* each a heading and its steps in order, every step named, so it reads the same out loud.
|
|
11
|
+
* Below 640px wide each track stacks: its steps one under the other, named over each band, with
|
|
12
|
+
* an arrow between them.
|
|
13
|
+
*
|
|
14
|
+
* Once, as it comes into view, the tracks arrive one after another. Nothing moves under reduced
|
|
15
|
+
* motion, and without script it is simply there.
|
|
16
|
+
*/
|
|
17
|
+
import Icon from './Icon.astro';
|
|
18
|
+
import type { IconName } from './icons';
|
|
19
|
+
|
|
20
|
+
type Tone = 'accent' | 'cool' | 'quiet';
|
|
21
|
+
|
|
22
|
+
interface Track {
|
|
23
|
+
/** On the left: "Netherlands". */
|
|
24
|
+
title: string;
|
|
25
|
+
/** Under the title, a few words. */
|
|
26
|
+
sub?: string;
|
|
27
|
+
/** In the disc: an icon, or a short mark such as "NL". Neither leaves the disc out. */
|
|
28
|
+
icon?: IconName;
|
|
29
|
+
short?: string;
|
|
30
|
+
tone?: Tone;
|
|
31
|
+
/** One sentence per step, in the order of `steps`. */
|
|
32
|
+
cells: string[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface Props {
|
|
36
|
+
/** What the tracks are, for a screen reader: the list is named by it. */
|
|
37
|
+
title: string;
|
|
38
|
+
/** The steps every track takes, named once over the columns. */
|
|
39
|
+
steps: string[];
|
|
40
|
+
tracks: Track[];
|
|
41
|
+
/** A tone per step. The last step is accent, the ones before it quiet, by default. */
|
|
42
|
+
stepTones?: Tone[];
|
|
43
|
+
caption?: string;
|
|
44
|
+
class?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const { title, steps, tracks, stepTones, caption, class: className } = Astro.props;
|
|
48
|
+
const n = steps.length;
|
|
49
|
+
const toneOf = (k: number): Tone => stepTones?.[k] ?? (k === n - 1 ? 'accent' : 'quiet');
|
|
50
|
+
const trackTones: Tone[] = ['accent', 'cool'];
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
<figure class:list={['tracks', className]} data-tracks>
|
|
54
|
+
<div class="plate" style={`--n: ${n}`}>
|
|
55
|
+
<div class="heads" aria-hidden="true">
|
|
56
|
+
<span></span>
|
|
57
|
+
<div class="head-cols">{steps.map((s) => <span>{s}</span>)}</div>
|
|
58
|
+
</div>
|
|
59
|
+
<ul aria-label={title}>
|
|
60
|
+
{
|
|
61
|
+
tracks.map((t, i) => (
|
|
62
|
+
<li class="track" style={`--i: ${i}`}>
|
|
63
|
+
<div class="name" data-tone={t.tone ?? trackTones[i % trackTones.length]}>
|
|
64
|
+
{(t.icon || t.short) && (
|
|
65
|
+
<span class="disc" aria-hidden="true">
|
|
66
|
+
{t.icon ? <Icon name={t.icon} size={20} /> : <span class="short">{t.short}</span>}
|
|
67
|
+
</span>
|
|
68
|
+
)}
|
|
69
|
+
<div>
|
|
70
|
+
<h3>{t.title}</h3>
|
|
71
|
+
{t.sub && <p class="sub">{t.sub}</p>}
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
<ol class="bands">
|
|
75
|
+
{steps.map((s, k) => (
|
|
76
|
+
<li class="band" data-tone={toneOf(k)}>
|
|
77
|
+
<span class="step">{s}</span>
|
|
78
|
+
<span class="text">{t.cells[k] ?? ''}</span>
|
|
79
|
+
</li>
|
|
80
|
+
))}
|
|
81
|
+
</ol>
|
|
82
|
+
</li>
|
|
83
|
+
))
|
|
84
|
+
}
|
|
85
|
+
</ul>
|
|
86
|
+
</div>
|
|
87
|
+
{caption && <figcaption>{caption}</figcaption>}
|
|
88
|
+
</figure>
|
|
89
|
+
|
|
90
|
+
<script is:inline>
|
|
91
|
+
// Before the first paint, so tracks waiting to arrive never show and then vanish.
|
|
92
|
+
(() => {
|
|
93
|
+
const all = document.querySelectorAll('[data-tracks]:not(.arrive)');
|
|
94
|
+
const fig = all[all.length - 1];
|
|
95
|
+
if (!fig || !('IntersectionObserver' in window) || matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
|
96
|
+
fig.classList.add('arrive');
|
|
97
|
+
const io = new IntersectionObserver(
|
|
98
|
+
(entries) => {
|
|
99
|
+
for (const e of entries) {
|
|
100
|
+
if (!e.isIntersecting) continue;
|
|
101
|
+
e.target.classList.add('in');
|
|
102
|
+
io.unobserve(e.target);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{ rootMargin: '0px 0px -15% 0px' },
|
|
106
|
+
);
|
|
107
|
+
io.observe(fig);
|
|
108
|
+
})();
|
|
109
|
+
</script>
|
|
110
|
+
|
|
111
|
+
<style>
|
|
112
|
+
.tracks {
|
|
113
|
+
--notch: 18px;
|
|
114
|
+
--name: 10rem;
|
|
115
|
+
min-width: 0;
|
|
116
|
+
margin: var(--sp-7) 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.plate {
|
|
120
|
+
container-type: inline-size;
|
|
121
|
+
background: var(--c-surface-sunken);
|
|
122
|
+
border: 1px solid var(--c-border);
|
|
123
|
+
border-radius: var(--radius-lg);
|
|
124
|
+
padding: var(--sp-5);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* The diagrams' tones: a tint for the band, the edge colour for the disc. */
|
|
128
|
+
[data-tone='accent'] {
|
|
129
|
+
--fill: color-mix(in oklab, var(--c-accent) 16%, var(--c-surface));
|
|
130
|
+
--edge: var(--c-accent-edge);
|
|
131
|
+
--mark: var(--c-accent);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
[data-tone='cool'] {
|
|
135
|
+
--fill: var(--c-tag-cool-bg);
|
|
136
|
+
--edge: color-mix(in oklab, var(--c-tag-cool-text) 55%, transparent);
|
|
137
|
+
--mark: var(--c-tag-cool-text);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
[data-tone='quiet'] {
|
|
141
|
+
--fill: var(--c-surface);
|
|
142
|
+
--edge: var(--c-diagram-edge);
|
|
143
|
+
--mark: var(--c-text-secondary);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.heads,
|
|
147
|
+
.track {
|
|
148
|
+
display: grid;
|
|
149
|
+
grid-template-columns: var(--name) minmax(0, 1fr);
|
|
150
|
+
column-gap: var(--sp-4);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* The step names, once, over their columns. */
|
|
154
|
+
.heads {
|
|
155
|
+
margin-bottom: var(--sp-3);
|
|
156
|
+
font-size: var(--text-caption);
|
|
157
|
+
font-weight: 600;
|
|
158
|
+
color: var(--c-text-secondary);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.head-cols {
|
|
162
|
+
display: grid;
|
|
163
|
+
grid-template-columns: repeat(var(--n), minmax(0, 1fr));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.head-cols > span {
|
|
167
|
+
padding-left: calc(var(--notch) + var(--sp-2));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.head-cols > span:first-child {
|
|
171
|
+
padding-left: var(--sp-4);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
ul {
|
|
175
|
+
display: flex;
|
|
176
|
+
flex-direction: column;
|
|
177
|
+
gap: var(--sp-3);
|
|
178
|
+
margin: 0;
|
|
179
|
+
padding: 0;
|
|
180
|
+
list-style: none;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.track {
|
|
184
|
+
align-items: stretch;
|
|
185
|
+
margin: 0;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.name {
|
|
189
|
+
display: flex;
|
|
190
|
+
gap: var(--sp-3);
|
|
191
|
+
align-items: center;
|
|
192
|
+
min-width: 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.disc {
|
|
196
|
+
flex: none;
|
|
197
|
+
display: grid;
|
|
198
|
+
place-items: center;
|
|
199
|
+
width: 40px;
|
|
200
|
+
height: 40px;
|
|
201
|
+
border-radius: 50%;
|
|
202
|
+
background: var(--fill);
|
|
203
|
+
border: 1.5px solid var(--edge);
|
|
204
|
+
color: var(--mark);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.short {
|
|
208
|
+
font-size: var(--text-caption);
|
|
209
|
+
font-weight: 700;
|
|
210
|
+
letter-spacing: 0.02em;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
h3 {
|
|
214
|
+
margin: 0;
|
|
215
|
+
font-family: var(--font-display);
|
|
216
|
+
font-weight: 600;
|
|
217
|
+
font-size: var(--text-body);
|
|
218
|
+
line-height: var(--leading-body-sm);
|
|
219
|
+
color: var(--c-text);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.sub {
|
|
223
|
+
margin: 0;
|
|
224
|
+
font-size: var(--text-caption);
|
|
225
|
+
line-height: var(--leading-caption);
|
|
226
|
+
color: var(--c-text-muted);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.bands {
|
|
230
|
+
display: grid;
|
|
231
|
+
grid-template-columns: repeat(var(--n), minmax(0, 1fr));
|
|
232
|
+
margin: 0;
|
|
233
|
+
padding: 0;
|
|
234
|
+
list-style: none;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/* Each band points on to the next; the next is cut to take the point, a hairline apart. */
|
|
238
|
+
.band {
|
|
239
|
+
display: flex;
|
|
240
|
+
align-items: center;
|
|
241
|
+
min-height: 64px;
|
|
242
|
+
margin: 0 calc(var(--notch) * -1 + 3px) 0 0;
|
|
243
|
+
padding: var(--sp-3) calc(var(--notch) + var(--sp-3)) var(--sp-3) calc(var(--notch) + var(--sp-2));
|
|
244
|
+
background: var(--fill);
|
|
245
|
+
clip-path: polygon(0 0, calc(100% - var(--notch)) 0, 100% 50%, calc(100% - var(--notch)) 100%, 0 100%, var(--notch) 50%);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.band:first-child {
|
|
249
|
+
clip-path: polygon(0 0, calc(100% - var(--notch)) 0, 100% 50%, calc(100% - var(--notch)) 100%, 0 100%);
|
|
250
|
+
border-radius: var(--radius-md) 0 0 var(--radius-md);
|
|
251
|
+
padding-left: var(--sp-4);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.band:last-child {
|
|
255
|
+
margin-right: 0;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.text {
|
|
259
|
+
font-size: var(--text-body-sm);
|
|
260
|
+
line-height: var(--leading-body-sm);
|
|
261
|
+
color: var(--c-text);
|
|
262
|
+
text-wrap: pretty;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/* On a wide screen the step's name is over the column, so here it is for a screen reader. */
|
|
266
|
+
.step {
|
|
267
|
+
position: absolute;
|
|
268
|
+
width: 1px;
|
|
269
|
+
height: 1px;
|
|
270
|
+
overflow: hidden;
|
|
271
|
+
clip-path: inset(50%);
|
|
272
|
+
white-space: nowrap;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
figcaption {
|
|
276
|
+
margin-top: var(--sp-3);
|
|
277
|
+
font-size: var(--text-caption);
|
|
278
|
+
line-height: var(--leading-caption);
|
|
279
|
+
color: var(--c-text-muted);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
@container (max-width: 640px) {
|
|
283
|
+
.heads {
|
|
284
|
+
display: none;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
ul {
|
|
288
|
+
gap: var(--sp-6);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.track {
|
|
292
|
+
grid-template-columns: minmax(0, 1fr);
|
|
293
|
+
row-gap: var(--sp-3);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.bands {
|
|
297
|
+
grid-template-columns: minmax(0, 1fr);
|
|
298
|
+
row-gap: var(--sp-5);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.band,
|
|
302
|
+
.band:first-child {
|
|
303
|
+
position: relative;
|
|
304
|
+
flex-direction: column;
|
|
305
|
+
align-items: stretch;
|
|
306
|
+
gap: 2px;
|
|
307
|
+
min-height: 0;
|
|
308
|
+
margin: 0;
|
|
309
|
+
padding: var(--sp-3) var(--sp-4);
|
|
310
|
+
clip-path: none;
|
|
311
|
+
border-radius: var(--radius-md);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.step {
|
|
315
|
+
position: static;
|
|
316
|
+
width: auto;
|
|
317
|
+
height: auto;
|
|
318
|
+
overflow: visible;
|
|
319
|
+
clip-path: none;
|
|
320
|
+
white-space: normal;
|
|
321
|
+
font-size: var(--text-caption);
|
|
322
|
+
font-weight: 600;
|
|
323
|
+
color: var(--c-text-secondary);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/* Stacked, an arrow down from each step to the next says they follow on. */
|
|
327
|
+
.band:not(:last-child)::after {
|
|
328
|
+
content: '';
|
|
329
|
+
position: absolute;
|
|
330
|
+
left: calc(50% - 7px);
|
|
331
|
+
bottom: calc(-1 * var(--sp-5));
|
|
332
|
+
width: 14px;
|
|
333
|
+
height: var(--sp-5);
|
|
334
|
+
background: var(--c-diagram-line);
|
|
335
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 20'%3E%3Cpath d='M7 2V17M2.5 13 7 17.5 11.5 13' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/* Arriving: the tracks slide in, 110ms apart. */
|
|
340
|
+
.arrive .track {
|
|
341
|
+
opacity: 0;
|
|
342
|
+
translate: -8px 0;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.arrive.in .track {
|
|
346
|
+
opacity: 1;
|
|
347
|
+
translate: 0 0;
|
|
348
|
+
transition:
|
|
349
|
+
opacity var(--motion-reveal, 500ms) var(--ease-out),
|
|
350
|
+
translate var(--motion-reveal, 500ms) var(--ease-out);
|
|
351
|
+
transition-delay: calc(var(--i) * 110ms);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
@media (forced-colors: active) {
|
|
355
|
+
.band,
|
|
356
|
+
.band:first-child {
|
|
357
|
+
border: 1px solid CanvasText;
|
|
358
|
+
clip-path: none;
|
|
359
|
+
margin-right: 0;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.band::after {
|
|
363
|
+
forced-color-adjust: none;
|
|
364
|
+
background: CanvasText;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.disc {
|
|
368
|
+
border-color: CanvasText;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
</style>
|
package/src/icons.ts
CHANGED
|
@@ -117,6 +117,8 @@ export const ICONS = {
|
|
|
117
117
|
// Pages about a home: what it cost, its rooms, the weather outside, the air inside.
|
|
118
118
|
'receipt-euro':
|
|
119
119
|
'<path d="M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z"/><path d="M8 12h5"/><path d="M16 9.5a4 4 0 1 0 0 5.2"/>',
|
|
120
|
+
'credit-card':
|
|
121
|
+
'<rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/>',
|
|
120
122
|
house:
|
|
121
123
|
'<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/><path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>',
|
|
122
124
|
'cloud-sun':
|