Skip to content

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

Site: an Empty shelf, a Marks shelf of three the skill drew, and the figures shown as a start for your own

Lucas Marques9fe9ee377fce
diff --git a/apps/site/.vitest/json/output.json b/apps/site/.vitest/json/output.json
new file mode 100644
index 0000000..a327f5e
--- /dev/null
+++ b/apps/site/.vitest/json/output.json
@@ -0,0 +1 @@
+{"numTotalTestSuites":19,"numPassedTestSuites":19,"numFailedTestSuites":0,"numPendingTestSuites":0,"numTotalTests":74,"numPassedTests":74,"numFailedTests":0,"numPendingTests":0,"numTodoTests":0,"snapshot":{"added":0,"failure":false,"filesAdded":0,"filesRemoved":0,"filesRemovedList":[],"filesUnmatched":0,"filesUpdated":0,"matched":0,"total":0,"unchecked":0,"uncheckedKeysByFile":[],"unmatched":0,"updated":0,"didUpdate":false},"startTime":1791220148462,"success":true,"testResults":[{"assertionResults":[{"ancestorTitles":["the catalogue"],"fullName":"the catalogue shelves every drawn figure once, with the copy the docs use","status":"passed","title":"shelves every drawn figure once, with the copy the docs use","duration":1.890416000000016,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the catalogue"],"fullName":"the catalogue names each figure once, on nine shelves","status":"passed","title":"names each figure once, on nine shelves","duration":0.5664579999999546,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the catalogue"],"fullName":"the catalogue keeps the marks apart: made by the skill, counted outside the package's tally","status":"passed","title":"keeps the marks apart: made by the skill, counted outside the package's tally","duration":0.554916999999989,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the catalogue"],"fullName":"the catalogue counts in words, read from the shelves","status":"passed","title":"counts in words, read from the shelves","duration":0.39387499999998,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the catalogue"],"fullName":"the catalogue pastes each figure three ways, and the docs' Terrain is the same as before","status":"passed","title":"pastes each figure three ways, and the docs' Terrain is the same as before","duration":1.3489159999999742,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]}],"startTime":1791220148835,"endTime":1791220148839.3489,"status":"passed","message":"","name":"/Users/lucasmarques/estudos/hairline/apps/site/test/catalogue.test.ts"},{"assertionResults":[{"ancestorTitles":["the figures"],"fullName":"the figures are the package's, each with a function and a component","status":"passed","title":"are the package's, each with a function and a component","duration":2.189083000000039,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the figures"],"fullName":"the figures copy the package's intensity table exactly","status":"passed","title":"copy the package's intensity table exactly","duration":0.5799590000000308,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the options table"],"fullName":"the options table has the four keys of HairlineOptions, in that order","status":"passed","title":"has the four keys of HairlineOptions, in that order","duration":0.2573330000000169,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the options table"],"fullName":"the options table gives intensity's default as 0.5","status":"passed","title":"gives intensity's default as 0.5","duration":0.7080829999999878,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the install commands"],"fullName":"the install commands put npm first and install from the address the site is built for","status":"passed","title":"put npm first and install from the address the site is built for","duration":0.2346249999999941,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the quick start"],"fullName":"the quick start pastes React, Vanilla and CDN, each under a file name, and none of them sets an option the package dropped","status":"passed","title":"pastes React, Vanilla and CDN, each under a file name, and none of them sets an option the package dropped","duration":0.539874999999995,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the theme's CSS"],"fullName":"the theme's CSS sets all six theme properties","status":"passed","title":"sets all six theme properties","duration":0.29325000000000045,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the signatures"],"fullName":"the signatures list the component's four options with their types, read from the options table","status":"passed","title":"list the component's four options with their types, read from the options table","duration":0.08366700000004812,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the signatures"],"fullName":"the signatures give the function's handle its two methods","status":"passed","title":"give the function's handle its two methods","duration":0.5672080000000506,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the Install note's size"],"fullName":"the Install note's size is the gzip size of the vanilla entry, to a tenth of a kB","status":"passed","title":"is the gzip size of the vanilla entry, to a tenth of a kB","duration":11.997916999999973,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the docs' sections"],"fullName":"the docs' sections are ten, in three groups in order, with unique ids that work as fragments","status":"passed","title":"are ten, in three groups in order, with unique ids that work as fragments","duration":0.36341600000002927,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the docs' sections"],"fullName":"the docs' sections share their headings with /llms.txt","status":"passed","title":"share their headings with /llms.txt","duration":0.9133749999999736,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the intensity table"],"fullName":"the intensity table writes each number with its unit, as /llms.txt does","status":"passed","title":"writes each number with its unit, as /llms.txt does","duration":0.4749170000000049,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt says how to install the skill and links each example, with its follow-up, to the page it produced","status":"passed","title":"says how to install the skill and links each example, with its follow-up, to the page it produced","duration":0.22129200000000537,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt says, right after the examples drawn from a company's mark, that the marks are their owners'","status":"passed","title":"says, right after the examples drawn from a company's mark, that the marks are their owners'","duration":0.05249999999995225,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Riffle with its row of the intensity table","status":"passed","title":"names Riffle with its row of the intensity table","duration":0.13025000000004638,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Terrain with its row of the intensity table","status":"passed","title":"names Terrain with its row of the intensity table","duration":0.08387499999997772,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Exploded with its row of the intensity table","status":"passed","title":"names Exploded with its row of the intensity table","duration":0.07587499999999636,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Phosphor with its row of the intensity table","status":"passed","title":"names Phosphor with its row of the intensity table","duration":0.14216600000003154,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Slow with its row of the intensity table","status":"passed","title":"names Slow with its row of the intensity table","duration":0.14699999999999136,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Turntable with its row of the intensity table","status":"passed","title":"names Turntable with its row of the intensity table","duration":0.09845899999999119,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Keyboard with its row of the intensity table","status":"passed","title":"names Keyboard with its row of the intensity table","duration":0.10316700000004175,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Elevator with its row of the intensity table","status":"passed","title":"names Elevator with its row of the intensity table","duration":0.06362500000000182,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Phone with its row of the intensity table","status":"passed","title":"names Phone with its row of the intensity table","duration":0.07620800000000827,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Laptop with its row of the intensity table","status":"passed","title":"names Laptop with its row of the intensity table","duration":0.07820799999996098,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Terminal with its row of the intensity table","status":"passed","title":"names Terminal with its row of the intensity table","duration":0.05912499999999454,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Cabinet with its row of the intensity table","status":"passed","title":"names Cabinet with its row of the intensity table","duration":0.07879200000002129,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Branches with its row of the intensity table","status":"passed","title":"names Branches with its row of the intensity table","duration":0.07675000000000409,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Vault with its row of the intensity table","status":"passed","title":"names Vault with its row of the intensity table","duration":0.07537499999995134,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Lockers with its row of the intensity table","status":"passed","title":"names Lockers with its row of the intensity table","duration":0.08333300000003874,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Padlock with its row of the intensity table","status":"passed","title":"names Padlock with its row of the intensity table","duration":0.07337499999999864,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Patch with its row of the intensity table","status":"passed","title":"names Patch with its row of the intensity table","duration":0.05787499999996726,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Dish with its row of the intensity table","status":"passed","title":"names Dish with its row of the intensity table","duration":0.249416999999994,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Router with its row of the intensity table","status":"passed","title":"names Router with its row of the intensity table","duration":0.13299999999998136,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Loupe with its row of the intensity table","status":"passed","title":"names Loupe with its row of the intensity table","duration":0.06837500000000318,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Sieve with its row of the intensity table","status":"passed","title":"names Sieve with its row of the intensity table","duration":0.15008299999999508,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Rail with its row of the intensity table","status":"passed","title":"names Rail with its row of the intensity table","duration":0.1618750000000091,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Plug with its row of the intensity table","status":"passed","title":"names Plug with its row of the intensity table","duration":0.10137500000001864,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Query with its row of the intensity table","status":"passed","title":"names Query with its row of the intensity table","duration":0.08729199999999082,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Drawer with its row of the intensity table","status":"passed","title":"names Drawer with its row of the intensity table","duration":0.06804199999999128,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Basket with its row of the intensity table","status":"passed","title":"names Basket with its row of the intensity table","duration":0.06433299999997644,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt names Plot with its row of the intensity table","status":"passed","title":"names Plot with its row of the intensity table","duration":0.07637500000004138,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt documents the four options, every theme property and the registry item","status":"passed","title":"documents the four options, every theme property and the registry item","duration":0.1344169999999849,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt mentions no option the package dropped","status":"passed","title":"mentions no option the package dropped","duration":0.12062500000001819,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["/llms.txt"],"fullName":"/llms.txt has no hole in it","status":"passed","title":"has no hole in it","duration":0.20129199999996672,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["highlighting"],"fullName":"highlighting colours tokens with the --code- variables only, and leaves the block one tab stop","status":"passed","title":"colours tokens with the --code- variables only, and leaves the block one tab stop","duration":376.21475000000004,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["highlighting"],"fullName":"highlighting writes only variables globals.css defines","status":"passed","title":"writes only variables globals.css defines","duration":7.295458999999937,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]}],"startTime":1791220148928,"endTime":1791220149335.2954,"status":"passed","message":"","name":"/Users/lucasmarques/estudos/hairline/apps/site/test/docs.test.ts"},{"assertionResults":[{"ancestorTitles":["the sitemap's pages"],"fullName":"the sitemap's pages are every page in app/ but the card's own, which is a picture to photograph and not a page to read","status":"passed","title":"are every page in app/ but the card's own, which is a picture to photograph and not a page to read","duration":1.4257910000000038,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]}],"startTime":1791220148732,"endTime":1791220148733.4258,"status":"passed","message":"","name":"/Users/lucasmarques/estudos/hairline/apps/site/test/share.test.ts"},{"assertionResults":[{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples are the seven ideas, in page order","status":"passed","title":"are the seven ideas, in page order","duration":1.1078329999999994,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples are exactly the files in public/skill","status":"passed","title":"are exactly the files in public/skill","duration":0.3665420000000097,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-funnel.html is byte for byte the page the skill wrote","status":"passed","title":"hairline-funnel.html is byte for byte the page the skill wrote","duration":0.963957999999991,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-clearance.html is byte for byte the page the skill wrote","status":"passed","title":"hairline-clearance.html is byte for byte the page the skill wrote","duration":0.7012079999999798,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-sidings.html is byte for byte the page the skill wrote","status":"passed","title":"hairline-sidings.html is byte for byte the page the skill wrote","duration":0.3811670000000049,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-storm.html is byte for byte the page the skill wrote","status":"passed","title":"hairline-storm.html is byte for byte the page the skill wrote","duration":0.43070900000000734,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-vercel.html is byte for byte the page the skill wrote","status":"passed","title":"hairline-vercel.html is byte for byte the page the skill wrote","duration":0.20904100000001336,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-mastra.html is byte for byte the page the skill wrote","status":"passed","title":"hairline-mastra.html is byte for byte the page the skill wrote","duration":0.12362500000000409,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-notion.html is byte for byte the page the skill wrote","status":"passed","title":"hairline-notion.html is byte for byte the page the skill wrote","duration":0.5347920000000101,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-funnel.html passes the skill's validator untouched","status":"passed","title":"hairline-funnel.html passes the skill's validator untouched","duration":94.14766700000001,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-clearance.html passes the skill's validator untouched","status":"passed","title":"hairline-clearance.html passes the skill's validator untouched","duration":79.516208,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-sidings.html passes the skill's validator untouched","status":"passed","title":"hairline-sidings.html passes the skill's validator untouched","duration":80.09700000000004,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-storm.html passes the skill's validator untouched","status":"passed","title":"hairline-storm.html passes the skill's validator untouched","duration":83.34270900000001,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-vercel.html passes the skill's validator untouched","status":"passed","title":"hairline-vercel.html passes the skill's validator untouched","duration":76.30004199999996,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-mastra.html passes the skill's validator untouched","status":"passed","title":"hairline-mastra.html passes the skill's validator untouched","duration":79.14433299999996,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples hairline-notion.html passes the skill's validator untouched","status":"passed","title":"hairline-notion.html passes the skill's validator untouched","duration":74.83183300000007,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples each carry the name their file is called by, a meaning, the prompt and the link","status":"passed","title":"each carry the name their file is called by, a meaning, the prompt and the link","duration":1.343584000000078,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples carry a follow-up only where the page shown came out of one","status":"passed","title":"carry a follow-up only where the page shown came out of one","duration":0.18033300000001873,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples read the meaning out of the page, escapes undone","status":"passed","title":"read the meaning out of the page, escapes undone","duration":0.06804199999999128,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's examples"],"fullName":"the skill's examples refuse a page with no figure in it, naming the file","status":"passed","title":"refuse a page with no figure in it, naming the file","duration":0.37220800000000054,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]},{"ancestorTitles":["the skill's commands"],"fullName":"the skill's commands are the ones the skill is installed and called by","status":"passed","title":"are the ones the skill is installed and called by","duration":0.21491600000001654,"failureMessages":[],"meta":{},"tags":[],"benchmarks":[]}],"startTime":1791220148734,"endTime":1791220149309.3723,"status":"passed","message":"","name":"/Users/lucasmarques/estudos/hairline/apps/site/test/skill.test.ts"}]}
\ No newline at end of file
diff --git a/apps/site/app/docs/page.tsx b/apps/site/app/docs/page.tsx
index dc84f96..fde6e63 100644
--- a/apps/site/app/docs/page.tsx
+++ b/apps/site/app/docs/page.tsx
@@ -7,7 +7,7 @@ import { COUNT, LINKS } from "@/lib/figures";
import { highlight } from "@/lib/highlight";
import { share } from "@/lib/share";
import { tiny } from "@/lib/size";
-import { CDN, CSS, QUICKSTART, REACT, REACT_SIGNATURE, VANILLA, VANILLA_SIGNATURE, install } from "@/lib/snippets";
+import { CDN, CSS, EMPTY, QUICKSTART, REACT, REACT_SIGNATURE, VANILLA, VANILLA_SIGNATURE, install } from "@/lib/snippets";
import { cap } from "@/lib/words";
import { Api, GettingStarted, Reference } from "./sections";
@@ -32,8 +32,9 @@ const RAIL: RailGroup[] = (Object.keys(MARK) as Group[]).map((group) => ({ title
* hydration on every deploy, as on the home.
*/
export default async function Docs() {
- const [quickstart, reactSignature, react, vanillaSignature, vanilla, cdn, css] = await Promise.all([
+ const [quickstart, empty, reactSignature, react, vanillaSignature, vanilla, cdn, css] = await Promise.all([
Promise.all(QUICKSTART.map(async (q) => ({ label: q.label, file: q.file, html: await highlight(q.code, q.lang) }))),
+ highlight(EMPTY, "tsx"),
highlight(REACT_SIGNATURE, "tsx"),
highlight(REACT, "tsx"),
highlight(VANILLA_SIGNATURE, "ts"),
@@ -53,7 +54,7 @@ export default async function Docs() {
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.
</p>
</header>
- <GettingStarted commands={install(SITE)} size={tiny()} quickstart={quickstart} />
+ <GettingStarted commands={install(SITE)} size={tiny()} quickstart={quickstart} empty={empty} />
<Api code={{ reactSignature, react, vanillaSignature, vanilla, cdn }} />
<Reference css={css} />
<p className="col-end">
diff --git a/apps/site/app/docs/sections.tsx b/apps/site/app/docs/sections.tsx
index fbf5cb6..24f1712 100644
--- a/apps/site/app/docs/sections.tsx
+++ b/apps/site/app/docs/sections.tsx
@@ -1,14 +1,14 @@
import type { ReactNode } from "react";
-import { Branches, Cabinet, Dish, Elevator, Exploded, Keyboard, Laptop, Lockers, Padlock, Patch, Phone, Phosphor, Riffle, Router, Slow, Terminal, Terrain, Turntable, Vault } from "@lucasmarkes/hairline/react";
+import { Basket, Branches, Cabinet, Dish, Drawer, Elevator, Exploded, Keyboard, Laptop, Lockers, Loupe, Padlock, Patch, Phone, Phosphor, Plot, Plug, Query, Rail, Riffle, Router, Sieve, Slow, Terminal, Terrain, Turntable, Vault } from "@lucasmarkes/hairline/react";
import { Anchor } from "@/components/anchor";
import { CodeBlock } from "@/components/code-block";
import { Install } from "@/components/install";
import { Tabs, type Tab } from "@/components/tabs";
import { SECTIONS } from "@/lib/docs";
import { COUNT, FIGURES, INTENSITY, OPTIONS, THEME, measure } from "@/lib/figures";
-import { PACKAGE } from "@/lib/snippets";
+import { NO_RESULTS, PACKAGE } from "@/lib/snippets";
-const SMALL = { riffle: Riffle, terrain: Terrain, exploded: Exploded, phosphor: Phosphor, slow: Slow, turntable: Turntable, keyboard: Keyboard, elevator: Elevator, phone: Phone, laptop: Laptop, terminal: Terminal, cabinet: Cabinet, branches: Branches, vault: Vault, lockers: Lockers, padlock: Padlock, patch: Patch, dish: Dish, router: Router };
+const SMALL = { riffle: Riffle, terrain: Terrain, exploded: Exploded, phosphor: Phosphor, slow: Slow, turntable: Turntable, keyboard: Keyboard, elevator: Elevator, phone: Phone, laptop: Laptop, terminal: Terminal, cabinet: Cabinet, branches: Branches, vault: Vault, lockers: Lockers, padlock: Padlock, patch: Patch, dish: Dish, router: Router, loupe: Loupe, sieve: Sieve, rail: Rail, plug: Plug, query: Query, drawer: Drawer, basket: Basket, plot: Plot };
/** A section takes its title from SECTIONS, the list the rail reads, so the two always agree. Its link copies from beside its title. */
function Section({ id, children }: { id: string; children: ReactNode }) {
@@ -26,7 +26,7 @@ function Section({ id, children }: { id: string; children: ReactNode }) {
const C = ({ children }: { children: ReactNode }) => <code className="doc-code">{children}</code>;
-export function GettingStarted({ commands, size, quickstart }: { commands: { label: string; code: string }[]; size: string; quickstart: Tab[] }) {
+export function GettingStarted({ commands, size, quickstart, empty }: { commands: { label: string; code: string }[]; size: string; quickstart: Tab[]; empty: string }) {
return (
<>
<Section id="install">
@@ -57,6 +57,15 @@ export function GettingStarted({ commands, size, quickstart }: { commands: { lab
</table>
</div>
</Section>
+ <Section id="empty-states">
+ <p className="doc-p">A figure works as an empty state at 160 to 240px, above a heading and one action. Its rest pose is the picture; the pointer is a bonus.</p>
+ <div className="empty-demo" data-empty>
+ <Sieve style={{ width: 200 }} label={NO_RESULTS.label} />
+ <h3 className="empty-demo-title">{NO_RESULTS.heading}</h3>
+ <button type="button" className="btn press">{NO_RESULTS.action}</button>
+ </div>
+ <CodeBlock title="no-results.tsx" html={empty} />
+ </Section>
</>
);
}
diff --git a/apps/site/app/figures/page.tsx b/apps/site/app/figures/page.tsx
index 14eb6bb..ab13785 100644
--- a/apps/site/app/figures/page.tsx
+++ b/apps/site/app/figures/page.tsx
@@ -2,7 +2,7 @@ import type { Metadata } from "next";
import type { CSSProperties } from "react";
import { Catalogue } from "@/components/catalogue";
import { Footer, Topbar } from "@/components/chrome";
-import { tally } from "@/lib/catalogue";
+import { SHELVES, spell, tally } from "@/lib/catalogue";
import { FIGURES, LINKS, type FigureId } from "@/lib/figures";
import { highlight } from "@/lib/highlight";
import { share } from "@/lib/share";
@@ -11,7 +11,14 @@ import { paste } from "@/lib/snippets";
/** A block's place in the header's entrance. */
const at = (i: number) => ({ "--i": i }) as CSSProperties;
-const LEDE = `${tally()}, grouped by what they draw. Each answers the pointer and takes the same four options. Pick one to see it large and copy its code.`;
+/** How many the skill drew from a mark: the Marks shelf's, counted apart from the package's as tally() does. */
+const MARKS = spell(SHELVES.find((s) => s.id === "marks")!.figures.length);
+
+/** The lede in three parts, so the page can link the skill's name and the metadata can keep it as text. */
+const LEAD = `${tally()}, grouped by what they draw. They ship in the package, but they are here to show what a figure can be: the`;
+const SKILL = "/hairline-create";
+const TAIL = `skill draws your own. Pick one to see it large and copy its code. A last shelf holds ${MARKS} the skill drew from a company's mark.`;
+const LEDE = `${LEAD} ${SKILL} ${TAIL}`;
export const metadata: Metadata = share("/figures", "Figures", LEDE);
@@ -34,7 +41,7 @@ export default async function Figures() {
header={
<header className="hero-rise">
<h1 className="col-h1" style={at(0)}>Every figure, by what it <em>draws</em>.</h1>
- <p className="col-lede" style={at(1)}>{LEDE}</p>
+ <p className="col-lede" style={at(1)}>{LEAD} <a className="doc-more" href="/skill">{SKILL}</a> {TAIL}</p>
</header>
}
end={
diff --git a/apps/site/app/globals.css b/apps/site/app/globals.css
index c68f962..d9a6f6c 100644
--- a/apps/site/app/globals.css
+++ b/apps/site/app/globals.css
@@ -134,6 +134,10 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }
.figure-text { margin-top: 4px; font-size: 13px; line-height: 1.55; color: var(--color-muted); text-wrap: pretty; }
.figure-text b { font-weight: 500; color: var(--color-ink); }
.figure-row .tile { box-shadow: inset 0 0 0 1px var(--color-stone); }
+/* the empty state drawn live: the figure at 200px, a heading and one action under it, on a card */
+.empty-demo { display: grid; justify-items: center; gap: 12px; padding: 32px 16px; border-radius: 12px; background: #fff; box-shadow: var(--card); text-align: center; }
+.empty-demo > [data-hairline] { max-width: 100%; }
+.empty-demo-title { font-size: 14px; font-weight: 500; line-height: 1.4; text-wrap: balance; }
.props, .intensity { width: 100%; border-collapse: collapse; font-size: 13px; }
:is(.props, .intensity) th { padding: 8px 14px 8px 0; text-align: left; font-size: 13px; font-weight: 500; color: var(--color-muted); }
:is(.props, .intensity) td { padding: 12px 14px 12px 0; vertical-align: top; border-top: 1px solid var(--color-line); line-height: 1.5; }
@@ -158,7 +162,7 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }
.col header > .col-h1:first-child { margin-top: 0; }
.col-lede { margin-top: 12px; max-width: 60ch; color: var(--color-muted); text-wrap: pretty; }
.col-end { margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--color-line); font-size: 13px; color: var(--color-muted); text-wrap: pretty; }
-.col-end .doc-more { font-size: inherit; }
+.col-end .doc-more, .col-lede .doc-more { font-size: inherit; }
/* A section opens 56px under the last, its title beside a link that shows when the pointer is on the title. */
.doc-section { display: grid; gap: 14px; padding-top: 56px; scroll-margin-top: calc(var(--topbar) + 44px); }
@@ -410,6 +414,9 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }
column less its sides up to 640px, a 5:4 stage, and the 148px of controls and lines under it, which wrap onto more
lines in a column narrower than 360px. */
.example-frame { display: block; width: 100%; height: calc(min(100cqw - 32px, 640px) * 0.8 + 148px + 48px + max(0px, 392px - 100cqw) * 0.75); border: 0; }
+/* a figure the skill made, on its tile: only the page's stage, in the figures' own box, so a page that does not load
+ leaves the tile its shape */
+.made-frame { display: block; width: 100%; aspect-ratio: 5 / 4; border: 0; background: transparent; }
/* /figures. The shelves are a filter: from 1100px a list by the column's left edge, sticky inside the page's grid so it
stops where the column ends and never runs over the footer; below that the docs' strip under the top bar. The list's
@@ -500,6 +507,13 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }
.detail-reads b { font: 400 11.5px/1 var(--font-mono); letter-spacing: 0.02em; color: var(--color-ink); }
.detail-ask { display: grid; gap: 6px; padding: 14px 16px; border-radius: 12px; background: var(--color-stone); font-size: 13px; color: var(--color-muted); text-wrap: pretty; }
.detail-ask .doc-more { font-size: 13px; }
+/* a made figure's drawer: its page as /skill shows it, a container so the frame's height is reserved for the drawer's
+ width, then the prompt that drew it */
+.detail-page { container-type: inline-size; margin-inline: -16px; }
+.detail-made { display: grid; gap: 10px; }
+.detail-made .pill { font-size: 12.5px; }
+.detail-made .doc-p { font-size: 13px; color: var(--color-muted); }
+.figs-notice { font-size: 12.5px; color: var(--color-muted); }
.drawer .code { background: #fff; box-shadow: var(--card); }
.drawer .code-bar { border-bottom-color: var(--color-line); }
.drawer .code-body { font-size: 12.5px; }
diff --git a/apps/site/app/skill/page.tsx b/apps/site/app/skill/page.tsx
index fd99051..b27942e 100644
--- a/apps/site/app/skill/page.tsx
+++ b/apps/site/app/skill/page.tsx
@@ -5,6 +5,7 @@ import { Footer, Topbar } from "@/components/chrome";
import { Command } from "@/components/command";
import { ExampleFrame } from "@/components/example-frame";
import { Rail } from "@/components/rail";
+import { NOTICE } from "@/lib/catalogue";
import { COUNT, LINKS } from "@/lib/figures";
import { share } from "@/lib/share";
import { COMMAND, FOLDER, INSTALL, STEPS, SUMMARY, USE, examples } from "@/lib/skill";
@@ -89,7 +90,7 @@ export default function Skill() {
</Section>
<Section id="examples" title="What it draws">
- <p className="doc-p">Four ideas, four files. Each one opens from disk with no dependencies. Move the pointer over one.</p>
+ <p className="doc-p">Seven ideas, seven files. The last three start from a company&rsquo;s mark. Each one opens from disk with no dependencies. Move the pointer over one.</p>
{shown.map((e) => (
<article key={e.file} className="card ex" data-example={e.name} aria-label={e.prompt}>
<div className="ex-h">
@@ -110,6 +111,7 @@ export default function Skill() {
</div>
</article>
))}
+ <p className="doc-p">{NOTICE}</p>
</Section>
<p className="col-end">
diff --git a/apps/site/components/catalogue.tsx b/apps/site/components/catalogue.tsx
index f7afa80..ecd711a 100644
--- a/apps/site/components/catalogue.tsx
+++ b/apps/site/components/catalogue.tsx
@@ -1,12 +1,15 @@
"use client";
import { useCallback, useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode } from "react";
-import { Branches, Cabinet, Dish, Elevator, Exploded, Keyboard, Laptop, Lockers, Padlock, Patch, Phone, Phosphor, Riffle, Router, Slow, Terminal, Terrain, Turntable, Vault } from "@lucasmarkes/hairline/react";
-import { ENTRIES, SHELVES, type Entry, type Shelf, type ShelfId } from "@/lib/catalogue";
+import { Basket, Branches, Cabinet, Dish, Drawer, Elevator, Exploded, Keyboard, Laptop, Lockers, Loupe, Padlock, Patch, Phone, Phosphor, Plot, Plug, Query, Rail, Riffle, Router, Sieve, Slow, Terminal, Terrain, Turntable, Vault } from "@lucasmarkes/hairline/react";
+import { ENTRIES, NOTICE, SHELVES, type Entry, type Shelf, type ShelfId } from "@/lib/catalogue";
import { LINKS, type FigureId } from "@/lib/figures";
+import { Command } from "./command";
+import { ExampleFrame } from "./example-frame";
+import { MadeFrame } from "./made-frame";
import { Tabs, type Tab } from "./tabs";
-const COMPONENTS: Record<FigureId, typeof Riffle> = { riffle: Riffle, terrain: Terrain, exploded: Exploded, phosphor: Phosphor, slow: Slow, turntable: Turntable, keyboard: Keyboard, elevator: Elevator, phone: Phone, laptop: Laptop, terminal: Terminal, cabinet: Cabinet, branches: Branches, vault: Vault, lockers: Lockers, padlock: Padlock, patch: Patch, dish: Dish, router: Router };
+const COMPONENTS: Record<FigureId, typeof Riffle> = { riffle: Riffle, terrain: Terrain, exploded: Exploded, phosphor: Phosphor, slow: Slow, turntable: Turntable, keyboard: Keyboard, elevator: Elevator, phone: Phone, laptop: Laptop, terminal: Terminal, cabinet: Cabinet, branches: Branches, vault: Vault, lockers: Lockers, padlock: Padlock, patch: Patch, dish: Dish, router: Router, loupe: Loupe, sieve: Sieve, rail: Rail, plug: Plug, query: Query, drawer: Drawer, basket: Basket, plot: Plot };
type Filter = "all" | ShelfId;
@@ -71,6 +74,18 @@ const ICONS: Record<Filter, ReactNode> = {
<path d="m5.6 10 4.8-4.1" />
</>,
),
+ empty: svg(
+ <>
+ <rect x="2.25" y="2.25" width="11.5" height="11.5" rx="3" fill="currentColor" fillOpacity=".2" stroke="none" />
+ <rect x="2.25" y="2.25" width="11.5" height="11.5" rx="3" strokeDasharray="2 2.4" />
+ </>,
+ ),
+ marks: svg(
+ <>
+ <path d="M8 2.5 13.5 12h-11L8 2.5Z" fill="currentColor" fillOpacity=".2" />
+ <circle cx="12.25" cy="4.25" r="1.5" />
+ </>,
+ ),
};
/** The rows of the filter: All, then each shelf, each in its colour with how many figures it holds. */
@@ -109,7 +124,8 @@ function Ghost() {
*
* A tile shows its figure live. Picking one opens a drawer with the figure large, an intensity slider, what the figure
* reads, and its code three ways, highlighted on the server. A planned figure has its outline instead, and a link to
- * ask for it. The header and the closing note come from the server, around the shelves.
+ * ask for it. A figure the skill made shows its page's stage, and its drawer the page with its own controls and the
+ * prompt that drew it. The header and the closing note come from the server, around the shelves.
*/
export function Catalogue({ code, header, end }: { code: Record<FigureId, Tab[]>; header: ReactNode; end: ReactNode }) {
const [filter, setFilterState] = useState<Filter>("all");
@@ -285,8 +301,7 @@ function ShelfSection({ shelf, picked, onPick }: { shelf: Shelf; picked?: string
<div className="doc-head figs-head">
<h2 id={`shelf-${shelf.id}-h`} className="doc-h2">{shelf.title}</h2>
<span className="figs-count">
- {drawn} of {shelf.figures.length}
- <span className="sr-only"> drawn</span>
+ {shelf.id === "marks" ? "made with the skill" : <>{drawn} of {shelf.figures.length}<span className="sr-only"> drawn</span></>}
</span>
</div>
<div className="fig-grid">
@@ -294,22 +309,25 @@ function ShelfSection({ shelf, picked, onPick }: { shelf: Shelf; picked?: string
<Tile key={f.id} entry={f} picked={picked === f.id} onPick={onPick} />
))}
</div>
+ {shelf.id === "marks" ? <p className="doc-p figs-notice">{NOTICE}</p> : null}
</section>
);
}
/**
* 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.
+ * 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.
*/
function Tile({ entry, picked, onPick }: { entry: Entry; picked: boolean; onPick: (f: Entry, from: HTMLElement | null, keyboard: boolean) => void }) {
const button = useRef<HTMLButtonElement>(null);
const Figure = entry.drawn ? COMPONENTS[entry.id] : null;
+ const made = entry.drawn ? undefined : entry.made;
return (
- <div className="fig-tile" data-planned={entry.drawn ? undefined : ""} data-picked={picked ? "" : undefined} onClick={(event) => onPick(entry, button.current, event.detail === 0)}>
- <div className="fig-stage">{Figure ? <Figure /> : <Ghost />}</div>
+ <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-foot">
- <button ref={button} type="button" className="fig-name" aria-label={entry.drawn ? undefined : `${entry.name}, planned`} aria-expanded={picked} aria-controls="figure-drawer" onClick={(event) => {
+ <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();
onPick(entry, button.current, event.detail === 0);
}}>
@@ -328,6 +346,7 @@ function Detail({
}) {
const shelf = SHELF_OF.get(entry.id)!;
const Figure = entry.drawn ? COMPONENTS[entry.id] : null;
+ const made = entry.drawn ? undefined : entry.made;
return (
<div className="detail">
<div className="detail-h">
@@ -335,7 +354,7 @@ function Detail({
<h2 id="figure-drawer-name" className="detail-name">{entry.name}</h2>
<p className="detail-meta">
<span className="detail-shelf" style={tint(shelf.color)}>{ICONS[shelf.id]}{shelf.title}</span>
- {entry.drawn ? null : <span className="detail-tag">planned</span>}
+ {entry.drawn || made ? null : <span className="detail-tag">planned</span>}
</p>
</div>
<button ref={closeRef} type="button" className="detail-close" aria-label="Close" onClick={(event) => onClose(event.detail === 0)}>
@@ -344,11 +363,22 @@ function Detail({
</svg>
</button>
</div>
- <div className="fig-stage detail-stage">{Figure ? <Figure intensity={intensity} onRead={setReads} /> : <Ghost />}</div>
+ {/* a made page brings its own plate and controls, so it sits outside the stage's box */}
+ {made ? (
+ <div className="detail-page"><ExampleFrame src={`/skill/${made.file}?theme=light`} title={entry.summary} /></div>
+ ) : (
+ <div className="fig-stage detail-stage">{Figure ? <Figure intensity={intensity} onRead={setReads} /> : <Ghost />}</div>
+ )}
<p className="detail-sum">
{entry.summary} <b>Higher intensity:</b> {entry.stronger}
</p>
- {Figure ? (
+ {made ? (
+ <div className="detail-made">
+ <Command code={made.prompt} kind="prompt" label={`Copy prompt: ${entry.name}`} />
+ <p className="doc-p">Made with <a className="doc-more" href="/skill">hairline-create</a>. It is not in the package: the page is one file, and the prompt above draws it again.</p>
+ <p className="doc-p figs-notice">{NOTICE}</p>
+ </div>
+ ) : Figure ? (
<>
<label className="slider">
<span>intensity</span>
diff --git a/apps/site/components/example-frame.tsx b/apps/site/components/example-frame.tsx
index 0eb47e9..81cb5fa 100644
--- a/apps/site/components/example-frame.tsx
+++ b/apps/site/components/example-frame.tsx
@@ -9,6 +9,19 @@ const PAD = 48;
const QUIET = "hl-site-quiet";
const HIDDEN = "#name, #read, #rules { display: none !important; }";
+/**
+ * Hands an Escape pressed inside a frame's document on to the frame element,
+ * where it bubbles to the site's document: a key pressed in the frame never
+ * reaches it otherwise, so the drawer would not close. Returns its remover.
+ */
+export function forwardEscape(el: HTMLIFrameElement, doc: Document): () => void {
+ const onKey = (event: KeyboardEvent) => {
+ if (event.key === "Escape") el.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }));
+ };
+ doc.addEventListener("keydown", onKey);
+ return () => doc.removeEventListener("keydown", onKey);
+}
+
/**
* A page the skill wrote, in a frame as tall as that page: the frame never
* scrolls inside. Its height is reserved in CSS before it loads, then fitted
@@ -29,16 +42,20 @@ export function ExampleFrame({ src, title }: { src: string; title: string }) {
const el = frame.current;
if (!el) return;
let watch: ResizeObserver | undefined;
+ let unkey: (() => void) | undefined;
const fit = () => {
const view = el.contentWindow as (Window & typeof globalThis) | null;
const doc = el.contentDocument;
const main = doc?.querySelector("main");
if (!view || !doc || !main) return;
+ // once a document: the style and the Escape go in together
if (!doc.getElementById(QUIET)) {
const style = doc.createElement("style");
style.id = QUIET;
style.textContent = HIDDEN;
doc.head.append(style);
+ unkey?.();
+ unkey = forwardEscape(el, doc);
}
const size = () => { el.style.height = `${Math.ceil(main.getBoundingClientRect().height) + PAD}px`; };
size();
@@ -52,6 +69,7 @@ export function ExampleFrame({ src, title }: { src: string; title: string }) {
return () => {
el.removeEventListener("load", fit);
watch?.disconnect();
+ unkey?.();
};
}, []);
diff --git a/apps/site/components/made-frame.tsx b/apps/site/components/made-frame.tsx
new file mode 100644
index 0000000..777e4e3
--- /dev/null
+++ b/apps/site/components/made-frame.tsx
@@ -0,0 +1,43 @@
+"use client";
+
+import { useEffect, useRef } from "react";
+import { forwardEscape } from "./example-frame";
+
+const QUIET = "hl-site-stage";
+/** Everything of the skill's page but its stage, hidden from the site's side: the page itself stays as the skill wrote it. */
+const ONLY_STAGE = "#name, #read, #rules, #means, .controls { display: none !important; } html, body { background: transparent !important; } body { padding: 0 !important; min-height: 0 !important; } main { max-width: none !important; } .plate { border: 0 !important; border-radius: 0 !important; }";
+
+/**
+ * A figure the skill made, as a tile shows it: the stage of its page and
+ * nothing else. The frame has the figures' own 5:4 box from CSS, so a page
+ * that is slow, missing or broken leaves the tile its shape. The page's ground
+ * goes clear, so the tile's ring, drawn under the frame, still shows.
+ */
+export function MadeFrame({ src, title }: { src: string; title: string }) {
+ const frame = useRef<HTMLIFrameElement>(null);
+
+ useEffect(() => {
+ const el = frame.current;
+ if (!el) return;
+ let unkey: (() => void) | undefined;
+ // once a document: the style and the Escape go in together
+ const quiet = () => {
+ const doc = el.contentDocument;
+ if (!doc?.head || doc.getElementById(QUIET)) return;
+ const style = doc.createElement("style");
+ style.id = QUIET;
+ style.textContent = ONLY_STAGE;
+ doc.head.append(style);
+ unkey?.();
+ unkey = forwardEscape(el, doc);
+ };
+ quiet();
+ el.addEventListener("load", quiet);
+ return () => {
+ el.removeEventListener("load", quiet);
+ unkey?.();
+ };
+ }, []);
+
+ return <iframe ref={frame} className="made-frame" src={src} title={title} loading="lazy" />;
+}
diff --git a/apps/site/lib/catalogue.ts b/apps/site/lib/catalogue.ts
index 05289f5..0da2c50 100644
--- a/apps/site/lib/catalogue.ts
+++ b/apps/site/lib/catalogue.ts
@@ -7,12 +7,18 @@ export { spell };
* /figures: every figure on its shelf, by what it draws. A drawn figure takes
* its copy from FIGURES, the list the docs and /llms.txt read, so the three
* never disagree. A planned one carries its own: it is a promise of a figure,
- * with no component behind it yet.
+ * with no component behind it yet. A made one (`made(...)`) carries its own
+ * too: a page the skill drew from a company's mark, kept in public/skill and
+ * shown in a frame, with the line that asked for it and no component behind it.
*/
-export type ShelfId = "interfaces" | "data" | "machines" | "devices" | "coding" | "security" | "connectivity";
+export type ShelfId = "interfaces" | "data" | "machines" | "devices" | "coding" | "security" | "connectivity" | "empty" | "marks";
-export type Entry = { id: string; name: string; summary: string; stronger: string } & ({ drawn: true; id: FigureId } | { drawn: false });
+export type Made = { file: string; prompt: string };
+
+export type Entry = { id: string; name: string; summary: string; stronger: string } & ({ drawn: true; id: FigureId } | { drawn: false; made?: Made });
+
+export const NOTICE = "Brands I like, drawn as a tribute. The marks belong to their owners; Hairline is not affiliated with them.";
export type Shelf = { id: ShelfId; title: string; color: string; figures: Entry[] };
@@ -22,6 +28,10 @@ const drawn = (id: FigureId): Entry => {
};
const planned = (id: string, name: string, summary: string, stronger: string): Entry => ({ id, name, summary, stronger, drawn: false });
+const COMMAND = "/hairline-create";
+/** A figure the skill drew: its page in public/skill and the line that asked for it. test/catalogue.test.ts holds both to lib/skill.ts, which a client module cannot import. */
+const made = (id: string, name: string, summary: string, stronger: string, idea: string): Entry => ({ id, name, summary, stronger, drawn: false, made: { file: `hairline-${id}.html`, prompt: `${COMMAND} ${idea}` } });
+
export const SHELVES: Shelf[] = [
{
id: "interfaces", title: "Interfaces", color: "#3b82f6", figures: [
@@ -70,11 +80,31 @@ export const SHELVES: Shelf[] = [
drawn("router"),
],
},
+ {
+ id: "empty", title: "Empty", color: "#64748b", figures: [
+ drawn("loupe"),
+ drawn("sieve"),
+ drawn("rail"),
+ drawn("plug"),
+ drawn("query"),
+ drawn("drawer"),
+ drawn("basket"),
+ drawn("plot"),
+ ],
+ },
+ {
+ id: "marks", title: "Marks", color: "#f97316", figures: [
+ made("vercel", "Vercel", "\"No deployments yet.\" The triangle hovers over its pad. The nearer the pointer, the lower it settles, until it seats.", "It answers from further away.", "an empty state for \"No deployments yet\", from Vercel's mark: the triangle as an upright slab hovering over a pad with its slot marked dim; the nearer the pointer, the lower it settles, until it seats. Name it vercel."),
+ made("mastra", "Mastra", "\"No agents connected.\" The spheres of the mark, joined, and one apart. The pointer draws it in; a neck forms, stretches and lets go.", "The neck holds further before it lets go.", "an empty state for \"No agents connected\", from Mastra's mark: the spheres of the M joined by necks on a board, the lone sphere standing apart; the pointer draws it toward the others, a neck forms, stretches and lets go. Name it mastra."),
+ made("notion", "Notion", "\"No pages inside.\" The cube as a box. The pointer's height opens its lid, and the box is empty.", "The lid opens wider.", "an empty state for \"No pages inside\", from Notion's mark: the cube as a box with a lid, the N a relief on its front face; the pointer's height opens the lid on a spring, and the box is empty. Name it notion."),
+ ],
+ },
];
export const ENTRIES: Entry[] = SHELVES.flatMap((s) => s.figures);
-/** "Seven shelves, nineteen figures" */
+/** "Eight shelves, twenty-seven figures": the package's. The marks are the skill's, and are counted apart. */
export function tally(): string {
- return `${cap(spell(SHELVES.length))} shelves, ${spell(ENTRIES.length)} figures`;
+ const own = SHELVES.filter((s) => s.id !== "marks");
+ return `${cap(spell(own.length))} shelves, ${spell(own.flatMap((s) => s.figures).length)} figures`;
}
diff --git a/apps/site/lib/docs.ts b/apps/site/lib/docs.ts
index 6823e7b..1c7422b 100644
--- a/apps/site/lib/docs.ts
+++ b/apps/site/lib/docs.ts
@@ -11,6 +11,7 @@ export const SECTIONS: Section[] = [
{ id: "install", group: "Getting started", title: "Install" },
{ id: "quick-start", group: "Getting started", title: "Quick start" },
{ id: "options", group: "Getting started", title: "Options" },
+ { id: "empty-states", group: "Getting started", title: "Empty states" },
{ id: "react", group: "API", title: "React" },
{ id: "vanilla", group: "API", title: "Vanilla" },
{ id: "cdn", group: "API", title: "CDN" },
diff --git a/apps/site/lib/figures.ts b/apps/site/lib/figures.ts
index e2e2be3..2b7f73e 100644
--- a/apps/site/lib/figures.ts
+++ b/apps/site/lib/figures.ts
@@ -8,7 +8,7 @@
import { spell } from "./words";
-export type FigureId = "riffle" | "terrain" | "exploded" | "phosphor" | "slow" | "turntable" | "keyboard" | "elevator" | "phone" | "laptop" | "terminal" | "cabinet" | "branches" | "vault" | "lockers" | "padlock" | "patch" | "dish" | "router";
+export type FigureId = "riffle" | "terrain" | "exploded" | "phosphor" | "slow" | "turntable" | "keyboard" | "elevator" | "phone" | "laptop" | "terminal" | "cabinet" | "branches" | "vault" | "lockers" | "padlock" | "patch" | "dish" | "router" | "loupe" | "sieve" | "rail" | "plug" | "query" | "drawer" | "basket" | "plot";
export type FigureDoc = {
id: FigureId;
@@ -155,9 +155,65 @@ export const FIGURES: FigureDoc[] = [
stronger: "The lean spreads further.",
parameter: { name: "spread", unit: "antennas" },
},
+ {
+ id: "loupe",
+ name: "Loupe",
+ summary: "A stand loupe on a blank ruled sheet. The pointer drags it across; the rules pass enlarged under the glass, with nothing between them.",
+ stronger: "The glass magnifies more.",
+ parameter: { name: "magnification", unit: "×" },
+ },
+ {
+ id: "sieve",
+ name: "Sieve",
+ summary: "Three test sieves stacked over a pan. The pointer's height picks one; it rises clear of the stack, and every mesh is bare.",
+ stronger: "The gap opens further.",
+ parameter: { name: "gap", unit: "viewBox units" },
+ },
+ {
+ id: "rail",
+ name: "Rail",
+ summary: "A garment rail with seven bare hangers. The pointer brushes them; each rocks away, the nearest most, and settles.",
+ stronger: "The brush reaches more hangers.",
+ parameter: { name: "radius", unit: "hangers" },
+ },
+ {
+ id: "plug",
+ name: "Plug",
+ summary: "A wall socket, and a plug lying on the floor at the end of its cord. The pointer draws the plug up toward the socket; it stops short, and falls back.",
+ stronger: "The plug comes closer to the socket.",
+ parameter: { name: "pull", unit: "of the way" },
+ },
+ {
+ id: "query",
+ name: "Query",
+ summary: "A question mark built as a bent bar over a loose ball. The hook turns toward the pointer, and the ball rolls after it.",
+ stronger: "The hook turns further.",
+ parameter: { name: "turn", unit: "degrees" },
+ },
+ {
+ id: "drawer",
+ name: "Drawer",
+ summary: "A cabinet of three drawers. The pointer's height picks one; it slides out and shows two dividers with nothing between them.",
+ stronger: "The drawer opens further.",
+ parameter: { name: "pull", unit: "viewBox units" },
+ },
+ {
+ id: "basket",
+ name: "Basket",
+ summary: "A wire basket under a bail handle. It tilts toward the pointer and shows its bare floor; the handle swings after it.",
+ stronger: "The basket tilts further.",
+ parameter: { name: "tilt", unit: "degrees" },
+ },
+ {
+ id: "plot",
+ name: "Plot",
+ summary: "A bar chart with seven flat tabs where the bars would stand. The pointer brushes them; each lifts a little and drops back to zero.",
+ stronger: "The tabs lift higher.",
+ parameter: { name: "lift", unit: "viewBox units" },
+ },
];
-/** How many figures the package has, as the prose writes it: "nineteen". */
+/** How many figures the package has, as the prose writes it: "twenty-seven". */
export const COUNT = spell(FIGURES.length);
/** Each figure's number at intensity 0, 0.5 and 1: a copy of the package's table. */
@@ -181,6 +237,14 @@ export const INTENSITY: Record<FigureId, readonly [number, number, number]> = {
patch: [1, 2.5, 5],
dish: [30, 50, 70],
router: [0.5, 1.5, 3],
+ loupe: [1.3, 1.8, 2.6],
+ sieve: [6, 14, 24],
+ rail: [1, 2, 3.5],
+ plug: [0.35, 0.6, 0.9],
+ query: [20, 40, 55],
+ drawer: [12, 22, 34],
+ basket: [8, 16, 28],
+ plot: [3, 6, 12],
};
/** A number with its unit, as the docs' table and /llms.txt write it: "40 ms", "0.2× normal speed". */
diff --git a/apps/site/lib/llms.ts b/apps/site/lib/llms.ts
index 73edb8d..8eea2d1 100644
--- a/apps/site/lib/llms.ts
+++ b/apps/site/lib/llms.ts
@@ -1,5 +1,6 @@
+import { NOTICE } from "./catalogue";
import { COUNT, FIGURES, INTENSITY, LINKS, OPTIONS, THEME, measure, type Row } from "./figures";
-import { CDN, PACKAGE, REACT, VANILLA, install } from "./snippets";
+import { CDN, EMPTY, 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. */
@@ -43,6 +44,12 @@ export function llms(base: string): string {
"",
table(OPTIONS),
"",
+ "## Empty states",
+ "",
+ "A figure works as an empty state at 160 to 240px, above a heading and one action. Its rest pose is the picture; the pointer is a bonus.",
+ "",
+ fence("tsx", EMPTY),
+ "",
"## Figures",
"",
"What a higher `intensity` does to each figure, and the number it sets inside the figure (two straight lines through these three points):",
@@ -59,8 +66,9 @@ export function llms(base: string): string {
"", "## 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, and the change asked for next where there was one:`,
+ "", `Then type \`${COMMAND} <idea>\` in the agent. Seven ideas, each with the page the skill wrote for it, and the change asked for next where there was one:`,
"", EXAMPLES.map((e) => `- \`${COMMAND} ${e.idea}\`${e.followUp ? `, then "${e.followUp}"` : ""}: ${base}/skill/${e.file}`).join("\n"),
+ "", NOTICE,
"", `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/lib/skill.ts b/apps/site/lib/skill.ts
index 31922d9..38cd19b 100644
--- a/apps/site/lib/skill.ts
+++ b/apps/site/lib/skill.ts
@@ -23,6 +23,9 @@ export const EXAMPLES: Example[] = [
{ idea: "a rate limiter", file: "hairline-clearance.html", sha256: "bcad4048389d9049880263ad113900cc6728f6bc5770880c7524a8836728bdce" },
{ idea: "git branches", file: "hairline-sidings.html", sha256: "de5ad4411e1b7a97049c6b74e9f4ffdb8a9dfc32b0c5367dddd585cd7dac5bf7", followUp: "The rails almost disappear and the trains read as loose blocks. Make it read as a railway at a glance." },
{ idea: "weather over a city", file: "hairline-storm.html", sha256: "af8e3e85414d2a38421cf98b858ce1a4c1f9138cc5ba7bbf6c5b42b0205c0e60", followUp: "The cloud looks like a stack of cylinders. Make it read as a cloud at a glance." },
+ { idea: "an empty state for \"No deployments yet\", from Vercel's mark: the triangle as an upright slab hovering over a pad with its slot marked dim; the nearer the pointer, the lower it settles, until it seats. Name it vercel.", file: "hairline-vercel.html", sha256: "66f4577ec763f5ea45983cdff12ec5fdd6a6d1be7ff427023a8d35271af43d94" },
+ { idea: "an empty state for \"No agents connected\", from Mastra's mark: the spheres of the M joined by necks on a board, the lone sphere standing apart; the pointer draws it toward the others, a neck forms, stretches and lets go. Name it mastra.", file: "hairline-mastra.html", sha256: "6a7c5d3f4942428b4ce6ce02c6667eb80503ea58bd501891e3b5f9f7eeb02f5a" },
+ { idea: "an empty state for \"No pages inside\", from Notion's mark: the cube as a box with a lid, the N a relief on its front face; the pointer's height opens the lid on a spring, and the box is empty. Name it notion.", file: "hairline-notion.html", sha256: "0027a7ea3a463638d60e7d0cc3cd94402862d68895a4c9b5e036a1a3c2163583" },
];
export type Shown = Example & { name: string; means: string; prompt: string; href: string };
diff --git a/apps/site/lib/snippets.ts b/apps/site/lib/snippets.ts
index 6bb4996..ab0d1fa 100644
--- a/apps/site/lib/snippets.ts
+++ b/apps/site/lib/snippets.ts
@@ -57,6 +57,23 @@ ${THEME.map((t) => ` ${t.property}: ${t.light};`).join("\n")}
}
`;
+/** The empty state's words, shared by its code and the live one the docs draw above it. */
+export const NO_RESULTS = { label: "An empty sieve", heading: "No results match these filters", action: "Clear filters" };
+
+/** A figure as an empty state: small, over a heading and one action. */
+export const EMPTY = `import { Sieve } from "@lucasmarkes/hairline/react";
+
+export function NoResults({ onClear }: { onClear: () => void }) {
+ return (
+ <div style={{ display: "grid", justifyItems: "center", gap: 12, padding: 48 }}>
+ <Sieve style={{ width: 200 }} label="${NO_RESULTS.label}" />
+ <h2>${NO_RESULTS.heading}</h2>
+ <button onClick={onClear}>${NO_RESULTS.action}</button>
+ </div>
+ );
+}
+`;
+
/** The quick start's tabs: the same figure three ways, each under the file it goes in. */
export const QUICKSTART = paste("Terrain", "terrain");
diff --git a/apps/site/public/skill/hairline-mastra.html b/apps/site/public/skill/hairline-mastra.html
new file mode 100644
index 0000000..3cdaef0
--- /dev/null
+++ b/apps/site/public/skill/hairline-mastra.html
@@ -0,0 +1,909 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Hairline figure</title>
+<link rel="icon" href="data:,">
+<style>
+ :root { color-scheme: light; --ground: #ffffff; --ink: #232327; --muted: #6f6f78; --line: #e0e0e4; }
+ @media (prefers-color-scheme: dark) {
+ :root:not([data-theme="light"]) { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ }
+ :root[data-theme="dark"] { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ :root[data-theme="light"] { color-scheme: light; }
+ * { box-sizing: border-box; }
+ body {
+ margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
+ background: var(--ground); color: var(--ink);
+ font: 13px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased;
+ }
+ main { width: 100%; max-width: 640px; }
+ .plate { position: relative; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
+ .tag, .label, output, button { font: 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.02em; }
+ .tag { position: absolute; top: 12px; z-index: 1; color: var(--muted); pointer-events: none; }
+ #name { left: 14px; }
+ #read { right: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
+ .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 14px; }
+ .label { color: var(--muted); }
+ input[type="range"] {
+ flex: 1 1 96px; min-width: 0; height: 32px; margin: 0; background: transparent; cursor: pointer;
+ -webkit-appearance: none; appearance: none;
+ }
+ input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-webkit-slider-thumb {
+ -webkit-appearance: none; width: 13px; height: 13px; margin-top: -6px; border-radius: 50%;
+ border: 1px solid var(--ink); background: var(--ground);
+ }
+ input[type="range"]::-moz-range-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--ink); background: var(--ground); }
+ input[type="range"]:focus-visible, button:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 2px; }
+ output { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
+ button {
+ height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
+ background: transparent; color: var(--ink); cursor: pointer;
+ }
+ #means { margin: 14px 0 0; text-wrap: pretty; }
+ #rules { margin: 6px 0 0; line-height: 1.6; }
+ #error { margin: 12px 0 0; padding-left: 10px; border-left: 1px solid var(--ink); }
+</style>
+</head>
+<body>
+<main>
+ <div class="plate">
+ <span class="tag" id="name"></span>
+ <span class="tag" id="read"></span>
+ <div id="stage"></div>
+ </div>
+ <div class="controls">
+ <label class="label" for="intensity">intensity</label>
+ <input id="intensity" type="range" min="0" max="1" step="0.01" value="0.5">
+ <output id="value" for="intensity"></output>
+ <span class="label">theme</span>
+ <button id="theme" type="button" aria-label="Switch between the light and the dark theme"></button>
+ </div>
+ <p id="means"></p>
+ <p id="rules" class="label"></p>
+ <p id="error" role="alert" hidden></p>
+</main>
+<script id="hl-kernel">
+/* hairline kernel sha256:8e2abcbdf63c7755195ee942c39e9c8ea6a539d1147e986dd1c153559121f075 */
+/*
+ * HL: everything a figure may call. Read this index; the code under it is the
+ * package's src/core, unchanged, and a figure should not need to read it.
+ *
+ * Every figure is drawn in a 400 × 320 viewBox. World space is x/y on the
+ * ground and z up. Plates are filled with the ground colour and painted back
+ * to front, so a nearer one covers a farther one: append in that order. At
+ * the default camera, Cam(45, 0.5, S), +x runs down to the right and +y down
+ * to the left, so the corner with the largest x and y is nearest the viewer:
+ * append by ascending x + y, from the far corner (smallest x and y) to it.
+ *
+ * Camera
+ * Cam(azDeg, k, S) a camera: azimuth in degrees, k = sin(elevation) (0.5 is the 2:1 view), S = scale
+ * fit(C, points, cx, cy) centres the box of [x, y, z] points on (cx, cy); call it once, before proj
+ * it only centres, it never scales: choose S by trying values, with the most extreme pose in points.
+ * The six figures use S 1.42 to 2.12; the boxes they fit come out 230 to 310 wide and 180 to 245 tall
+ * proj(C) returns P(x, y, z), which gives [sx, sy]
+ * unproj(C, sx, sy, z) the world [x, y] under a screen point, on the plane at height z
+ * facing(C) returns front(sample): whether a ring sample faces the camera
+ * Rounded solids
+ * rrect(u0, v0, u1, v1, r, n) a rounded rectangle, as a ring of samples {u, v, nu, nv}
+ * circ(R, n) a circle, as a ring
+ * rings(x0, y0, x1, y1, r, b) [ring, inner]: a rounded footprint and its crease ring, inset by b
+ * r, the corner radius, is cut to half the shorter side. b, the crease's inset in world units
+ * (0.6 to 2.2 in the figures), must stay under half the shorter side or the crease turns inside out
+ * prism(P, front, ring, inner, z0, z1) {sil, crease}: a solid standing from z0 to z1, as two path strings
+ * ringAt(P, ring, z) the ring's points, projected at height z
+ * run(ring, keep) the one cyclic run of samples that pass keep
+ * hull(points) the convex hull of screen points
+ * extremes(P, ring) [left, right, nearest] samples: where dashed drops fall from
+ * fillet(points, radii, n) rounds every vertex of a closed polygon; returns the new points
+ * radii is an array, one radius per vertex, each cut to half its shorter edge; a single number gives NaN.
+ * n is the steps round each corner, default 4: each vertex becomes n + 1 points
+ * ghost(P, front, ring, z0, depth) a reflection's path {d, y0, y1}; reflect() draws it for you
+ * Paths and numbers
+ * poly(points) a closed path string
+ * open(points) an open polyline string
+ * seg(a, b) one segment between two screen points [sx, sy], as its own subpath; project world points with P first
+ * clamp(v, a, b)
+ * lerp(a, b, t)
+ * rad(deg)
+ * r2(n) two decimals
+ * The continuous clock: one spring per moving number
+ * spring(x, opts) at rest on x; write .t to retarget; opts {k, c, m, eps}, default k 100, c 18, m 1
+ * stepS(sp, dt) advances by dt seconds; returns whether it is still moving
+ * The discrete clock: a 700ms tween on (.32, .72, 0, 1)
+ * tween(v, dur) at rest on v; dur defaults to 700 (ms)
+ * tset(tw, to, now, delay) retargets from where it is, after delay ms: the stagger
+ * the same target again does nothing, so calling it on every pointer move is safe
+ * tval(tw, now) its value at now
+ * tdone(tw, now) whether it has landed
+ * bezier(x1, y1, x2, y2) a CSS cubic-bezier, as a function of progress
+ * EASE_LIFT the lift curve itself
+ * reducedMotion() true when the reader asked for less motion; springs and tweens already land at once
+ * setReducedMotion(on) the loop's business, not a figure's
+ * Drawing
+ * mk(tag, attrs, parent) one svg element: the only way a figure makes a node
+ * solid(parent) {g, sil, cr}: a group holding a silhouette path and a crease path
+ * put(solid, paths) writes prism()'s {sil, crease} into solid()'s {sil, cr}: sil into sil, crease into cr
+ * flatDot(parent, C, r, cls) a dot lying on the ground plane; cls is "dot", "dot m" or "dot off"
+ * place(el, point) moves a dot or a circle to [sx, sy]
+ * reflect(svg, parent, P, front, ring, z0, depth) a fading mirror under a solid
+ * fade(svg, y0, y1, a0) a vertical fade, as a mask; returns the value for a mask attribute
+ * Life
+ * register(stage, tick) joins the one frame loop; tick(dt in seconds, now in ms) returns true to ask for another frame; gives {wake, unregister}
+ * pointer(stage, handlers) {move(point), down(point), leave()}, points in viewBox units; returns its disposer
+ * disposer() {add, on, dispose}: collects tear-down, so destroy is bag.dispose
+ * The bench's business, not a figure's
+ * css(lightDark)
+ * inject(root)
+ *
+ * Classes, on path, polygon, ellipse and line. They are the whole palette; a
+ * figure sets no colour, width or fill of its own.
+ * (none) filled with the ground colour, medium stroke
+ * sil the silhouette's stroke hi the bright stroke: the only highlight
+ * lo the dim stroke nf no fill fo fill only, no stroke
+ * dash a dashed guide
+ * dot a bright dot dot m a medium dot dot off a dim dot
+ */
+var HL = (() => {
+ var __defProp = Object.defineProperty;
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
+ var __getOwnPropNames = Object.getOwnPropertyNames;
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
+ var __export = (target, all) => {
+ for (var name in all)
+ __defProp(target, name, { get: all[name], enumerable: true });
+ };
+ var __copyProps = (to, from, except, desc) => {
+ if (from && typeof from === "object" || typeof from === "function") {
+ for (let key of __getOwnPropNames(from))
+ if (!__hasOwnProp.call(to, key) && key !== except)
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
+ }
+ return to;
+ };
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
+
+ // packages/hairline/src/core/kernel.ts
+ var kernel_exports = {};
+ __export(kernel_exports, {
+ Cam: () => Cam,
+ EASE_LIFT: () => EASE_LIFT,
+ bezier: () => bezier,
+ circ: () => circ,
+ clamp: () => clamp,
+ css: () => css,
+ disposer: () => disposer,
+ extremes: () => extremes,
+ facing: () => facing,
+ fade: () => fade,
+ fillet: () => fillet,
+ fit: () => fit,
+ flatDot: () => flatDot,
+ ghost: () => ghost,
+ hull: () => hull,
+ inject: () => inject,
+ lerp: () => lerp,
+ mk: () => mk,
+ open: () => open,
+ place: () => place,
+ pointer: () => pointer,
+ poly: () => poly,
+ prism: () => prism,
+ proj: () => proj,
+ put: () => put,
+ r2: () => r2,
+ rad: () => rad,
+ reducedMotion: () => reducedMotion,
+ reflect: () => reflect,
+ register: () => register,
+ ringAt: () => ringAt,
+ rings: () => rings,
+ rrect: () => rrect,
+ run: () => run,
+ seg: () => seg,
+ setReducedMotion: () => setReducedMotion,
+ solid: () => solid,
+ spring: () => spring,
+ stepS: () => stepS,
+ tdone: () => tdone,
+ tset: () => tset,
+ tval: () => tval,
+ tween: () => tween,
+ unproj: () => unproj
+ });
+
+ // packages/hairline/src/core/iso.ts
+ var clamp = (v, a, b) => Math.max(a, Math.min(b, v));
+ var lerp = (a, b, t) => a + (b - a) * t;
+ var rad = (d) => d * Math.PI / 180;
+ var r2 = (n) => Math.round(n * 100) / 100;
+ var poly = (pts) => "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L") + "Z";
+ var seg = (a, b) => `M${r2(a[0])} ${r2(a[1])}L${r2(b[0])} ${r2(b[1])}`;
+ var open = (pts) => pts.length < 2 ? "" : "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L");
+ var Cam = (azDeg, k, S) => ({ az: rad(azDeg), k, S, ox: 0, oy: 0 });
+ function proj(C) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ return (x, y, z) => {
+ const X = x * c - y * s, Y = x * s + y * c;
+ return [C.ox + C.S * X, C.oy + C.S * (Y * C.k - z * zf)];
+ };
+ }
+ function unproj(C, sx, sy, z) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ const X = (sx - C.ox) / C.S, Y = ((sy - C.oy) / C.S + z * zf) / C.k;
+ return [X * c + Y * s, -X * s + Y * c];
+ }
+ function fit(C, pts, cx, cy) {
+ C.ox = 0;
+ C.oy = 0;
+ const P = proj(C);
+ let a = 1e9, b = -1e9, c = 1e9, d = -1e9;
+ for (const p of pts) {
+ const q = P(p[0], p[1], p[2]);
+ a = Math.min(a, q[0]);
+ b = Math.max(b, q[0]);
+ c = Math.min(c, q[1]);
+ d = Math.max(d, q[1]);
+ }
+ C.ox = cx - (a + b) / 2;
+ C.oy = cy - (c + d) / 2;
+ }
+ function rrect(u0, v0, u1, v1, r, n = 4) {
+ r = Math.max(0, Math.min(r, (u1 - u0) / 2, (v1 - v0) / 2));
+ const out = [];
+ for (const [cu, cv, a0] of [[u1 - r, v1 - r, 0], [u0 + r, v1 - r, 90], [u0 + r, v0 + r, 180], [u1 - r, v0 + r, 270]])
+ for (let k = 0; k <= n; k++) {
+ const a = rad(a0 + 90 * k / n), ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: cu + r * ca, v: cv + r * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function circ(R, n = 96) {
+ const out = [];
+ for (let k = 0; k < n; k++) {
+ const a = k / n * Math.PI * 2, ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: R * ca, v: R * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function hull(input) {
+ const pts = input.slice().sort((a, b) => a[0] - b[0] || a[1] - b[1]);
+ const x = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
+ const lo = [], up = [];
+ for (const p of pts) {
+ while (lo.length > 1 && x(lo[lo.length - 2], lo[lo.length - 1], p) <= 0) lo.pop();
+ lo.push(p);
+ }
+ for (let i = pts.length - 1; i >= 0; i--) {
+ const p = pts[i];
+ while (up.length > 1 && x(up[up.length - 2], up[up.length - 1], p) <= 0) up.pop();
+ up.push(p);
+ }
+ lo.pop();
+ up.pop();
+ return lo.concat(up);
+ }
+ var ringAt = (P, ring, z) => ring.map((q) => P(q.u, q.v, z));
+ var facing = (C) => {
+ const s = Math.sin(C.az), c = Math.cos(C.az);
+ return (q) => q.nu * s + q.nv * c >= -1e-6;
+ };
+ function run(ring, keep) {
+ const n = ring.length;
+ let s = -1;
+ for (let i = 0; i < n; i++) if (keep(ring[i]) && !keep(ring[(i + n - 1) % n])) {
+ s = i;
+ break;
+ }
+ if (s < 0) return keep(ring[0]) ? ring.slice() : [];
+ const out = [];
+ for (let k = 0; k < n && keep(ring[(s + k) % n]); k++) out.push(ring[(s + k) % n]);
+ return out;
+ }
+ function prism(P, front, ring, inner, z0, z1) {
+ return {
+ sil: poly(hull(ringAt(P, ring, z1).concat(ringAt(P, ring, z0)))),
+ crease: inner ? open(ringAt(P, run(inner, front), z1)) : ""
+ };
+ }
+ var rings = (x0, y0, x1, y1, r, b) => [
+ rrect(x0, y0, x1, y1, r),
+ rrect(x0 + b, y0 + b, x1 - b, y1 - b, Math.max(0.3, r - b))
+ ];
+ function extremes(P, ring) {
+ const pr = ring.map((q) => P(q.u, q.v, 0));
+ let a = 0, b = 0, c = 0;
+ pr.forEach((p, k) => {
+ if (p[0] < pr[a][0]) a = k;
+ if (p[0] > pr[b][0]) b = k;
+ if (p[1] > pr[c][1]) c = k;
+ });
+ return [ring[a], ring[b], ring[c]];
+ }
+ function fillet(pts, rs, n = 4) {
+ const m = pts.length, out = [];
+ for (let i = 0; i < m; i++) {
+ const a = pts[(i + m - 1) % m], p = pts[i], b = pts[(i + 1) % m];
+ const la = Math.hypot(a[0] - p[0], a[1] - p[1]), lb = Math.hypot(b[0] - p[0], b[1] - p[1]);
+ const t = Math.min(rs[i], la / 2, lb / 2);
+ const p1 = [p[0] + (a[0] - p[0]) / la * t, p[1] + (a[1] - p[1]) / la * t];
+ const p2 = [p[0] + (b[0] - p[0]) / lb * t, p[1] + (b[1] - p[1]) / lb * t];
+ for (let k = 0; k <= n; k++) {
+ const s = k / n, w = 1 - s;
+ out.push([w * w * p1[0] + 2 * w * s * p[0] + s * s * p2[0], w * w * p1[1] + 2 * w * s * p[1] + s * s * p2[1]]);
+ }
+ }
+ return out;
+ }
+ function ghost(P, front, ring, z0, depth) {
+ const f = run(ring, front), lowP = ringAt(P, f, z0 - depth);
+ return {
+ d: open(lowP) + [f[0], f[f.length - 1]].map((q) => seg(P(q.u, q.v, z0), P(q.u, q.v, z0 - depth))).join(""),
+ y0: Math.min(...ringAt(P, f, z0).map((p) => p[1])),
+ y1: Math.max(...lowP.map((p) => p[1])) + 2
+ };
+ }
+
+ // packages/hairline/src/core/motion.ts
+ var reduced = false;
+ var setReducedMotion = (on) => {
+ reduced = on;
+ };
+ var reducedMotion = () => reduced;
+ function spring(x, o = {}) {
+ return { x, v: 0, t: x, k: o.k ?? 100, c: o.c ?? 18, m: o.m ?? 1, eps: o.eps ?? 0.01 };
+ }
+ function stepS(sp, dt) {
+ if (reduced) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ const n = Math.max(1, Math.ceil(dt * 240)), h = dt / n;
+ for (let i = 0; i < n; i++) {
+ const a = (-sp.k * (sp.x - sp.t) - sp.c * sp.v) / sp.m;
+ sp.v += a * h;
+ sp.x += sp.v * h;
+ }
+ if (Math.abs(sp.x - sp.t) < sp.eps && Math.abs(sp.v) < sp.eps * 10) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ return true;
+ }
+ function bezier(x1, y1, x2, y2) {
+ const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx;
+ const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by;
+ const X = (u) => ((ax * u + bx) * u + cx) * u;
+ const Y = (u) => ((ay * u + by) * u + cy) * u;
+ const dX = (u) => (3 * ax * u + 2 * bx) * u + cx;
+ return (t) => {
+ if (t <= 0) return 0;
+ if (t >= 1) return 1;
+ let u = t;
+ for (let i = 0; i < 8; i++) {
+ const e = X(u) - t;
+ if (Math.abs(e) < 1e-5) break;
+ const d = dX(u);
+ if (Math.abs(d) < 1e-6) break;
+ u -= e / d;
+ }
+ if (!(u >= 0 && u <= 1) || Math.abs(X(u) - t) > 1e-4) {
+ let lo = 0, hi = 1;
+ u = t;
+ for (let i = 0; i < 24; i++) {
+ if (X(u) < t) lo = u;
+ else hi = u;
+ u = (lo + hi) / 2;
+ }
+ }
+ return Y(u);
+ };
+ }
+ var EASE_LIFT = bezier(0.32, 0.72, 0, 1);
+ var tween = (v, dur = 700) => ({ from: v, to: v, t0: -1e9, dur });
+ var tval = (tw, now) => {
+ const p = clamp((now - tw.t0) / tw.dur, 0, 1);
+ return tw.from + (tw.to - tw.from) * (reduced ? 1 : EASE_LIFT(p));
+ };
+ var tset = (tw, to, now, delay) => {
+ if (tw.to === to) return;
+ tw.from = tval(tw, now);
+ tw.to = to;
+ tw.t0 = now + delay;
+ };
+ var tdone = (tw, now) => reduced || now >= tw.t0 + tw.dur;
+
+ // packages/hairline/src/core/stage.ts
+ var NS = "http://www.w3.org/2000/svg";
+ function mk(tag, attrs, parent) {
+ const e = document.createElementNS(NS, tag);
+ if (attrs) for (const k in attrs) e.setAttribute(k, String(attrs[k]));
+ if (parent) parent.appendChild(e);
+ return e;
+ }
+ function solid(parent) {
+ const g = mk("g", {}, parent);
+ return { g, sil: mk("path", { class: "sil" }, g), cr: mk("path", { class: "nf lo" }, g) };
+ }
+ var put = (el, s) => {
+ el.sil.setAttribute("d", s.sil);
+ el.cr.setAttribute("d", s.crease);
+ };
+ var flatDot = (parent, C, r, cls) => mk("ellipse", { rx: r2(r * C.S), ry: r2(r * C.S * C.k), class: cls }, parent);
+ var place = (el, q) => {
+ el.setAttribute("cx", String(r2(q[0])));
+ el.setAttribute("cy", String(r2(q[1])));
+ };
+ var fid = 0;
+ function fade(svg, y0, y1, a0 = 0.7) {
+ const id = "hl-fd" + ++fid, defs = mk("defs", {}, svg);
+ const lg = mk("linearGradient", { id: id + "g", gradientUnits: "userSpaceOnUse", x1: 0, y1: r2(y0), x2: 0, y2: r2(y1) }, defs);
+ mk("stop", { offset: 0, "stop-color": "#fff", "stop-opacity": a0 }, lg);
+ mk("stop", { offset: 1, "stop-color": "#fff", "stop-opacity": 0 }, lg);
+ const m = mk("mask", { id, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: 400, height: 320 }, defs);
+ mk("rect", { x: 0, y: 0, width: 400, height: 320, fill: `url(#${id}g)` }, m);
+ return `url(#${id})`;
+ }
+ function reflect(svg, parent, P, front, ring, z0, depth) {
+ const r = ghost(P, front, ring, z0, depth);
+ const gh = mk("g", { class: "ghost", mask: fade(svg, r.y0, r.y1) }, parent);
+ mk("path", { d: r.d }, gh);
+ }
+ var boards = [];
+ var byStage = /* @__PURE__ */ new Map();
+ var raf = 0;
+ var last = 0;
+ var io = null;
+ var rm = null;
+ function frame(now) {
+ const dt = Math.min(0.05, Math.max(0, (now - last) / 1e3));
+ last = now;
+ let any = false;
+ for (const b of boards.slice()) if (b.vis && b.awake) {
+ b.awake = !!b.tick(dt, now);
+ any = any || b.awake;
+ }
+ raf = any ? requestAnimationFrame(frame) : 0;
+ }
+ function wake(b) {
+ b.awake = true;
+ if (!raf) {
+ last = performance.now();
+ raf = requestAnimationFrame(frame);
+ }
+ }
+ var onMotion = () => {
+ setReducedMotion(!!rm?.matches);
+ boards.forEach(wake);
+ };
+ function start() {
+ if (io) return;
+ io = new IntersectionObserver((es) => {
+ for (const e of es) {
+ const b = byStage.get(e.target);
+ if (!b) continue;
+ b.vis = e.isIntersecting;
+ if (b.vis) wake(b);
+ }
+ }, { rootMargin: "80px" });
+ rm = matchMedia("(prefers-reduced-motion: reduce)");
+ setReducedMotion(rm.matches);
+ rm.addEventListener("change", onMotion);
+ }
+ function stop() {
+ if (raf) cancelAnimationFrame(raf);
+ raf = 0;
+ io?.disconnect();
+ io = null;
+ rm?.removeEventListener("change", onMotion);
+ rm = null;
+ }
+ function register(stage, tick) {
+ start();
+ const b = { stage, tick, vis: false, awake: true };
+ boards.push(b);
+ byStage.set(stage, b);
+ io.observe(stage);
+ tick(0, performance.now());
+ let gone = false;
+ return {
+ wake: () => {
+ if (!gone) wake(b);
+ },
+ unregister: () => {
+ if (gone) return;
+ gone = true;
+ boards = boards.filter((x) => x !== b);
+ if (byStage.get(stage) === b) {
+ byStage.delete(stage);
+ io?.unobserve(stage);
+ }
+ if (!boards.length) stop();
+ }
+ };
+ }
+ function pointer(stage, on) {
+ let tm = 0;
+ const pt = (e) => {
+ const r = stage.getBoundingClientRect();
+ return [(e.clientX - r.left) / r.width * 400, (e.clientY - r.top) / r.height * 320];
+ };
+ const move = (e) => {
+ clearTimeout(tm);
+ on.move(pt(e), e);
+ };
+ const down = (e) => {
+ clearTimeout(tm);
+ if (e.pointerType !== "mouse") stage.releasePointerCapture?.(e.pointerId);
+ if (on.down) on.down(pt(e), e);
+ else on.move(pt(e), e);
+ };
+ const leave = (e) => {
+ clearTimeout(tm);
+ tm = window.setTimeout(() => on.leave(e), e.pointerType === "mouse" ? 0 : 1400);
+ };
+ stage.addEventListener("pointermove", move);
+ stage.addEventListener("pointerdown", down);
+ stage.addEventListener("pointerleave", leave);
+ return () => {
+ clearTimeout(tm);
+ stage.removeEventListener("pointermove", move);
+ stage.removeEventListener("pointerdown", down);
+ stage.removeEventListener("pointerleave", leave);
+ };
+ }
+ function disposer() {
+ let fns = [];
+ return {
+ add: (fn) => {
+ fns.push(fn);
+ },
+ on: (target, type, fn, opts) => {
+ const h = fn;
+ target.addEventListener(type, h, opts);
+ fns.push(() => target.removeEventListener(type, h, opts));
+ },
+ dispose: () => {
+ const run2 = fns;
+ fns = [];
+ for (let i = run2.length - 1; i >= 0; i--) run2[i]();
+ }
+ };
+ }
+
+ // packages/hairline/src/core/styles.ts
+ var LIGHT = { plate: "#ffffff", hi: "#232327", edge: "#a4a4ac", mid: "#c3c3c9", lo: "#e0e0e4" };
+ var DARK = { plate: "#08090a", hi: "#d0d6e0", edge: "#5b5d64", mid: "#3e3e44", lo: "#29292d" };
+ var KEYS = ["plate", "hi", "edge", "mid", "lo"];
+ var vars = (p) => KEYS.map((k) => `--hl-${k}:var(--hairline-${k},${p[k]});`).join("");
+ var EASE = "cubic-bezier(0.5,0,0.1,1)";
+ var SVG = ":where([data-hairline]>svg)";
+ function css(lightDark) {
+ const both = Object.fromEntries(KEYS.map((k) => [k, `light-dark(${LIGHT[k]},${DARK[k]})`]));
+ return [
+ // the box, and the palette: light unless something below says otherwise
+ `:where([data-hairline]){display:block;position:relative;aspect-ratio:5/4;touch-action:pan-y;user-select:none;-webkit-user-select:none;--hl-sw:var(--hairline-stroke,0.9);${vars(LIGHT)}}`,
+ // the page's color-scheme
+ lightDark ? `:where([data-hairline]){${vars(both)}}` : "",
+ // an ancestor that says dark
+ `:where(.dark,[data-theme="dark"]) :where([data-hairline]){${vars(DARK)}}`,
+ // the figure's own theme option
+ `:where([data-hairline][data-hairline-theme="light"]){${vars(LIGHT)}}`,
+ `:where([data-hairline][data-hairline-theme="dark"]){${vars(DARK)}}`,
+ `:where([data-hairline]:focus-visible){outline:1.5px solid var(--hl-hi);outline-offset:2px}`,
+ `${SVG}{position:absolute;inset:0;width:100%;height:100%;display:block}`,
+ // Riffle's live region: read, not seen
+ `:where([data-hairline]>[data-hairline-live]){position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}`,
+ // the drawing: plates are filled with the plate colour and painted back to front
+ `${SVG} :where(path,polygon,ellipse,line){fill:var(--hl-plate);stroke:var(--hl-mid);stroke-width:var(--hl-sw);vector-effect:non-scaling-stroke;stroke-linejoin:round;stroke-linecap:round;transition:stroke 260ms ${EASE}}`,
+ `${SVG} :where(.nf){fill:none}`,
+ `${SVG} :where(.fo){stroke:none}`,
+ `${SVG} :where(.sil){stroke:var(--hl-edge)}`,
+ `${SVG} :where(.hi){stroke:var(--hl-hi)}`,
+ `${SVG} :where(.lo){stroke:var(--hl-lo)}`,
+ `${SVG} :where(.dash){stroke-dasharray:1 3}`,
+ `${SVG} :where(.dot){stroke:none;fill:var(--hl-hi);transition:fill 260ms ${EASE}}`,
+ `${SVG} :where(.dot.m){fill:var(--hl-edge)}`,
+ `${SVG} :where(.dot.off){fill:var(--hl-lo)}`,
+ `${SVG} :where(.ghost path){fill:none;stroke:var(--hl-mid)}`
+ ].join("");
+ }
+ var done = /* @__PURE__ */ new WeakSet();
+ function inject(root) {
+ if (done.has(root)) return;
+ done.add(root);
+ const doc = root.nodeType === 9 ? root : root.ownerDocument;
+ const win = doc.defaultView;
+ const text = css(!!win?.CSS?.supports?.("color", "light-dark(#000,#fff)"));
+ if (win && "adoptedStyleSheets" in root) {
+ try {
+ const sheet = new win.CSSStyleSheet();
+ sheet.replaceSync(text);
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
+ return;
+ } catch {
+ }
+ }
+ const style = doc.createElement("style");
+ style.setAttribute("data-hairline-style", "");
+ style.textContent = text;
+ (root.nodeType === 9 ? doc.head ?? doc.documentElement : root).appendChild(style);
+ }
+ return __toCommonJS(kernel_exports);
+})();
+/* /hairline kernel */
+</script>
+<script id="hl-bench">
+/*
+ * The bench: the page a figure is shown on. It makes the host and the svg the
+ * way the package's mount does, hands them to the figure, and owns everything
+ * around it: the read-out, the slider, the theme, the line under the stage.
+ */
+(() => {
+ const RULES = ["hit", "order", "reach", "accent", "rest", "honesty", "cost", "clock", "radius", "quiet"];
+ const $ = (id) => document.getElementById(id);
+ const root = document.documentElement, params = new URLSearchParams(location.search);
+
+ /* the theme: the system's until the switch is pressed, then the switch's */
+ const dark = () => (root.dataset.theme ? root.dataset.theme === "dark" : matchMedia("(prefers-color-scheme: dark)").matches);
+ const label = () => { $("theme").textContent = dark() ? "dark" : "light"; };
+ $("theme").addEventListener("click", () => { root.dataset.theme = dark() ? "light" : "dark"; label(); });
+ /* ?theme=light or ?theme=dark wins over the system's, as pressing the switch does */
+ if (["light", "dark"].includes(params.get("theme"))) root.dataset.theme = params.get("theme");
+ label();
+
+ /* ?intensity=0 sets the slider before the figure mounts, for a look at either end */
+ const i = (params.get("intensity") || "").trim();
+ if (i && Number.isFinite(Number(i))) $("intensity").value = String(Math.min(1, Math.max(0, Number(i))));
+
+ /* ?w=240 narrows the page, for a look at the size of a thumbnail */
+ const w = Number(params.get("w"));
+ if (w > 0) document.querySelector("main").style.maxWidth = w + "px";
+
+ /* a figure that fails says so under the stage, instead of leaving an empty plate */
+ addEventListener("error", (e) => {
+ $("error").hidden = false;
+ $("error").textContent = String((e.error && e.error.message) || e.message);
+ });
+
+ let mounted = false;
+ window.hairline = (figure) => {
+ if (mounted) throw new Error("hairline: one figure per page.");
+ mounted = true;
+ const stage = $("stage"), slider = $("intensity");
+
+ /* intensity to the figure's own number: two straight lines that meet at 0.5, as in the package */
+ const [lo, mid, hi] = figure.range;
+ const at = (i) => Math.round((i <= 0.5 ? lo + (i / 0.5) * (mid - lo) : mid + ((i - 0.5) / 0.5) * (hi - mid)) * 1000) / 1000;
+
+ HL.inject(document);
+ stage.setAttribute("data-hairline", figure.name);
+ stage.setAttribute("role", "img");
+ stage.setAttribute("aria-label", figure.means);
+ const svg = HL.mk("svg", { viewBox: "0 0 400 320", "aria-hidden": "true" }, stage);
+
+ let text = null;
+ const read = {
+ get textContent() { return text; },
+ set textContent(value) { text = value == null ? "" : String(value); $("read").textContent = text; },
+ };
+
+ document.title = "Hairline · " + figure.name;
+ $("name").textContent = figure.name;
+ $("means").textContent = figure.means;
+ $("rules").textContent = figure.rules.map((n) => String(n).padStart(2, "0") + " " + RULES[n - 1]).join(" · ");
+ const show = () => { $("value").textContent = String(at(Number(slider.value))); };
+ show();
+
+ const handle = figure.mount({ stage, svg, read }, at(Number(slider.value)));
+ if (text === null) read.textContent = "rest";
+ slider.addEventListener("input", () => { show(); handle.set(at(Number(slider.value))); });
+ window.hairline.figure = handle;
+
+ /* ?at=200,160 holds the pointer at a viewBox point, for a picture of the answer without a mouse */
+ const p = (params.get("at") || "").split(",").map(Number);
+ if (p.length === 2 && p.every(Number.isFinite)) {
+ const r = stage.getBoundingClientRect();
+ stage.dispatchEvent(new PointerEvent("pointermove", {
+ pointerType: "mouse", pointerId: 1, bubbles: true,
+ clientX: r.left + (p[0] / 400) * r.width, clientY: r.top + (p[1] / 320) * r.height,
+ }));
+ }
+ };
+})();
+</script>
+<script type="module" id="hl-figure">
+/**
+ * Mastra: the mark built as a solid. Four spheres stand on a board, joined by
+ * necks into the M; the fifth, its foot, stands apart with no neck: no agent
+ * connected. The pointer's x draws the lone sphere along the board. Close
+ * enough, a neck forms (a tween: two bumps reach out, meet, thicken); pulled
+ * back, it thins and tugs the chain, each sphere less the farther along it is;
+ * past the slider's stretch it lets go. Leaving lets go too.
+ *
+ * Every sphere is a circle on screen, so the mark is drawn as one field on the
+ * screen: each sphere's distance, necks blended in by a smooth minimum, traced
+ * where it crosses zero. The trace is the silhouette, filled, so the board
+ * behind it stays hidden.
+ */
+const {
+ Cam, fit, proj, facing, rrect, prism, poly, open, clamp,
+ spring, stepS, tween, tset, tval, tdone, mk, solid, put, register, pointer, disposer,
+} = HL;
+
+// The mark's centres, measured off it in pixels at K world units a pixel: u along
+// the board, z up, stretched back by what the camera's tilt and turn take off.
+const TURN = 14, K = 0.4 / Math.cos((TURN * Math.PI) / 180), R = 15.6, PB = 6, G = 1.8;
+const TOP = R + (97 * 0.4) / Math.sqrt(0.75);
+const M = [[-55.5 * K, TOP], [0, R], [55.5 * K, TOP], [106.5 * K, R]];
+const UJ = -106.5 * K, U0 = UJ - 5, UF = UJ - 2, PULL = [1, 0.5, 0.25, 0.1];
+
+// A smooth minimum: where two parts come within k of each other, a fillet joins them.
+const smin = (a, b, k) => {
+ if (k <= 0) return Math.min(a, b);
+ const h = Math.max(k - Math.abs(a - b), 0) / k;
+ return Math.min(a, b) - (h * h * k) / 4;
+};
+
+// Where f crosses zero on a grid of n × m cells of G from (x0, y0): closed loops of points.
+function trace(f, x0, y0, n, m) {
+ const v = new Float64Array((n + 1) * (m + 1)), pt = new Map(), nb = new Map();
+ for (let j = 0; j <= m; j++) for (let i = 0; i <= n; i++) v[j * (n + 1) + i] = f(x0 + i * G, y0 + j * G);
+ const at = (i, j) => v[j * (n + 1) + i];
+ const edge = (i, j, h) => {
+ const k = 2 * (j * (n + 1) + i) + (h ? 0 : 1);
+ if (!pt.has(k)) { const a = at(i, j), b = h ? at(i + 1, j) : at(i, j + 1), t = a / (a - b); pt.set(k, h ? [x0 + (i + t) * G, y0 + j * G] : [x0 + i * G, y0 + (j + t) * G]); }
+ return k;
+ };
+ const link = (a, b) => { for (const [p, q] of [[a, b], [b, a]]) (nb.get(p) || nb.set(p, []).get(p)).push(q); };
+ for (let j = 0; j < m; j++) for (let i = 0; i < n; i++) {
+ const a = at(i, j) < 0, b = at(i + 1, j) < 0, c = at(i + 1, j + 1) < 0, d = at(i, j + 1) < 0, e = [];
+ if (a !== b) e[0] = edge(i, j, 1);
+ if (b !== c) e[1] = edge(i + 1, j, 0);
+ if (d !== c) e[2] = edge(i, j + 1, 1);
+ if (a !== d) e[3] = edge(i, j, 0);
+ const k = e.filter((x) => x !== undefined);
+ if (k.length === 2) link(k[0], k[1]);
+ else if (k.length === 4) {
+ if ((f(x0 + (i + 0.5) * G, y0 + (j + 0.5) * G) < 0) === a) { link(e[0], e[1]); link(e[2], e[3]); } else { link(e[3], e[0]); link(e[1], e[2]); }
+ }
+ }
+ const loops = [], seen = new Set();
+ for (const s of nb.keys()) {
+ if (seen.has(s)) continue;
+ const loop = [];
+ for (let prev = -1, cur = s; !seen.has(cur);) { seen.add(cur); loop.push(pt.get(cur)); const [p, q] = nb.get(cur), nx = p !== prev ? p : q; prev = cur; cur = nx; }
+ loops.push(loop);
+ }
+ return loops;
+}
+
+function mount({ stage, svg, read }, value) {
+ const bag = disposer();
+ const a = ((TURN - 45) * Math.PI) / 180, ex = Math.cos(a), ey = Math.sin(a);
+ const W = (u, v, z) => [u * ex - v * ey, u * ey + v * ex, z];
+ const B0 = U0 - 20 - R - 7, B1 = M[3][0] + R + 7, V = R + 9;
+
+ const C = Cam(45, 0.5, 1.72);
+ fit(C, [[B0, -V, -PB], [B1, -V, -PB], [B0, V, -PB], [B1, V, -PB], [M[0][0], 0, TOP + R], [M[2][0], 0, TOP + R]].map(([u, v, z]) => W(u, v, z)), 200, 166);
+ const P = proj(C), S = (u, z) => P(...W(u, 0, z)), o = P(0, 0, 0);
+ let rs = 0;
+ for (let i = 0; i < 32; i++) { const q = P(R * Math.cos(i * Math.PI / 16), R * Math.sin(i * Math.PI / 16), 0); rs = Math.max(rs, Math.hypot(q[0] - o[0], q[1] - o[1])); }
+ // A neck is a rod between two centres, as thick as the mark's (its waist is 0.47 of a radius).
+ const KS = 0.5 * rs, WM = 0.47 * rs, D = new Float64Array(9);
+ const rod = (x, y, p, q, t0, t1, w) => {
+ const dx = q[0] - p[0], dy = q[1] - p[1], t = clamp(((x - p[0]) * dx + (y - p[1]) * dy) / (dx * dx + dy * dy), t0, t1);
+ const a = x - p[0] - t * dx, b = y - p[1] - t * dy;
+ return Math.sqrt(a * a + b * b) - w;
+ };
+
+ // The board, turned with the mark: its ring's samples and normals rotated into the world.
+ const turn = (ring) => ring.map((s) => { const [x, y] = W(s.u, s.v, 0), [nx, ny] = W(s.nu, s.nv, 0); return { ...s, u: x, v: y, nu: nx, nv: ny }; });
+ const g = mk("g", {}, svg);
+ put(solid(g), prism(P, facing(C), turn(rrect(B0, -V, B1, V, 12, 8)), turn(rrect(B0 + 2, -V + 2, B1 - 2, V - 2, 10, 8)), -PB, 0));
+ const out = mk("path", { class: "sil" }, g), cr = mk("path", { class: "lo nf" }, g), hi = mk("path", { class: "sil hi nf" }, g);
+
+ const lone = spring(U0), tug = M.map(() => spring(0)), nw = tween(0);
+ let conn = false, over = null, stretch = value, last = "";
+
+ function draw(u, n) {
+ const cs = M.map(([mu, z], i) => S(mu - tug[i].x, z)).concat([S(u, R)]);
+ // The foot's neck: two rods reach from either end, meet (m), then thicken; stretched, it thins.
+ const ub = U0 - stretch, m = clamp(2 * n, 0, 1) / 2;
+ const wL = WM * clamp((u - ub) / (UJ - ub), 0.25, 1) * (0.4 + 0.6 * clamp(2 * n - 1, 0, 1));
+ // Each part's distance, into one buffer: the five spheres, the M's three necks, the foot's.
+ const ds = (x, y) => {
+ for (let i = 0; i < 5; i++) { const a = x - cs[i][0], b = y - cs[i][1]; D[i] = Math.sqrt(a * a + b * b) - rs; }
+ for (let i = 0; i < 3; i++) D[5 + i] = rod(x, y, cs[i], cs[i + 1], 0, 1, WM);
+ D[8] = n > 0.002 ? Math.min(rod(x, y, cs[0], cs[4], 0, m, wL), rod(x, y, cs[0], cs[4], 1 - m, 1, wL)) : 1e3;
+ return D;
+ };
+ const field = (d) => { let v = d[0]; for (let i = 1; i < 9; i++) v = smin(v, d[i], KS); return v; };
+ const f = (x, y) => field(ds(x, y));
+ const xs = cs.map((c) => c[0]), ys = cs.map((c) => c[1]), x0 = Math.min(...xs) - rs - 4, y0 = Math.min(...ys) - rs - 4;
+ const loops = trace(f, x0, y0, Math.ceil((Math.max(...xs) + rs + 4 - x0) / G), Math.ceil((Math.max(...ys) + rs + 4 - y0) / G));
+ out.setAttribute("d", loops.map(poly).join(""));
+ // The bright run: the lone sphere's outline, and once joined, the neck it grew with it.
+ const lit = ([x, y]) => {
+ const d = ds(x, y), o = conn ? Math.min(d[4], d[8]) : d[4];
+ return Math.min(d[0], d[1], d[2], d[3], d[5], d[6], d[7]) >= o;
+ };
+ let h = "";
+ for (const loop of loops) {
+ const on = loop.map(lit), s = on.findIndex((x, i) => x && !on[(i + loop.length - 1) % loop.length]);
+ if (on.every(Boolean)) { h += poly(loop); continue; }
+ if (s < 0) continue;
+ for (let i = 0, run = []; i <= loop.length; i++) {
+ const k = (s + i) % loop.length;
+ if (i < loop.length && on[k]) run.push(loop[k]); else { if (run.length > 1) h += open(run.concat([loop[k]])); run = []; }
+ }
+ }
+ hi.setAttribute("d", h);
+ // A dim crease along each sphere's lower side, broken where a neck leaves it.
+ let d = "";
+ cs.forEach((c, ci) => {
+ let run = [];
+ for (let i = 0; i <= 20; i++) {
+ const t = ((28 + i * 6.2) * Math.PI) / 180, p = [c[0] + (rs - 2.6) * Math.cos(t), c[1] + (rs - 2.6) * Math.sin(t)], e = ds(...p);
+ if (field(e) < e[ci] - 0.3 || Math.min(...e) < e[ci]) { if (run.length > 1) d += open(run); run = []; } else run.push(p);
+ }
+ if (run.length > 1) d += open(run);
+ });
+ cr.setAttribute("d", d);
+ }
+
+ const B = register(stage, (dt, now) => {
+ let moving = stepS(lone, dt);
+ for (const t of tug) if (stepS(t, dt)) moving = true;
+ const n = tval(nw, now), key = [lone.x, n, ...tug.map((t) => t.x)].map((v) => v.toFixed(3)).join() + conn;
+ if (key !== last) { last = key; draw(lone.x, n); }
+ return moving || !tdone(nw, now);
+ });
+ bag.add(B.unregister);
+ draw(U0, 0);
+
+ function retarget() {
+ if (over === null) { lone.t = U0; conn = false; } else {
+ lone.t = clamp(over + UJ - U0 + 2, U0 - stretch - 4, UJ);
+ if (!conn && lone.t >= UF) conn = true;
+ else if (conn && lone.t < U0 - stretch) conn = false;
+ }
+ // Joined, the chain leans to its foot, and the more the neck is stretched the more,
+ // each sphere less the farther along the chain it is.
+ const pull = conn ? clamp(2.2 + (UJ - lone.t) * 0.2, 0, 5) : 0;
+ tug.forEach((t, i) => { t.t = pull * PULL[i]; });
+ tset(nw, conn ? 1 : 0, performance.now(), 0);
+ read.textContent = over === null ? "rest" : `agent · ${conn ? 1 : 0}`;
+ B.wake();
+ }
+
+ // The pointer's x, read as a place on the board's line at the spheres' height. On the
+ // lone sphere or right of it, the sphere is drawn in; left of it, the sphere follows.
+ const s0 = S(0, R)[0], s1 = S(1, R)[0];
+ bag.add(pointer(stage, {
+ move: (p) => { over = (p[0] - s0) / (s1 - s0); retarget(); },
+ leave: () => { over = null; retarget(); },
+ }));
+ bag.add(() => svg.replaceChildren());
+
+ return {
+ set: (v) => { stretch = v; if (over !== null) retarget(); },
+ destroy: bag.dispose,
+ };
+}
+
+hairline({
+ name: "mastra",
+ means: "No agents connected: the pointer draws the lone sphere to the M, a neck forms, stretches, and lets go.",
+ rules: [3, 4, 5, 8],
+ range: [4, 9, 14],
+ mount,
+});
+</script>
+</body>
+</html>
diff --git a/apps/site/public/skill/hairline-notion.html b/apps/site/public/skill/hairline-notion.html
new file mode 100644
index 0000000..17bbdfa
--- /dev/null
+++ b/apps/site/public/skill/hairline-notion.html
@@ -0,0 +1,856 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Hairline figure</title>
+<link rel="icon" href="data:,">
+<style>
+ :root { color-scheme: light; --ground: #ffffff; --ink: #232327; --muted: #6f6f78; --line: #e0e0e4; }
+ @media (prefers-color-scheme: dark) {
+ :root:not([data-theme="light"]) { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ }
+ :root[data-theme="dark"] { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ :root[data-theme="light"] { color-scheme: light; }
+ * { box-sizing: border-box; }
+ body {
+ margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
+ background: var(--ground); color: var(--ink);
+ font: 13px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased;
+ }
+ main { width: 100%; max-width: 640px; }
+ .plate { position: relative; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
+ .tag, .label, output, button { font: 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.02em; }
+ .tag { position: absolute; top: 12px; z-index: 1; color: var(--muted); pointer-events: none; }
+ #name { left: 14px; }
+ #read { right: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
+ .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 14px; }
+ .label { color: var(--muted); }
+ input[type="range"] {
+ flex: 1 1 96px; min-width: 0; height: 32px; margin: 0; background: transparent; cursor: pointer;
+ -webkit-appearance: none; appearance: none;
+ }
+ input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-webkit-slider-thumb {
+ -webkit-appearance: none; width: 13px; height: 13px; margin-top: -6px; border-radius: 50%;
+ border: 1px solid var(--ink); background: var(--ground);
+ }
+ input[type="range"]::-moz-range-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--ink); background: var(--ground); }
+ input[type="range"]:focus-visible, button:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 2px; }
+ output { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
+ button {
+ height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
+ background: transparent; color: var(--ink); cursor: pointer;
+ }
+ #means { margin: 14px 0 0; text-wrap: pretty; }
+ #rules { margin: 6px 0 0; line-height: 1.6; }
+ #error { margin: 12px 0 0; padding-left: 10px; border-left: 1px solid var(--ink); }
+</style>
+</head>
+<body>
+<main>
+ <div class="plate">
+ <span class="tag" id="name"></span>
+ <span class="tag" id="read"></span>
+ <div id="stage"></div>
+ </div>
+ <div class="controls">
+ <label class="label" for="intensity">intensity</label>
+ <input id="intensity" type="range" min="0" max="1" step="0.01" value="0.5">
+ <output id="value" for="intensity"></output>
+ <span class="label">theme</span>
+ <button id="theme" type="button" aria-label="Switch between the light and the dark theme"></button>
+ </div>
+ <p id="means"></p>
+ <p id="rules" class="label"></p>
+ <p id="error" role="alert" hidden></p>
+</main>
+<script id="hl-kernel">
+/* hairline kernel sha256:8e2abcbdf63c7755195ee942c39e9c8ea6a539d1147e986dd1c153559121f075 */
+/*
+ * HL: everything a figure may call. Read this index; the code under it is the
+ * package's src/core, unchanged, and a figure should not need to read it.
+ *
+ * Every figure is drawn in a 400 × 320 viewBox. World space is x/y on the
+ * ground and z up. Plates are filled with the ground colour and painted back
+ * to front, so a nearer one covers a farther one: append in that order. At
+ * the default camera, Cam(45, 0.5, S), +x runs down to the right and +y down
+ * to the left, so the corner with the largest x and y is nearest the viewer:
+ * append by ascending x + y, from the far corner (smallest x and y) to it.
+ *
+ * Camera
+ * Cam(azDeg, k, S) a camera: azimuth in degrees, k = sin(elevation) (0.5 is the 2:1 view), S = scale
+ * fit(C, points, cx, cy) centres the box of [x, y, z] points on (cx, cy); call it once, before proj
+ * it only centres, it never scales: choose S by trying values, with the most extreme pose in points.
+ * The six figures use S 1.42 to 2.12; the boxes they fit come out 230 to 310 wide and 180 to 245 tall
+ * proj(C) returns P(x, y, z), which gives [sx, sy]
+ * unproj(C, sx, sy, z) the world [x, y] under a screen point, on the plane at height z
+ * facing(C) returns front(sample): whether a ring sample faces the camera
+ * Rounded solids
+ * rrect(u0, v0, u1, v1, r, n) a rounded rectangle, as a ring of samples {u, v, nu, nv}
+ * circ(R, n) a circle, as a ring
+ * rings(x0, y0, x1, y1, r, b) [ring, inner]: a rounded footprint and its crease ring, inset by b
+ * r, the corner radius, is cut to half the shorter side. b, the crease's inset in world units
+ * (0.6 to 2.2 in the figures), must stay under half the shorter side or the crease turns inside out
+ * prism(P, front, ring, inner, z0, z1) {sil, crease}: a solid standing from z0 to z1, as two path strings
+ * ringAt(P, ring, z) the ring's points, projected at height z
+ * run(ring, keep) the one cyclic run of samples that pass keep
+ * hull(points) the convex hull of screen points
+ * extremes(P, ring) [left, right, nearest] samples: where dashed drops fall from
+ * fillet(points, radii, n) rounds every vertex of a closed polygon; returns the new points
+ * radii is an array, one radius per vertex, each cut to half its shorter edge; a single number gives NaN.
+ * n is the steps round each corner, default 4: each vertex becomes n + 1 points
+ * ghost(P, front, ring, z0, depth) a reflection's path {d, y0, y1}; reflect() draws it for you
+ * Paths and numbers
+ * poly(points) a closed path string
+ * open(points) an open polyline string
+ * seg(a, b) one segment between two screen points [sx, sy], as its own subpath; project world points with P first
+ * clamp(v, a, b)
+ * lerp(a, b, t)
+ * rad(deg)
+ * r2(n) two decimals
+ * The continuous clock: one spring per moving number
+ * spring(x, opts) at rest on x; write .t to retarget; opts {k, c, m, eps}, default k 100, c 18, m 1
+ * stepS(sp, dt) advances by dt seconds; returns whether it is still moving
+ * The discrete clock: a 700ms tween on (.32, .72, 0, 1)
+ * tween(v, dur) at rest on v; dur defaults to 700 (ms)
+ * tset(tw, to, now, delay) retargets from where it is, after delay ms: the stagger
+ * the same target again does nothing, so calling it on every pointer move is safe
+ * tval(tw, now) its value at now
+ * tdone(tw, now) whether it has landed
+ * bezier(x1, y1, x2, y2) a CSS cubic-bezier, as a function of progress
+ * EASE_LIFT the lift curve itself
+ * reducedMotion() true when the reader asked for less motion; springs and tweens already land at once
+ * setReducedMotion(on) the loop's business, not a figure's
+ * Drawing
+ * mk(tag, attrs, parent) one svg element: the only way a figure makes a node
+ * solid(parent) {g, sil, cr}: a group holding a silhouette path and a crease path
+ * put(solid, paths) writes prism()'s {sil, crease} into solid()'s {sil, cr}: sil into sil, crease into cr
+ * flatDot(parent, C, r, cls) a dot lying on the ground plane; cls is "dot", "dot m" or "dot off"
+ * place(el, point) moves a dot or a circle to [sx, sy]
+ * reflect(svg, parent, P, front, ring, z0, depth) a fading mirror under a solid
+ * fade(svg, y0, y1, a0) a vertical fade, as a mask; returns the value for a mask attribute
+ * Life
+ * register(stage, tick) joins the one frame loop; tick(dt in seconds, now in ms) returns true to ask for another frame; gives {wake, unregister}
+ * pointer(stage, handlers) {move(point), down(point), leave()}, points in viewBox units; returns its disposer
+ * disposer() {add, on, dispose}: collects tear-down, so destroy is bag.dispose
+ * The bench's business, not a figure's
+ * css(lightDark)
+ * inject(root)
+ *
+ * Classes, on path, polygon, ellipse and line. They are the whole palette; a
+ * figure sets no colour, width or fill of its own.
+ * (none) filled with the ground colour, medium stroke
+ * sil the silhouette's stroke hi the bright stroke: the only highlight
+ * lo the dim stroke nf no fill fo fill only, no stroke
+ * dash a dashed guide
+ * dot a bright dot dot m a medium dot dot off a dim dot
+ */
+var HL = (() => {
+ var __defProp = Object.defineProperty;
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
+ var __getOwnPropNames = Object.getOwnPropertyNames;
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
+ var __export = (target, all) => {
+ for (var name in all)
+ __defProp(target, name, { get: all[name], enumerable: true });
+ };
+ var __copyProps = (to, from, except, desc) => {
+ if (from && typeof from === "object" || typeof from === "function") {
+ for (let key of __getOwnPropNames(from))
+ if (!__hasOwnProp.call(to, key) && key !== except)
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
+ }
+ return to;
+ };
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
+
+ // packages/hairline/src/core/kernel.ts
+ var kernel_exports = {};
+ __export(kernel_exports, {
+ Cam: () => Cam,
+ EASE_LIFT: () => EASE_LIFT,
+ bezier: () => bezier,
+ circ: () => circ,
+ clamp: () => clamp,
+ css: () => css,
+ disposer: () => disposer,
+ extremes: () => extremes,
+ facing: () => facing,
+ fade: () => fade,
+ fillet: () => fillet,
+ fit: () => fit,
+ flatDot: () => flatDot,
+ ghost: () => ghost,
+ hull: () => hull,
+ inject: () => inject,
+ lerp: () => lerp,
+ mk: () => mk,
+ open: () => open,
+ place: () => place,
+ pointer: () => pointer,
+ poly: () => poly,
+ prism: () => prism,
+ proj: () => proj,
+ put: () => put,
+ r2: () => r2,
+ rad: () => rad,
+ reducedMotion: () => reducedMotion,
+ reflect: () => reflect,
+ register: () => register,
+ ringAt: () => ringAt,
+ rings: () => rings,
+ rrect: () => rrect,
+ run: () => run,
+ seg: () => seg,
+ setReducedMotion: () => setReducedMotion,
+ solid: () => solid,
+ spring: () => spring,
+ stepS: () => stepS,
+ tdone: () => tdone,
+ tset: () => tset,
+ tval: () => tval,
+ tween: () => tween,
+ unproj: () => unproj
+ });
+
+ // packages/hairline/src/core/iso.ts
+ var clamp = (v, a, b) => Math.max(a, Math.min(b, v));
+ var lerp = (a, b, t) => a + (b - a) * t;
+ var rad = (d) => d * Math.PI / 180;
+ var r2 = (n) => Math.round(n * 100) / 100;
+ var poly = (pts) => "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L") + "Z";
+ var seg = (a, b) => `M${r2(a[0])} ${r2(a[1])}L${r2(b[0])} ${r2(b[1])}`;
+ var open = (pts) => pts.length < 2 ? "" : "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L");
+ var Cam = (azDeg, k, S) => ({ az: rad(azDeg), k, S, ox: 0, oy: 0 });
+ function proj(C) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ return (x, y, z) => {
+ const X = x * c - y * s, Y = x * s + y * c;
+ return [C.ox + C.S * X, C.oy + C.S * (Y * C.k - z * zf)];
+ };
+ }
+ function unproj(C, sx, sy, z) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ const X = (sx - C.ox) / C.S, Y = ((sy - C.oy) / C.S + z * zf) / C.k;
+ return [X * c + Y * s, -X * s + Y * c];
+ }
+ function fit(C, pts, cx, cy) {
+ C.ox = 0;
+ C.oy = 0;
+ const P = proj(C);
+ let a = 1e9, b = -1e9, c = 1e9, d = -1e9;
+ for (const p of pts) {
+ const q = P(p[0], p[1], p[2]);
+ a = Math.min(a, q[0]);
+ b = Math.max(b, q[0]);
+ c = Math.min(c, q[1]);
+ d = Math.max(d, q[1]);
+ }
+ C.ox = cx - (a + b) / 2;
+ C.oy = cy - (c + d) / 2;
+ }
+ function rrect(u0, v0, u1, v1, r, n = 4) {
+ r = Math.max(0, Math.min(r, (u1 - u0) / 2, (v1 - v0) / 2));
+ const out = [];
+ for (const [cu, cv, a0] of [[u1 - r, v1 - r, 0], [u0 + r, v1 - r, 90], [u0 + r, v0 + r, 180], [u1 - r, v0 + r, 270]])
+ for (let k = 0; k <= n; k++) {
+ const a = rad(a0 + 90 * k / n), ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: cu + r * ca, v: cv + r * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function circ(R, n = 96) {
+ const out = [];
+ for (let k = 0; k < n; k++) {
+ const a = k / n * Math.PI * 2, ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: R * ca, v: R * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function hull(input) {
+ const pts = input.slice().sort((a, b) => a[0] - b[0] || a[1] - b[1]);
+ const x = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
+ const lo = [], up = [];
+ for (const p of pts) {
+ while (lo.length > 1 && x(lo[lo.length - 2], lo[lo.length - 1], p) <= 0) lo.pop();
+ lo.push(p);
+ }
+ for (let i = pts.length - 1; i >= 0; i--) {
+ const p = pts[i];
+ while (up.length > 1 && x(up[up.length - 2], up[up.length - 1], p) <= 0) up.pop();
+ up.push(p);
+ }
+ lo.pop();
+ up.pop();
+ return lo.concat(up);
+ }
+ var ringAt = (P, ring, z) => ring.map((q) => P(q.u, q.v, z));
+ var facing = (C) => {
+ const s = Math.sin(C.az), c = Math.cos(C.az);
+ return (q) => q.nu * s + q.nv * c >= -1e-6;
+ };
+ function run(ring, keep) {
+ const n = ring.length;
+ let s = -1;
+ for (let i = 0; i < n; i++) if (keep(ring[i]) && !keep(ring[(i + n - 1) % n])) {
+ s = i;
+ break;
+ }
+ if (s < 0) return keep(ring[0]) ? ring.slice() : [];
+ const out = [];
+ for (let k = 0; k < n && keep(ring[(s + k) % n]); k++) out.push(ring[(s + k) % n]);
+ return out;
+ }
+ function prism(P, front, ring, inner, z0, z1) {
+ return {
+ sil: poly(hull(ringAt(P, ring, z1).concat(ringAt(P, ring, z0)))),
+ crease: inner ? open(ringAt(P, run(inner, front), z1)) : ""
+ };
+ }
+ var rings = (x0, y0, x1, y1, r, b) => [
+ rrect(x0, y0, x1, y1, r),
+ rrect(x0 + b, y0 + b, x1 - b, y1 - b, Math.max(0.3, r - b))
+ ];
+ function extremes(P, ring) {
+ const pr = ring.map((q) => P(q.u, q.v, 0));
+ let a = 0, b = 0, c = 0;
+ pr.forEach((p, k) => {
+ if (p[0] < pr[a][0]) a = k;
+ if (p[0] > pr[b][0]) b = k;
+ if (p[1] > pr[c][1]) c = k;
+ });
+ return [ring[a], ring[b], ring[c]];
+ }
+ function fillet(pts, rs, n = 4) {
+ const m = pts.length, out = [];
+ for (let i = 0; i < m; i++) {
+ const a = pts[(i + m - 1) % m], p = pts[i], b = pts[(i + 1) % m];
+ const la = Math.hypot(a[0] - p[0], a[1] - p[1]), lb = Math.hypot(b[0] - p[0], b[1] - p[1]);
+ const t = Math.min(rs[i], la / 2, lb / 2);
+ const p1 = [p[0] + (a[0] - p[0]) / la * t, p[1] + (a[1] - p[1]) / la * t];
+ const p2 = [p[0] + (b[0] - p[0]) / lb * t, p[1] + (b[1] - p[1]) / lb * t];
+ for (let k = 0; k <= n; k++) {
+ const s = k / n, w = 1 - s;
+ out.push([w * w * p1[0] + 2 * w * s * p[0] + s * s * p2[0], w * w * p1[1] + 2 * w * s * p[1] + s * s * p2[1]]);
+ }
+ }
+ return out;
+ }
+ function ghost(P, front, ring, z0, depth) {
+ const f = run(ring, front), lowP = ringAt(P, f, z0 - depth);
+ return {
+ d: open(lowP) + [f[0], f[f.length - 1]].map((q) => seg(P(q.u, q.v, z0), P(q.u, q.v, z0 - depth))).join(""),
+ y0: Math.min(...ringAt(P, f, z0).map((p) => p[1])),
+ y1: Math.max(...lowP.map((p) => p[1])) + 2
+ };
+ }
+
+ // packages/hairline/src/core/motion.ts
+ var reduced = false;
+ var setReducedMotion = (on) => {
+ reduced = on;
+ };
+ var reducedMotion = () => reduced;
+ function spring(x, o = {}) {
+ return { x, v: 0, t: x, k: o.k ?? 100, c: o.c ?? 18, m: o.m ?? 1, eps: o.eps ?? 0.01 };
+ }
+ function stepS(sp, dt) {
+ if (reduced) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ const n = Math.max(1, Math.ceil(dt * 240)), h = dt / n;
+ for (let i = 0; i < n; i++) {
+ const a = (-sp.k * (sp.x - sp.t) - sp.c * sp.v) / sp.m;
+ sp.v += a * h;
+ sp.x += sp.v * h;
+ }
+ if (Math.abs(sp.x - sp.t) < sp.eps && Math.abs(sp.v) < sp.eps * 10) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ return true;
+ }
+ function bezier(x1, y1, x2, y2) {
+ const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx;
+ const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by;
+ const X = (u) => ((ax * u + bx) * u + cx) * u;
+ const Y = (u) => ((ay * u + by) * u + cy) * u;
+ const dX = (u) => (3 * ax * u + 2 * bx) * u + cx;
+ return (t) => {
+ if (t <= 0) return 0;
+ if (t >= 1) return 1;
+ let u = t;
+ for (let i = 0; i < 8; i++) {
+ const e = X(u) - t;
+ if (Math.abs(e) < 1e-5) break;
+ const d = dX(u);
+ if (Math.abs(d) < 1e-6) break;
+ u -= e / d;
+ }
+ if (!(u >= 0 && u <= 1) || Math.abs(X(u) - t) > 1e-4) {
+ let lo = 0, hi = 1;
+ u = t;
+ for (let i = 0; i < 24; i++) {
+ if (X(u) < t) lo = u;
+ else hi = u;
+ u = (lo + hi) / 2;
+ }
+ }
+ return Y(u);
+ };
+ }
+ var EASE_LIFT = bezier(0.32, 0.72, 0, 1);
+ var tween = (v, dur = 700) => ({ from: v, to: v, t0: -1e9, dur });
+ var tval = (tw, now) => {
+ const p = clamp((now - tw.t0) / tw.dur, 0, 1);
+ return tw.from + (tw.to - tw.from) * (reduced ? 1 : EASE_LIFT(p));
+ };
+ var tset = (tw, to, now, delay) => {
+ if (tw.to === to) return;
+ tw.from = tval(tw, now);
+ tw.to = to;
+ tw.t0 = now + delay;
+ };
+ var tdone = (tw, now) => reduced || now >= tw.t0 + tw.dur;
+
+ // packages/hairline/src/core/stage.ts
+ var NS = "http://www.w3.org/2000/svg";
+ function mk(tag, attrs, parent) {
+ const e = document.createElementNS(NS, tag);
+ if (attrs) for (const k in attrs) e.setAttribute(k, String(attrs[k]));
+ if (parent) parent.appendChild(e);
+ return e;
+ }
+ function solid(parent) {
+ const g = mk("g", {}, parent);
+ return { g, sil: mk("path", { class: "sil" }, g), cr: mk("path", { class: "nf lo" }, g) };
+ }
+ var put = (el, s) => {
+ el.sil.setAttribute("d", s.sil);
+ el.cr.setAttribute("d", s.crease);
+ };
+ var flatDot = (parent, C, r, cls) => mk("ellipse", { rx: r2(r * C.S), ry: r2(r * C.S * C.k), class: cls }, parent);
+ var place = (el, q) => {
+ el.setAttribute("cx", String(r2(q[0])));
+ el.setAttribute("cy", String(r2(q[1])));
+ };
+ var fid = 0;
+ function fade(svg, y0, y1, a0 = 0.7) {
+ const id = "hl-fd" + ++fid, defs = mk("defs", {}, svg);
+ const lg = mk("linearGradient", { id: id + "g", gradientUnits: "userSpaceOnUse", x1: 0, y1: r2(y0), x2: 0, y2: r2(y1) }, defs);
+ mk("stop", { offset: 0, "stop-color": "#fff", "stop-opacity": a0 }, lg);
+ mk("stop", { offset: 1, "stop-color": "#fff", "stop-opacity": 0 }, lg);
+ const m = mk("mask", { id, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: 400, height: 320 }, defs);
+ mk("rect", { x: 0, y: 0, width: 400, height: 320, fill: `url(#${id}g)` }, m);
+ return `url(#${id})`;
+ }
+ function reflect(svg, parent, P, front, ring, z0, depth) {
+ const r = ghost(P, front, ring, z0, depth);
+ const gh = mk("g", { class: "ghost", mask: fade(svg, r.y0, r.y1) }, parent);
+ mk("path", { d: r.d }, gh);
+ }
+ var boards = [];
+ var byStage = /* @__PURE__ */ new Map();
+ var raf = 0;
+ var last = 0;
+ var io = null;
+ var rm = null;
+ function frame(now) {
+ const dt = Math.min(0.05, Math.max(0, (now - last) / 1e3));
+ last = now;
+ let any = false;
+ for (const b of boards.slice()) if (b.vis && b.awake) {
+ b.awake = !!b.tick(dt, now);
+ any = any || b.awake;
+ }
+ raf = any ? requestAnimationFrame(frame) : 0;
+ }
+ function wake(b) {
+ b.awake = true;
+ if (!raf) {
+ last = performance.now();
+ raf = requestAnimationFrame(frame);
+ }
+ }
+ var onMotion = () => {
+ setReducedMotion(!!rm?.matches);
+ boards.forEach(wake);
+ };
+ function start() {
+ if (io) return;
+ io = new IntersectionObserver((es) => {
+ for (const e of es) {
+ const b = byStage.get(e.target);
+ if (!b) continue;
+ b.vis = e.isIntersecting;
+ if (b.vis) wake(b);
+ }
+ }, { rootMargin: "80px" });
+ rm = matchMedia("(prefers-reduced-motion: reduce)");
+ setReducedMotion(rm.matches);
+ rm.addEventListener("change", onMotion);
+ }
+ function stop() {
+ if (raf) cancelAnimationFrame(raf);
+ raf = 0;
+ io?.disconnect();
+ io = null;
+ rm?.removeEventListener("change", onMotion);
+ rm = null;
+ }
+ function register(stage, tick) {
+ start();
+ const b = { stage, tick, vis: false, awake: true };
+ boards.push(b);
+ byStage.set(stage, b);
+ io.observe(stage);
+ tick(0, performance.now());
+ let gone = false;
+ return {
+ wake: () => {
+ if (!gone) wake(b);
+ },
+ unregister: () => {
+ if (gone) return;
+ gone = true;
+ boards = boards.filter((x) => x !== b);
+ if (byStage.get(stage) === b) {
+ byStage.delete(stage);
+ io?.unobserve(stage);
+ }
+ if (!boards.length) stop();
+ }
+ };
+ }
+ function pointer(stage, on) {
+ let tm = 0;
+ const pt = (e) => {
+ const r = stage.getBoundingClientRect();
+ return [(e.clientX - r.left) / r.width * 400, (e.clientY - r.top) / r.height * 320];
+ };
+ const move = (e) => {
+ clearTimeout(tm);
+ on.move(pt(e), e);
+ };
+ const down = (e) => {
+ clearTimeout(tm);
+ if (e.pointerType !== "mouse") stage.releasePointerCapture?.(e.pointerId);
+ if (on.down) on.down(pt(e), e);
+ else on.move(pt(e), e);
+ };
+ const leave = (e) => {
+ clearTimeout(tm);
+ tm = window.setTimeout(() => on.leave(e), e.pointerType === "mouse" ? 0 : 1400);
+ };
+ stage.addEventListener("pointermove", move);
+ stage.addEventListener("pointerdown", down);
+ stage.addEventListener("pointerleave", leave);
+ return () => {
+ clearTimeout(tm);
+ stage.removeEventListener("pointermove", move);
+ stage.removeEventListener("pointerdown", down);
+ stage.removeEventListener("pointerleave", leave);
+ };
+ }
+ function disposer() {
+ let fns = [];
+ return {
+ add: (fn) => {
+ fns.push(fn);
+ },
+ on: (target, type, fn, opts) => {
+ const h = fn;
+ target.addEventListener(type, h, opts);
+ fns.push(() => target.removeEventListener(type, h, opts));
+ },
+ dispose: () => {
+ const run2 = fns;
+ fns = [];
+ for (let i = run2.length - 1; i >= 0; i--) run2[i]();
+ }
+ };
+ }
+
+ // packages/hairline/src/core/styles.ts
+ var LIGHT = { plate: "#ffffff", hi: "#232327", edge: "#a4a4ac", mid: "#c3c3c9", lo: "#e0e0e4" };
+ var DARK = { plate: "#08090a", hi: "#d0d6e0", edge: "#5b5d64", mid: "#3e3e44", lo: "#29292d" };
+ var KEYS = ["plate", "hi", "edge", "mid", "lo"];
+ var vars = (p) => KEYS.map((k) => `--hl-${k}:var(--hairline-${k},${p[k]});`).join("");
+ var EASE = "cubic-bezier(0.5,0,0.1,1)";
+ var SVG = ":where([data-hairline]>svg)";
+ function css(lightDark) {
+ const both = Object.fromEntries(KEYS.map((k) => [k, `light-dark(${LIGHT[k]},${DARK[k]})`]));
+ return [
+ // the box, and the palette: light unless something below says otherwise
+ `:where([data-hairline]){display:block;position:relative;aspect-ratio:5/4;touch-action:pan-y;user-select:none;-webkit-user-select:none;--hl-sw:var(--hairline-stroke,0.9);${vars(LIGHT)}}`,
+ // the page's color-scheme
+ lightDark ? `:where([data-hairline]){${vars(both)}}` : "",
+ // an ancestor that says dark
+ `:where(.dark,[data-theme="dark"]) :where([data-hairline]){${vars(DARK)}}`,
+ // the figure's own theme option
+ `:where([data-hairline][data-hairline-theme="light"]){${vars(LIGHT)}}`,
+ `:where([data-hairline][data-hairline-theme="dark"]){${vars(DARK)}}`,
+ `:where([data-hairline]:focus-visible){outline:1.5px solid var(--hl-hi);outline-offset:2px}`,
+ `${SVG}{position:absolute;inset:0;width:100%;height:100%;display:block}`,
+ // Riffle's live region: read, not seen
+ `:where([data-hairline]>[data-hairline-live]){position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}`,
+ // the drawing: plates are filled with the plate colour and painted back to front
+ `${SVG} :where(path,polygon,ellipse,line){fill:var(--hl-plate);stroke:var(--hl-mid);stroke-width:var(--hl-sw);vector-effect:non-scaling-stroke;stroke-linejoin:round;stroke-linecap:round;transition:stroke 260ms ${EASE}}`,
+ `${SVG} :where(.nf){fill:none}`,
+ `${SVG} :where(.fo){stroke:none}`,
+ `${SVG} :where(.sil){stroke:var(--hl-edge)}`,
+ `${SVG} :where(.hi){stroke:var(--hl-hi)}`,
+ `${SVG} :where(.lo){stroke:var(--hl-lo)}`,
+ `${SVG} :where(.dash){stroke-dasharray:1 3}`,
+ `${SVG} :where(.dot){stroke:none;fill:var(--hl-hi);transition:fill 260ms ${EASE}}`,
+ `${SVG} :where(.dot.m){fill:var(--hl-edge)}`,
+ `${SVG} :where(.dot.off){fill:var(--hl-lo)}`,
+ `${SVG} :where(.ghost path){fill:none;stroke:var(--hl-mid)}`
+ ].join("");
+ }
+ var done = /* @__PURE__ */ new WeakSet();
+ function inject(root) {
+ if (done.has(root)) return;
+ done.add(root);
+ const doc = root.nodeType === 9 ? root : root.ownerDocument;
+ const win = doc.defaultView;
+ const text = css(!!win?.CSS?.supports?.("color", "light-dark(#000,#fff)"));
+ if (win && "adoptedStyleSheets" in root) {
+ try {
+ const sheet = new win.CSSStyleSheet();
+ sheet.replaceSync(text);
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
+ return;
+ } catch {
+ }
+ }
+ const style = doc.createElement("style");
+ style.setAttribute("data-hairline-style", "");
+ style.textContent = text;
+ (root.nodeType === 9 ? doc.head ?? doc.documentElement : root).appendChild(style);
+ }
+ return __toCommonJS(kernel_exports);
+})();
+/* /hairline kernel */
+</script>
+<script id="hl-bench">
+/*
+ * The bench: the page a figure is shown on. It makes the host and the svg the
+ * way the package's mount does, hands them to the figure, and owns everything
+ * around it: the read-out, the slider, the theme, the line under the stage.
+ */
+(() => {
+ const RULES = ["hit", "order", "reach", "accent", "rest", "honesty", "cost", "clock", "radius", "quiet"];
+ const $ = (id) => document.getElementById(id);
+ const root = document.documentElement, params = new URLSearchParams(location.search);
+
+ /* the theme: the system's until the switch is pressed, then the switch's */
+ const dark = () => (root.dataset.theme ? root.dataset.theme === "dark" : matchMedia("(prefers-color-scheme: dark)").matches);
+ const label = () => { $("theme").textContent = dark() ? "dark" : "light"; };
+ $("theme").addEventListener("click", () => { root.dataset.theme = dark() ? "light" : "dark"; label(); });
+ /* ?theme=light or ?theme=dark wins over the system's, as pressing the switch does */
+ if (["light", "dark"].includes(params.get("theme"))) root.dataset.theme = params.get("theme");
+ label();
+
+ /* ?intensity=0 sets the slider before the figure mounts, for a look at either end */
+ const i = (params.get("intensity") || "").trim();
+ if (i && Number.isFinite(Number(i))) $("intensity").value = String(Math.min(1, Math.max(0, Number(i))));
+
+ /* ?w=240 narrows the page, for a look at the size of a thumbnail */
+ const w = Number(params.get("w"));
+ if (w > 0) document.querySelector("main").style.maxWidth = w + "px";
+
+ /* a figure that fails says so under the stage, instead of leaving an empty plate */
+ addEventListener("error", (e) => {
+ $("error").hidden = false;
+ $("error").textContent = String((e.error && e.error.message) || e.message);
+ });
+
+ let mounted = false;
+ window.hairline = (figure) => {
+ if (mounted) throw new Error("hairline: one figure per page.");
+ mounted = true;
+ const stage = $("stage"), slider = $("intensity");
+
+ /* intensity to the figure's own number: two straight lines that meet at 0.5, as in the package */
+ const [lo, mid, hi] = figure.range;
+ const at = (i) => Math.round((i <= 0.5 ? lo + (i / 0.5) * (mid - lo) : mid + ((i - 0.5) / 0.5) * (hi - mid)) * 1000) / 1000;
+
+ HL.inject(document);
+ stage.setAttribute("data-hairline", figure.name);
+ stage.setAttribute("role", "img");
+ stage.setAttribute("aria-label", figure.means);
+ const svg = HL.mk("svg", { viewBox: "0 0 400 320", "aria-hidden": "true" }, stage);
+
+ let text = null;
+ const read = {
+ get textContent() { return text; },
+ set textContent(value) { text = value == null ? "" : String(value); $("read").textContent = text; },
+ };
+
+ document.title = "Hairline · " + figure.name;
+ $("name").textContent = figure.name;
+ $("means").textContent = figure.means;
+ $("rules").textContent = figure.rules.map((n) => String(n).padStart(2, "0") + " " + RULES[n - 1]).join(" · ");
+ const show = () => { $("value").textContent = String(at(Number(slider.value))); };
+ show();
+
+ const handle = figure.mount({ stage, svg, read }, at(Number(slider.value)));
+ if (text === null) read.textContent = "rest";
+ slider.addEventListener("input", () => { show(); handle.set(at(Number(slider.value))); });
+ window.hairline.figure = handle;
+
+ /* ?at=200,160 holds the pointer at a viewBox point, for a picture of the answer without a mouse */
+ const p = (params.get("at") || "").split(",").map(Number);
+ if (p.length === 2 && p.every(Number.isFinite)) {
+ const r = stage.getBoundingClientRect();
+ stage.dispatchEvent(new PointerEvent("pointermove", {
+ pointerType: "mouse", pointerId: 1, bubbles: true,
+ clientX: r.left + (p[0] / 400) * r.width, clientY: r.top + (p[1] / 320) * r.height,
+ }));
+ }
+ };
+})();
+</script>
+<script type="module" id="hl-figure">
+/**
+ * Notion: the mark's cube built as a box with a lid, its serif N a relief on
+ * the front face, inside a framed panel. The lid is hinged on the far edge and
+ * the pointer's height opens it, on a spring: low closes it, high throws it
+ * back. Inside there is nothing: a bare well whose floor seam is the bright
+ * mark at rest. Under the pointer the lid takes the bright stroke and the
+ * read-out gives its angle and what the box holds, none. The slider is how far
+ * the lid can open, in degrees.
+ *
+ * The pattern: a continuous position on one spring, read from the pointer's
+ * own height (never from the moving lid), and an empty state built from a mark.
+ */
+const {
+ Cam, clamp, facing, fillet, fit, hull, open, poly, proj, rad, ringAt, rrect, run, spring, stepS,
+ disposer, mk, pointer, register,
+} = HL;
+
+const L = 96, H = 86, LT = 10, T = 9, F = 52, R = 12, RD = 3, REST = 58, WIDEST = 125;
+
+/** A run of points ordered left to right on screen. */
+const LR = (pts) => (pts[0][0] <= pts[pts.length - 1][0] ? pts : pts.slice().reverse());
+
+/** The N, serif, thin stems and a thick diagonal, in a 100 × 100 box: s to the right, t up. */
+const NG = [
+ [0, 100], [38, 100], [79, 28], [79, 93], [68, 93], [68, 100], [100, 100], [100, 93], [88, 93], [88, 0],
+ [68, 0], [21, 72], [21, 7], [33, 7], [33, 0], [0, 0], [0, 7], [12, 7], [12, 93], [0, 93],
+];
+const NW = 52, NH = 46;
+
+/** A point of the lid, hinged on the far edge (x 0, z H): u away from the hinge, v along it, w through its thickness. */
+const lidPt = (u, v, w, th) => {
+ const c = Math.cos(rad(th)), s = Math.sin(rad(th));
+ return [u * c - w * s, v, H + u * s + w * c];
+};
+
+function mount({ stage, svg, read }, value) {
+ const bag = disposer();
+ let widest = value, over = false;
+
+ // Fitted to the box with the lid at rest, upright and thrown back as far as the slider allows.
+ const C = Cam(45, 0.5, 1.12), ext = [];
+ for (const th of [0, REST, 90, WIDEST]) for (const [u, v, w] of [[0, 0, LT], [0, L, LT], [L, 0, 0], [L, L, 0], [L, 0, LT], [L, L, LT]]) ext.push(lidPt(u, v, w, th));
+ fit(C, ext.concat([[0, 0, 0], [L, 0, 0], [0, L, 0], [L, L, 0]]), 200, 166);
+ const P = proj(C), front = facing(C);
+
+ // Toward the camera, from the projection itself: the cross of its two screen rows, pointing up.
+ const o = P(0, 0, 0), ax = [0, 1, 2].map((k) => [k === 0, k === 1, k === 2].map(Number));
+ const a = ax.map((e) => P(...e)[0] - o[0]), b = ax.map((e) => P(...e)[1] - o[1]);
+ let V = [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
+ if (V[2] < 0) V = V.map((n) => -n);
+
+ const outer = rrect(0, 0, L, L, R, 6), inner = rrect(T, T, L - T, L - T, R - T, 4);
+ const g = mk("g", {}, svg);
+
+ // The box, far half: body, the opening, and the floor seam along the far walls.
+ mk("path", { d: poly(hull(ringAt(P, outer, 0).concat(ringAt(P, outer, H)))), class: "sil" }, g);
+ mk("path", { d: poly(ringAt(P, inner, H)), class: "nf" }, g);
+ const seam = mk("path", { d: open(ringAt(P, run(inner, (q) => !front(q)), F)), class: "nf hi" }, g);
+
+ // Near half: one opaque piece from the opening's near edge down to the foot, which hides the floor behind the near walls.
+ const iF = LR(ringAt(P, run(inner, front), H)), oT = LR(ringAt(P, run(outer, front), H)), oB = LR(ringAt(P, run(outer, front), 0));
+ mk("path", { d: poly([...iF, oT[oT.length - 1], ...oB.slice().reverse(), oT[0]]), class: "fo" }, g);
+ mk("path", { d: open(oT), class: "nf lo" }, g);
+ mk("path", { d: open(iF), class: "nf" }, g);
+ mk("path", { d: open([oT[0], ...oB, oT[oT.length - 1]]), class: "nf sil" }, g);
+
+ // The front face (x = L), seen from outside: s runs left to right on screen, which is y from L down to 0.
+ const onFace = (s, z, d) => P(L + d, L - s, z);
+ const panel = rrect(14, 11, L - 14, H - 11, 7, 5).map((q) => onFace(q.u, q.v, 0));
+ mk("path", { d: poly(panel), class: "nf lo" }, g);
+ const glyph = fillet(NG, NG.map(() => 1.6), 2).map(([s, t]) => [L / 2 - NW / 2 + (s * NW) / 100, H / 2 - NH / 2 + (t * NH) / 100]);
+ mk("path", { d: poly(glyph.map(([s, z]) => onFace(s, z, 0))), class: "lo" }, g);
+ mk("path", { d: poly(glyph.map(([s, z]) => onFace(s, z, RD))) }, g);
+
+ // The lid, painted last: past 39° it stands beyond the hinge and covers nothing of the box.
+ const lidRing = rrect(0, 0, L, L, R, 6), lidIn = rrect(1.2, 1.2, L - 1.2, L - 1.2, R - 1.2, 6);
+ const lidSil = mk("path", { class: "sil" }, g), lidCr = mk("path", { class: "nf lo" }, g);
+ const sp = spring(REST, { eps: 0.05 });
+ let drawn = NaN;
+
+ function drawLid() {
+ const th = sp.x;
+ if (th === drawn) return;
+ drawn = th;
+ const c = Math.cos(rad(th)), s = Math.sin(rad(th));
+ const W = (q, w) => P(...lidPt(q.u, q.v, w, th));
+ // which face is toward us, and which of its edges have the lid's thickness showing below them
+ const wf = -s * V[0] + c * V[2] > 0 ? LT : 0;
+ const side = (q) => q.nu * c * V[0] + q.nv * V[1] + q.nu * s * V[2] > 0;
+ lidSil.setAttribute("d", poly(hull(lidRing.map((q) => W(q, 0)).concat(lidRing.map((q) => W(q, LT))))));
+ lidCr.setAttribute("d", open(run(lidIn, side).map((q) => W(q, wf))));
+ }
+ drawLid();
+
+ const B = register(stage, (dt) => {
+ const m = stepS(sp, dt);
+ drawLid();
+ return m;
+ });
+ bag.add(B.unregister);
+
+ // The pointer's height, between the closed lip and the lip held upright, is how far the lid opens.
+ const yShut = P(L, L / 2, H + LT)[1], yUp = P(0, L / 2, H + L)[1];
+ let py = null;
+ function retarget() {
+ over = py !== null;
+ sp.t = over ? clamp((yShut - py) / (yShut - yUp), 0, 1) * widest : REST;
+ lidSil.classList.toggle("hi", over);
+ seam.classList.toggle("hi", !over);
+ seam.classList.toggle("lo", over);
+ read.textContent = over ? `lid ${Math.round(sp.t)}° · 0` : "rest";
+ B.wake();
+ }
+
+ bag.add(pointer(stage, {
+ move: (p) => { py = p[1]; retarget(); },
+ leave: () => { py = null; retarget(); },
+ }));
+ bag.add(() => svg.replaceChildren());
+
+ return {
+ set: (v) => { widest = v; if (over) retarget(); },
+ destroy: bag.dispose,
+ };
+}
+
+hairline({
+ name: "notion",
+ means: "Notion's cube as a box: the pointer's height lifts the lid on a spring, and inside there are no pages.",
+ rules: [1, 5, 6, 9],
+ range: [75, 100, 125],
+ mount,
+});
+</script>
+</body>
+</html>
diff --git a/apps/site/public/skill/hairline-vercel.html b/apps/site/public/skill/hairline-vercel.html
new file mode 100644
index 0000000..f308582
--- /dev/null
+++ b/apps/site/public/skill/hairline-vercel.html
@@ -0,0 +1,848 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Hairline figure</title>
+<link rel="icon" href="data:,">
+<style>
+ :root { color-scheme: light; --ground: #ffffff; --ink: #232327; --muted: #6f6f78; --line: #e0e0e4; }
+ @media (prefers-color-scheme: dark) {
+ :root:not([data-theme="light"]) { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ }
+ :root[data-theme="dark"] { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ :root[data-theme="light"] { color-scheme: light; }
+ * { box-sizing: border-box; }
+ body {
+ margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
+ background: var(--ground); color: var(--ink);
+ font: 13px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased;
+ }
+ main { width: 100%; max-width: 640px; }
+ .plate { position: relative; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
+ .tag, .label, output, button { font: 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.02em; }
+ .tag { position: absolute; top: 12px; z-index: 1; color: var(--muted); pointer-events: none; }
+ #name { left: 14px; }
+ #read { right: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
+ .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 14px; }
+ .label { color: var(--muted); }
+ input[type="range"] {
+ flex: 1 1 96px; min-width: 0; height: 32px; margin: 0; background: transparent; cursor: pointer;
+ -webkit-appearance: none; appearance: none;
+ }
+ input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-webkit-slider-thumb {
+ -webkit-appearance: none; width: 13px; height: 13px; margin-top: -6px; border-radius: 50%;
+ border: 1px solid var(--ink); background: var(--ground);
+ }
+ input[type="range"]::-moz-range-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--ink); background: var(--ground); }
+ input[type="range"]:focus-visible, button:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 2px; }
+ output { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
+ button {
+ height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
+ background: transparent; color: var(--ink); cursor: pointer;
+ }
+ #means { margin: 14px 0 0; text-wrap: pretty; }
+ #rules { margin: 6px 0 0; line-height: 1.6; }
+ #error { margin: 12px 0 0; padding-left: 10px; border-left: 1px solid var(--ink); }
+</style>
+</head>
+<body>
+<main>
+ <div class="plate">
+ <span class="tag" id="name"></span>
+ <span class="tag" id="read"></span>
+ <div id="stage"></div>
+ </div>
+ <div class="controls">
+ <label class="label" for="intensity">intensity</label>
+ <input id="intensity" type="range" min="0" max="1" step="0.01" value="0.5">
+ <output id="value" for="intensity"></output>
+ <span class="label">theme</span>
+ <button id="theme" type="button" aria-label="Switch between the light and the dark theme"></button>
+ </div>
+ <p id="means"></p>
+ <p id="rules" class="label"></p>
+ <p id="error" role="alert" hidden></p>
+</main>
+<script id="hl-kernel">
+/* hairline kernel sha256:8e2abcbdf63c7755195ee942c39e9c8ea6a539d1147e986dd1c153559121f075 */
+/*
+ * HL: everything a figure may call. Read this index; the code under it is the
+ * package's src/core, unchanged, and a figure should not need to read it.
+ *
+ * Every figure is drawn in a 400 × 320 viewBox. World space is x/y on the
+ * ground and z up. Plates are filled with the ground colour and painted back
+ * to front, so a nearer one covers a farther one: append in that order. At
+ * the default camera, Cam(45, 0.5, S), +x runs down to the right and +y down
+ * to the left, so the corner with the largest x and y is nearest the viewer:
+ * append by ascending x + y, from the far corner (smallest x and y) to it.
+ *
+ * Camera
+ * Cam(azDeg, k, S) a camera: azimuth in degrees, k = sin(elevation) (0.5 is the 2:1 view), S = scale
+ * fit(C, points, cx, cy) centres the box of [x, y, z] points on (cx, cy); call it once, before proj
+ * it only centres, it never scales: choose S by trying values, with the most extreme pose in points.
+ * The six figures use S 1.42 to 2.12; the boxes they fit come out 230 to 310 wide and 180 to 245 tall
+ * proj(C) returns P(x, y, z), which gives [sx, sy]
+ * unproj(C, sx, sy, z) the world [x, y] under a screen point, on the plane at height z
+ * facing(C) returns front(sample): whether a ring sample faces the camera
+ * Rounded solids
+ * rrect(u0, v0, u1, v1, r, n) a rounded rectangle, as a ring of samples {u, v, nu, nv}
+ * circ(R, n) a circle, as a ring
+ * rings(x0, y0, x1, y1, r, b) [ring, inner]: a rounded footprint and its crease ring, inset by b
+ * r, the corner radius, is cut to half the shorter side. b, the crease's inset in world units
+ * (0.6 to 2.2 in the figures), must stay under half the shorter side or the crease turns inside out
+ * prism(P, front, ring, inner, z0, z1) {sil, crease}: a solid standing from z0 to z1, as two path strings
+ * ringAt(P, ring, z) the ring's points, projected at height z
+ * run(ring, keep) the one cyclic run of samples that pass keep
+ * hull(points) the convex hull of screen points
+ * extremes(P, ring) [left, right, nearest] samples: where dashed drops fall from
+ * fillet(points, radii, n) rounds every vertex of a closed polygon; returns the new points
+ * radii is an array, one radius per vertex, each cut to half its shorter edge; a single number gives NaN.
+ * n is the steps round each corner, default 4: each vertex becomes n + 1 points
+ * ghost(P, front, ring, z0, depth) a reflection's path {d, y0, y1}; reflect() draws it for you
+ * Paths and numbers
+ * poly(points) a closed path string
+ * open(points) an open polyline string
+ * seg(a, b) one segment between two screen points [sx, sy], as its own subpath; project world points with P first
+ * clamp(v, a, b)
+ * lerp(a, b, t)
+ * rad(deg)
+ * r2(n) two decimals
+ * The continuous clock: one spring per moving number
+ * spring(x, opts) at rest on x; write .t to retarget; opts {k, c, m, eps}, default k 100, c 18, m 1
+ * stepS(sp, dt) advances by dt seconds; returns whether it is still moving
+ * The discrete clock: a 700ms tween on (.32, .72, 0, 1)
+ * tween(v, dur) at rest on v; dur defaults to 700 (ms)
+ * tset(tw, to, now, delay) retargets from where it is, after delay ms: the stagger
+ * the same target again does nothing, so calling it on every pointer move is safe
+ * tval(tw, now) its value at now
+ * tdone(tw, now) whether it has landed
+ * bezier(x1, y1, x2, y2) a CSS cubic-bezier, as a function of progress
+ * EASE_LIFT the lift curve itself
+ * reducedMotion() true when the reader asked for less motion; springs and tweens already land at once
+ * setReducedMotion(on) the loop's business, not a figure's
+ * Drawing
+ * mk(tag, attrs, parent) one svg element: the only way a figure makes a node
+ * solid(parent) {g, sil, cr}: a group holding a silhouette path and a crease path
+ * put(solid, paths) writes prism()'s {sil, crease} into solid()'s {sil, cr}: sil into sil, crease into cr
+ * flatDot(parent, C, r, cls) a dot lying on the ground plane; cls is "dot", "dot m" or "dot off"
+ * place(el, point) moves a dot or a circle to [sx, sy]
+ * reflect(svg, parent, P, front, ring, z0, depth) a fading mirror under a solid
+ * fade(svg, y0, y1, a0) a vertical fade, as a mask; returns the value for a mask attribute
+ * Life
+ * register(stage, tick) joins the one frame loop; tick(dt in seconds, now in ms) returns true to ask for another frame; gives {wake, unregister}
+ * pointer(stage, handlers) {move(point), down(point), leave()}, points in viewBox units; returns its disposer
+ * disposer() {add, on, dispose}: collects tear-down, so destroy is bag.dispose
+ * The bench's business, not a figure's
+ * css(lightDark)
+ * inject(root)
+ *
+ * Classes, on path, polygon, ellipse and line. They are the whole palette; a
+ * figure sets no colour, width or fill of its own.
+ * (none) filled with the ground colour, medium stroke
+ * sil the silhouette's stroke hi the bright stroke: the only highlight
+ * lo the dim stroke nf no fill fo fill only, no stroke
+ * dash a dashed guide
+ * dot a bright dot dot m a medium dot dot off a dim dot
+ */
+var HL = (() => {
+ var __defProp = Object.defineProperty;
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
+ var __getOwnPropNames = Object.getOwnPropertyNames;
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
+ var __export = (target, all) => {
+ for (var name in all)
+ __defProp(target, name, { get: all[name], enumerable: true });
+ };
+ var __copyProps = (to, from, except, desc) => {
+ if (from && typeof from === "object" || typeof from === "function") {
+ for (let key of __getOwnPropNames(from))
+ if (!__hasOwnProp.call(to, key) && key !== except)
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
+ }
+ return to;
+ };
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
+
+ // packages/hairline/src/core/kernel.ts
+ var kernel_exports = {};
+ __export(kernel_exports, {
+ Cam: () => Cam,
+ EASE_LIFT: () => EASE_LIFT,
+ bezier: () => bezier,
+ circ: () => circ,
+ clamp: () => clamp,
+ css: () => css,
+ disposer: () => disposer,
+ extremes: () => extremes,
+ facing: () => facing,
+ fade: () => fade,
+ fillet: () => fillet,
+ fit: () => fit,
+ flatDot: () => flatDot,
+ ghost: () => ghost,
+ hull: () => hull,
+ inject: () => inject,
+ lerp: () => lerp,
+ mk: () => mk,
+ open: () => open,
+ place: () => place,
+ pointer: () => pointer,
+ poly: () => poly,
+ prism: () => prism,
+ proj: () => proj,
+ put: () => put,
+ r2: () => r2,
+ rad: () => rad,
+ reducedMotion: () => reducedMotion,
+ reflect: () => reflect,
+ register: () => register,
+ ringAt: () => ringAt,
+ rings: () => rings,
+ rrect: () => rrect,
+ run: () => run,
+ seg: () => seg,
+ setReducedMotion: () => setReducedMotion,
+ solid: () => solid,
+ spring: () => spring,
+ stepS: () => stepS,
+ tdone: () => tdone,
+ tset: () => tset,
+ tval: () => tval,
+ tween: () => tween,
+ unproj: () => unproj
+ });
+
+ // packages/hairline/src/core/iso.ts
+ var clamp = (v, a, b) => Math.max(a, Math.min(b, v));
+ var lerp = (a, b, t) => a + (b - a) * t;
+ var rad = (d) => d * Math.PI / 180;
+ var r2 = (n) => Math.round(n * 100) / 100;
+ var poly = (pts) => "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L") + "Z";
+ var seg = (a, b) => `M${r2(a[0])} ${r2(a[1])}L${r2(b[0])} ${r2(b[1])}`;
+ var open = (pts) => pts.length < 2 ? "" : "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L");
+ var Cam = (azDeg, k, S) => ({ az: rad(azDeg), k, S, ox: 0, oy: 0 });
+ function proj(C) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ return (x, y, z) => {
+ const X = x * c - y * s, Y = x * s + y * c;
+ return [C.ox + C.S * X, C.oy + C.S * (Y * C.k - z * zf)];
+ };
+ }
+ function unproj(C, sx, sy, z) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ const X = (sx - C.ox) / C.S, Y = ((sy - C.oy) / C.S + z * zf) / C.k;
+ return [X * c + Y * s, -X * s + Y * c];
+ }
+ function fit(C, pts, cx, cy) {
+ C.ox = 0;
+ C.oy = 0;
+ const P = proj(C);
+ let a = 1e9, b = -1e9, c = 1e9, d = -1e9;
+ for (const p of pts) {
+ const q = P(p[0], p[1], p[2]);
+ a = Math.min(a, q[0]);
+ b = Math.max(b, q[0]);
+ c = Math.min(c, q[1]);
+ d = Math.max(d, q[1]);
+ }
+ C.ox = cx - (a + b) / 2;
+ C.oy = cy - (c + d) / 2;
+ }
+ function rrect(u0, v0, u1, v1, r, n = 4) {
+ r = Math.max(0, Math.min(r, (u1 - u0) / 2, (v1 - v0) / 2));
+ const out = [];
+ for (const [cu, cv, a0] of [[u1 - r, v1 - r, 0], [u0 + r, v1 - r, 90], [u0 + r, v0 + r, 180], [u1 - r, v0 + r, 270]])
+ for (let k = 0; k <= n; k++) {
+ const a = rad(a0 + 90 * k / n), ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: cu + r * ca, v: cv + r * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function circ(R, n = 96) {
+ const out = [];
+ for (let k = 0; k < n; k++) {
+ const a = k / n * Math.PI * 2, ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: R * ca, v: R * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function hull(input) {
+ const pts = input.slice().sort((a, b) => a[0] - b[0] || a[1] - b[1]);
+ const x = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
+ const lo = [], up = [];
+ for (const p of pts) {
+ while (lo.length > 1 && x(lo[lo.length - 2], lo[lo.length - 1], p) <= 0) lo.pop();
+ lo.push(p);
+ }
+ for (let i = pts.length - 1; i >= 0; i--) {
+ const p = pts[i];
+ while (up.length > 1 && x(up[up.length - 2], up[up.length - 1], p) <= 0) up.pop();
+ up.push(p);
+ }
+ lo.pop();
+ up.pop();
+ return lo.concat(up);
+ }
+ var ringAt = (P, ring, z) => ring.map((q) => P(q.u, q.v, z));
+ var facing = (C) => {
+ const s = Math.sin(C.az), c = Math.cos(C.az);
+ return (q) => q.nu * s + q.nv * c >= -1e-6;
+ };
+ function run(ring, keep) {
+ const n = ring.length;
+ let s = -1;
+ for (let i = 0; i < n; i++) if (keep(ring[i]) && !keep(ring[(i + n - 1) % n])) {
+ s = i;
+ break;
+ }
+ if (s < 0) return keep(ring[0]) ? ring.slice() : [];
+ const out = [];
+ for (let k = 0; k < n && keep(ring[(s + k) % n]); k++) out.push(ring[(s + k) % n]);
+ return out;
+ }
+ function prism(P, front, ring, inner, z0, z1) {
+ return {
+ sil: poly(hull(ringAt(P, ring, z1).concat(ringAt(P, ring, z0)))),
+ crease: inner ? open(ringAt(P, run(inner, front), z1)) : ""
+ };
+ }
+ var rings = (x0, y0, x1, y1, r, b) => [
+ rrect(x0, y0, x1, y1, r),
+ rrect(x0 + b, y0 + b, x1 - b, y1 - b, Math.max(0.3, r - b))
+ ];
+ function extremes(P, ring) {
+ const pr = ring.map((q) => P(q.u, q.v, 0));
+ let a = 0, b = 0, c = 0;
+ pr.forEach((p, k) => {
+ if (p[0] < pr[a][0]) a = k;
+ if (p[0] > pr[b][0]) b = k;
+ if (p[1] > pr[c][1]) c = k;
+ });
+ return [ring[a], ring[b], ring[c]];
+ }
+ function fillet(pts, rs, n = 4) {
+ const m = pts.length, out = [];
+ for (let i = 0; i < m; i++) {
+ const a = pts[(i + m - 1) % m], p = pts[i], b = pts[(i + 1) % m];
+ const la = Math.hypot(a[0] - p[0], a[1] - p[1]), lb = Math.hypot(b[0] - p[0], b[1] - p[1]);
+ const t = Math.min(rs[i], la / 2, lb / 2);
+ const p1 = [p[0] + (a[0] - p[0]) / la * t, p[1] + (a[1] - p[1]) / la * t];
+ const p2 = [p[0] + (b[0] - p[0]) / lb * t, p[1] + (b[1] - p[1]) / lb * t];
+ for (let k = 0; k <= n; k++) {
+ const s = k / n, w = 1 - s;
+ out.push([w * w * p1[0] + 2 * w * s * p[0] + s * s * p2[0], w * w * p1[1] + 2 * w * s * p[1] + s * s * p2[1]]);
+ }
+ }
+ return out;
+ }
+ function ghost(P, front, ring, z0, depth) {
+ const f = run(ring, front), lowP = ringAt(P, f, z0 - depth);
+ return {
+ d: open(lowP) + [f[0], f[f.length - 1]].map((q) => seg(P(q.u, q.v, z0), P(q.u, q.v, z0 - depth))).join(""),
+ y0: Math.min(...ringAt(P, f, z0).map((p) => p[1])),
+ y1: Math.max(...lowP.map((p) => p[1])) + 2
+ };
+ }
+
+ // packages/hairline/src/core/motion.ts
+ var reduced = false;
+ var setReducedMotion = (on) => {
+ reduced = on;
+ };
+ var reducedMotion = () => reduced;
+ function spring(x, o = {}) {
+ return { x, v: 0, t: x, k: o.k ?? 100, c: o.c ?? 18, m: o.m ?? 1, eps: o.eps ?? 0.01 };
+ }
+ function stepS(sp, dt) {
+ if (reduced) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ const n = Math.max(1, Math.ceil(dt * 240)), h = dt / n;
+ for (let i = 0; i < n; i++) {
+ const a = (-sp.k * (sp.x - sp.t) - sp.c * sp.v) / sp.m;
+ sp.v += a * h;
+ sp.x += sp.v * h;
+ }
+ if (Math.abs(sp.x - sp.t) < sp.eps && Math.abs(sp.v) < sp.eps * 10) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ return true;
+ }
+ function bezier(x1, y1, x2, y2) {
+ const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx;
+ const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by;
+ const X = (u) => ((ax * u + bx) * u + cx) * u;
+ const Y = (u) => ((ay * u + by) * u + cy) * u;
+ const dX = (u) => (3 * ax * u + 2 * bx) * u + cx;
+ return (t) => {
+ if (t <= 0) return 0;
+ if (t >= 1) return 1;
+ let u = t;
+ for (let i = 0; i < 8; i++) {
+ const e = X(u) - t;
+ if (Math.abs(e) < 1e-5) break;
+ const d = dX(u);
+ if (Math.abs(d) < 1e-6) break;
+ u -= e / d;
+ }
+ if (!(u >= 0 && u <= 1) || Math.abs(X(u) - t) > 1e-4) {
+ let lo = 0, hi = 1;
+ u = t;
+ for (let i = 0; i < 24; i++) {
+ if (X(u) < t) lo = u;
+ else hi = u;
+ u = (lo + hi) / 2;
+ }
+ }
+ return Y(u);
+ };
+ }
+ var EASE_LIFT = bezier(0.32, 0.72, 0, 1);
+ var tween = (v, dur = 700) => ({ from: v, to: v, t0: -1e9, dur });
+ var tval = (tw, now) => {
+ const p = clamp((now - tw.t0) / tw.dur, 0, 1);
+ return tw.from + (tw.to - tw.from) * (reduced ? 1 : EASE_LIFT(p));
+ };
+ var tset = (tw, to, now, delay) => {
+ if (tw.to === to) return;
+ tw.from = tval(tw, now);
+ tw.to = to;
+ tw.t0 = now + delay;
+ };
+ var tdone = (tw, now) => reduced || now >= tw.t0 + tw.dur;
+
+ // packages/hairline/src/core/stage.ts
+ var NS = "http://www.w3.org/2000/svg";
+ function mk(tag, attrs, parent) {
+ const e = document.createElementNS(NS, tag);
+ if (attrs) for (const k in attrs) e.setAttribute(k, String(attrs[k]));
+ if (parent) parent.appendChild(e);
+ return e;
+ }
+ function solid(parent) {
+ const g = mk("g", {}, parent);
+ return { g, sil: mk("path", { class: "sil" }, g), cr: mk("path", { class: "nf lo" }, g) };
+ }
+ var put = (el, s) => {
+ el.sil.setAttribute("d", s.sil);
+ el.cr.setAttribute("d", s.crease);
+ };
+ var flatDot = (parent, C, r, cls) => mk("ellipse", { rx: r2(r * C.S), ry: r2(r * C.S * C.k), class: cls }, parent);
+ var place = (el, q) => {
+ el.setAttribute("cx", String(r2(q[0])));
+ el.setAttribute("cy", String(r2(q[1])));
+ };
+ var fid = 0;
+ function fade(svg, y0, y1, a0 = 0.7) {
+ const id = "hl-fd" + ++fid, defs = mk("defs", {}, svg);
+ const lg = mk("linearGradient", { id: id + "g", gradientUnits: "userSpaceOnUse", x1: 0, y1: r2(y0), x2: 0, y2: r2(y1) }, defs);
+ mk("stop", { offset: 0, "stop-color": "#fff", "stop-opacity": a0 }, lg);
+ mk("stop", { offset: 1, "stop-color": "#fff", "stop-opacity": 0 }, lg);
+ const m = mk("mask", { id, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: 400, height: 320 }, defs);
+ mk("rect", { x: 0, y: 0, width: 400, height: 320, fill: `url(#${id}g)` }, m);
+ return `url(#${id})`;
+ }
+ function reflect(svg, parent, P, front, ring, z0, depth) {
+ const r = ghost(P, front, ring, z0, depth);
+ const gh = mk("g", { class: "ghost", mask: fade(svg, r.y0, r.y1) }, parent);
+ mk("path", { d: r.d }, gh);
+ }
+ var boards = [];
+ var byStage = /* @__PURE__ */ new Map();
+ var raf = 0;
+ var last = 0;
+ var io = null;
+ var rm = null;
+ function frame(now) {
+ const dt = Math.min(0.05, Math.max(0, (now - last) / 1e3));
+ last = now;
+ let any = false;
+ for (const b of boards.slice()) if (b.vis && b.awake) {
+ b.awake = !!b.tick(dt, now);
+ any = any || b.awake;
+ }
+ raf = any ? requestAnimationFrame(frame) : 0;
+ }
+ function wake(b) {
+ b.awake = true;
+ if (!raf) {
+ last = performance.now();
+ raf = requestAnimationFrame(frame);
+ }
+ }
+ var onMotion = () => {
+ setReducedMotion(!!rm?.matches);
+ boards.forEach(wake);
+ };
+ function start() {
+ if (io) return;
+ io = new IntersectionObserver((es) => {
+ for (const e of es) {
+ const b = byStage.get(e.target);
+ if (!b) continue;
+ b.vis = e.isIntersecting;
+ if (b.vis) wake(b);
+ }
+ }, { rootMargin: "80px" });
+ rm = matchMedia("(prefers-reduced-motion: reduce)");
+ setReducedMotion(rm.matches);
+ rm.addEventListener("change", onMotion);
+ }
+ function stop() {
+ if (raf) cancelAnimationFrame(raf);
+ raf = 0;
+ io?.disconnect();
+ io = null;
+ rm?.removeEventListener("change", onMotion);
+ rm = null;
+ }
+ function register(stage, tick) {
+ start();
+ const b = { stage, tick, vis: false, awake: true };
+ boards.push(b);
+ byStage.set(stage, b);
+ io.observe(stage);
+ tick(0, performance.now());
+ let gone = false;
+ return {
+ wake: () => {
+ if (!gone) wake(b);
+ },
+ unregister: () => {
+ if (gone) return;
+ gone = true;
+ boards = boards.filter((x) => x !== b);
+ if (byStage.get(stage) === b) {
+ byStage.delete(stage);
+ io?.unobserve(stage);
+ }
+ if (!boards.length) stop();
+ }
+ };
+ }
+ function pointer(stage, on) {
+ let tm = 0;
+ const pt = (e) => {
+ const r = stage.getBoundingClientRect();
+ return [(e.clientX - r.left) / r.width * 400, (e.clientY - r.top) / r.height * 320];
+ };
+ const move = (e) => {
+ clearTimeout(tm);
+ on.move(pt(e), e);
+ };
+ const down = (e) => {
+ clearTimeout(tm);
+ if (e.pointerType !== "mouse") stage.releasePointerCapture?.(e.pointerId);
+ if (on.down) on.down(pt(e), e);
+ else on.move(pt(e), e);
+ };
+ const leave = (e) => {
+ clearTimeout(tm);
+ tm = window.setTimeout(() => on.leave(e), e.pointerType === "mouse" ? 0 : 1400);
+ };
+ stage.addEventListener("pointermove", move);
+ stage.addEventListener("pointerdown", down);
+ stage.addEventListener("pointerleave", leave);
+ return () => {
+ clearTimeout(tm);
+ stage.removeEventListener("pointermove", move);
+ stage.removeEventListener("pointerdown", down);
+ stage.removeEventListener("pointerleave", leave);
+ };
+ }
+ function disposer() {
+ let fns = [];
+ return {
+ add: (fn) => {
+ fns.push(fn);
+ },
+ on: (target, type, fn, opts) => {
+ const h = fn;
+ target.addEventListener(type, h, opts);
+ fns.push(() => target.removeEventListener(type, h, opts));
+ },
+ dispose: () => {
+ const run2 = fns;
+ fns = [];
+ for (let i = run2.length - 1; i >= 0; i--) run2[i]();
+ }
+ };
+ }
+
+ // packages/hairline/src/core/styles.ts
+ var LIGHT = { plate: "#ffffff", hi: "#232327", edge: "#a4a4ac", mid: "#c3c3c9", lo: "#e0e0e4" };
+ var DARK = { plate: "#08090a", hi: "#d0d6e0", edge: "#5b5d64", mid: "#3e3e44", lo: "#29292d" };
+ var KEYS = ["plate", "hi", "edge", "mid", "lo"];
+ var vars = (p) => KEYS.map((k) => `--hl-${k}:var(--hairline-${k},${p[k]});`).join("");
+ var EASE = "cubic-bezier(0.5,0,0.1,1)";
+ var SVG = ":where([data-hairline]>svg)";
+ function css(lightDark) {
+ const both = Object.fromEntries(KEYS.map((k) => [k, `light-dark(${LIGHT[k]},${DARK[k]})`]));
+ return [
+ // the box, and the palette: light unless something below says otherwise
+ `:where([data-hairline]){display:block;position:relative;aspect-ratio:5/4;touch-action:pan-y;user-select:none;-webkit-user-select:none;--hl-sw:var(--hairline-stroke,0.9);${vars(LIGHT)}}`,
+ // the page's color-scheme
+ lightDark ? `:where([data-hairline]){${vars(both)}}` : "",
+ // an ancestor that says dark
+ `:where(.dark,[data-theme="dark"]) :where([data-hairline]){${vars(DARK)}}`,
+ // the figure's own theme option
+ `:where([data-hairline][data-hairline-theme="light"]){${vars(LIGHT)}}`,
+ `:where([data-hairline][data-hairline-theme="dark"]){${vars(DARK)}}`,
+ `:where([data-hairline]:focus-visible){outline:1.5px solid var(--hl-hi);outline-offset:2px}`,
+ `${SVG}{position:absolute;inset:0;width:100%;height:100%;display:block}`,
+ // Riffle's live region: read, not seen
+ `:where([data-hairline]>[data-hairline-live]){position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}`,
+ // the drawing: plates are filled with the plate colour and painted back to front
+ `${SVG} :where(path,polygon,ellipse,line){fill:var(--hl-plate);stroke:var(--hl-mid);stroke-width:var(--hl-sw);vector-effect:non-scaling-stroke;stroke-linejoin:round;stroke-linecap:round;transition:stroke 260ms ${EASE}}`,
+ `${SVG} :where(.nf){fill:none}`,
+ `${SVG} :where(.fo){stroke:none}`,
+ `${SVG} :where(.sil){stroke:var(--hl-edge)}`,
+ `${SVG} :where(.hi){stroke:var(--hl-hi)}`,
+ `${SVG} :where(.lo){stroke:var(--hl-lo)}`,
+ `${SVG} :where(.dash){stroke-dasharray:1 3}`,
+ `${SVG} :where(.dot){stroke:none;fill:var(--hl-hi);transition:fill 260ms ${EASE}}`,
+ `${SVG} :where(.dot.m){fill:var(--hl-edge)}`,
+ `${SVG} :where(.dot.off){fill:var(--hl-lo)}`,
+ `${SVG} :where(.ghost path){fill:none;stroke:var(--hl-mid)}`
+ ].join("");
+ }
+ var done = /* @__PURE__ */ new WeakSet();
+ function inject(root) {
+ if (done.has(root)) return;
+ done.add(root);
+ const doc = root.nodeType === 9 ? root : root.ownerDocument;
+ const win = doc.defaultView;
+ const text = css(!!win?.CSS?.supports?.("color", "light-dark(#000,#fff)"));
+ if (win && "adoptedStyleSheets" in root) {
+ try {
+ const sheet = new win.CSSStyleSheet();
+ sheet.replaceSync(text);
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
+ return;
+ } catch {
+ }
+ }
+ const style = doc.createElement("style");
+ style.setAttribute("data-hairline-style", "");
+ style.textContent = text;
+ (root.nodeType === 9 ? doc.head ?? doc.documentElement : root).appendChild(style);
+ }
+ return __toCommonJS(kernel_exports);
+})();
+/* /hairline kernel */
+</script>
+<script id="hl-bench">
+/*
+ * The bench: the page a figure is shown on. It makes the host and the svg the
+ * way the package's mount does, hands them to the figure, and owns everything
+ * around it: the read-out, the slider, the theme, the line under the stage.
+ */
+(() => {
+ const RULES = ["hit", "order", "reach", "accent", "rest", "honesty", "cost", "clock", "radius", "quiet"];
+ const $ = (id) => document.getElementById(id);
+ const root = document.documentElement, params = new URLSearchParams(location.search);
+
+ /* the theme: the system's until the switch is pressed, then the switch's */
+ const dark = () => (root.dataset.theme ? root.dataset.theme === "dark" : matchMedia("(prefers-color-scheme: dark)").matches);
+ const label = () => { $("theme").textContent = dark() ? "dark" : "light"; };
+ $("theme").addEventListener("click", () => { root.dataset.theme = dark() ? "light" : "dark"; label(); });
+ /* ?theme=light or ?theme=dark wins over the system's, as pressing the switch does */
+ if (["light", "dark"].includes(params.get("theme"))) root.dataset.theme = params.get("theme");
+ label();
+
+ /* ?intensity=0 sets the slider before the figure mounts, for a look at either end */
+ const i = (params.get("intensity") || "").trim();
+ if (i && Number.isFinite(Number(i))) $("intensity").value = String(Math.min(1, Math.max(0, Number(i))));
+
+ /* ?w=240 narrows the page, for a look at the size of a thumbnail */
+ const w = Number(params.get("w"));
+ if (w > 0) document.querySelector("main").style.maxWidth = w + "px";
+
+ /* a figure that fails says so under the stage, instead of leaving an empty plate */
+ addEventListener("error", (e) => {
+ $("error").hidden = false;
+ $("error").textContent = String((e.error && e.error.message) || e.message);
+ });
+
+ let mounted = false;
+ window.hairline = (figure) => {
+ if (mounted) throw new Error("hairline: one figure per page.");
+ mounted = true;
+ const stage = $("stage"), slider = $("intensity");
+
+ /* intensity to the figure's own number: two straight lines that meet at 0.5, as in the package */
+ const [lo, mid, hi] = figure.range;
+ const at = (i) => Math.round((i <= 0.5 ? lo + (i / 0.5) * (mid - lo) : mid + ((i - 0.5) / 0.5) * (hi - mid)) * 1000) / 1000;
+
+ HL.inject(document);
+ stage.setAttribute("data-hairline", figure.name);
+ stage.setAttribute("role", "img");
+ stage.setAttribute("aria-label", figure.means);
+ const svg = HL.mk("svg", { viewBox: "0 0 400 320", "aria-hidden": "true" }, stage);
+
+ let text = null;
+ const read = {
+ get textContent() { return text; },
+ set textContent(value) { text = value == null ? "" : String(value); $("read").textContent = text; },
+ };
+
+ document.title = "Hairline · " + figure.name;
+ $("name").textContent = figure.name;
+ $("means").textContent = figure.means;
+ $("rules").textContent = figure.rules.map((n) => String(n).padStart(2, "0") + " " + RULES[n - 1]).join(" · ");
+ const show = () => { $("value").textContent = String(at(Number(slider.value))); };
+ show();
+
+ const handle = figure.mount({ stage, svg, read }, at(Number(slider.value)));
+ if (text === null) read.textContent = "rest";
+ slider.addEventListener("input", () => { show(); handle.set(at(Number(slider.value))); });
+ window.hairline.figure = handle;
+
+ /* ?at=200,160 holds the pointer at a viewBox point, for a picture of the answer without a mouse */
+ const p = (params.get("at") || "").split(",").map(Number);
+ if (p.length === 2 && p.every(Number.isFinite)) {
+ const r = stage.getBoundingClientRect();
+ stage.dispatchEvent(new PointerEvent("pointermove", {
+ pointerType: "mouse", pointerId: 1, bubbles: true,
+ clientX: r.left + (p[0] / 400) * r.width, clientY: r.top + (p[1] / 320) * r.height,
+ }));
+ }
+ };
+})();
+</script>
+<script type="module" id="hl-figure">
+/**
+ * Vercel: the mark as an upright slab, an equilateral triangle with a little
+ * thickness, hovering over an empty pad whose slot is marked dim. Nothing is
+ * deployed yet. The nearer the pointer comes to the slot, the lower the slab
+ * settles and the more it levels, on one spring, until it seats. At rest it
+ * hovers, leaning a few degrees, with dashed drops to where it would land.
+ * The slider is the reach, in viewBox units.
+ *
+ * The pattern: a field with one part. A spring, a clamped falloff by distance
+ * from a fixed anchor (where the seated slab's middle sits), and a rest pose
+ * that is already the empty state.
+ */
+const {
+ Cam, clamp, fillet, fit, hull, open, poly, proj, prism, put, rad, ringAt, rings, rrect, run, seg,
+ spring, stepS, disposer, facing, mk, pointer, register, solid,
+} = HL;
+
+const L = 72, HT = (L * Math.sqrt(3)) / 2, T = 7, H0 = 26, LEAN = 5, CR = 1.4, B = 1.7;
+const PL = L / 2 + 22, PN = 28, PB = 6, SM = 3.2, TH = -30, SEAT = 0.45;
+const D = [Math.cos(rad(TH)), Math.sin(rad(TH))], N = [-D[1], D[0]];
+
+/** A ring drawn along the slab (u) and across it (v), turned to the slab's heading. */
+const turn = (ring) => ring.map((q) => ({
+ u: q.u * D[0] + q.v * N[0], v: q.u * D[1] + q.v * N[1],
+ nu: q.nu * D[0] + q.nv * N[0], nv: q.nu * D[1] + q.nv * N[1],
+}));
+
+/** The mark, in its own plane: a along its base, b up. Its corners keep the smallest round that reads as built. */
+const TRI = [[-L / 2, 0], [L / 2, 0], [0, HT]];
+const IC = HT / 3, RI = L / (2 * Math.sqrt(3));
+const OUT = fillet(TRI, [CR, CR, CR], 4);
+const IN = fillet(TRI.map(([a, b]) => [a * (RI - B) / RI, IC + (b - IC) * (RI - B) / RI]), [1, 1, 1], 4);
+
+function mount({ stage, svg, read }, value) {
+ const bag = disposer();
+ const C = Cam(45, 0.5, 1.9);
+ const corner = (u, v, z) => [u * D[0] + v * N[0], u * D[1] + v * N[1], z];
+ fit(C, [
+ corner(-PL, -PN, -PB), corner(PL, -PN, -PB), corner(-PL, PN, -PB), corner(PL, PN, -PB),
+ [0, 0, H0 + HT + 4], corner(L / 2, 0, H0 + 6),
+ ], 200, 166);
+ const P = proj(C), front = facing(C);
+ let R = value, over = null;
+
+ /** A point of the slab's plane (a, b), t across it, hovering at h and leaning by angle (s, c) about its middle. */
+ const at = (a, b, t, h, s, c) => {
+ const a2 = a * c - (b - IC) * s, b2 = IC + a * s + (b - IC) * c;
+ return [a2 * D[0] + t * N[0], a2 * D[1] + t * N[1], h + b2];
+ };
+ const W = (p) => P(p[0], p[1], p[2]);
+ const o0 = P(0, 0, 0), o1 = P(-T * N[0], -T * N[1], 0), o = [o1[0] - o0[0], o1[1] - o0[1]];
+
+ const g = mk("g", {}, svg);
+ // The pad, and the slot marked on it: where the slab would stand.
+ const [pr, pi] = rings(-PL, -PN, PL, PN, 10, 2.2);
+ put(solid(g), prism(P, front, turn(pr), turn(pi), -PB, 0));
+ const slot = turn(rrect(-L / 2 - SM, -T / 2 - SM, L / 2 + SM, T / 2 + SM, 2.6, 4));
+ mk("path", { d: poly(ringAt(P, slot, 0)), class: "nf lo" }, g);
+ // The drops, painted before the slab they hang from.
+ const drops = mk("path", { class: "dash" }, g);
+ const slab = solid(g);
+ slab.sil.classList.add("hi");
+
+ /** The crease: the near face's inset outline, along the edges whose side face shows. */
+ function crease(pts) {
+ const n = pts.length, cx = pts.reduce((m, p) => m + p[0], 0) / n, cy = pts.reduce((m, p) => m + p[1], 0) / n;
+ const ring = pts.map((p, i) => {
+ const q = pts[(i + 1) % n], r = pts[(i + n - 1) % n];
+ let m = [q[1] - r[1], r[0] - q[0]];
+ if ((p[0] - cx) * m[0] + (p[1] - cy) * m[1] < 0) m = [-m[0], -m[1]];
+ return { p, k: m[0] * o[0] + m[1] * o[1] > 0.35 * Math.hypot(m[0], m[1]) * Math.hypot(o[0], o[1]) };
+ });
+ return open(run(ring, (q) => q.k).map((q) => q.p));
+ }
+
+ const sp = spring(H0, { eps: 0.02 });
+ let drawn = NaN;
+ function draw() {
+ const h = Math.max(0, sp.x);
+ if (h === drawn) return;
+ drawn = h;
+ const th = rad(LEAN) * (h / H0), s = Math.sin(th), c = Math.cos(th);
+ const near = OUT.map(([a, b]) => W(at(a, b, T / 2, h, s, c)));
+ const far = OUT.map(([a, b]) => W(at(a, b, -T / 2, h, s, c)));
+ put(slab, { sil: poly(hull(near.concat(far))), crease: crease(IN.map(([a, b]) => W(at(a, b, T / 2, h, s, c)))) });
+ drops.setAttribute("d", [-L / 2, L / 2].map((a) => {
+ const p = at(a, 0, 0, h, s, c);
+ return seg(W(p), P(p[0], p[1], 0));
+ }).join(""));
+ }
+
+ const Bk = register(stage, (dt) => { const m = stepS(sp, dt); draw(); return m; });
+ bag.add(Bk.unregister);
+
+ // Where the seated slab's middle sits on screen: fixed, so the slab moving never moves the hit.
+ const anchor = P(0, 0, IC);
+ function retarget() {
+ if (!over) { sp.t = H0; read.textContent = "rest"; }
+ else {
+ const u = Math.hypot(over[0] - anchor[0], over[1] - anchor[1]) / R;
+ sp.t = H0 * clamp((u - SEAT) / (1 - SEAT), 0, 1);
+ read.textContent = `gap ${Math.round(sp.t)}`;
+ }
+ Bk.wake();
+ }
+
+ bag.add(pointer(stage, {
+ move: (p) => { over = p; retarget(); },
+ leave: () => { over = null; retarget(); },
+ }));
+ bag.add(() => svg.replaceChildren());
+
+ return {
+ set: (v) => { R = v; if (over) retarget(); },
+ destroy: bag.dispose,
+ };
+}
+
+hairline({
+ name: "vercel",
+ means: "No deployments yet: the triangle hovers over its empty slot, and the nearer the pointer, the lower it settles, until it seats.",
+ rules: [1, 3, 5, 9],
+ range: [70, 110, 160],
+ mount,
+});
+</script>
+</body>
+</html>
diff --git a/apps/site/test/catalogue.test.ts b/apps/site/test/catalogue.test.ts
index f0cd328..96264a0 100644
--- a/apps/site/test/catalogue.test.ts
+++ b/apps/site/test/catalogue.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
-import { ENTRIES, SHELVES, spell, tally } from "@/lib/catalogue";
+import { ENTRIES, NOTICE, SHELVES, spell, tally } from "@/lib/catalogue";
import { FIGURES } from "@/lib/figures";
+import { COMMAND, EXAMPLES } from "@/lib/skill";
import { REACT, VANILLA, CDN, paste } from "@/lib/snippets";
describe("the catalogue", () => {
@@ -13,15 +14,30 @@ describe("the catalogue", () => {
}
});
- it("names each figure once, on seven shelves of three", () => {
+ it("names each figure once, on nine shelves", () => {
expect(new Set(ENTRIES.map((e) => e.id)).size).toBe(ENTRIES.length);
expect(new Set(ENTRIES.map((e) => e.name)).size).toBe(ENTRIES.length);
- expect(SHELVES.map((s) => s.figures.length)).toEqual([1, 3, 3, 3, 3, 3, 3]);
+ expect(SHELVES.map((s) => s.figures.length)).toEqual([1, 3, 3, 3, 3, 3, 3, 8, 3]);
+ });
+
+ it("keeps the marks apart: made by the skill, counted outside the package's tally", () => {
+ const marks = SHELVES[SHELVES.length - 1];
+ expect([marks.id, marks.figures.map((f) => f.id)]).toEqual(["marks", ["vercel", "mastra", "notion"]]);
+ for (const f of marks.figures) {
+ expect(f.drawn).toBe(false);
+ const made = (f as { made?: { file: string; prompt: string } }).made!;
+ const example = EXAMPLES.find((e) => e.file === made.file)!;
+ expect(made.prompt).toBe(`${COMMAND} ${example.idea}`);
+ }
+ // each line says what that page's slider does
+ expect(marks.figures.map((f) => f.stronger)).toEqual(["It answers from further away.", "The neck holds further before it lets go.", "The lid opens wider."]);
+ expect(tally()).toBe("Eight shelves, twenty-seven figures");
+ expect(NOTICE).toMatch(/not affiliated/);
});
it("counts in words, read from the shelves", () => {
expect([spell(7), spell(19), spell(20), spell(21), spell(40), spell(99)]).toEqual(["seven", "nineteen", "twenty", "twenty-one", "forty", "ninety-nine"]);
- expect(tally()).toBe("Seven shelves, nineteen figures");
+ expect(tally()).toBe("Eight shelves, twenty-seven figures");
});
it("pastes each figure three ways, and the docs' Terrain is the same as before", () => {
diff --git a/apps/site/test/docs.test.ts b/apps/site/test/docs.test.ts
index 401a2c5..c483375 100644
--- a/apps/site/test/docs.test.ts
+++ b/apps/site/test/docs.test.ts
@@ -5,13 +5,14 @@ import * as components from "@lucasmarkes/hairline/react";
import * as figures from "@lucasmarkes/hairline";
import type { HairlineOptions } from "@lucasmarkes/hairline";
import { TABLE } from "../../../packages/hairline/src/intensity";
+import { NOTICE } from "@/lib/catalogue";
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 } from "@/lib/snippets";
+import { CDN, CSS, EMPTY, QUICKSTART, REACT, REACT_SIGNATURE, VANILLA, VANILLA_SIGNATURE, install } from "@/lib/snippets";
/** The docs describe the package, and these check that nothing was written by hand around it. */
@@ -92,12 +93,12 @@ describe("the Install note's size", () => {
});
describe("the docs' sections", () => {
- it("are nine, in three groups in order, with unique ids that work as fragments", () => {
- expect(SECTIONS.map((s) => s.id)).toEqual(["install", "quick-start", "options", "react", "vanilla", "cdn", "figures", "theme", "accessibility"]);
- expect(new Set(SECTIONS.map((s) => s.id)).size).toBe(9);
+ it("are ten, in three groups in order, with unique ids that work as fragments", () => {
+ expect(SECTIONS.map((s) => s.id)).toEqual(["install", "quick-start", "options", "empty-states", "react", "vanilla", "cdn", "figures", "theme", "accessibility"]);
+ expect(new Set(SECTIONS.map((s) => s.id)).size).toBe(10);
for (const s of SECTIONS) expect(s.id).toMatch(/^[a-z-]+$/);
expect(SECTIONS.map((s) => s.group)).toEqual([
- "Getting started", "Getting started", "Getting started",
+ "Getting started", "Getting started", "Getting started", "Getting started",
"API", "API", "API",
"Reference", "Reference", "Reference",
]);
@@ -105,7 +106,7 @@ describe("the docs' sections", () => {
it("share their headings with /llms.txt", () => {
const text = llms("https://example.test");
- for (const title of ["Install", "Options", "Figures", "Theme", "Accessibility"]) {
+ for (const title of ["Install", "Options", "Empty states", "Figures", "Theme", "Accessibility"]) {
expect(SECTIONS.map((s) => s.title)).toContain(title);
expect(text).toContain(`\n## ${title}\n`);
}
@@ -137,6 +138,11 @@ describe("/llms.txt", () => {
expect(text.indexOf("## Make your own")).toBeLessThan(text.indexOf("## Links"));
});
+ it("says, right after the examples drawn from a company's mark, that the marks are their owners'", () => {
+ const last = EXAMPLES.at(-1)!;
+ expect(text).toContain(`https://example.test/skill/${last.file}\n\n${NOTICE}\n`);
+ });
+
it.each(FIGURES)("names $name with its row of the intensity table", (doc) => {
expect(text).toContain(`### ${doc.name}`);
expect(text).toContain(doc.stronger);
@@ -162,7 +168,7 @@ describe("/llms.txt", () => {
});
/** Every snippet the docs highlight, with its language. */
-const SAMPLES: [code: string, lang: string][] = [[REACT, "tsx"], [VANILLA, "ts"], [CDN, "html"], [CSS, "css"], [REACT_SIGNATURE, "tsx"], [VANILLA_SIGNATURE, "ts"]];
+const SAMPLES: [code: string, lang: string][] = [[REACT, "tsx"], [VANILLA, "ts"], [CDN, "html"], [CSS, "css"], [REACT_SIGNATURE, "tsx"], [VANILLA_SIGNATURE, "ts"], [EMPTY, "tsx"]];
describe("highlighting", () => {
it("colours tokens with the --code- variables only, and leaves the block one tab stop", async () => {
diff --git a/apps/site/test/figures.spec.ts b/apps/site/test/figures.spec.ts
index d65a233..944ffa8 100644
--- a/apps/site/test/figures.spec.ts
+++ b/apps/site/test/figures.spec.ts
@@ -1,6 +1,6 @@
import { expect, test, type Page } from "@playwright/test";
-const SHELVES = ["Interfaces", "Data", "Machines", "Devices", "Coding", "Security", "Connectivity"];
+const SHELVES = ["Interfaces", "Data", "Machines", "Devices", "Coding", "Security", "Connectivity", "Empty", "Marks"];
function watch(page: Page): string[] {
const noise: string[] = [];
@@ -16,16 +16,16 @@ function watch(page: Page): string[] {
const tiles = (page: Page) => page.locator(".fig-tile");
const shelf = (page: Page, name: string) => page.locator(".shelves .shelf", { hasText: name });
-test("/figures prerenders nineteen empty boxes among nineteen tiles, then draws them with a clean console", async ({ page, request }) => {
+test("/figures prerenders twenty-seven empty boxes among thirty tiles, then draws them with a clean console", async ({ page, request }) => {
const html = await (await request.get("/figures")).text();
- expect(html.match(/<div style="aspect-ratio:5 \/ 4"><\/div>/g)).toHaveLength(19);
- expect(html.match(/class="fig-tile"/g)).toHaveLength(19);
+ expect(html.match(/<div style="aspect-ratio:5 \/ 4"><\/div>/g)).toHaveLength(27);
+ expect(html.match(/class="fig-tile"/g)).toHaveLength(30);
expect(html).not.toContain("data-planned");
const noise = watch(page);
await page.goto("/figures");
- await expect(tiles(page)).toHaveCount(19);
- await expect(page.locator(".fig-tile [data-hairline] > svg")).toHaveCount(19);
+ await expect(tiles(page)).toHaveCount(30);
+ await expect(page.locator(".fig-tile [data-hairline] > svg")).toHaveCount(27);
await expect(page.locator(".fig-tile .fig-ghost, .fig-tile[data-planned]")).toHaveCount(0);
await expect(page.locator("h1")).toHaveText("Every figure, by what it draws.");
await expect(page.locator(".doc-section h2")).toHaveText(SHELVES);
@@ -36,7 +36,7 @@ test("/figures prerenders nineteen empty boxes among nineteen tiles, then draws
test("the shelves filter: All is pressed at first, a shelf shows only itself and names itself in the address", async ({ page }) => {
await page.goto("/figures");
await expect(shelf(page, "All")).toHaveAttribute("aria-pressed", "true");
- await expect(page.locator(".shelves .shelf-n")).toHaveText(["19", "1", "3", "3", "3", "3", "3", "3"]);
+ await expect(page.locator(".shelves .shelf-n")).toHaveText(["30", "1", "3", "3", "3", "3", "3", "3", "8", "3"]);
await shelf(page, "Machines").click();
await expect(shelf(page, "Machines")).toHaveAttribute("aria-pressed", "true");
@@ -53,7 +53,7 @@ test("the shelves filter: All is pressed at first, a shelf shows only itself and
})).toBeLessThan(1);
await shelf(page, "All").click();
- await expect(tiles(page)).toHaveCount(19);
+ await expect(tiles(page)).toHaveCount(30);
expect(new URL(page.url()).hash).toBe("");
});
@@ -186,7 +186,7 @@ test("on a phone the shelves are a strip under the top bar, and nothing scrolls
await page.setViewportSize({ width, height: 800 });
await page.goto("/figures");
await expect(page.locator(".shelves")).toBeHidden();
- await expect(page.locator(".figs-pill")).toHaveCount(8);
+ await expect(page.locator(".figs-pill")).toHaveCount(10);
expect(await page.evaluate(() => document.documentElement.scrollWidth), `${width}`).toBeLessThanOrEqual(width);
// the top bar's links stay inside it
const right = await page.evaluate(() => document.querySelector(".topbar nav")!.getBoundingClientRect().right);
@@ -207,3 +207,46 @@ test("on a phone the shelves are a strip under the top bar, and nothing scrolls
expect(box!.width).toBe(width);
}
});
+
+test("the Marks shelf shows three figures the skill made, each with its prompt and no install code", async ({ page }) => {
+ await page.goto("/figures#marks");
+ const shelf = page.locator("#shelf-marks");
+ await expect(shelf.locator(".fig-tile")).toHaveCount(3);
+ await expect(shelf).toContainText("not affiliated");
+ const tile = shelf.locator(".fig-tile").first();
+ const frame = tile.frameLocator("iframe");
+ await expect(frame.locator("#stage svg > *").first()).toBeAttached();
+ await expect(frame.locator(".controls")).toBeHidden();
+ // the page's ground is clear, so the tile's ring, under the frame, shows
+ await expect(frame.locator("body")).toHaveCSS("background-color", "rgba(0, 0, 0, 0)");
+ await tile.getByRole("button", { name: "Vercel" }).click();
+ const drawer = page.locator("#figure-drawer");
+ await expect(drawer).toContainText("/hairline-create an empty state for");
+ await expect(drawer).toContainText("not affiliated");
+ await expect(drawer.getByRole("tab")).toHaveCount(0);
+ await expect(drawer.locator("input[type=range]")).toHaveCount(0);
+ await expect(drawer.getByRole("link", { name: "hairline-create" })).toHaveAttribute("href", "/skill");
+});
+
+test("Escape pressed inside a made page's frame closes the drawer, as it does outside", async ({ page }) => {
+ await page.goto("/figures#marks");
+ const name = page.locator("#shelf-marks").getByRole("button", { name: "Vercel" });
+ await name.click();
+ const drawer = page.locator("#figure-drawer");
+ await expect(drawer).toHaveAttribute("data-open", "");
+ // the page's own slider, in the drawer's frame, takes the keys
+ const slider = drawer.frameLocator("iframe").locator("#intensity");
+ await slider.focus();
+ await expect(slider).toBeFocused();
+ await page.keyboard.press("Escape");
+ await expect(drawer).not.toHaveAttribute("data-open");
+ await expect(name).toBeFocused();
+});
+
+// Review Focus 4: a page that does not load leaves the tile its box
+test("a made tile keeps its box when its page is missing", async ({ page }) => {
+ await page.route("**/skill/hairline-mastra.html*", (route) => route.fulfill({ status: 404, body: "" }));
+ await page.goto("/figures#marks");
+ const box = (await page.locator("#shelf-marks .fig-tile").nth(1).locator("iframe.made-frame").boundingBox())!;
+ expect(box.width / box.height).toBeCloseTo(5 / 4, 1);
+});
diff --git a/apps/site/test/site.spec.ts b/apps/site/test/site.spec.ts
index e52d032..3152858 100644
--- a/apps/site/test/site.spec.ts
+++ b/apps/site/test/site.spec.ts
@@ -1,6 +1,6 @@
import { expect, test, type Page } from "@playwright/test";
-const IDS = ["riffle", "terrain", "exploded", "phosphor", "slow", "turntable", "keyboard", "elevator", "phone", "laptop", "terminal", "cabinet", "branches", "vault", "lockers", "padlock", "patch", "dish", "router"];
+const IDS = ["riffle", "terrain", "exploded", "phosphor", "slow", "turntable", "keyboard", "elevator", "phone", "laptop", "terminal", "cabinet", "branches", "vault", "lockers", "padlock", "patch", "dish", "router", "loupe", "sieve", "rail", "plug", "query", "drawer", "basket", "plot"];
const MANAGERS = [
["npm", "npm i @lucasmarkes/hairline"],
["pnpm", "pnpm add @lucasmarkes/hairline"],
@@ -79,20 +79,40 @@ test("the top bar's links sit as one row: one height, one centre line, one type,
test("the docs prerender an empty box per figure, then draw one figure per row with a clean console", async ({ page, request }) => {
const html = await (await request.get("/docs")).text();
expect(html.match(/<div style="aspect-ratio:5 \/ 4"><\/div>/g)).toHaveLength(IDS.length);
- expect(html).not.toMatch(/aspect-ratio:5 \/ 4"[^>]*><svg/);
+ // the empty state's figure is the one more, at its own width
+ expect(html.match(/<div style="aspect-ratio:5 \/ 4;width:200px"><\/div>/g)).toHaveLength(1);
+ expect(html).not.toMatch(/aspect-ratio:5 \/ 4[^"]*"[^>]*><svg/);
const noise = watch(page);
await page.goto("/docs");
- await expect(page.locator("[data-hairline] > svg")).toHaveCount(IDS.length);
+ await expect(page.locator("[data-hairline] > svg")).toHaveCount(IDS.length + 1);
for (const id of IDS) await expect(page.locator(`[data-row="${id}"] [data-hairline] > svg > *`).first()).toBeAttached();
await expect(page.locator("[data-size]")).toHaveText(/^\d+\.\d kB$/);
expect(noise).toEqual([]);
});
+test("the empty-states section draws its snippet live: a sieve at 200px over a heading and a button, then the code", async ({ page }) => {
+ await page.goto("/docs");
+ const section = page.locator("#empty-states");
+ const demo = section.locator("[data-empty]");
+ const figure = demo.locator("[data-hairline]");
+ await expect(figure.locator("> svg > *").first()).toBeAttached();
+ await expect(figure).toHaveAttribute("aria-label", /empty sieve/i);
+ expect((await figure.boundingBox())!.width).toBeCloseTo(200, 0);
+ await expect(demo.getByRole("heading", { level: 3 })).toHaveText("No results match these filters");
+ await expect(demo.getByRole("button", { name: "Clear filters" })).toBeVisible();
+ // the live block comes first, the code after it, and the code says the same words
+ const code = section.locator("pre");
+ expect((await demo.boundingBox())!.y).toBeLessThan((await code.boundingBox())!.y);
+ await expect(code).toContainText('<Sieve style={{ width: 200 }} label="An empty sieve" />');
+ await expect(code).toContainText("<h2>No results match these filters</h2>");
+ await expect(code).toContainText("Clear filters</button>");
+});
+
test("the docs' code is in greys: every token's colour has equal red, green and blue", async ({ page }) => {
await page.goto("/docs");
const colours = await page.locator("main pre span").evaluateAll((spans) => spans.map((s) => getComputedStyle(s).color));
- // seven blocks of highlighted code, nearly two hundred spans: a page that lost its highlighting falls far short
+ // eight blocks of highlighted code, some two hundred spans: a page that lost its highlighting falls far short
expect(colours.length).toBeGreaterThan(150);
const tinted = colours.filter((c) => {
const [r, g, b] = c.match(/\d+(\.\d+)?/g)!.map(Number);
@@ -312,9 +332,9 @@ const BASE = "http://localhost:3000";
test("a pasted link shows the page it leads to: each page's card has its own title, text and address", async ({ request }) => {
const CARDS = [
- ["/", "hairline", /^Nineteen isometric line figures/],
- ["/figures", "Figures", /^Seven shelves, nineteen figures, grouped by what they draw/],
- ["/docs", "Docs", /^Nineteen isometric line figures/],
+ ["/", "hairline", /^Twenty-seven isometric line figures/],
+ ["/figures", "Figures", /^Eight shelves, twenty-seven figures, grouped by what they draw/],
+ ["/docs", "Docs", /^Twenty-seven isometric line figures/],
["/skill", "Make your own figure", /^hairline-create is a skill/],
["/inspo", "How Hairline was made", /^A long brief/],
] as const;
@@ -475,7 +495,7 @@ test("the figures' link goes to the figures page", async ({ page }) => {
test("the sidebar's links land on their section under the top bar and mark it, and scrolling moves the mark", async ({ page }) => {
await page.goto("/docs");
const nav = page.getByRole("navigation", { name: "Docs" });
- await expect(nav.getByRole("link")).toHaveText(["Install", "Quick start", "Options", "React", "Vanilla", "CDN", "Figures", "Theme", "Accessibility"]);
+ await expect(nav.getByRole("link")).toHaveText(["Install", "Quick start", "Options", "Empty states", "React", "Vanilla", "CDN", "Figures", "Theme", "Accessibility"]);
await expect(nav.getByRole("link", { name: "Install" })).toHaveAttribute("aria-current", "location");
await nav.getByRole("link", { name: "Theme" }).click();
@@ -549,7 +569,7 @@ test("the sidebar draws the line to its section in its group's colour, and only
const other = nav.querySelector(".rail-group:not(:has([aria-current]))")!;
const scale = (ul: Element) => {
const after = style(ul, "::after");
- const bottom = after.clipPath.match(/^inset\(\S+ \S+ (\S+)/)?.[1] ?? "0px";
+ const bottom = after.clipPath.match(/^inset\(\S+ \S+ ([^\s)]+)/)?.[1] ?? "0px";
return 1 - (bottom.endsWith("%") ? parseFloat(bottom) / 100 : parseFloat(bottom) / parseFloat(after.height));
};
return {
@@ -592,7 +612,7 @@ test("the line draws from section to section instead of jumping, and under reduc
const tick = () => {
// the trunk is a border uncovered from the top: its reach is what the clip-path's bottom inset leaves
const after = getComputedStyle(ul, "::after");
- const bottom = after.clipPath.match(/^inset\(\S+ \S+ (\S+)/)?.[1] ?? "0px";
+ const bottom = after.clipPath.match(/^inset\(\S+ \S+ ([^\s)]+)/)?.[1] ?? "0px";
ys.push(1 - (bottom.endsWith("%") ? parseFloat(bottom) / 100 : parseFloat(bottom) / parseFloat(after.height)));
if (performance.now() - t0 < 700) requestAnimationFrame(tick);
else done(ys);
diff --git a/apps/site/test/skill.spec.ts b/apps/site/test/skill.spec.ts
index 3e47c61..fe5d812 100644
--- a/apps/site/test/skill.spec.ts
+++ b/apps/site/test/skill.spec.ts
@@ -1,7 +1,17 @@
import { expect, test, type FrameLocator, type Page } from "@playwright/test";
const INSTALL = "npx skills add lucasmarkes/hairline";
-const IDEAS = ["a sales funnel", "a rate limiter", "git branches", "weather over a city"];
+const IDEAS = [
+ "a sales funnel",
+ "a rate limiter",
+ "git branches",
+ "weather over a city",
+ "an empty state for \"No deployments yet\", from Vercel's mark: the triangle as an upright slab hovering over a pad with its slot marked dim; the nearer the pointer, the lower it settles, until it seats. Name it vercel.",
+ "an empty state for \"No agents connected\", from Mastra's mark: the spheres of the M joined by necks on a board, the lone sphere standing apart; the pointer draws it toward the others, a neck forms, stretches and lets go. Name it mastra.",
+ "an empty state for \"No pages inside\", from Notion's mark: the cube as a box with a lid, the N a relief on its front face; the pointer's height opens the lid on a spring, and the box is empty. Name it notion.",
+];
+/** A line as a pattern that matches only itself: the marks' prompts hold full stops. */
+const literal = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
function watch(page: Page): string[] {
const noise: string[] = [];
@@ -36,14 +46,15 @@ const fit = (frame: FrameLocator) => frame.locator("main").evaluate((main) => ({
band: window.innerHeight - main.getBoundingClientRect().bottom - 24,
}));
-test("/skill opens with the install command, four prompts and four live figures, and a clean console", async ({ page }) => {
+test("/skill opens with the install command, seven prompts and seven live figures, and a clean console", async ({ page }) => {
const noise = watch(page);
await page.goto("/skill");
await expect(page).toHaveTitle("Make your own figure · hairline");
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Make your own figure");
await expect(page.locator('[data-command="install"]')).toHaveText(new RegExp(INSTALL));
- await expect(page.locator('[data-command="prompt"]')).toHaveText(IDEAS.map((idea) => new RegExp(`/hairline-create ${idea}$`)));
+ await expect(page.locator('[data-command="prompt"]')).toHaveText(IDEAS.map((idea) => new RegExp(`/hairline-create ${literal(idea)}$`)));
await expect(page.locator("[data-steps] > li")).toHaveCount(5);
+ await expect(page.locator("#examples")).toContainText("Hairline is not affiliated with them.");
await frames(page);
expect(noise).toEqual([]);
});
@@ -73,7 +84,7 @@ test("a figure on /skill answers the pointer and goes back to rest", async ({ pa
test("each frame is named by what its figure means, and shows the page the skill wrote, light", async ({ page, request }) => {
await page.goto("/skill");
- await expect(page.locator("[data-example]")).toHaveCount(4);
+ await expect(page.locator("[data-example]")).toHaveCount(IDEAS.length);
for (const row of await page.locator("[data-example]").all()) {
const frame = row.locator("iframe");
expect((await frame.getAttribute("title"))!.length).toBeGreaterThan(20);
@@ -133,7 +144,7 @@ for (const width of [320, 900]) {
await page.setViewportSize({ width, height: 800 });
await page.goto("/skill");
const lines = page.locator('[data-command="prompt"] .pill-line');
- await expect(lines).toHaveCount(4);
+ await expect(lines).toHaveCount(IDEAS.length);
for (const over of await lines.evaluateAll((els) => els.map((el) => el.scrollWidth - el.clientWidth))) expect(over).toBeLessThanOrEqual(0);
const install = page.locator('[data-command="install"] .pill-line');
expect(await install.evaluate((el) => getComputedStyle(el).whiteSpace)).toBe("nowrap");
@@ -184,8 +195,8 @@ test.describe("without JavaScript", () => {
test("/skill still gives the install command, the prompts and the frames with the pages", async ({ page }) => {
await page.goto("/skill");
await expect(page.locator('[data-command="install"]')).toHaveText(new RegExp(INSTALL));
- await expect(page.locator('[data-command="prompt"]')).toHaveCount(4);
- await expect(page.locator('[data-example] iframe[src^="/skill/hairline-"]')).toHaveCount(4);
+ await expect(page.locator('[data-command="prompt"]')).toHaveCount(IDEAS.length);
+ await expect(page.locator('[data-example] iframe[src^="/skill/hairline-"]')).toHaveCount(IDEAS.length);
});
});
@@ -246,6 +257,9 @@ const FOLLOW_UPS: Record<string, string | undefined> = {
clearance: undefined,
sidings: "The rails almost disappear and the trains read as loose blocks. Make it read as a railway at a glance.",
storm: "The cloud looks like a stack of cylinders. Make it read as a cloud at a glance.",
+ vercel: undefined,
+ mastra: undefined,
+ notion: undefined,
};
test("a follow-up sits under its prompt as a second line that wraps instead of scrolling, and copies on its own", async ({ page, context }) => {
diff --git a/apps/site/test/skill.test.ts b/apps/site/test/skill.test.ts
index be247cf..e1e0e94 100644
--- a/apps/site/test/skill.test.ts
+++ b/apps/site/test/skill.test.ts
@@ -13,9 +13,22 @@ import { COMMAND, EXAMPLES, INSTALL, declared, examples } from "@/lib/skill";
const PUBLIC = fileURLToPath(new URL("../public/skill/", import.meta.url));
const VALIDATE = fileURLToPath(new URL("../../../skills/hairline-create/validate.mjs", import.meta.url));
+/** The three marks, each the whole line typed after the command. */
+const VERCEL = "an empty state for \"No deployments yet\", from Vercel's mark: the triangle as an upright slab hovering over a pad with its slot marked dim; the nearer the pointer, the lower it settles, until it seats. Name it vercel.";
+const MASTRA = "an empty state for \"No agents connected\", from Mastra's mark: the spheres of the M joined by necks on a board, the lone sphere standing apart; the pointer draws it toward the others, a neck forms, stretches and lets go. Name it mastra.";
+const NOTION = "an empty state for \"No pages inside\", from Notion's mark: the cube as a box with a lid, the N a relief on its front face; the pointer's height opens the lid on a spring, and the box is empty. Name it notion.";
+
describe("the skill's examples", () => {
- it("are the four ideas, in page order", () => {
- expect(EXAMPLES.map((e) => e.idea)).toEqual(["a sales funnel", "a rate limiter", "git branches", "weather over a city"]);
+ it("are the seven ideas, in page order", () => {
+ expect(EXAMPLES.map((e) => e.idea)).toEqual([
+ "a sales funnel",
+ "a rate limiter",
+ "git branches",
+ "weather over a city",
+ VERCEL,
+ MASTRA,
+ NOTION,
+ ]);
});
it("are exactly the files in public/skill", () => {
@@ -48,6 +61,9 @@ describe("the skill's examples", () => {
"a rate limiter": undefined,
"git branches": "The rails almost disappear and the trains read as loose blocks. Make it read as a railway at a glance.",
"weather over a city": "The cloud looks like a stack of cylinders. Make it read as a cloud at a glance.",
+ [VERCEL]: undefined,
+ [MASTRA]: undefined,
+ [NOTION]: undefined,
});
});