Isometric line figures that answer the pointer. For React and for anything with a DOM.
Skill page: a Skill link in the top bar, and the skill in llms.txt with each example's page
Lucas Marques56a0fa1a481f
diff --git a/apps/site/components/chrome.tsx b/apps/site/components/chrome.tsxindex a1c2bc8..d827f04 100644--- a/apps/site/components/chrome.tsx+++ b/apps/site/components/chrome.tsx@@ -9,12 +9,13 @@ export function GitHub() {);}-/** The bar on every page: the name home, the docs, the story, the version, GitHub. */+/** The bar on every page: the name home, the skill, the docs, the story, the version, GitHub. */export function Topbar() {return (<header className="topbar"><a href="/" className="text-[15px] font-medium tracking-[-0.02em]">hairline</a><nav className="flex items-center">+ <a className="topbar-link" href="/skill">Skill</a><a className="topbar-link" href="/docs">Docs</a><a className="topbar-link" href="/inspo">Inspo</a><span className="topbar-link tabular-nums" data-version>v{pkg.version}</span>diff --git a/apps/site/lib/llms.ts b/apps/site/lib/llms.tsindex 908cb02..a29b9ca 100644--- a/apps/site/lib/llms.ts+++ b/apps/site/lib/llms.ts@@ -1,5 +1,6 @@import { FIGURES, INTENSITY, LINKS, OPTIONS, THEME, measure, type Row } from "./figures";import { CDN, PACKAGE, REACT, VANILLA, install } from "./snippets";+import { COMMAND, EXAMPLES, INSTALL, SUMMARY } from "./skill";/** The page as plain text, for a model to read: the same data, the same copy. */@@ -55,6 +56,12 @@ export function llms(base: string): string {"", THEME.map((t) => `- \`${t.property}\` (light: ${t.light}): ${t.role}`).join("\n"),"", "## Accessibility", "","A figure is an image with a description you can replace with `label`. Riffle is a focusable group: the arrow keys walk its cards and a live region reads out the card's number. Under prefers-reduced-motion, Phosphor and Slow hold still, and every figure still answers the pointer.",+ "", "## Make your own", "",+ SUMMARY,+ "", fence("sh", INSTALL),+ "", `Then type \`${COMMAND} <idea>\` in the agent. Four ideas, each with the page the skill wrote for it:`,+ "", EXAMPLES.map((e) => `- \`${COMMAND} ${e.idea}\`: ${base}/skill/${e.file}`).join("\n"),+ "", `More: ${base}/skill`,"", "## Links", "",`- Site: ${base}`, `- Source: ${LINKS.github}`, `- npm: ${LINKS.npm}`, `- The essay the figures come from: ${LINKS.essay}`, `- shadcn registry item: ${base}/r/hairline.json`, "",);diff --git a/apps/site/test/docs.test.ts b/apps/site/test/docs.test.tsindex 2a53e61..4945eda 100644--- a/apps/site/test/docs.test.ts+++ b/apps/site/test/docs.test.ts@@ -9,6 +9,7 @@ import { SECTIONS } from "@/lib/docs";import { FIGURES, INTENSITY, OPTIONS, measure } from "@/lib/figures";import { llms, scale } from "@/lib/llms";import { tiny } from "@/lib/size";+import { COMMAND, EXAMPLES, INSTALL } from "@/lib/skill";import { highlight } from "@/lib/highlight";import { CDN, CSS, QUICKSTART, REACT, REACT_SIGNATURE, VANILLA, VANILLA_SIGNATURE, install, snippet } from "@/lib/snippets";@@ -150,6 +151,14 @@ describe("the intensity table", () => {describe("/llms.txt", () => {const text = llms("https://example.test");+ it("says how to install the skill and links each example to the page it produced", () => {+ expect(text).toContain("## Make your own");+ expect(text).toContain(INSTALL);+ for (const e of EXAMPLES) expect(text).toContain(`- \`${COMMAND} ${e.idea}\`: https://example.test/skill/${e.file}`);+ expect(text).toContain("https://example.test/skill\n");+ expect(text.indexOf("## Make your own")).toBeLessThan(text.indexOf("## Links"));+ });+it.each(FIGURES)("names $name with its row of the intensity table", (doc) => {expect(text).toContain(`### ${doc.name}`);expect(text).toContain(doc.stronger);diff --git a/apps/site/test/site.spec.ts b/apps/site/test/site.spec.tsindex 28df824..cd5d3ca 100644--- a/apps/site/test/site.spec.ts+++ b/apps/site/test/site.spec.ts@@ -39,9 +39,11 @@ test("the home prerenders an empty box, then draws the inspector's figure with aexpect(noise).toEqual([]);});-test("the top bar holds the docs, the story, the version and GitHub, and no llms.txt button", async ({ page }) => {+test("the top bar holds the skill, the docs, the story, the version and GitHub, and no llms.txt button", async ({ page }) => {await page.goto("/");- await expect(page.locator(".topbar nav > *")).toHaveCount(4);+ await expect(page.locator(".topbar nav > *")).toHaveCount(5);+ await expect(page.locator(".topbar nav > a").nth(0)).toHaveText("Skill");+ await expect(page.locator(".topbar nav > a").nth(1)).toHaveText("Docs");await expect(page.locator(".topbar")).not.toContainText("llms.txt");});@@ -56,7 +58,7 @@ test("the top bar's links sit as one row: one height, one centre line, one type,const style = getComputedStyle(el);return { height: box.height, middle: box.top + box.height / 2, left: ink.left, right: ink.right, type: [style.fontSize, style.fontWeight, style.color, style.backgroundColor].join(" ") };}));- expect(items).toHaveLength(4);+ expect(items).toHaveLength(5);expect(new Set(items.map((i) => i.height)).size).toBe(1);for (const i of items) expect(Math.abs(i.middle - items[0].middle)).toBeLessThan(0.5);expect(new Set(items.map((i) => i.type)).size).toBe(1);diff --git a/apps/site/test/skill.spec.ts b/apps/site/test/skill.spec.tsindex b6002dc..0590855 100644--- a/apps/site/test/skill.spec.ts+++ b/apps/site/test/skill.spec.ts@@ -122,3 +122,21 @@ test.describe("without JavaScript", () => {await expect(page.getByRole("link", { name: "Open the page" })).toHaveCount(4);});});++test("the top bar's Skill link opens /skill", async ({ page }) => {+ await page.goto("/");+ await page.getByRole("banner").getByRole("link", { name: "Skill" }).click();+ await expect(page).toHaveURL(/\/skill$/);+ await expect(page.getByRole("heading", { level: 1 })).toHaveText("Make your own figure");+});++test("the top bar fits a 320px screen with its five items on one row", async ({ page }) => {+ await page.setViewportSize({ width: 320, height: 700 });+ await page.goto("/skill");+ expect(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)).toBe(0);+ const tops = await page.locator(".topbar nav > *").evaluateAll((els) => els.filter((el) => getComputedStyle(el).display !== "none").map((el) => Math.round(el.getBoundingClientRect().top)));+ expect(new Set(tops).size).toBe(1);+ const bar = (await page.locator(".topbar").boundingBox())!;+ const last = (await page.locator(".topbar nav > *").last().boundingBox())!;+ expect(last.x + last.width).toBeLessThanOrEqual(bar.x + bar.width);+});