Skip to content

Isometric line figures that answer the pointer. For React and for anything with a DOM.

Site: the catalogue's tiles walk their figures, and the docs list five options

Lucas Marques93b34e9d0337
diff --git a/apps/site/app/docs/page.tsx b/apps/site/app/docs/page.tsx
index fde6e63..a8dc74b 100644
--- a/apps/site/app/docs/page.tsx
+++ b/apps/site/app/docs/page.tsx
@@ -51,7 +51,7 @@ export default async function Docs() {
<header className="hero-rise">
<h1 className="col-h1" style={at(0)}>{cap(COUNT)} figures, one set of options.</h1>
<p className="col-lede" style={at(1)}>
- Every figure takes the same four options and draws itself in SVG, with no dependencies. Install the package, paste a figure, and turn <code className="doc-code">intensity</code> up or down.
+ Every figure takes the same five options and draws itself in SVG, with no dependencies. Install the package, paste a figure, and turn <code className="doc-code">intensity</code> up or down.
</p>
</header>
<GettingStarted commands={install(SITE)} size={tiny()} quickstart={quickstart} empty={empty} />
diff --git a/apps/site/app/docs/sections.tsx b/apps/site/app/docs/sections.tsx
index 24f1712..e82f9f8 100644
--- a/apps/site/app/docs/sections.tsx
+++ b/apps/site/app/docs/sections.tsx
@@ -41,7 +41,7 @@ export function GettingStarted({ commands, size, quickstart, empty }: { commands
<Tabs tabs={quickstart} label="Quick start" />
</Section>
<Section id="options">
- <p className="doc-p">Every figure takes the same four options, all optional.</p>
+ <p className="doc-p">Every figure takes the same five options, all optional.</p>
<div className="tbl-card">
<table className="props" data-options>
<thead>
diff --git a/apps/site/components/catalogue.tsx b/apps/site/components/catalogue.tsx
index ecd711a..e9b52f0 100644
--- a/apps/site/components/catalogue.tsx
+++ b/apps/site/components/catalogue.tsx
@@ -317,7 +317,7 @@ function ShelfSection({ shelf, picked, onPick }: { shelf: Shelf; picked?: string
/**
* One figure on its shelf. The whole tile takes a click, but the button is its name: the figure in the stage answers
* the pointer and the keyboard itself, and Riffle's cards cannot sit inside a button. A click inside a made figure's
- * frame stays in the frame, so that tile opens from its name.
+ * frame stays in the frame, so that tile opens from its name. Every tile plays its figure until a hand arrives.
*/
function Tile({ entry, picked, onPick }: { entry: Entry; picked: boolean; onPick: (f: Entry, from: HTMLElement | null, keyboard: boolean) => void }) {
const button = useRef<HTMLButtonElement>(null);
@@ -325,7 +325,7 @@ function Tile({ entry, picked, onPick }: { entry: Entry; picked: boolean; onPick
const made = entry.drawn ? undefined : entry.made;
return (
<div className="fig-tile" data-planned={entry.drawn || made ? undefined : ""} data-picked={picked ? "" : undefined} onClick={(event) => onPick(entry, button.current, event.detail === 0)}>
- <div className="fig-stage">{Figure ? <Figure /> : made ? <MadeFrame src={`/skill/${made.file}?theme=light`} title={entry.summary} /> : <Ghost />}</div>
+ <div className="fig-stage">{Figure ? <Figure play /> : made ? <MadeFrame src={`/skill/${made.file}?theme=light&play=1`} title={entry.summary} /> : <Ghost />}</div>
<div className="fig-foot">
<button ref={button} type="button" className="fig-name" aria-label={entry.drawn || made ? undefined : `${entry.name}, planned`} aria-expanded={picked} aria-controls="figure-drawer" onClick={(event) => {
event.stopPropagation();
diff --git a/apps/site/lib/figures.ts b/apps/site/lib/figures.ts
index 2b7f73e..6c90a0b 100644
--- a/apps/site/lib/figures.ts
+++ b/apps/site/lib/figures.ts
@@ -260,6 +260,7 @@ export const OPTIONS: Row[] = [
{ name: "theme", type: "\"auto\" | \"light\" | \"dark\"", default: "\"auto\"", description: "\"auto\" follows the page: an ancestor with class dark or data-theme=\"dark\", then the page's color-scheme." },
{ name: "label", type: "string", default: "a description", description: "The accessible name. In React, aria-label does the same." },
{ name: "onRead", type: "(text: string) => void", default: "", description: "The figure's caption, each time it changes. Called once at mount with the rest caption." },
+ { name: "play", type: "boolean", default: "false", description: "Walks the figure through its answer on its own, in a loop, until the pointer or focus arrives; it resumes after they leave. Under prefers-reduced-motion the figure rests." },
];
/** The public theme: six custom properties, set on the figure or on anything above it. */
diff --git a/apps/site/lib/llms.ts b/apps/site/lib/llms.ts
index 8eea2d1..9a677b6 100644
--- a/apps/site/lib/llms.ts
+++ b/apps/site/lib/llms.ts
@@ -18,7 +18,7 @@ export function llms(base: string): string {
const out: string[] = [
"# hairline",
"",
- `> ${PACKAGE}: ${COUNT} isometric line figures that answer the pointer. SVG, no dependencies, ESM only. A function per figure, and a React component per figure. Every figure takes the same four options.`,
+ `> ${PACKAGE}: ${COUNT} isometric line figures that answer the pointer. SVG, no dependencies, ESM only. A function per figure, and a React component per figure. Every figure takes the same five options.`,
"",
"## Install",
"",
diff --git a/apps/site/lib/skill.ts b/apps/site/lib/skill.ts
index 219aa4b..8c0d642 100644
--- a/apps/site/lib/skill.ts
+++ b/apps/site/lib/skill.ts
@@ -67,6 +67,6 @@ export const FOLDER = "What you install is one folder of small text files. There
export const USE: string[] = [
"Type the command with an idea. If you already have the metaphor, say it, and the concepts step is skipped.",
- "Out comes hairline-<name>.html: one file with no dependencies that opens from disk, holding the figure, an intensity slider and a theme switch.",
+ "Out comes hairline-<name>.html: one file with no dependencies that opens from disk, holding the figure, an intensity slider, a theme switch and a play button that walks its tour.",
"It runs on any agent that reads skills: Claude Code, Cursor, Codex and others.",
];
diff --git a/apps/site/test/docs.test.ts b/apps/site/test/docs.test.ts
index c483375..59c8518 100644
--- a/apps/site/test/docs.test.ts
+++ b/apps/site/test/docs.test.ts
@@ -17,7 +17,7 @@ import { CDN, CSS, EMPTY, QUICKSTART, REACT, REACT_SIGNATURE, VANILLA, VANILLA_S
/** The docs describe the package, and these check that nothing was written by hand around it. */
/* a key added to or taken from HairlineOptions fails the typecheck here, before the table can drift */
-const KEYS = { intensity: true, theme: true, label: true, onRead: true } satisfies Record<keyof HairlineOptions, true>;
+const KEYS = { intensity: true, theme: true, label: true, onRead: true, play: true } satisfies Record<keyof HairlineOptions, true>;
describe("the figures", () => {
it("are the package's, each with a function and a component", () => {
@@ -31,7 +31,7 @@ describe("the figures", () => {
});
describe("the options table", () => {
- it("has the four keys of HairlineOptions, in that order", () => {
+ it("has the five keys of HairlineOptions, in that order", () => {
expect(OPTIONS.map((r) => r.name)).toEqual(Object.keys(KEYS));
});
@@ -64,12 +64,13 @@ describe("the theme's CSS", () => {
});
describe("the signatures", () => {
- it("list the component's four options with their types, read from the options table", () => {
+ it("list the component's five options with their types, read from the options table", () => {
expect(REACT_SIGNATURE).toBe(`<Terrain
intensity?: number
theme?: "auto" | "light" | "dark"
label?: string
onRead?: (text: string) => void
+ play?: boolean
{...divProps}
/>
`);
@@ -150,7 +151,7 @@ describe("/llms.txt", () => {
for (const n of INTENSITY[doc.id]) expect(scale(doc.id, doc.parameter)).toContain(String(n));
});
- it("documents the four options, every theme property and the registry item", () => {
+ it("documents the five options, every theme property and the registry item", () => {
for (const row of OPTIONS) expect(text).toContain(`- \`${row.name}\``);
for (const key of ["plate", "hi", "edge", "mid", "lo", "stroke"]) expect(text).toContain(`--hairline-${key}`);
expect(text).toContain("https://example.test/r/hairline.json");
diff --git a/apps/site/test/figures.spec.ts b/apps/site/test/figures.spec.ts
index fa38913..e0cbf5e 100644
--- a/apps/site/test/figures.spec.ts
+++ b/apps/site/test/figures.spec.ts
@@ -269,3 +269,27 @@ test("a made tile never shows its page's controls while the page loads", async (
await expect(frame).toHaveCSS("opacity", "1");
await expect(frame.contentFrame().locator(".controls")).toBeHidden();
});
+
+const terrainStage = (page: Page) => tiles(page).filter({ has: page.locator(".fig-name", { hasText: "Terrain" }) }).locator(".fig-stage svg").first();
+
+test("a tile walks its figure with no hand on the page", async ({ page }) => {
+ const noise = watch(page);
+ await page.goto("/figures");
+ const svg = terrainStage(page);
+ await expect(svg).toBeVisible();
+ const first = await svg.innerHTML();
+ await expect.poll(() => svg.innerHTML(), { timeout: 15000 }).not.toBe(first);
+ expect(noise).toEqual([]);
+});
+
+test("under reduced motion a tile rests", async ({ page }) => {
+ const noise = watch(page);
+ await page.emulateMedia({ reducedMotion: "reduce" });
+ await page.goto("/figures");
+ const svg = terrainStage(page);
+ await expect(svg).toBeVisible();
+ const first = await svg.innerHTML();
+ await page.waitForTimeout(4000);
+ expect(await svg.innerHTML()).toBe(first);
+ expect(noise).toEqual([]);
+});
diff --git a/apps/site/test/site.spec.ts b/apps/site/test/site.spec.ts
index 3152858..7f7f52f 100644
--- a/apps/site/test/site.spec.ts
+++ b/apps/site/test/site.spec.ts
@@ -312,7 +312,7 @@ test("Get started leads to the docs, whose quick start pastes three ways and cop
await expect(quick.getByRole("tabpanel")).toContainText("https://esm.sh/@lucasmarkes/hairline");
await quick.getByRole("button", { name: "Copy code" }).click();
expect(await page.evaluate(() => navigator.clipboard.readText())).toMatch(/^<div id="figure"/);
- await expect(page.locator("#options [data-options] tbody tr td:first-child")).toHaveText(["intensity", "theme", "label", "onRead"]);
+ await expect(page.locator("#options [data-options] tbody tr td:first-child")).toHaveText(["intensity", "theme", "label", "onRead", "play"]);
});
test("llms.txt and the registry item are served", async ({ request }) => {