@n1kname/components 0.24.0 → 0.25.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n1kname/components",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -2,8 +2,8 @@
2
2
  /**
3
3
  * A career framework: the levels as a ladder you can pick from, forking where one level has two
4
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.
5
+ * one line, what it's responsible for, what changes from the level before (the promotion step),
6
+ * and what it does in each skill area. On request, every level side by side in one table.
7
7
  *
8
8
  * The ladder is a tab list: the arrow keys move along it and pick as they go, Home and End go to
9
9
  * the ends. Picking changes the panel at once; it's an answer to a question, not a moment. Without
@@ -27,6 +27,8 @@ interface Level {
27
27
  summary?: string;
28
28
  /** What it's expected to do, by area id. */
29
29
  skills?: Record<string, string>;
30
+ /** What changes from the level before: the few things a promotion to it rests on. */
31
+ changes?: string[];
30
32
  }
31
33
 
32
34
  interface Area {
@@ -43,14 +45,29 @@ interface Props {
43
45
  areas?: Area[];
44
46
  /** The level shown first. The first one by default. */
45
47
  selected?: string;
46
- /** The label on the table's disclosure. */
48
+ /** Shows every level side by side in a table, under this label. None by default. */
47
49
  compare?: string;
50
+ /** The panel's headings. */
51
+ scopeLabel?: string;
52
+ changesLabel?: string;
53
+ skillsLabel?: string;
48
54
  caption?: string;
49
55
  id?: string;
50
56
  class?: string;
51
57
  }
52
58
 
53
- const { title, levels, areas = [], selected, compare = 'Compare every level', caption, class: className } = Astro.props;
59
+ const {
60
+ title,
61
+ levels,
62
+ areas = [],
63
+ selected,
64
+ compare,
65
+ scopeLabel = 'Responsible for',
66
+ changesLabel = 'What changes from the level before',
67
+ skillsLabel = 'Skills',
68
+ caption,
69
+ class: className,
70
+ } = Astro.props;
54
71
  let hash = 0;
55
72
  for (const c of title) hash = (hash * 31 + c.charCodeAt(0)) | 0;
56
73
  const uid = Astro.props.id ?? `career-${(hash >>> 0).toString(36)}`;
@@ -113,35 +130,54 @@ const ordered = ranks.flatMap((r) => at(r));
113
130
  <h3 class="panel-title">{l.title}</h3>
114
131
  <p class="meta">{[l.label, l.track, l.experience].filter(Boolean).join(' · ')}</p>
115
132
  {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
133
  </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
+ <div class="cols">
135
+ <div class="main">
136
+ {l.scope && (
137
+ <>
138
+ <h4 class="part">{scopeLabel}</h4>
139
+ <p class="scope">{l.scope}</p>
140
+ </>
141
+ )}
142
+ {l.changes && l.changes.length > 0 && (
143
+ <>
144
+ <h4 class="part">{changesLabel}</h4>
145
+ <ul class="changes">
146
+ {l.changes.map((c) => (
147
+ <li>{c}</li>
134
148
  ))}
135
- </dl>
149
+ </ul>
150
+ </>
151
+ )}
152
+ </div>
153
+ {l.skills && (
154
+ <div class="skills">
155
+ <h4 class="part">{skillsLabel}</h4>
156
+ {themes.map((t) => (
157
+ <div class="theme">
158
+ {t && <h5 class="theme-title">{t}</h5>}
159
+ <dl>
160
+ {byTheme(t)
161
+ .filter((a) => l.skills?.[a.id])
162
+ .map((a) => (
163
+ <div>
164
+ <dt>{a.label}</dt>
165
+ <dd>{l.skills![a.id]}</dd>
166
+ </div>
167
+ ))}
168
+ </dl>
169
+ </div>
170
+ ))}
136
171
  </div>
137
- ))}
172
+ )}
173
+ </div>
138
174
  </section>
139
175
  ))
140
176
  }
141
177
  </div>
142
178
 
