@rxova/astro-ui 0.6.1 → 0.6.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.
Files changed (48) hide show
  1. package/README.md +14 -14
  2. package/package.json +11 -8
  3. package/src/components/BackLink.astro +4 -4
  4. package/src/components/CodeRecipes.astro +7 -7
  5. package/src/components/CopyButton.astro +20 -20
  6. package/src/components/CtaBand.astro +10 -10
  7. package/src/components/DataTable.astro +9 -9
  8. package/src/components/DocAccordionItem.astro +6 -6
  9. package/src/components/Header.astro +11 -11
  10. package/src/components/Icon.astro +9 -9
  11. package/src/components/ModeTabs.astro +7 -7
  12. package/src/components/PageHeader.astro +8 -8
  13. package/src/components/ProjectSwitcher.astro +6 -6
  14. package/src/components/ProofStats.astro +29 -29
  15. package/src/components/QuickStart.astro +3 -3
  16. package/src/components/ScreenshotGrid.astro +13 -13
  17. package/src/components/Section.astro +7 -7
  18. package/src/components/SectionNav.astro +8 -8
  19. package/src/components/ShowMore.astro +3 -3
  20. package/src/components/SiteFooter.astro +16 -16
  21. package/src/components/SizeTable.astro +7 -7
  22. package/src/components/ThemeScript.astro +12 -12
  23. package/src/components/ThemeToggle.astro +35 -35
  24. package/src/components/ValueGrid.astro +6 -6
  25. package/src/components/VisuallyHidden.astro +4 -4
  26. package/src/components/icons/Check.astro +3 -3
  27. package/src/components/icons/Collapse.astro +3 -3
  28. package/src/components/icons/Copy.astro +3 -3
  29. package/src/components/icons/Expand.astro +3 -3
  30. package/src/components/icons/Next.astro +3 -3
  31. package/src/components/icons/Pause.astro +3 -3
  32. package/src/components/icons/Play.astro +3 -3
  33. package/src/components/icons/Prev.astro +3 -3
  34. package/src/components/icons/Replay.astro +3 -3
  35. package/src/env.d.ts +3 -3
  36. package/src/lib/entries.ts +27 -27
  37. package/src/lib/icons.ts +7 -7
  38. package/src/scripts/show-more.ts +23 -23
  39. package/src/starlight/Footer.astro +4 -4
  40. package/src/starlight/SiteTitle.astro +5 -5
  41. package/src/starlight/SocialIcons.astro +4 -4
  42. package/src/starlight/ThemeSelect.astro +14 -14
  43. package/src/starlight/index.ts +30 -30
  44. package/src/styles/chrome.css +2 -2
  45. package/src/styles/document.css +1 -1
  46. package/src/styles/footer.css +1 -1
  47. package/src/styles/mermaid.css +2 -2
  48. package/src/styles/starlight.css +4 -4
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <p align="center">
4
4
  Astro components, the Starlight preset and the shared chrome for every
5
- <a href="https://rxova.org">rxova.org</a> surface, built on
5
+ <a href="https://rxova.dev">rxova.dev</a> surface, built on
6
6
  <a href="../brand"><code>@rxova/brand</code></a>.
7
7
  </p>
8
8
 
@@ -14,22 +14,22 @@
14
14
 
15
15
  ```js
16
16
  // astro.config.mjs
17
- import { defineConfig } from 'astro/config'
18
- import starlight from '@astrojs/starlight'
19
- import { sharedStarlightConfig } from '@rxova/astro-ui/starlight'
17
+ import { defineConfig } from "astro/config";
18
+ import starlight from "@astrojs/starlight";
19
+ import { sharedStarlightConfig } from "@rxova/astro-ui/starlight";
20
20
 
21
21
  export default defineConfig({
22
- site: process.env.DOCS_URL ?? 'https://rxova.org',
23
- base: process.env.DOCS_BASE_URL ?? '/',
22
+ site: process.env.DOCS_URL ?? "https://rxova.dev",
23
+ base: process.env.DOCS_BASE_URL ?? "/",
24
24
  integrations: [
25
25
  starlight(
26
26
  sharedStarlightConfig({
27
- project: 'use-everywhere',
28
- sidebar: [{ label: 'Learn', items: [{ autogenerate: { directory: 'learn' } }] }],
27
+ project: "use-everywhere",
28
+ sidebar: [{ label: "Learn", items: [{ autogenerate: { directory: "learn" } }] }],
29
29
  }),
30
30
  ),
31
31
  ],
32
- })
32
+ });
33
33
  ```
