@n1kname/components 0.17.0 → 0.17.2

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.17.0",
3
+ "version": "0.17.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -25,7 +25,7 @@
25
25
  "./match.css": "./src/match.css"
26
26
  },
27
27
  "dependencies": {
28
- "@n1kname/charts": "0.9.0"
28
+ "@n1kname/charts": "0.9.1"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "astro": "^7.4.4"
package/src/PageNav.astro CHANGED
@@ -2,8 +2,10 @@
2
2
  /**
3
3
  * The row of links across a site's pages, with the current page marked by a pill. The pill is
4
4
  * an empty shape behind the link's text, so that with page-change.css it can glide to the next
5
- * page's link while the words cross-fade, without stretching them. Without page-change.css, or
6
- * in a browser without cross-document view transitions, the page simply changes.
5
+ * page's link while the words cross-fade, without stretching them. A shape on the move is drawn
6
+ * above the page, so while it glides it is only its outline, and the links it passes stay
7
+ * readable; it fills in as it lands. Without page-change.css, or in a browser without
8
+ * cross-document view transitions, the page simply changes.
7
9
  *
8
10
  * One per page: the pill's transition name must be unique.
9
11
  */
@@ -88,6 +90,11 @@ const { items, label = 'Pages' } = Astro.props;
88
90
  border-radius: inherit;
89
91
  background: var(--c-surface);
90
92
  view-transition-name: page-nav-current;
93
+ transition: background-color var(--motion-fast) var(--ease-out);
94
+ }
95
+
96
+ :global(:root:active-view-transition) .pill {
97
+ background-color: transparent;
91
98
  }
92
99
 
93
100
  /* A fingertip needs more room than a pointer. */
package/src/legend.js CHANGED
@@ -7,18 +7,23 @@ const reduced = () => matchMedia('(prefers-reduced-motion: reduce)').matches;
7
7
  const esc = (s) => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
8
8
 
9
9
  export const setKeys = (ul, keys) => {
10
- const now = new Map([...ul.children].map((li) => [li.dataset.key ?? li.textContent.trim(), li]));
11
- const want = new Set(keys.map((k) => k.label));
12
- // The scoped class Astro gave the legend's items, so new ones are styled the same.
10
+ // Keys built by Legend have no data-key yet: their label is their key.
11
+ for (const li of ul.children) if (!li.dataset.key) li.dataset.key = li.textContent.trim();
12
+ // The scoped attribute Astro gave the legend's items, so new ones are styled the same.
13
13
  const scope = [...(ul.firstElementChild?.attributes ?? [])].find((a) => a.name.startsWith('data-astro-cid'))?.name;
14
+ const now = new Map([...ul.children].filter((li) => !li.hasAttribute('data-leaving')).map((li) => [li.dataset.key, li]));
15
+ const want = new Set(keys.map((k) => k.label));
14
16
  for (const [key, li] of now) {
15
17
  if (want.has(key)) continue;
18
+ li.setAttribute('data-leaving', '');
16
19
  if (reduced()) li.remove();
17
20
  else li.animate([{ opacity: 1 }, { opacity: 0, transform: 'scale(0.9)' }], { duration: 140, easing: 'ease-in' }).finished.then(() => li.remove());
18
21
  }
19
- keys.forEach((k, i) => {
22
+ // In the order given: each key moved to the end in turn, so they end up in order after any
23
+ // that are still fading out.
24
+ for (const k of keys) {
20
25
  let li = now.get(k.label);
21
- if (!li || !want.has(k.label)) {
26
+ if (!li) {
22
27
  li = document.createElement('li');
23
28
  li.dataset.key = k.label;
24
29
  li.innerHTML = `<i class="mark" data-mark="${k.mark ?? 'fill'}"${k.color ? ` style="--mark:${k.color}"` : ''}></i>${esc(k.label)}`;
@@ -28,8 +33,6 @@ export const setKeys = (ul, keys) => {
28
33
  }
29
34
  if (!reduced()) li.animate([{ opacity: 0, transform: 'translateY(3px)' }, { opacity: 1, transform: 'none' }], { duration: 220, delay: 120, easing: 'ease-out', fill: 'backwards' });
30
35
  }
31
- li.dataset.key = k.label;
32
- const at = [...ul.children].filter((c) => want.has(c.dataset.key ?? ''))[i];
33
- if (at !== li) ul.insertBefore(li, at ?? null);
34
- });
36
+ ul.append(li);
37
+ }
35
38
  };