143
179
  {
144
- areas.length > 0 && (
180
+ compare && areas.length > 0 && (
145
181
  <details class="compare">
146
182
  <summary>{compare}</summary>
147
183
  <div class="scroll" role="region" aria-label={`${title}: every level side by side`} tabindex="0">
@@ -319,29 +355,80 @@ const ordered = ranks.flatMap((r) => at(r));
319
355
  text-wrap: pretty;
320
356
  }
321
357
 
358
+ /* What it's responsible for and what changes, beside its skills where there's room. */
359
+ .cols {
360
+ display: grid;
361
+ gap: var(--sp-5);
362
+ margin-top: var(--sp-5);
363
+ padding-top: var(--sp-5);
364
+ border-top: 1px solid var(--c-border);
365
+ }
366
+
367
+ @container (min-width: 760px) {
368
+ .cols {
369
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
370
+ gap: var(--sp-7);
371
+ }
372
+ }
373
+
374
+ .part {
375
+ margin: 0 0 var(--sp-2);
376
+ font-size: var(--text-overline);
377
+ line-height: var(--leading-overline);
378
+ letter-spacing: var(--tracking-overline);
379
+ text-transform: uppercase;
380
+ color: var(--c-text-accent);
381
+ }
382
+
383
+ .main > .part:not(:first-child) {
384
+ margin-top: var(--sp-5);
385
+ }
386
+
322
387
  .scope {
323
- margin: var(--sp-3) 0 0;
388
+ margin: 0;
324
389
  font-size: var(--text-body-sm);
325
390
  line-height: var(--leading-body-sm);
326
391
  color: var(--c-text-secondary);
327
392
  }
328
393
 
329
- .scope strong {
330
- color: var(--c-text);
394
+ .changes {
395
+ display: grid;
396
+ gap: var(--sp-2);
397
+ margin: 0;
398
+ padding: 0;
399
+ list-style: none;
400
+ font-size: var(--text-body-sm);
401
+ line-height: var(--leading-body-sm);
402
+ color: var(--c-text-secondary);
331
403
  }
332
404
 
333
- .theme {
334
- margin-top: var(--sp-5);
335
- padding-top: var(--sp-4);
336
- border-top: 1px solid var(--c-border);
405
+ /* A small step up for each change: what the promotion adds. */
406
+ .changes li {
407
+ position: relative;
408
+ padding-left: var(--sp-5);
409
+ }
410
+
411
+ .changes li::before {
412
+ content: '';
413
+ position: absolute;
414
+ left: 2px;
415
+ top: 0.55em;
416
+ width: 8px;
417
+ height: 8px;
418
+ border-top: 1.75px solid var(--c-accent-edge);
419
+ border-right: 1.75px solid var(--c-accent-edge);
420
+ rotate: -45deg;
421
+ }
422
+
423
+ .theme + .theme {
424
+ margin-top: var(--sp-4);
337
425
  }
338
426
 
339
427
  .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);
428
+ margin: 0 0 var(--sp-2);
429
+ font-size: var(--text-body-sm);
430
+ font-weight: 600;
431
+ color: var(--c-text);
345
432
  }
346
433
 
347
434
  dl {
@@ -352,8 +439,7 @@ const ordered = ranks.flatMap((r) => at(r));
352
439
 
353
440
  dl > div {
354
441
  display: grid;
355
- grid-template-columns: minmax(10rem, 14rem) 1fr;
356
- gap: var(--sp-4);
442
+ gap: 2px;
357
443
  }
358
444
 
359
445
  dt {
@@ -492,11 +578,6 @@ const ordered = ranks.flatMap((r) => at(r));
492
578
  .panel {
493
579
  padding: var(--sp-4);
494
580
  }
495
-
496
- dl > div {
497
- grid-template-columns: 1fr;
498
- gap: var(--sp-1);
499
- }
500
581
  }
501
582
 
502
583
  @media (forced-colors: active) {
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  /**
3
3
  * A design process as diamonds: each phase opens out (diverge) and narrows again (converge), with
4
- * the moments between them as stops on one line, such as kick-off and launch. A last phase can
4
+ * the moments between them as stops at the diamonds' points, such as kick-off and launch. A last phase can
5
5
  * repeat instead, as smaller diamonds that fade out, for the work that goes on after launch.
6
6
  *
7
- * Drawn in the diagrams' own style, on a sunken plate: tinted fills with a hairline edge, as in
8
- * Flow diagram, so it sits beside them. HTML and SVG, so the words are text: they wrap, scale with
7
+ * Drawn in the diagrams' own style, on a sunken plate: tinted fills with a hairline edge and soft
8
+ * corners, as in Flow diagram, so it sits beside them. HTML and SVG, so the words are text: they wrap, scale with
9
9
  * the page, and are read out in order (moment, phase, its two halves, its name, its notes). Below
10
10
  * 560px wide the phases stack.
11
11
  *
@@ -51,6 +51,27 @@ const items = phases.flatMap((p, i) => {
51
51
  const tone = p.tone ?? (p.repeat ? 'quiet' : tones[i % tones.length]);
52
52
  return [...(milestones[i] ? [{ kind: 'moment' as const, label: milestones[i]!, tone }] : []), { kind: 'phase' as const, phase: p, tone }];
53
53
  });
54
+ // A diamond with soft corners: rounder at top and bottom, a little at the points. Drawn on a fixed
55
+ // viewBox the shape keeps, so the corners never stretch.
56
+ const rounded = (pts: [number, number][], radii: number[]) =>
57
+ pts
58
+ .map((p, i) => {
59
+ const prev = pts[(i + pts.length - 1) % pts.length];
60
+ const next = pts[(i + 1) % pts.length];
61
+ const cut = (to: [number, number]) => {
62
+ const [dx, dy] = [to[0] - p[0], to[1] - p[1]];
63
+ const len = Math.hypot(dx, dy);
64
+ return [p[0] + (dx / len) * radii[i], p[1] + (dy / len) * radii[i]].map((v) => +v.toFixed(2));
65
+ };
66
+ const [a, b] = [cut(prev), cut(next)];
67
+ return `${i ? 'L' : 'M'}${a[0]} ${a[1]} Q${p[0]} ${p[1]} ${b[0]} ${b[1]}`;
68
+ })
69
+ .join(' ') + ' Z';
70
+ const big = rounded([[1, 60], [100, 1], [199, 60], [100, 119]], [5, 16, 5, 16]);
71
+ const small = (x: number) => rounded([[x + 4, 50], [x + 50, 18], [x + 96, 50], [x + 50, 82]], [3, 9, 3, 9]);
72
+ let hash = 0;
73
+ for (const c of title) hash = (hash * 31 + c.charCodeAt(0)) | 0;
74
+ const uid = `dia-${(hash >>> 0).toString(36)}`;
54
75
  const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repeat ? 'minmax(0, 0.75fr)' : 'minmax(0, 1fr)')).join(' ');
55
76
  ---
56
77
 
@@ -72,20 +93,30 @@ const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repe
72
93
  {it.phase.repeat ? (
73
94
  <svg viewBox="0 0 300 100" aria-hidden="true">
74
95
  {[0, 1, 2].map((k) => (
75
- <g opacity={[1, 0.6, 0.3][k]}>
76
- <polygon class="open" points={`${k * 100 + 2},50 ${k * 100 + 50},16 ${k * 100 + 50},84`} />
77
- <polygon class="close" points={`${k * 100 + 50},16 ${k * 100 + 98},50 ${k * 100 + 50},84`} />
78
- <polygon class="edge" points={`${k * 100 + 2},50 ${k * 100 + 50},16 ${k * 100 + 98},50 ${k * 100 + 50},84`} />
96
+ <g opacity={[1, 0.6, 0.32][k]}>
97
+ <clipPath id={`${uid}-${i}-${k}`}>
98
+ <path d={small(k * 100)} />
99
+ </clipPath>
100
+ <g clip-path={`url(#${uid}-${i}-${k})`}>
101
+ <rect class="open" x={k * 100} y="0" width="50" height="100" />
102
+ <rect class="close" x={k * 100 + 50} y="0" width="50" height="100" />
103
+ </g>
104
+ <path class="edge" d={small(k * 100)} vector-effect="non-scaling-stroke" />
79
105
  </g>
80
106
  ))}
81
107
  </svg>
82
108
  ) : (
83
109
  <>
84
- <svg viewBox="0 0 200 120" preserveAspectRatio="none" aria-hidden="true">
85
- <polygon class="open" points="1,60 100,1 100,119" />
86
- <polygon class="close" points="100,1 199,60 100,119" />
87
- <polygon class="edge" points="1,60 100,1 199,60 100,119" vector-effect="non-scaling-stroke" />
88
- <line class="split" x1="100" y1="1" x2="100" y2="119" vector-effect="non-scaling-stroke" />
110
+ <svg viewBox="0 0 200 120" aria-hidden="true">
111
+ <clipPath id={`${uid}-${i}`}>
112
+ <path d={big} />
113
+ </clipPath>
114
+ <g clip-path={`url(#${uid}-${i})`}>
115
+ <rect class="open" x="0" y="0" width="100" height="120" />
116
+ <rect class="close" x="100" y="0" width="100" height="120" />
117
+ <line class="split" x1="100" y1="0" x2="100" y2="120" vector-effect="non-scaling-stroke" />
118
+ </g>
119
+ <path class="edge" d={big} vector-effect="non-scaling-stroke" />
89
120
  </svg>
90
121
  <p class="halves">
91
122
  {it.phase.halves?.map((h) => (
@@ -184,42 +215,20 @@ const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repe
184
215
  min-width: 0;
185
216
  }
186
217
 
187
- /* One line through every stop and behind every diamond, level with their points: each cell in
188
- * the diamonds' row draws its own piece, across the gap to the next. */
189
- .stop-cell,
190
- .shape {
191
- position: relative;
192
- }
193
-
194
- .stop-cell::before,
195
- .shape::before {
196
- content: '';
197
- position: absolute;
198
- top: calc(50% - 0.875px);
199
- left: calc(var(--sp-2) / -2);
200
- right: calc(var(--sp-2) / -2);
201
- height: 1.75px;
202
- background: var(--c-diagram-line);
203
- }
204
-
205
- .row > li:first-child .stop-cell::before {
206
- left: 50%;
207
- }
208
-
218
+ /* A moment: a stop level with the diamonds' points, its name just under it. */
209
219
  .stop-cell {
220
+ position: relative;
210
221
  grid-row: 1;
211
222
  display: grid;
212
223
  place-items: center;
213
224
  }
214
225
 
215
226
  .stop {
216
- position: relative;
217
- width: 14px;
218
- height: 14px;
227
+ width: 12px;
228
+ height: 12px;
219
229
  border-radius: 50%;
220
230
  background: var(--c-surface);
221
231
  border: 2px solid var(--mark);
222
- box-shadow: 0 0 0 4px var(--c-surface-sunken);
223
232
  }
224
233
 
225
234
  .moment-label {
@@ -244,7 +253,6 @@ const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repe
244
253
  }
245
254
 
246
255
  .shape svg {
247
- position: relative;
248
256
  display: block;
249
257
  width: 100%;
250
258
  height: 100%;
@@ -268,32 +276,42 @@ const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repe
268
276
  stroke-linejoin: round;
269
277
  }
270
278
 
279
+ .split {
280
+ stroke-width: 1;
281
+ opacity: 0.6;
282
+ }
283
+
271
284
  .repeat .edge {
272
285
  stroke-dasharray: 3 4;
273
286
  }
274
287
 
288
+ /* Each label centred on its half's own middle, a third of the way in from its point, at one
289
+ * size wherever the diamond is drawn. */
275
290
  .halves {
276
291
  position: absolute;
277
292
  inset: 0;
278
- display: grid;
279
- grid-template-columns: 1fr 1fr;
280
- align-items: center;
281
293
  margin: 0;
282
294
  color: var(--c-text);
283
295
  font-weight: 600;
284
- font-size: clamp(0.75rem, 1.9cqi, 0.9375rem);
296
+ font-size: var(--text-body-sm);
285
297
  line-height: 1.25;
298
+ text-align: center;
299
+ }
300
+
301
+ .halves span {
302
+ position: absolute;
303
+ top: 50%;
304
+ width: 30%;
305
+ translate: -50% -50%;
306
+ text-wrap: balance;
286
307
  }
287
308
 
288
- /* Each label sits toward the middle, where its half is widest. */
289
309
  .halves span:first-child {
290
- justify-self: end;
291
- padding-right: 12%;
292
- text-align: right;
310
+ left: 34%;
293
311
  }
294
312
 
295
313
  .halves span:last-child {
296
- padding-left: 12%;
314
+ left: 66%;
297
315
  }
298
316
 
299
317
  .name {
@@ -360,11 +378,6 @@ const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repe
360
378
  row-gap: var(--sp-5);
361
379
  }
362
380
 
363
- .stop-cell::before,
364
- .shape::before {
365
- display: none;
366
- }
367
-
368
381
  .row > li {
369
382
  grid-row: auto;
370
383
  grid-template-rows: none;
@@ -396,9 +409,6 @@ const columns = items.map((it) => (it.kind === 'moment' ? 'auto' : it.phase.repe
396
409
  justify-self: center;
397
410
  }
398
411
 
399
- .halves {
400
- font-size: var(--text-body-sm);
401
- }
402
412
  }
403
413
 
404
414
  @media (prefers-reduced-motion: no-preference) {