34
34
 
35
35
  That gets you the tokens, the typefaces, the rxova mark linking back to the
@@ -39,9 +39,9 @@ umbrella site, the cross-project switcher, the shared footer and Pagefind search
39
39
 
40
40
  ```astro
41
41
  ---
42
- import '@rxova/brand/fonts.css'
43
- import '@rxova/astro-ui/styles/document.css'
44
- import SiteFooter from '@rxova/astro-ui/components/SiteFooter.astro'
42
+ import "@rxova/brand/fonts.css";
43
+ import "@rxova/astro-ui/styles/document.css";
44
+ import SiteFooter from "@rxova/astro-ui/components/SiteFooter.astro";
45
45
  ---
46
46
  ```
47
47
 
@@ -76,8 +76,8 @@ the export checks for this package.
76
76
 
77
77
  `apps/preview` also carries the gallery: one page per component under
78
78
  `/gallery/`, each state in a `Story` frame. `pnpm --filter @rxova/preview
79
- screenshots` rebuilds it and writes `screenshots/<component>.png` here, light and
80
- dark, for the pull request that adds or changes a component.
79
+ screenshots` rebuilds it and writes `screenshots/<component>.png` here (git-ignored), light
80
+ and dark, to attach to the pull request that adds or changes a component.
81
81
 
82
82
  `apps/storybook` is the Storybook: a story file per component with its states,
83
83
  a Docs page built from the component's frontmatter, and a light/dark toolbar.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@rxova/astro-ui",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
- "description": "Astro components, Starlight preset and shared chrome for rxova.org",
5
+ "description": "Astro components, Starlight preset and shared chrome for rxova.dev",
6
6
  "keywords": [
7
7
  "rxova",
8
8
  "astro",
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "license": "MIT",
13
13
  "author": "Jonatan Kruszewski <jonakrusze@gmail.com>",
14
- "homepage": "https://rxova.org",
14
+ "homepage": "https://rxova.dev",
15
15
  "repository": {
16
16
  "type": "git",
17
17
  "url": "git+https://github.com/rxova/rxova-website.git",
@@ -46,26 +46,29 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
- "@rxova/brand": "^1.3.0",
49
+ "@rxova/brand": "^1.4.0",
50
50
  "lucide-static": "^1.45.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@astrojs/check": "^0.9.10",
54
54
  "@astrojs/starlight": "^0.42.1",
55
- "@rxova/repo-tooling": "0.0.1",
56
55
  "@types/node": "^26.6.1",
57
56
  "@vitest/coverage-v8": "^5.0.1",
58
- "astro": "^7.3.2",
57
+ "astro": "^7.3.3",
59
58
  "happy-dom": "^20.14.5",
60
59
  "publint": "^0.3.24",
61
- "tsx": "^4.23.13",
62
60
  "typescript": "6.0.3",
63
61
  "vitest": "^5.0.1"
64
62
  },
63
+ "repoConfig": {
64
+ "packSmoke": {
65
+ "load": "never"
66
+ }
67
+ },
65
68
  "scripts": {
66
69
  "check:astro": "astro check",
67
70
  "check:exports": "publint --strict",
68
- "pack:smoke": "node --import tsx ../brand/scripts/pack-smoke.ts",
71
+ "pack:smoke": "rxova-repo-config pack-smoke",
69
72
  "test": "vitest run --coverage"
70
73
  }
71
74
  }
@@ -1,13 +1,13 @@
1
1
  ---
2
- import type { HTMLAttributes } from 'astro/types'
2
+ import type { HTMLAttributes } from "astro/types";
3
3
 
4
4
  /** An "← up one level" link; the caller's class sets its spacing. */
5
- type Props = HTMLAttributes<'a'> & { href: string }
5
+ type Props = HTMLAttributes<"a"> & { href: string };
6
6
 
7
- const { href, class: className, ...rest } = Astro.props
7
+ const { href, class: className, ...rest } = Astro.props;
8
8
  ---
9
9
 
10
- <a class:list={['back-link', className]} href={href} {...rest}>
10
+ <a class:list={["back-link", className]} href={href} {...rest}>
11
11
  ← <slot />
12
12
  </a>
13
13
 
@@ -1,19 +1,19 @@
1
1
  ---
2
2
  /** Titled source listings, one per recipe: a heading linking to the library, then the source in a code frame. */
3
3
  export interface Recipe {
4
- id: string
5
- label: string
6
- href: string
7
- source: string
4
+ id: string;
5
+ label: string;
6
+ href: string;
7
+ source: string;
8
8
  }
9
9
 
10
10
  interface Props {
11
- recipes: readonly Recipe[]
11
+ recipes: readonly Recipe[];
12
12
  /** Heading ids are `<idPrefix>-<recipe.id>`, so a page can link to one recipe. */
13
- idPrefix?: string
13
+ idPrefix?: string;
14
14
  }
15
15
 
16
- const { recipes, idPrefix = 'recipe' } = Astro.props
16
+ const { recipes, idPrefix = "recipe" } = Astro.props;
17
17
  ---
18
18
 
19
19
  <div class="rx-recipes">
@@ -3,17 +3,17 @@
3
3
  * An icon button that puts `text` on the clipboard and shows a tick for a moment. Drawn in
4
4
  * `currentColor`, so it sits on any surface, a dark terminal included; the caller places it.
5
5
  */
6
- import Check from './icons/Check.astro'
7
- import Copy from './icons/Copy.astro'
6
+ import Check from "./icons/Check.astro";
7
+ import Copy from "./icons/Copy.astro";
8
8
 
9
9
  interface Props {
10
10
  /** What goes on the clipboard. */
11
- text: string
11
+ text: string;
12
12
  /** The accessible name and tooltip; there is no visible text, so this is what a screen reader says. */
13
- label?: string
13
+ label?: string;
14
14
  }
15
15
 
16
- const { text, label = 'Copy' } = Astro.props
16
+ const { text, label = "Copy" } = Astro.props;
17
17
  ---
18
18
 
19
19
  <button class="rx-copy" type="button" data-rx-copy={text} aria-label={label} title={label}>
@@ -23,24 +23,24 @@ const { text, label = 'Copy' } = Astro.props
23
23
  </button>
24
24
 
25
25
  <script>
26
- for (const button of document.querySelectorAll<HTMLButtonElement>('[data-rx-copy]')) {
27
- if (button.dataset.rxCopyBound) continue
28
- button.dataset.rxCopyBound = ''
29
- const status = button.querySelector<HTMLElement>('.rx-copy__status')
30
- button.addEventListener('click', async () => {
26
+ for (const button of document.querySelectorAll<HTMLButtonElement>("[data-rx-copy]")) {
27
+ if (button.dataset.rxCopyBound) continue;
28
+ button.dataset.rxCopyBound = "";
29
+ const status = button.querySelector<HTMLElement>(".rx-copy__status");
30
+ button.addEventListener("click", async () => {
31
31
  try {
32
- await navigator.clipboard.writeText(button.dataset.rxCopy ?? '')
32
+ await navigator.clipboard.writeText(button.dataset.rxCopy ?? "");
33
33
  } catch {
34
34
  // Clipboard access can be denied; saying nothing beats claiming a copy that did not happen.
35
- return
35
+ return;
36
36
  }
37
- button.dataset.state = 'done'
38
- if (status) status.textContent = 'Copied'
37
+ button.dataset.state = "done";
38
+ if (status) status.textContent = "Copied";
39
39
  window.setTimeout(() => {
40
- delete button.dataset.state
41
- if (status) status.textContent = ''
42
- }, 1600)
43
- })
40
+ delete button.dataset.state;
41
+ if (status) status.textContent = "";
42
+ }, 1600);
43
+ });
44
44
  }
45
45
  </script>
46
46
 
@@ -81,11 +81,11 @@ const { text, label = 'Copy' } = Astro.props
81
81
  }
82
82
 
83
83
  .rx-copy :global(.rx-copy__done),
84
- .rx-copy[data-state='done'] :global(.rx-copy__idle) {
84
+ .rx-copy[data-state="done"] :global(.rx-copy__idle) {
85
85
  visibility: hidden;
86
86
  }
87
87
 
88
- .rx-copy[data-state='done'] :global(.rx-copy__done) {
88
+ .rx-copy[data-state="done"] :global(.rx-copy__done) {
89
89
  visibility: visible;
90
90
  }
91
91
 
@@ -4,19 +4,19 @@
4
4
  * base-aware; external ones get `rel="noopener"` and a visible marker.
5
5
  */
6
6
  export interface CtaAction {
7
- text: string
8
- href: string
9
- variant?: 'primary' | 'minimal'
10
- external?: boolean
7
+ text: string;
8
+ href: string;
9
+ variant?: "primary" | "minimal";
10
+ external?: boolean;
11
11
  }
12
12
 
13
13
  interface Props {
14
- title: string
15
- lede: string
16
- actions: readonly CtaAction[]
14
+ title: string;
15
+ lede: string;
16
+ actions: readonly CtaAction[];
17
17
  }
18
18
 
19
- const { title, lede, actions } = Astro.props
19
+ const { title, lede, actions } = Astro.props;
20
20
  ---
21
21
 
22
22
  <aside class="rx-cta not-content">
@@ -25,9 +25,9 @@ const { title, lede, actions } = Astro.props
25
25
  <div class="rx-cta__actions">
26
26
  {actions.map((action) => (
27
27
  <a
28
- class:list={['rx-btn', `rx-btn--${action.variant ?? 'minimal'}`]}
28
+ class:list={["rx-btn", `rx-btn--${action.variant ?? "minimal"}`]}
29
29
  href={action.href}
30
- rel={action.external ? 'noopener' : undefined}
30
+ rel={action.external ? "noopener" : undefined}
31
31
  >
32
32
  {action.text}
33
33
  {action.external && (
@@ -3,23 +3,23 @@
3
3
  * Facts a page reads from somewhere else, as a framed table: column headings, a row heading per
4
4
  * row, cells that may render as code. Scrollable and focusable when narrow, so a keyboard can reach it.
5
5
  */
6
- export type Cell = string | { code: string }
6
+ export type Cell = string | { code: string };
7
7
 
8
8
  export interface DataRow {
9
- label: string
10
- cells: readonly Cell[]
9
+ label: string;
10
+ cells: readonly Cell[];
11
11
  }
12
12
 
13
13
  interface Props {
14
14
  /** The accessible name of the scrollable region: "Framework compatibility". */
15
- label: string
16
- columns: readonly string[]
17
- rows: readonly DataRow[]
15
+ label: string;
16
+ columns: readonly string[];
17
+ rows: readonly DataRow[];
18
18
  /** Where the facts come from, under the table. */
19
- caption?: string
19
+ caption?: string;
20
20
  }
21
21
 
22
- const { label, columns, rows, caption } = Astro.props
22
+ const { label, columns, rows, caption } = Astro.props;
23
23
  ---
24
24
 
25
25
  <div class="rx-table" tabindex="0" role="region" aria-label={label}>
@@ -39,7 +39,7 @@ const { label, columns, rows, caption } = Astro.props
39
39
  {row.label}
40
40
  </th>
41
41
  {row.cells.map((cell) => (
42
- <td>{typeof cell === 'string' ? cell : <code>{cell.code}</code>}</td>
42
+ <td>{typeof cell === "string" ? cell : <code>{cell.code}</code>}</td>
43
43
  ))}
44
44
  </tr>
45
45
  ))}
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  /** One collapsible block of a `DocAccordion`: a title, an optional one-line summary, and the slot. */
3
3
  interface Props {
4
- title: string
5
- summary?: string
6
- defaultOpen?: boolean
4
+ title: string;
5
+ summary?: string;
6
+ defaultOpen?: boolean;
7
7
  }
8
8
 
9
- const { title, summary, defaultOpen = false } = Astro.props
9
+ const { title, summary, defaultOpen = false } = Astro.props;
10
10
  ---
11
11
 
12
12
  <details class="doc-accordion-item" open={defaultOpen}>
@@ -46,7 +46,7 @@ const { title, summary, defaultOpen = false } = Astro.props
46
46
  }
47
47
 
48
48
  summary::after {
49
- content: '+';
49
+ content: "+";
50
50
  flex: 0 0 auto;
51
51
  font-size: 1.3rem;
52
52
  line-height: 1;
@@ -54,7 +54,7 @@ const { title, summary, defaultOpen = false } = Astro.props
54
54
  }
55
55
 
56
56
  .doc-accordion-item[open] summary::after {
57
- content: '−';
57
+ content: "−";
58
58
  }
59
59
 
60
60
  .summary-text {
@@ -1,28 +1,28 @@
1
1
  ---
2
2
  /**
3
- * The single rxova.org header, rendered by the website's layout; callers pass
3
+ * The single rxova.dev header, rendered by the website's layout; callers pass
4
4
  * the menu fully resolved. Not for the Starlight docs sites, which use `sharedStarlightConfig`.
5
5
  */
6
- import ThemeToggle from './ThemeToggle.astro'
6
+ import ThemeToggle from "./ThemeToggle.astro";
7
7
 
8
8
  export interface HeaderItem {
9
- label: string
9
+ label: string;
10
10
  /** Fully resolved by the caller — absolute or root-relative as its base needs. */
11
- href: string
11
+ href: string;
12
12
  /** Marks the item for the surface the reader is on. */
13
- current?: boolean
13
+ current?: boolean;
14
14
  }
15
15
 
16
16
  interface Props {
17
17
  /** Where the brand mark links — the site root, resolved by the caller. */
18
- homeHref: string
18
+ homeHref: string;
19
19
  /** Logo `src`, resolved by the caller for its base. */
20
- logoSrc: string
20
+ logoSrc: string;
21
21
  /** The menu, in the one fixed order every surface shows it. */
22
- items: readonly HeaderItem[]
22
+ items: readonly HeaderItem[];
23
23
  }
24
24
 
25
- const { homeHref, logoSrc, items } = Astro.props
25
+ const { homeHref, logoSrc, items } = Astro.props;
26
26
  ---
27
27
 
28
28
  {/* Outside <main> so it spans the viewport; sticky, not fixed, so nothing needs a top margin. */}
@@ -34,7 +34,7 @@ const { homeHref, logoSrc, items } = Astro.props
34
34
  </a>
35
35
  <nav aria-label="Sections">
36
36
  {items.map((item) => (
37
- <a href={item.href} aria-current={item.current ? 'page' : undefined}>
37
+ <a href={item.href} aria-current={item.current ? "page" : undefined}>
38
38
  {item.label}
39
39
  </a>
40
40
  ))}
@@ -108,7 +108,7 @@ const { homeHref, logoSrc, items } = Astro.props
108
108
  }
109
109
  /* The current section is marked for everyone, not only for assistive tech —
110
110
  aria-current on its own is invisible. */
111
- nav a[aria-current='page'] {
111
+ nav a[aria-current="page"] {
112
112
  color: var(--rx-fg);
113
113
  text-decoration: underline;
114
114
  text-underline-offset: 5px;
@@ -1,24 +1,24 @@
1
1
  ---
2
- import type { HTMLAttributes } from 'astro/types'
2
+ import type { HTMLAttributes } from "astro/types";
3
3
 
4
4
  /** The frame every glyph in `icons/` draws in: a 16px grid in the text colour. Decorative: label the button. */
5
- type Props = HTMLAttributes<'svg'> & {
5
+ type Props = HTMLAttributes<"svg"> & {
6
6
  /** Width and height, in pixels. */
7
- size?: number
7
+ size?: number;
8
8
  /** Fills the shape instead of stroking it. */
9
- solid?: boolean
10
- }
9
+ solid?: boolean;
10
+ };
11
11
 
12
- const { size = 16, solid = false, class: className, ...rest } = Astro.props
12
+ const { size = 16, solid = false, class: className, ...rest } = Astro.props;
13
13
  ---
14
14
 
15
15
  <svg
16
- class:list={['icon', className]}
16
+ class:list={["icon", className]}
17
17
  viewBox="0 0 16 16"
18
18
  width={size}
19
19
  height={size}
20
- fill={solid ? 'currentColor' : 'none'}
21
- stroke={solid ? 'none' : 'currentColor'}
20
+ fill={solid ? "currentColor" : "none"}
21
+ stroke={solid ? "none" : "currentColor"}
22
22
  stroke-width="1.6"
23
23
  stroke-linecap="round"
24
24
  stroke-linejoin="round"
@@ -4,23 +4,23 @@
4
4
  * (one per `mode.slot`), so a page writes fenced blocks and gets the docs' Shiki highlighting.
5
5
  */
6
6
  export interface Mode {
7
- name: string
7
+ name: string;
8
8
  /** The named slot holding this mode's code. */
9
- slot: string
10
- summary: string
9
+ slot: string;
10
+ summary: string;
11
11
  }
12
12
 
13
13
  interface Props {
14
- modes: readonly Mode[]
14
+ modes: readonly Mode[];
15
15
  }
16
16
 
17
- const { modes } = Astro.props
17
+ const { modes } = Astro.props;
18
18
  const panes = await Promise.all(
19
19
  modes.map(async (mode) => ({
20
20
  ...mode,
21
- html: Astro.slots.has(mode.slot) ? await Astro.slots.render(mode.slot) : '',
21
+ html: Astro.slots.has(mode.slot) ? await Astro.slots.render(mode.slot) : "",
22
22
  })),
23
- )
23
+ );
24
24
  ---
25
25
 
26
26
  <ol class="rx-modes">
@@ -3,27 +3,27 @@
3
3
  * A page's title and lede, with an optional back link. The default slot is the lede.
4
4
  * `detail` keeps the repo pages' heavier title, which still inherits the body's line height.
5
5
  */
6
- import BackLink from './BackLink.astro'
6
+ import BackLink from "./BackLink.astro";
7
7
 
8
8
  interface Props {
9
- title: string
10
- back?: { href: string; label: string }
11
- variant?: 'index' | 'detail'
9
+ title: string;
10
+ back?: { href: string; label: string };
11
+ variant?: "index" | "detail";
12
12
  /** The lede's measure: `narrow` is 46ch, `wide` 56ch. */
13
- measure?: 'narrow' | 'wide'
13
+ measure?: "narrow" | "wide";
14
14
  }
15
15
 
16
- const { title, back, variant = 'index', measure = 'wide' } = Astro.props
16
+ const { title, back, variant = "index", measure = "wide" } = Astro.props;
17
17
  ---
18
18
 
19
- <header class:list={['head', variant]}>
19
+ <header class:list={["head", variant]}>
20
20
  {back && (
21
21
  <BackLink class="back" href={back.href}>
22
22
  {back.label}
23
23
  </BackLink>
24
24
  )}
25
25
  <h1>{title}</h1>
26
- <p class:list={['lede', measure]}>
26
+ <p class:list={["lede", measure]}>
27
27
  <slot />
28
28
  </p>
29
29
  </header>
@@ -3,14 +3,14 @@
3
3
  * Cross-project navigation as a zero-JS `<details>`. Every href is absolute: a relative one would
4
4
  * resolve under the current site's base path.
5
5
  */
6
- import { PROJECTS, RXOVA_ORIGIN, type ProjectId } from '@rxova/brand'
6
+ import { PROJECTS, RXOVA_ORIGIN, type ProjectId } from "@rxova/brand";
7
7
 
8
8
  interface Props {
9
9
  /** Which project this site is, so it can be marked as current. */
10
- current?: ProjectId
10
+ current?: ProjectId;
11
11
  }
12
12
 
13
- const { current } = Astro.props
13
+ const { current } = Astro.props;
14
14
  ---
15
15
 
16
16
  <details class="rx-switcher">
@@ -22,14 +22,14 @@ const { current } = Astro.props
22
22
  </summary>
23
23
  <ul class="rx-switcher__menu">
24
24
  <li>
25
- <a href={RXOVA_ORIGIN}>rxova.org</a>
25
+ <a href={RXOVA_ORIGIN}>rxova.dev</a>
26
26
  </li>
27
27
  {PROJECTS.map((project) => (
28
28
  <li>
29
29
  <a
30
30
  href={`${RXOVA_ORIGIN}${project.mount}`}
31
- class={project.id === current ? 'rx-switcher__current' : undefined}
32
- aria-current={project.id === current ? 'page' : undefined}
31
+ class={project.id === current ? "rx-switcher__current" : undefined}
32
+ aria-current={project.id === current ? "page" : undefined}
33
33
  >
34
34
  {project.label}
35
35
  </a>
@@ -4,16 +4,16 @@
4
4
  * Figures are server-rendered at their final value, so with JS off or motion reduced it is a static panel.
5
5
  */
6
6
  export interface Stat {
7
- value: string
8
- label: string
9
- note: string
7
+ value: string;
8
+ label: string;
9
+ note: string;
10
10
  }
11
11
 
12
12
  interface Props {
13
- stats: readonly Stat[]
13
+ stats: readonly Stat[];
14
14
  }
15
15
 
16
- const { stats } = Astro.props
16
+ const { stats } = Astro.props;
17
17
  ---
18
18
 
19
19
  <div class="rx-stats">
@@ -32,52 +32,52 @@ const { stats } = Astro.props
32
32
  </div>
33
33
 
34
34
  <script>
35
- const DURATION = 1100
35
+ const DURATION = 1100;
36
36
 
37
37
  const animate = (panel: HTMLElement) => {
38
38
  // Values are display strings ("7.58 kB", "95%"); the leading number animates and the rest stays.
39
- const figures = [...panel.querySelectorAll<HTMLElement>('.rx-stats__value')].flatMap((el) => {
40
- const match = /^(\d+(?:\.\d+)?)(.*)$/s.exec(el.textContent ?? '')
41
- if (!match) return []
42
- const [, number = '', suffix = ''] = match
43
- const final = el.textContent ?? ''
39
+ const figures = [...panel.querySelectorAll<HTMLElement>(".rx-stats__value")].flatMap((el) => {
40
+ const match = /^(\d+(?:\.\d+)?)(.*)$/s.exec(el.textContent ?? "");
41
+ if (!match) return [];
42
+ const [, number = "", suffix = ""] = match;
43
+ const final = el.textContent ?? "";
44
44
  return [
45
45
  {
46
46
  el,
47
47
  target: Number(number),
48
- decimals: (number.split('.')[1] ?? '').length,
48
+ decimals: (number.split(".")[1] ?? "").length,
49
49
  suffix,
50
50
  final,
51
51
  },
52
- ]
53
- })
52
+ ];
53
+ });
54
54
 
55
55
  const frame = (start: number) => {
56
- const t = Math.min(1, (performance.now() - start) / DURATION)
56
+ const t = Math.min(1, (performance.now() - start) / DURATION);
57
57
  // easeOutExpo: quick to nearly-there, then settles.
58
- const eased = t === 1 ? 1 : 1 - Math.pow(2, -10 * t)
58
+ const eased = t === 1 ? 1 : 1 - Math.pow(2, -10 * t);
59
59
  for (const f of figures) {
60
- f.el.textContent = t === 1 ? f.final : (f.target * eased).toFixed(f.decimals) + f.suffix
60
+ f.el.textContent = t === 1 ? f.final : (f.target * eased).toFixed(f.decimals) + f.suffix;
61
61
  }
62
- if (t < 1) requestAnimationFrame(() => frame(start))
63
- }
62
+ if (t < 1) requestAnimationFrame(() => frame(start));
63
+ };
64
64
 
65
65
  const observer = new IntersectionObserver(
66
66
  (entries) => {
67
67
  for (const entry of entries) {
68
- if (!entry.isIntersecting) continue
69
- observer.disconnect()
70
- for (const f of figures) f.el.textContent = '0' + f.suffix
71
- requestAnimationFrame(() => frame(performance.now()))
68
+ if (!entry.isIntersecting) continue;
69
+ observer.disconnect();
70
+ for (const f of figures) f.el.textContent = "0" + f.suffix;
71
+ requestAnimationFrame(() => frame(performance.now()));
72
72
  }
73
73
  },
74
74
  { threshold: 0.3 },
75
- )
76
- observer.observe(panel)
77
- }
75
+ );
76
+ observer.observe(panel);
77
+ };
78
78
 
79
- if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
80
- for (const panel of document.querySelectorAll<HTMLElement>('.rx-stats')) animate(panel)
79
+ if (!window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
80
+ for (const panel of document.querySelectorAll<HTMLElement>(".rx-stats")) animate(panel);
81
81
  }
82
82
  </script>
83
83
 
@@ -147,7 +147,7 @@ const { stats } = Astro.props
147
147
 
148
148
  /* A gradient wash that fades up from the bottom of the hovered tile. */
149
149
  .rx-stats__item::after {
150
- content: '';
150
+ content: "";
151
151
  position: absolute;
152
152
  inset: 0;
153
153
  background: var(--rx-gradient);