@n1kname/components 0.67.1 → 0.67.3

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.67.1",
3
+ "version": "0.67.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -39,7 +39,7 @@
39
39
  "@n1kname/charts": "0.15.0"
40
40
  },
41
41
  "peerDependencies": {
42
- "@n1kname/tokens": "^0.11.1",
42
+ "@n1kname/tokens": "^0.11.2",
43
43
  "astro": "^7.4.4"
44
44
  },
45
45
  "publishConfig": {
@@ -6,8 +6,10 @@
6
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
- * 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.
9
+ * the ends. Picking changes the panel at once; it's an answer to a question, not a moment. The
10
+ * level picked goes in the URL (`?level=`, or `?<id>=` with more than one map on a page), so a
11
+ * reload or a shared link opens on it. Without script only the level given as `selected` shows,
12
+ * and the table still holds everything.
11
13
  *
12
14
  * Drawn in the diagrams' own style, on a sunken plate, as Flow diagram is. Below 640px wide the
13
15
  * ladder becomes a list.
@@ -91,7 +93,7 @@ const byTheme = (t: string) => areas.filter((a) => (a.theme ?? '') === t);
91
93
  const ordered = ranks.flatMap((r) => at(r));
92
94
  ---
93
95
 
94
- <figure class:list={['career-map', className]} data-career-map>
96
+ <figure class:list={['career-map', className]} data-career-map={uid}>
95
97
  <div class="plate">
96
98
  <div class="ladder" role="tablist" aria-label={title} style={`grid-template-columns: ${columns}`}>
97
99
  {
@@ -592,8 +594,17 @@ const ordered = ranks.flatMap((r) => at(r));
592
594
  <script>
593
595
  // Picking a level shows its panel. The arrow keys move along the ladder in reading order and pick
594
596
  // as they go; Home and End go to the ends.
595
- document.querySelectorAll<HTMLElement>('[data-career-map]').forEach((map) => {
597
+ // The level picked goes in the URL, replacing the entry rather than adding one, so Back still
598
+ // leaves the page.
599
+ const maps = [...document.querySelectorAll<HTMLElement>('[data-career-map]')];
600
+ maps.forEach((map) => {
596
601
  const tabs = [...map.querySelectorAll<HTMLButtonElement>('[role="tab"]')];
602
+ const key = maps.length > 1 ? map.dataset.careerMap || 'level' : 'level';
603
+ const remember = (tab: HTMLButtonElement) => {
604
+ const url = new URL(location.href);
605
+ url.searchParams.set(key, tab.dataset.level ?? '');
606
+ history.replaceState(history.state, '', url);
607
+ };
597
608
  // Reading order follows the ranks: the DOM already lists them so.
598
609
  const pick = (tab: HTMLButtonElement, focus = false) => {
599
610
  tabs.forEach((t) => {
@@ -606,13 +617,21 @@ const ordered = ranks.flatMap((r) => at(r));
606
617
  if (focus) tab.focus();
607
618
  };
608
619
  tabs.forEach((t, i) => {
609
- t.addEventListener('click', () => pick(t));
620
+ t.addEventListener('click', () => {
621
+ pick(t);
622
+ remember(t);
623
+ });
610
624
  t.addEventListener('keydown', (e) => {
611
625
  const to = { ArrowRight: i + 1, ArrowDown: i + 1, ArrowLeft: i - 1, ArrowUp: i - 1, Home: 0, End: tabs.length - 1 }[e.key];
612
626
  if (to === undefined) return;
613
627
  e.preventDefault();
614
- pick(tabs[(to + tabs.length) % tabs.length], true);
628
+ const next = tabs[(to + tabs.length) % tabs.length];
629
+ pick(next, true);
630
+ remember(next);
615
631
  });
616
632
  });
633
+ const asked = new URL(location.href).searchParams.get(key);
634
+ const start = asked && tabs.find((t) => t.dataset.level === asked);
635
+ if (start) pick(start);
617
636
  });
618
637
  </script>
@@ -74,7 +74,8 @@ interface Props {
74
74
  device?: 'laptop' | 'phone';
75
75
  /** A view-transition-name, so a card's stack can grow into the cover on the page it opens. */
76
76
  transition?: string;
77
- /** Load the front screen first, for a cover above the fold. */
77
+ /** For a cover above the fold: every picture loads at once (none lazily), and the front screen,
78
+ * or the widest layer, first. */
78
79
  eager?: boolean;
79
80
  /** Follow the pointer. On by default for a cover; a card fans out on hover instead. */
80
81
  parallax?: boolean;
@@ -101,6 +102,8 @@ const layerSizes = (width: number) =>
101
102
  ? `(max-width: 640px) ${Math.round(width * 0.7)}vw, ${Math.round(width * 7)}px`
102
103
  : `(max-width: 640px) ${Math.round(width * 0.9)}vw, ${Math.round(width * 3.6)}px`;
103
104
  const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.width))];
105
+ // The widest layer is the largest paint on a cover, so it is the one fetched first.
106
+ const lead = layers.reduce((best, l, i) => (l.width > layers[best].width ? i : best), 0);
104
107
  ---
105
108
 
106
109
  <div
@@ -115,7 +118,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
115
118
  {layers.map((l, i) => (
116
119
  <div class:list={['layer', { float: l.float }]} style={`left: ${l.x}%; top: ${l.y}%; width: ${l.width}%; --depth: ${l.depth ?? 0}; --i: ${i}`}>
117
120
  {typeof l.image === 'string' ? (
118
- <img src={l.image} alt={l.alt ?? ''} width={l.size?.width} height={l.size?.height} loading={eager ? 'eager' : 'lazy'} />
121
+ <img src={l.image} alt={l.alt ?? ''} width={l.size?.width} height={l.size?.height} loading={eager ? 'eager' : 'lazy'} fetchpriority={eager && i === lead ? 'high' : 'auto'} />
119
122
  ) : (
120
123
  <Image
121
124
  src={l.image}
@@ -125,6 +128,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
125
128
  format="webp"
126
129
  quality={80}
127
130
  loading={eager ? 'eager' : 'lazy'}
131
+ fetchpriority={eager && i === lead ? 'high' : 'auto'}
128
132
  />
129
133
  )}
130
134
  </div>
@@ -139,7 +143,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
139
143
  return (
140
144
  <div class={`screen s${i}`}>
141
145
  {typeof s.image === 'string' ? (
142
- <img src={s.image} alt={s.alt} width={s.size?.width} height={s.size?.height} loading={eager && first ? 'eager' : 'lazy'} />
146
+ <img src={s.image} alt={s.alt} width={s.size?.width} height={s.size?.height} loading={eager ? 'eager' : 'lazy'} fetchpriority={eager && first ? 'high' : 'auto'} />
143
147
  ) : (
144
148
  <Image
145
149
  src={s.image}
@@ -148,7 +152,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
148
152
  sizes={sizes}
149
153
  format="webp"
150
154
  quality={82}
151
- loading={eager && first ? 'eager' : 'lazy'}
155
+ loading={eager ? 'eager' : 'lazy'}
152
156
  fetchpriority={eager && first ? 'high' : 'auto'}
153
157
  />
154
158
  )}
@@ -126,12 +126,21 @@ const { label, placeholder, shortcut = '/', param, describedBy, id = 'search' }
126
126
  opacity: 0;
127
127
  transform: scale(0.6);
128
128
  pointer-events: none;
129
+ /* Hidden, not only see-through, while there is nothing to clear: Tab skips it. Visibility
130
+ * switches off after the fade and on before it. */
131
+ visibility: hidden;
132
+ transition:
133
+ opacity var(--motion-fast) var(--ease-out),
134
+ transform var(--motion-fast) var(--ease-out),
135
+ visibility 0s linear var(--motion-fast);
129
136
  }
130
137
 
131
138
  .search-field[data-filled] .clear {
132
139
  opacity: 1;
133
140
  transform: none;
134
141
  pointer-events: auto;
142
+ visibility: visible;
143
+ transition-delay: 0s;
135
144
  }
136
145
 
137
146
  .clear:focus-visible {