Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions site/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions site/docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -74,7 +74,7 @@ The inline head script adds `dark` or `light` to `<html>` 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.

Expand Down
3 changes: 2 additions & 1 deletion site/e2e/blog-hero.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/blog-mobile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/blog.spec.ts
Original file line number Diff line number Diff line change
@@ -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/";
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/catalog.spec.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/controls.spec.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/demo-fit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/docs-areas.spec.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/gallery.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]");
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/landing-anchor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/landing-edit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/landing-entrance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/landing-fold.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/landing-height.spec.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/landing-hero.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down
3 changes: 2 additions & 1 deletion site/e2e/landing-play.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]");
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/landing-publish.spec.ts
Original file line number Diff line number Diff line change
@@ -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" });
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/landing-responsive-scroll.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/landing-story.spec.ts
Original file line number Diff line number Diff line change
@@ -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) =>
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/landing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading
Loading