diff --git a/bun.lock b/bun.lock index 2434bd804..617bdfe18 100644 --- a/bun.lock +++ b/bun.lock @@ -47,7 +47,7 @@ }, "packages/core": { "name": "@opendata-ai/openchart-core", - "version": "9.0.0", + "version": "9.7.1", "dependencies": { "d3-color": "^3.1.0", "d3-format": "^3.1.0", @@ -63,7 +63,7 @@ }, "packages/engine": { "name": "@opendata-ai/openchart-engine", - "version": "9.0.0", + "version": "9.7.1", "dependencies": { "@opendata-ai/openchart-core": "workspace:*", "d3-array": "^3.2.0", @@ -92,7 +92,7 @@ }, "packages/react": { "name": "@opendata-ai/openchart-react", - "version": "9.0.0", + "version": "9.7.1", "dependencies": { "@opendata-ai/openchart-core": "workspace:*", "@opendata-ai/openchart-engine": "workspace:*", @@ -111,7 +111,7 @@ }, "packages/svelte": { "name": "@opendata-ai/openchart-svelte", - "version": "9.0.0", + "version": "9.7.1", "dependencies": { "@opendata-ai/openchart-core": "workspace:*", "@opendata-ai/openchart-engine": "workspace:*", @@ -130,7 +130,7 @@ }, "packages/vanilla": { "name": "@opendata-ai/openchart-vanilla", - "version": "9.0.0", + "version": "9.7.1", "dependencies": { "@floating-ui/dom": "^1.7.6", "@opendata-ai/openchart-core": "workspace:*", @@ -165,7 +165,7 @@ }, "packages/vue": { "name": "@opendata-ai/openchart-vue", - "version": "9.0.0", + "version": "9.7.1", "dependencies": { "@opendata-ai/openchart-core": "workspace:*", "@opendata-ai/openchart-engine": "workspace:*", @@ -199,7 +199,7 @@ "@opendata-ai/openchart-react": "workspace:*", "@opendata-ai/openchart-vanilla": "workspace:*", "@shikijs/transformers": "4.6.0", - "@steamfield/ui": "^0.5.0", + "@steamfield/ui": "~0.7.0", "@tailwindcss/typography": "^0.5.20", "@tailwindcss/vite": "^4.3.5", "astro": "^7.4.13", @@ -2436,7 +2436,7 @@ "@opendata-ai/site/@playwright/test": ["@playwright/test@1.65.1", "", { "dependencies": { "playwright": "1.65.1" }, "bin": { "playwright": "cli.js" } }, "sha512-y+NCIRm2LvY4slUVWvGh1nujJ8RF/hEisIsq2mtUPgdQC4L701bq5hZGMhrpeXjACvwvO9tj5dJqhvM6TP9lbw=="], - "@opendata-ai/site/@steamfield/ui": ["@steamfield/ui@0.5.0", "", { "peerDependencies": { "@types/react": "^19.2", "github-slugger": "^2.0.0", "react": "^19.2", "react-dom": "^19.2", "satteri": "^0.10.5", "shiki": "^4.5.0", "vue": "^3.5" }, "optionalPeers": ["@types/react", "github-slugger", "react", "react-dom", "satteri", "shiki", "vue"] }, "sha512-LxP/hSqP+mB9NRF0ey6oi8lwSxQF4wpGXbIX1d6EBVIIVBjWGDF7cOfEB0lEsWSNYbOtXrU+FckUMVxXfd6ptw=="], + "@opendata-ai/site/@steamfield/ui": ["@steamfield/ui@0.7.0", "", { "peerDependencies": { "@types/react": "^19.2", "github-slugger": "^2.0.0", "react": "^19.2", "react-dom": "^19.2", "satteri": "^0.10.5", "shiki": "^4.5.0", "vue": "^3.5" }, "optionalPeers": ["@types/react", "github-slugger", "react", "react-dom", "satteri", "shiki", "vue"] }, "sha512-hdz7Cx/Kva6k/W+9tJwv9KmBo0P7GhiiKZ1EGQhMbY5mmtMDyAWrclrdtSkMpT/fFOgHJ+1LoQ8a9d/Yw6Tmxg=="], "@opendata-ai/site/@testing-library/jest-dom": ["@testing-library/jest-dom@8.0.0", "", { "dependencies": { "@adobe/css-tools": "^4.4.0", "aria-query": "^5.0.0", "css.escape": "^1.5.1", "dom-accessibility-api": "^0.6.3", "picocolors": "^1.1.1", "redent": "^3.0.0" }, "peerDependencies": { "@testing-library/dom": ">=10 <11", "vitest": ">=5 <6" }, "optionalPeers": ["vitest"] }, "sha512-Nu45KEeFgP/ydCMipnisMblq6YHViqEFi3fKN0a40s+zdKDDD7vEPCEavS0i7i4RxmclcEIL8q2o42pu+WgNgg=="], diff --git a/site/AGENTS.md b/site/AGENTS.md index 8b9553688..27a3b2bf4 100644 --- a/site/AGENTS.md +++ b/site/AGENTS.md @@ -39,7 +39,7 @@ src/content/docs/ catalog pages, one .mdx per chart type, grouped by sectio src/content.config.ts collections: catalog pages plus the repository's docs Markdown (docs/ and docs/reference/) that declares a `section` src/demos/ demo specs per section, found by registry.ts; fixtures/ for tests src/content/blog/ blog posts, one .md or .mdx each; the file name is the slug -src/lib/ docs navigation and exports, Markdown plugins, demo rendering, gallery entries, blog posts, search index attributes, analytics, consent +src/lib/ GitHub star count at build time (stars.ts), docs navigation and exports, Markdown plugins, demo rendering, gallery entries, blog posts, search index attributes, analytics, consent src/components/ landing sections and their islands, docs chrome, the Demo figure, gallery tiles, blog parts, the search dialog src/layouts/ BaseLayout (head, header, footer, analytics), DocsLayout (sidebar, outline, pager) and BlogLayout (byline, JSON-LD) src/pages/ landing, docs and their .md exports, examples (wall and entry pages), blog (index, posts, tags, rss.xml), tile images (/tiles/*.svg), llms files, social cards, robots, 404, test fixtures @@ -141,7 +141,7 @@ Public build-time values (`PUBLIC_POSTHOG_KEY`, `PUBLIC_POSTHOG_HOST`) come from ## Analytics -`src/lib/analytics.ts` is the only module that loads `posthog-js`. `BaseLayout` passes it `PUBLIC_POSTHOG_KEY` and `PUBLIC_POSTHOG_HOST` (empty host means PostHog US cloud); without a key the SDK never loads, which is the state in dev, tests, CI and previews. Consent comes from the shared Steamfield banner (`src/lib/consent.ts`, the `sf-consent` cookie on `.steamfield.io`, linking `https://steamfield.io/privacy`): until the visitor accepts, PostHog runs cookieless (pageviews, autocapture clicks without input values, web vitals; no URL hashes, no feature flags, no Logs extension) and stores nothing; after Accept, PostHog enables cookies across `.steamfield.io`, heatmaps, and masked session recordings with console logs (masking all inputs and `[data-ph-mask]` on the search input, results and status, with no network payloads or headers). A withdrawal stops recordings/heatmaps and clears stored data, including on bfcache restore. Every event carries `site: "openchart"`. Event names are in `src/lib/events.ts`; send them with `track()`. Tests: `src/lib/analytics.test.ts` runs real `posthog-js` against `tests/fixtures/posthog/remote-config.json` and `everythingOn`; `tests/build.test.ts` checks keyless vs. keyed builds; `e2e/analytics.spec.ts` checks the live behavior in Chromium. +`src/lib/analytics.ts` is the only module that loads `posthog-js`. `BaseLayout` passes it `PUBLIC_POSTHOG_KEY` and `PUBLIC_POSTHOG_HOST` (empty host means PostHog US cloud); without a key the SDK never loads, which is the state in dev, tests, CI and previews. Consent comes from the shared Steamfield banner (`src/lib/consent.ts`, the `sf-consent` cookie on `.steamfield.io`, linking `https://steamfield.io/privacy`): until the visitor accepts, PostHog runs cookieless (pageviews, autocapture clicks without input values, web vitals; no URL hashes, no feature flags, no Logs extension) and stores nothing; after Accept, PostHog enables cookies across `.steamfield.io`, heatmaps, and masked session recordings with console logs (masking all inputs and `[data-ph-mask]` on the search input, results and status, with no network payloads or headers). A withdrawal stops recordings/heatmaps and clears stored data, including on bfcache restore. The header and footer carry the GitHub star button from `@steamfield/ui`: its count is fetched at build time (`src/lib/stars.ts`, with `GITHUB_TOKEN` when set) and `enhanceStarButtons` in `BaseLayout` refreshes it in the browser on idle, so every page asks api.github.com for the public star count (the visitor's IP reaches GitHub; the shared privacy page covers it). The e2e specs import `test` from `e2e/test.ts`, which answers that request with a stub so runs never hit GitHub's rate limit. Every event carries `site: "openchart"`. Event names are in `src/lib/events.ts`; send them with `track()`. Tests: `src/lib/analytics.test.ts` runs real `posthog-js` against `tests/fixtures/posthog/remote-config.json` and `everythingOn`; `tests/build.test.ts` checks keyless vs. keyed builds; `e2e/analytics.spec.ts` checks the live behavior in Chromium. ## Build workarounds diff --git a/site/docs/DEVELOPMENT.md b/site/docs/DEVELOPMENT.md index e91157a08..22faeafad 100644 --- a/site/docs/DEVELOPMENT.md +++ b/site/docs/DEVELOPMENT.md @@ -4,7 +4,7 @@ | Path | Owns | | --- | --- | -| `src/config.ts` | Product name, tagline, URL, install commands, demo lines, features, logos, links, license, the header `nav` and `footer` columns, the docs areas and sections (`docsAreas`), the blog's tags (`blogTags`) and the `islands` list | +| `src/config.ts` | Product name, tagline, URL, install commands, demo lines, features, logos, links, license, the header `nav`, the `footer` columns, `repoName`, the docs areas and sections (`docsAreas`), the blog's tags (`blogTags`) and the `islands` list | | `src/content/docs/` | Site docs pages, one MDX or Markdown file each, validated by `src/content/schema.ts` | | `../docs/` | The repository's docs; a file with a `section` in its frontmatter is a page (see "Repository docs") | | `src/lib/repo-link-targets.ts` | Where links in repository docs go when the target is not a published page: aliases and the Ladle story map | @@ -74,7 +74,7 @@ The inline head script adds `dark` or `light` to `` before paint, from `lo ## Header and layout -The header's mark is `BrandMarkAnimated`: on each page load its shapes drop in and bounce into the logo, from the keyframes in `src/styles/brand-mark-motion.css`, which `node brand/source/build.mjs` generates (still under reduced motion); the footer keeps the static `BrandMark`. The header lists Docs, then `site.nav` (Examples, Blog), then `site.social` (GitHub), then the search trigger and the theme toggle. Every entry in `site.nav` renders, so add one only when its page exists. The link whose path the current route starts with gets `aria-current="page"`. To fit a 360px screen, the social links hide under 640px (the footer keeps them) and the wordmark text is visually hidden under 480px; the home link keeps its name, "OpenChart home". The search trigger and the theme toggle keep their boxes while hidden (`visibility: hidden` until their scripts set `data-search-ready` and `data-theme-ready`), so wiring them never moves the links. +The header's mark is `BrandMarkAnimated`: on each page load its shapes drop in and bounce into the logo, from the keyframes in `src/styles/brand-mark-motion.css`, which `node brand/source/build.mjs` generates (still under reduced motion); the footer keeps the static `BrandMark`. The header lists Docs, then `site.nav` (Examples, Blog), then the GitHub star button (`GitHubStarButton` from `@steamfield/ui`, compact; the footer's GitHub link is the split one), then the search trigger and the theme toggle. Every entry in `site.nav` renders, so add one only when its page exists. The link whose path the current route starts with gets `aria-current="page"`. To fit a 360px screen, the star button hides under 640px (the footer keeps one) and the wordmark text is visually hidden under 480px; the home link keeps its name, "OpenChart home". The search trigger and the theme toggle keep their boxes while hidden (`visibility: hidden` until their scripts set `data-search-ready` and `data-theme-ready`), so wiring them never moves the links. `BaseLayout` takes `ogType` (`"article"` for a post), `robots` (`"noindex, follow"` for a thin page whose links should still count; `noindex` is shorthand for `"noindex, nofollow"`) and a named `head` slot for JSON-LD and article meta. Every page links the RSS feed as an alternate. diff --git a/site/e2e/blog-hero.spec.ts b/site/e2e/blog-hero.spec.ts index ef03263ff..9810c46f0 100644 --- a/site/e2e/blog-hero.spec.ts +++ b/site/e2e/blog-hero.spec.ts @@ -5,7 +5,8 @@ */ import { readdirSync, readFileSync } from "node:fs"; import { join } from "node:path"; -import { expect, test } from "@playwright/test"; +import { expect } from "@playwright/test"; +import { test } from "./test"; /** Every published post that names a lead chart, from the content folder (drafts never build). */ const SLUGS = readdirSync("src/content/blog") diff --git a/site/e2e/blog-mobile.spec.ts b/site/e2e/blog-mobile.spec.ts index d06a365df..928849ede 100644 --- a/site/e2e/blog-mobile.spec.ts +++ b/site/e2e/blog-mobile.spec.ts @@ -7,7 +7,8 @@ */ import { readdirSync, readFileSync } from "node:fs"; import { join } from "node:path"; -import { expect, type Page, test } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; +import { test } from "./test"; const POSTS = readdirSync("src/content/blog") .filter((file) => /\.mdx?$/.test(file)) diff --git a/site/e2e/blog.spec.ts b/site/e2e/blog.spec.ts index c81b6f3c5..56a705343 100644 --- a/site/e2e/blog.spec.ts +++ b/site/e2e/blog.spec.ts @@ -1,8 +1,9 @@ import { readdirSync, readFileSync } from "node:fs"; import { join } from "node:path"; -import { expect, type Page, test } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; import { pageViolations } from "./axe"; import { sidewaysOverflow } from "./layout"; +import { test } from "./test"; const POST = "/blog/how-to-chart-a-temperature-anomaly/"; const TAG = "/blog/tags/climate/"; diff --git a/site/e2e/catalog.spec.ts b/site/e2e/catalog.spec.ts index cdb0ff681..c3f62e24c 100644 --- a/site/e2e/catalog.spec.ts +++ b/site/e2e/catalog.spec.ts @@ -1,6 +1,7 @@ -import { expect, type Page, test } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; import { catalogPages } from "../tests/catalog-pages"; import { pageViolations } from "./axe"; +import { test } from "./test"; // The first page of each section stands in for the section. const pages = Object.entries(catalogPages).map( diff --git a/site/e2e/controls.spec.ts b/site/e2e/controls.spec.ts index b41b1674c..93e22e7c0 100644 --- a/site/e2e/controls.spec.ts +++ b/site/e2e/controls.spec.ts @@ -1,5 +1,6 @@ import { readFile } from "node:fs/promises"; -import { expect, type Page, test } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; +import { test } from "./test"; /** * Reader controls on live demos in a real browser: state buttons, Replay, the diff --git a/site/e2e/demo-fit.spec.ts b/site/e2e/demo-fit.spec.ts index 1ec1a5e07..8f53757c9 100644 --- a/site/e2e/demo-fit.spec.ts +++ b/site/e2e/demo-fit.spec.ts @@ -8,8 +8,9 @@ */ import { readdirSync, readFileSync } from "node:fs"; import { join } from "node:path"; -import { expect, type Page, test } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; import { catalogPages } from "../tests/catalog-pages"; +import { test } from "./test"; const POSTS = readdirSync("src/content/blog") .filter((file) => /\.mdx?$/.test(file)) diff --git a/site/e2e/docs-areas.spec.ts b/site/e2e/docs-areas.spec.ts index 9d5d215b9..6f2d1f669 100644 --- a/site/e2e/docs-areas.spec.ts +++ b/site/e2e/docs-areas.spec.ts @@ -1,6 +1,7 @@ -import { expect, type Page, test } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; import { docsPages } from "../tests/docs-pages"; import { pageViolations } from "./axe"; +import { test } from "./test"; // The first page of each phase 4 section stands in for the section. const pages = Object.entries(docsPages).map( diff --git a/site/e2e/gallery.spec.ts b/site/e2e/gallery.spec.ts index 796647260..b38a96816 100644 --- a/site/e2e/gallery.spec.ts +++ b/site/e2e/gallery.spec.ts @@ -6,10 +6,11 @@ * contract comments of src/components/gallery/GalleryTile.astro and * GalleryFilter.astro. */ -import { expect, type Page, test } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; import { inflationReference } from "../src/demos/gallery/composition"; import { pageViolations } from "./axe"; import { sidewaysOverflow } from "./layout"; +import { test } from "./test"; const WALL = "/examples/"; const tiles = (page: Page) => page.locator("[data-gallery-tile]"); diff --git a/site/e2e/landing-anchor.spec.ts b/site/e2e/landing-anchor.spec.ts index 7b4704a8c..635895db9 100644 --- a/site/e2e/landing-anchor.spec.ts +++ b/site/e2e/landing-anchor.spec.ts @@ -4,7 +4,8 @@ * without an input event). A reload keeps the reader's own position, and a * malformed hash is harmless. */ -import { expect, type Page, test } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; +import { test } from "./test"; const sectionTop = (page: Page, id: string) => page.locator(`#${id}`).evaluate((section) => Math.round(section.getBoundingClientRect().top)); diff --git a/site/e2e/landing-edit.spec.ts b/site/e2e/landing-edit.spec.ts index 174c72956..a789c41fd 100644 --- a/site/e2e/landing-edit.spec.ts +++ b/site/e2e/landing-edit.spec.ts @@ -9,11 +9,12 @@ * The tests that handle the chart run with reduced motion, so the * self-demonstration never moves the callout under the pointer. */ -import { expect, type Locator, type Page, test } from "@playwright/test"; +import { expect, type Locator, type Page } from "@playwright/test"; import { startOffset } from "../src/components/landing/edit/edit-spec"; import { offsetLine } from "../src/components/landing/edit/edit-state"; import { LIVE_UNAVAILABLE_TEXT, NO_SCRIPT_TEXT } from "../src/components/shared/StillNote"; import { landingCopy } from "../src/landing/copy"; +import { test } from "./test"; const START_LINE = offsetLine(startOffset); /** Longer than the self-demonstration (1.6s), so a second run would show inside it. */ diff --git a/site/e2e/landing-entrance.spec.ts b/site/e2e/landing-entrance.spec.ts index 0909aa87e..90a5eeaf6 100644 --- a/site/e2e/landing-entrance.spec.ts +++ b/site/e2e/landing-entrance.spec.ts @@ -2,8 +2,9 @@ * The page's entrance: the headline's words rise in sequence without ever being * hidden, and each section's rule draws in from the left as it arrives. */ -import { expect, type Page, test } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; import { landingCopy } from "../src/landing/copy"; +import { test } from "./test"; const headline = (page: Page) => page.getByRole("heading", { level: 1 }); const words = (page: Page) => headline(page).locator(".hero-word"); diff --git a/site/e2e/landing-fold.spec.ts b/site/e2e/landing-fold.spec.ts index 579a35fef..de8d5fa99 100644 --- a/site/e2e/landing-fold.spec.ts +++ b/site/e2e/landing-fold.spec.ts @@ -2,7 +2,8 @@ * The hero's first screen at phone and tablet sizes: the chart has to be in it. * Each test sets its own viewport, so the file runs on the desktop project only. */ -import { expect, test } from "@playwright/test"; +import { expect } from "@playwright/test"; +import { test } from "./test"; const NARROW = [ { width: 375, height: 812 }, diff --git a/site/e2e/landing-height.spec.ts b/site/e2e/landing-height.spec.ts index 9b946e9e7..7a7a87fe5 100644 --- a/site/e2e/landing-height.spec.ts +++ b/site/e2e/landing-height.spec.ts @@ -1,5 +1,6 @@ /** The landing page's length budget: new sections must not make the page longer than it was. */ -import { expect, test } from "@playwright/test"; +import { expect } from "@playwright/test"; +import { test } from "./test"; /** * The cap at 1440x900. Its commit (95937bfb, scaffold phase 2) recorded no diff --git a/site/e2e/landing-hero.spec.ts b/site/e2e/landing-hero.spec.ts index dff16042f..a3297cc77 100644 --- a/site/e2e/landing-hero.spec.ts +++ b/site/e2e/landing-hero.spec.ts @@ -3,8 +3,9 @@ * scroll sideways on one row. A fuel picked while the picker is off screen must * bring its chip into view in the row without moving the page. */ -import { expect, type Page, test } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; import { HERO_SPOTLIGHTS } from "../src/landing/hero"; +import { test } from "./test"; const PHONE = { width: 390, height: 844 }; diff --git a/site/e2e/landing-play.spec.ts b/site/e2e/landing-play.spec.ts index 5a86d270f..7961d8128 100644 --- a/site/e2e/landing-play.spec.ts +++ b/site/e2e/landing-play.spec.ts @@ -2,9 +2,10 @@ * The motion section's playback figure: it leads the section, plays when seen, * and its controls work. Runs on the desktop and mobile projects. */ -import { expect, type Page, test } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; import { LIVE_UNAVAILABLE_TEXT, NO_SCRIPT_TEXT } from "../src/components/shared/StillNote"; import { sidewaysOverflow } from "./layout"; +import { test } from "./test"; const section = (page: Page) => page.locator("#motion"); const figure = (page: Page) => section(page).locator("[data-playback-figure]"); diff --git a/site/e2e/landing-publish.spec.ts b/site/e2e/landing-publish.spec.ts index 75b1f79bc..72d95d1eb 100644 --- a/site/e2e/landing-publish.spec.ts +++ b/site/e2e/landing-publish.spec.ts @@ -1,5 +1,6 @@ /** The publish section: the chart at article width, what a screen reader reads, and the exports. */ -import { expect, type Page, type Route, test } from "@playwright/test"; +import { expect, type Page, type Route } from "@playwright/test"; +import { test } from "./test"; const section = (page: Page) => page.locator("#publish"); const exportGroup = (page: Page) => section(page).getByRole("group", { name: "Export this chart" }); diff --git a/site/e2e/landing-responsive-scroll.spec.ts b/site/e2e/landing-responsive-scroll.spec.ts index 9d351f714..66c9f15f5 100644 --- a/site/e2e/landing-responsive-scroll.spec.ts +++ b/site/e2e/landing-responsive-scroll.spec.ts @@ -9,7 +9,8 @@ * sections above. Content above that grows is re-measured page-wide, before * the frame hydrates too, which the styles pin above the section shows. */ -import { expect, type Page, test } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; +import { test } from "./test"; const WIDE = { width: 1440, height: 900 }; const FOLLOW_HINT = diff --git a/site/e2e/landing-story.spec.ts b/site/e2e/landing-story.spec.ts index ee0536865..98902c8dd 100644 --- a/site/e2e/landing-story.spec.ts +++ b/site/e2e/landing-story.spec.ts @@ -1,5 +1,6 @@ /** The scroll story's larger chart and its scroll-filled rail. */ -import { expect, type Page, test } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; +import { test } from "./test"; const section = (page: Page) => page.locator("#story"); const railProgress = (page: Page) => diff --git a/site/e2e/landing.spec.ts b/site/e2e/landing.spec.ts index 0de5e5a5d..9ec889260 100644 --- a/site/e2e/landing.spec.ts +++ b/site/e2e/landing.spec.ts @@ -5,12 +5,13 @@ * the hero and the agent session run on Playwright's clock, so no test sleeps. */ import { validateSpec } from "@opendata-ai/openchart-engine"; -import { expect, type Locator, type Page, test } from "@playwright/test"; +import { expect, type Locator, type Page } from "@playwright/test"; import { LIVE_UNAVAILABLE_TEXT, NO_SCRIPT_TEXT } from "../src/components/shared/StillNote"; import { agentSession } from "../src/landing/agents"; import { LANDING_SECTION_IDS } from "../src/landing/copy"; import { pageViolations } from "./axe"; import { sidewaysOverflow } from "./layout"; +import { test } from "./test"; const BAR = "/docs/comparison/bar/"; const PRESETS = ["essay", "wire", "broadsheet", "terminal"] as const; diff --git a/site/e2e/search.spec.ts b/site/e2e/search.spec.ts index a5e509d9f..f2868d44e 100644 --- a/site/e2e/search.spec.ts +++ b/site/e2e/search.spec.ts @@ -1,8 +1,9 @@ import { existsSync, readdirSync, readFileSync } from "node:fs"; -import { expect, type Locator, type Page, type Request, test } from "@playwright/test"; +import { expect, type Locator, type Page, type Request } from "@playwright/test"; import { galleryEntries } from "../src/lib/gallery"; import { SEARCH_AREAS, SEARCH_UNAVAILABLE } from "../src/lib/search-index"; import { pageViolations } from "./axe"; +import { test } from "./test"; const BAR = "/docs/comparison/bar/"; const DATA_TABLE = "/docs/tables/data-table/"; diff --git a/site/e2e/site.spec.ts b/site/e2e/site.spec.ts index 45fe606ee..1ff723a45 100644 --- a/site/e2e/site.spec.ts +++ b/site/e2e/site.spec.ts @@ -1,6 +1,7 @@ -import { expect, type Locator, type Page, test } from "@playwright/test"; +import { expect, type Locator, type Page } from "@playwright/test"; import { pageViolations } from "./axe"; import { sidewaysOverflow } from "./layout"; +import { test } from "./test"; const BAR = "/docs/comparison/bar/"; const GUIDE = "/docs/get-started/getting-started/"; @@ -267,7 +268,7 @@ test("the area switcher moves from Visualizations to Guides", async ({ page, isM }); // The header holds four links, search and the theme toggle; on a phone it drops -// GitHub (under 640px) and the wordmark text (under 480px) to fit. +// the GitHub star button (under 640px) and the wordmark text (under 480px) to fit. for (const width of [360, 390]) { test(`at ${width}px the header fits and no page scrolls sideways`, async ({ page }) => { await page.setViewportSize({ width, height: 800 }); @@ -276,7 +277,7 @@ for (const width of [360, 390]) { const header = page.locator("body > header"); const nav = header.getByRole("navigation", { name: "Main" }); await expect(nav.getByRole("link", { name: "Blog" })).toBeVisible(); - await expect(nav.getByRole("link", { name: "GitHub" })).toBeHidden(); + await expect(nav.locator('[data-part="github-star"]')).toBeHidden(); await expect(header.getByRole("link", { name: "OpenChart home" })).toBeVisible(); // `scrollbar-gutter: stable` reserves the bar's space, so the document's // scrollWidth can be smaller than its clientWidth (negative here, on Linux). diff --git a/site/e2e/test.ts b/site/e2e/test.ts new file mode 100644 index 000000000..83c42d6cf --- /dev/null +++ b/site/e2e/test.ts @@ -0,0 +1,21 @@ +/** + * Playwright's `test` with the browser kept off api.github.com. The pages ask GitHub + * for the star count on idle, and an unauthenticated runner is rate limited (a 403 is + * a console error that fails the specs collecting them). The stub answers like the API + * with a count under the button's threshold, so it stays the uncounted "Star" button. + */ +import { test as base } from "@playwright/test"; + +export const test = base.extend({ + context: async ({ context }, use) => { + await context.route("https://api.github.com/**", (route) => + route.fulfill({ + status: 200, + contentType: "application/json", + headers: { "access-control-allow-origin": "*" }, + body: JSON.stringify({ stargazers_count: 0 }), + }), + ); + await use(context); + }, +}); diff --git a/site/package.json b/site/package.json index 6a26504e9..05276c650 100644 --- a/site/package.json +++ b/site/package.json @@ -21,7 +21,7 @@ "@opendata-ai/openchart-react": "workspace:*", "@opendata-ai/openchart-vanilla": "workspace:*", "@shikijs/transformers": "4.6.0", - "@steamfield/ui": "^0.5.0", + "@steamfield/ui": "~0.7.0", "@tailwindcss/typography": "^0.5.20", "@tailwindcss/vite": "^4.3.5", "astro": "^7.4.13", diff --git a/site/src/config.ts b/site/src/config.ts index 027378c1d..a97be029a 100644 --- a/site/src/config.ts +++ b/site/src/config.ts @@ -20,6 +20,8 @@ export const site = { /** Absolute production URL: canonicals, the sitemap, OG images and llms.txt use it. */ url: "https://openchart.steamfield.io", repo, + /** The repository as "owner/name", for the star button and its count. */ + repoName: new URL(repo).pathname.slice(1), /** Current release, shown in the header: the core package's version, which every package shares. */ version: corePackage.version, install: [ @@ -27,8 +29,7 @@ export const site = { { label: "bun", command: "bun add @opendata-ai/openchart-react" }, { label: "pnpm", command: "pnpm add @opendata-ai/openchart-react" }, ] as InstallOption[], - social: [{ label: "GitHub", href: repo }] as Link[], - /** Header links between Docs and the social links, in order. Every entry renders, so list built pages only. */ + /** Header links after Docs, in order (the GitHub star button follows them). Every entry renders, so list built pages only. */ nav: [ { label: "Examples", href: "/examples/" }, { label: "Blog", href: "/blog/" }, diff --git a/site/src/layouts/BaseLayout.astro b/site/src/layouts/BaseLayout.astro index fe57e85dd..0b589eb22 100644 --- a/site/src/layouts/BaseLayout.astro +++ b/site/src/layouts/BaseLayout.astro @@ -106,6 +106,7 @@ const pageTitle = path === "/" ? `${site.name}: ${title}` : `${title} | ${site.n {/* Demos: closes code blocks and holds back entering charts before paint; lifts if scripts never arrive. */}