@n1kname/components 0.22.0 → 0.24.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/CareerMap.astro +537 -0
- package/src/Diamonds.astro +446 -0
- package/src/Phases.astro +376 -0
- package/src/SectionNav.astro +149 -0
package/package.json
CHANGED
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* A career framework: the levels as a ladder you can pick from, forking where one level has two
|
|
4
|
+
* routes (a lead and a specialist at the same level, say), and for the level picked, what it is in
|
|
5
|
+
* one line, its scope and what it's expected to do in each skill area. Under it, every level side
|
|
6
|
+
* by side in one table, to compare.
|
|
7
|
+
*
|
|
8
|
+
* The ladder is a tab list: the arrow keys move along it and pick as they go, Home and End go to
|
|
9
|
+
* the ends. Picking changes the panel at once; it's an answer to a question, not a moment. Without
|
|
10
|
+
* script only the level given as `selected` shows, and the table still holds everything.
|
|
11
|
+
*
|
|
12
|
+
* Drawn in the diagrams' own style, on a sunken plate, as Flow diagram is. Below 640px wide the
|
|
13
|
+
* ladder becomes a list.
|
|
14
|
+
*/
|
|
15
|
+
interface Level {
|
|
16
|
+
id: string;
|
|
17
|
+
/** Its place on the ladder, 1 first. Two levels with the same rank sit one above the other. */
|
|
18
|
+
rank: number;
|
|
19
|
+
title: string;
|
|
20
|
+
/** Above the title, small: "Level 3". */
|
|
21
|
+
label?: string;
|
|
22
|
+
/** The route it's on, where there's more than one: "Individual contributor". */
|
|
23
|
+
track?: string;
|
|
24
|
+
experience?: string;
|
|
25
|
+
scope?: string;
|
|
26
|
+
/** The level in one sentence. */
|
|
27
|
+
summary?: string;
|
|
28
|
+
/** What it's expected to do, by area id. */
|
|
29
|
+
skills?: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface Area {
|
|
33
|
+
id: string;
|
|
34
|
+
label: string;
|
|
35
|
+
/** The group it belongs to: "Craft", "Collaboration". */
|
|
36
|
+
theme?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface Props {
|
|
40
|
+
/** Names the ladder and the table for a screen reader. */
|
|
41
|
+
title: string;
|
|
42
|
+
levels: Level[];
|
|
43
|
+
areas?: Area[];
|
|
44
|
+
/** The level shown first. The first one by default. */
|
|
45
|
+
selected?: string;
|
|
46
|
+
/** The label on the table's disclosure. */
|
|
47
|
+
compare?: string;
|
|
48
|
+
caption?: string;
|
|
49
|
+
id?: string;
|
|
50
|
+
class?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { title, levels, areas = [], selected, compare = 'Compare every level', caption, class: className } = Astro.props;
|
|
54
|
+
let hash = 0;
|
|
55
|
+
for (const c of title) hash = (hash * 31 + c.charCodeAt(0)) | 0;
|
|
56
|
+
const uid = Astro.props.id ?? `career-${(hash >>> 0).toString(36)}`;
|
|
57
|
+
const current = selected ?? levels[0]?.id;
|
|
58
|
+
|
|
59
|
+
const ranks = [...new Set(levels.map((l) => l.rank))].sort((a, b) => a - b);
|
|
60
|
+
const at = (r: number) => levels.filter((l) => l.rank === r);
|
|
61
|
+
// The ladder's columns: a level (or two) per rank, a joint between ranks.
|
|
62
|
+
const columns = ranks.map(() => 'minmax(0, 1fr)').join(' var(--joint) ');
|
|
63
|
+
// A joint's shape: straight on, forking into two, joining from two, or two straight on.
|
|
64
|
+
const joint = (a: number, b: number) => {
|
|
65
|
+
const [from, to] = [at(a).length > 1, at(b).length > 1];
|
|
66
|
+
if (!from && !to) return 'M0 50 H28';
|
|
67
|
+
if (!from && to) return 'M0 50 H12 V25 H28 M12 50 V75 H28';
|
|
68
|
+
if (from && !to) return 'M0 25 H16 V50 H28 M0 75 H16 V50';
|
|
69
|
+
return 'M0 25 H28 M0 75 H28';
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const themes = [...new Set(areas.map((a) => a.theme ?? ''))];
|
|
73
|
+
const byTheme = (t: string) => areas.filter((a) => (a.theme ?? '') === t);
|
|
74
|
+
const ordered = ranks.flatMap((r) => at(r));
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
<figure class:list={['career-map', className]} data-career-map>
|
|
78
|
+
<div class="plate">
|
|
79
|
+
<div class="ladder" role="tablist" aria-label={title} style={`grid-template-columns: ${columns}`}>
|
|
80
|
+
{
|
|
81
|
+
ranks.map((r, k) => (
|
|
82
|
+
<>
|
|
83
|
+
{k > 0 && (
|
|
84
|
+
<svg class="joint" style={`grid-column: ${k * 2}`} viewBox="0 0 28 100" preserveAspectRatio="none" aria-hidden="true">
|
|
85
|
+
<path d={joint(ranks[k - 1], r)} vector-effect="non-scaling-stroke" />
|
|
86
|
+
</svg>
|
|
87
|
+
)}
|
|
88
|
+
{at(r).map((l, j, all) => (
|
|
89
|
+
<button
|
|
90
|
+
type="button"
|
|
91
|
+
role="tab"
|
|
92
|
+
class:list={['level', { fork: all.length > 1 }]}
|
|
93
|
+
id={`${uid}-tab-${l.id}`}
|
|
94
|
+
aria-selected={l.id === current ? 'true' : 'false'}
|
|
95
|
+
aria-controls={`${uid}-panel-${l.id}`}
|
|
96
|
+
tabindex={l.id === current ? 0 : -1}
|
|
97
|
+
data-level={l.id}
|
|
98
|
+
style={`grid-column: ${k * 2 + 1}; grid-row: ${all.length > 1 ? j + 1 : '1 / span 2'}`}
|
|
99
|
+
>
|
|
100
|
+
{l.label && <span class="level-label">{l.label}</span>}
|
|
101
|
+
<span class="level-title">{l.title}</span>
|
|
102
|
+
</button>
|
|
103
|
+
))}
|
|
104
|
+
</>
|
|
105
|
+
))
|
|
106
|
+
}
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
{
|
|
110
|
+
ordered.map((l) => (
|
|
111
|
+
<section class="panel" role="tabpanel" id={`${uid}-panel-${l.id}`} aria-labelledby={`${uid}-tab-${l.id}`} hidden={l.id !== current} tabindex="0">
|
|
112
|
+
<header class="panel-head">
|
|
113
|
+
<h3 class="panel-title">{l.title}</h3>
|
|
114
|
+
<p class="meta">{[l.label, l.track, l.experience].filter(Boolean).join(' · ')}</p>
|
|
115
|
+
{l.summary && <p class="summary">{l.summary}</p>}
|
|
116
|
+
{l.scope && (
|
|
117
|
+
<p class="scope">
|
|
118
|
+
<strong>Scope.</strong> {l.scope}
|
|
119
|
+
</p>
|
|
120
|
+
)}
|
|
121
|
+
</header>
|
|
122
|
+
{l.skills &&
|
|
123
|
+
themes.map((t) => (
|
|
124
|
+
<div class="theme">
|
|
125
|
+
{t && <h4 class="theme-title">{t}</h4>}
|
|
126
|
+
<dl>
|
|
127
|
+
{byTheme(t)
|
|
128
|
+
.filter((a) => l.skills?.[a.id])
|
|
129
|
+
.map((a) => (
|
|
130
|
+
<div>
|
|
131
|
+
<dt>{a.label}</dt>
|
|
132
|
+
<dd>{l.skills![a.id]}</dd>
|
|
133
|
+
</div>
|
|
134
|
+
))}
|
|
135
|
+
</dl>
|
|
136
|
+
</div>
|
|
137
|
+
))}
|
|
138
|
+
</section>
|
|
139
|
+
))
|
|
140
|
+
}
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
{
|
|
144
|
+
areas.length > 0 && (
|
|
145
|
+
<details class="compare">
|
|
146
|
+
<summary>{compare}</summary>
|
|
147
|
+
<div class="scroll" role="region" aria-label={`${title}: every level side by side`} tabindex="0">
|
|
148
|
+
<table>
|
|
149
|
+
<thead>
|
|
150
|
+
<tr>
|
|
151
|
+
<td />
|
|
152
|
+
{ordered.map((l) => (
|
|
153
|
+
<th scope="col">
|
|
154
|
+
{l.label && <span class="level-label">{l.label}</span>}
|
|
155
|
+
{l.title}
|
|
156
|
+
</th>
|
|
157
|
+
))}
|
|
158
|
+
</tr>
|
|
159
|
+
</thead>
|
|
160
|
+
{themes.map((t) => (
|
|
161
|
+
<tbody>
|
|
162
|
+
{t && (
|
|
163
|
+
<tr class="theme-row">
|
|
164
|
+
<th scope="colgroup" colspan={ordered.length + 1}>
|
|
165
|
+
{t}
|
|
166
|
+
</th>
|
|
167
|
+
</tr>
|
|
168
|
+
)}
|
|
169
|
+
{byTheme(t).map((a) => (
|
|
170
|
+
<tr>
|
|
171
|
+
<th scope="row">{a.label}</th>
|
|
172
|
+
{ordered.map((l) => (
|
|
173
|
+
<td>{l.skills?.[a.id] ?? ''}</td>
|
|
174
|
+
))}
|
|
175
|
+
</tr>
|
|
176
|
+
))}
|
|
177
|
+
</tbody>
|
|
178
|
+
))}
|
|
179
|
+
</table>
|
|
180
|
+
</div>
|
|
181
|
+
</details>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
{caption && <figcaption>{caption}</figcaption>}
|
|
185
|
+
</figure>
|
|
186
|
+
|
|
187
|
+
<style>
|
|
188
|
+
.career-map {
|
|
189
|
+
--joint: 28px;
|
|
190
|
+
min-width: 0;
|
|
191
|
+
margin: 0;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.plate {
|
|
195
|
+
container-type: inline-size;
|
|
196
|
+
background: var(--c-surface-sunken);
|
|
197
|
+
border: 1px solid var(--c-border);
|
|
198
|
+
border-radius: var(--radius-lg);
|
|
199
|
+
padding: var(--sp-5);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/* The ladder: a level per rank, a joint between ranks, two levels stacked where it forks. */
|
|
203
|
+
.ladder {
|
|
204
|
+
display: grid;
|
|
205
|
+
grid-template-rows: auto auto;
|
|
206
|
+
align-items: center;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.joint {
|
|
210
|
+
grid-row: 1 / span 2;
|
|
211
|
+
align-self: stretch;
|
|
212
|
+
width: 100%;
|
|
213
|
+
height: 100%;
|
|
214
|
+
overflow: visible;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.joint path {
|
|
218
|
+
fill: none;
|
|
219
|
+
stroke: var(--c-diagram-line);
|
|
220
|
+
stroke-width: 1.75;
|
|
221
|
+
stroke-linejoin: round;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.level {
|
|
225
|
+
display: flex;
|
|
226
|
+
flex-direction: column;
|
|
227
|
+
align-items: center;
|
|
228
|
+
justify-content: center;
|
|
229
|
+
gap: 2px;
|
|
230
|
+
min-height: 56px;
|
|
231
|
+
margin-block: var(--sp-1);
|
|
232
|
+
padding: var(--sp-2) var(--sp-3);
|
|
233
|
+
border: 1.5px solid var(--c-diagram-edge);
|
|
234
|
+
border-radius: var(--radius-md);
|
|
235
|
+
background: var(--c-surface);
|
|
236
|
+
color: var(--c-text);
|
|
237
|
+
font: inherit;
|
|
238
|
+
text-align: center;
|
|
239
|
+
cursor: pointer;
|
|
240
|
+
transition: border-color var(--motion-hover) var(--ease-hover);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.level.fork {
|
|
244
|
+
background: var(--c-surface-tint);
|
|
245
|
+
border-color: var(--c-accent-edge);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.level:hover {
|
|
249
|
+
border-color: var(--c-border-strong);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.level.fork:hover {
|
|
253
|
+
border-color: var(--c-accent);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* The level picked: the one solid node, as in Flow diagram. */
|
|
257
|
+
.level[aria-selected='true'] {
|
|
258
|
+
background: var(--c-accent);
|
|
259
|
+
border-color: var(--c-accent);
|
|
260
|
+
color: var(--c-on-accent);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.level:focus-visible {
|
|
264
|
+
outline: 2px solid var(--c-focus);
|
|
265
|
+
outline-offset: 2px;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.level-label {
|
|
269
|
+
display: block;
|
|
270
|
+
font-size: var(--text-caption);
|
|
271
|
+
line-height: var(--leading-caption);
|
|
272
|
+
color: var(--c-text-muted);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.level[aria-selected='true'] .level-label {
|
|
276
|
+
color: inherit;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.level-title {
|
|
280
|
+
font-size: var(--text-body-sm);
|
|
281
|
+
font-weight: 600;
|
|
282
|
+
line-height: 1.3;
|
|
283
|
+
text-wrap: balance;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/* The level picked. */
|
|
287
|
+
.panel {
|
|
288
|
+
margin-top: var(--sp-5);
|
|
289
|
+
padding: var(--sp-5);
|
|
290
|
+
border: 1px solid var(--c-border);
|
|
291
|
+
border-radius: var(--radius-md);
|
|
292
|
+
background: var(--c-surface);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.panel:focus-visible {
|
|
296
|
+
outline: 2px solid var(--c-focus);
|
|
297
|
+
outline-offset: 2px;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.panel-title {
|
|
301
|
+
margin: 0;
|
|
302
|
+
font-family: var(--font-display);
|
|
303
|
+
font-size: var(--text-h3);
|
|
304
|
+
line-height: var(--leading-h3);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.meta {
|
|
308
|
+
margin: var(--sp-1) 0 0;
|
|
309
|
+
font-size: var(--text-caption);
|
|
310
|
+
color: var(--c-text-muted);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.summary {
|
|
314
|
+
margin: var(--sp-4) 0 0;
|
|
315
|
+
font-family: var(--font-display);
|
|
316
|
+
font-size: var(--text-sub);
|
|
317
|
+
line-height: var(--leading-sub);
|
|
318
|
+
color: var(--c-text);
|
|
319
|
+
text-wrap: pretty;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.scope {
|
|
323
|
+
margin: var(--sp-3) 0 0;
|
|
324
|
+
font-size: var(--text-body-sm);
|
|
325
|
+
line-height: var(--leading-body-sm);
|
|
326
|
+
color: var(--c-text-secondary);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.scope strong {
|
|
330
|
+
color: var(--c-text);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.theme {
|
|
334
|
+
margin-top: var(--sp-5);
|
|
335
|
+
padding-top: var(--sp-4);
|
|
336
|
+
border-top: 1px solid var(--c-border);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.theme-title {
|
|
340
|
+
margin: 0 0 var(--sp-3);
|
|
341
|
+
font-size: var(--text-overline);
|
|
342
|
+
letter-spacing: var(--tracking-overline);
|
|
343
|
+
text-transform: uppercase;
|
|
344
|
+
color: var(--c-text-accent);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
dl {
|
|
348
|
+
display: grid;
|
|
349
|
+
gap: var(--sp-3);
|
|
350
|
+
margin: 0;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
dl > div {
|
|
354
|
+
display: grid;
|
|
355
|
+
grid-template-columns: minmax(10rem, 14rem) 1fr;
|
|
356
|
+
gap: var(--sp-4);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
dt {
|
|
360
|
+
font-size: var(--text-body-sm);
|
|
361
|
+
font-weight: 600;
|
|
362
|
+
color: var(--c-text);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
dd {
|
|
366
|
+
margin: 0;
|
|
367
|
+
font-size: var(--text-body-sm);
|
|
368
|
+
line-height: var(--leading-body-sm);
|
|
369
|
+
color: var(--c-text-secondary);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/* Every level side by side. */
|
|
373
|
+
.compare {
|
|
374
|
+
margin-top: var(--sp-4);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.compare summary {
|
|
378
|
+
display: inline-flex;
|
|
379
|
+
align-items: center;
|
|
380
|
+
gap: var(--sp-2);
|
|
381
|
+
padding: var(--sp-2) var(--sp-3);
|
|
382
|
+
border: 1px solid var(--c-border);
|
|
383
|
+
border-radius: var(--radius-full);
|
|
384
|
+
background: var(--c-surface);
|
|
385
|
+
font-size: var(--text-body-sm);
|
|
386
|
+
font-weight: 600;
|
|
387
|
+
cursor: pointer;
|
|
388
|
+
list-style: none;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.compare summary::-webkit-details-marker {
|
|
392
|
+
display: none;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.compare summary::after {
|
|
396
|
+
content: '';
|
|
397
|
+
width: 7px;
|
|
398
|
+
height: 7px;
|
|
399
|
+
border-right: 1.75px solid currentColor;
|
|
400
|
+
border-bottom: 1.75px solid currentColor;
|
|
401
|
+
rotate: 45deg;
|
|
402
|
+
translate: 0 -2px;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
.compare[open] summary::after {
|
|
406
|
+
rotate: 225deg;
|
|
407
|
+
translate: 0 2px;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.compare summary:focus-visible,
|
|
411
|
+
.scroll:focus-visible {
|
|
412
|
+
outline: 2px solid var(--c-focus);
|
|
413
|
+
outline-offset: 2px;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.scroll {
|
|
417
|
+
margin-top: var(--sp-3);
|
|
418
|
+
overflow-x: auto;
|
|
419
|
+
border: 1px solid var(--c-border);
|
|
420
|
+
border-radius: var(--radius-md);
|
|
421
|
+
background: var(--c-surface);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
table {
|
|
425
|
+
min-width: 1080px;
|
|
426
|
+
border-collapse: collapse;
|
|
427
|
+
font-size: var(--text-caption);
|
|
428
|
+
line-height: var(--leading-caption);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
th,
|
|
432
|
+
td {
|
|
433
|
+
padding: var(--sp-3);
|
|
434
|
+
text-align: left;
|
|
435
|
+
vertical-align: top;
|
|
436
|
+
border-bottom: 1px solid var(--c-border);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
td {
|
|
440
|
+
color: var(--c-text-secondary);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
thead th {
|
|
444
|
+
position: sticky;
|
|
445
|
+
top: 0;
|
|
446
|
+
background: var(--c-surface);
|
|
447
|
+
font-weight: 600;
|
|
448
|
+
color: var(--c-text);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
tbody th[scope='row'] {
|
|
452
|
+
width: 9rem;
|
|
453
|
+
font-weight: 600;
|
|
454
|
+
color: var(--c-text);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
.theme-row th {
|
|
458
|
+
padding-top: var(--sp-4);
|
|
459
|
+
background: var(--c-surface-sunken);
|
|
460
|
+
font-size: var(--text-overline);
|
|
461
|
+
letter-spacing: var(--tracking-overline);
|
|
462
|
+
text-transform: uppercase;
|
|
463
|
+
color: var(--c-text-accent);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
figcaption {
|
|
467
|
+
margin-top: var(--sp-3);
|
|
468
|
+
font-size: var(--text-caption);
|
|
469
|
+
line-height: var(--leading-caption);
|
|
470
|
+
color: var(--c-text-muted);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/* Too narrow for a ladder: a list, the routes marked in each level's label. */
|
|
474
|
+
@container (max-width: 640px) {
|
|
475
|
+
.ladder {
|
|
476
|
+
grid-template-columns: 1fr !important;
|
|
477
|
+
grid-template-rows: none;
|
|
478
|
+
gap: var(--sp-2);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
.joint {
|
|
482
|
+
display: none;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
.level {
|
|
486
|
+
grid-column: 1 !important;
|
|
487
|
+
grid-row: auto !important;
|
|
488
|
+
margin: 0;
|
|
489
|
+
min-height: 0;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.panel {
|
|
493
|
+
padding: var(--sp-4);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
dl > div {
|
|
497
|
+
grid-template-columns: 1fr;
|
|
498
|
+
gap: var(--sp-1);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
@media (forced-colors: active) {
|
|
503
|
+
.level[aria-selected='true'] {
|
|
504
|
+
forced-color-adjust: none;
|
|
505
|
+
background: Highlight;
|
|
506
|
+
color: HighlightText;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
</style>
|
|
510
|
+
|
|
511
|
+
<script>
|
|
512
|
+
// Picking a level shows its panel. The arrow keys move along the ladder in reading order and pick
|
|
513
|
+
// as they go; Home and End go to the ends.
|
|
514
|
+
document.querySelectorAll<HTMLElement>('[data-career-map]').forEach((map) => {
|
|
515
|
+
const tabs = [...map.querySelectorAll<HTMLButtonElement>('[role="tab"]')];
|
|
516
|
+
// Reading order follows the ranks: the DOM already lists them so.
|
|
517
|
+
const pick = (tab: HTMLButtonElement, focus = false) => {
|
|
518
|
+
tabs.forEach((t) => {
|
|
519
|
+
const on = t === tab;
|
|
520
|
+
t.setAttribute('aria-selected', String(on));
|
|
521
|
+
t.tabIndex = on ? 0 : -1;
|
|
522
|
+
const panel = map.querySelector<HTMLElement>(`#${t.getAttribute('aria-controls')}`);
|
|
523
|
+
if (panel) panel.hidden = !on;
|
|
524
|
+
});
|
|
525
|
+
if (focus) tab.focus();
|
|
526
|
+
};
|
|
527
|
+
tabs.forEach((t, i) => {
|
|
528
|
+
t.addEventListener('click', () => pick(t));
|
|
529
|
+
t.addEventListener('keydown', (e) => {
|
|
530
|
+
const to = { ArrowRight: i + 1, ArrowDown: i + 1, ArrowLeft: i - 1, ArrowUp: i - 1, Home: 0, End: tabs.length - 1 }[e.key];
|
|
531
|
+
if (to === undefined) return;
|
|
532
|
+
e.preventDefault();
|
|
533
|
+
pick(tabs[(to + tabs.length) % tabs.length], true);
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
</script>
|