Isometric line figures that answer the pointer. For React and for anything with a DOM.
Home: the six figures play as a reel under one 36px row, the command beside Get started, and the skill one line away
Lucas Marquesd4b865aa7be3
diff --git a/apps/site/app/globals.css b/apps/site/app/globals.cssindex 79603f9..f37132d 100644--- a/apps/site/app/globals.css+++ b/apps/site/app/globals.css@@ -93,12 +93,6 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }@media (hover: hover) { .pill-manager:hover { background: var(--color-stone); } }.pill-manager:active { transform: scale(0.96); }-.slider { width: 100%; height: 18px; appearance: none; background: transparent; cursor: pointer; }-.slider::-webkit-slider-runnable-track { height: 2px; border-radius: 1px; background: rgba(0, 0, 0, 0.16); }-.slider::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), var(--lift); }-.slider::-moz-range-track { height: 2px; border-radius: 1px; background: rgba(0, 0, 0, 0.16); }-.slider::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2); }-/* Code: a frame, a bar with the title and a copy icon, the code. Line numbers are a counter in ::before, so they are never selected or copied. */.code { overflow: hidden; border-radius: 12px; background: #fafafa; box-shadow: inset 0 0 0 1px var(--color-stone); }.code-bar { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 4px 4px 14px; border-bottom: 1px solid var(--color-stone); }@@ -108,6 +102,12 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }.code-tab[aria-selected="true"] { background: #fff; color: var(--color-ink); box-shadow: 0 0 0 1px var(--color-stone); }@media (hover: hover) { .code-tab:hover { color: var(--color-ink); } }.code-tab:active { transform: scale(0.96); }+/* The tabs' highlight slides to the selected tab, under the tabs and never in the pointer's way. */+.slide { position: relative; display: flex; isolation: isolate; }+.slide-hl { position: absolute; top: 0; left: 0; z-index: -1; pointer-events: none; }+.slide[data-ready] .slide-hl, .slide[data-ready] .slide-hl::before { transition: transform 200ms var(--ease-out), clip-path 200ms var(--ease-out); }+/* a choice made with the keyboard lands at once */+.slide[data-keyed] .slide-hl, .slide[data-keyed] .slide-hl::before { transition: none; }/* Once measured, the selected tab's white plate and its ring are one highlight that slides: a stone layer clipped tothe tab plus a pixel, and a white one over it clipped to the tab. */.code-tabs[data-hl] .code-tab[aria-selected="true"] { background: none; box-shadow: none; }@@ -208,18 +208,21 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }/* The links hang off their group's mark on a hairline: a trunk down from the mark's centre, and an arm that bends out toeach link. Each row draws its own stretch of trunk and its arm, from 6px over the row before's centre, so the rowsstack into one line. The marked row's line is drawn in the group's colour: the trunk reaches down to the row's bend,- then the arm draws out, then a tip lands at its end; the line to a row left behind draws back the other way. */+ then the arm draws out, then a tip lands at its end; the line to a row left behind draws back the other way. The+ trunk is a border, revealed by a clip, not a scaled bar, on a box as wide as the rows' own, so it lands on the same+ device pixels as the grey line and the arms' borders at any zoom or column offset, with no grey showing beside it. */.rail ul { position: relative; padding-left: 24px; }.rail li { position: relative; }.rail li::before, .rail li::after { content: ""; position: absolute; left: -17px; width: 11px; border: 0 solid #e5e5e5; border-width: 0 0 1px 1px; border-bottom-left-radius: 6px; pointer-events: none; }.rail li::before { top: calc(-50% - 6px); bottom: 50%; }.rail li:first-child::before { top: -2px; }-.rail li::after { top: calc(50% - 6px); height: 6px; border-color: var(--gc); clip-path: inset(0 100% 0 0); }+/* over the next row's grey stretch, which starts at this row's bend and would otherwise cross the coloured arm */+.rail li::after { top: calc(50% - 6px); height: 6px; z-index: 1; border-color: var(--gc); clip-path: inset(0 100% 0 0); }.rail li:has(> [aria-current])::after { clip-path: inset(0); }-.rail ul::after { content: ""; position: absolute; top: -2px; bottom: 0; left: 7px; width: 1px; background: var(--gc); transform: scaleY(var(--reach, 0)); transform-origin: top; pointer-events: none; }+.rail ul::after { content: ""; position: absolute; top: -2px; bottom: 0; left: 7px; width: 11px; border-left: 1px solid var(--gc); clip-path: inset(0 0 calc((1 - var(--reach, 0)) * 100%) 0); pointer-events: none; }.rail .doc-link::before { content: ""; position: absolute; top: calc(50% - 2.5px); left: -6.5px; width: 4px; height: 4px; border-radius: 50%; background: var(--gc); transform: scale(0); }.rail .doc-link[aria-current]::before { transform: none; }-.rail [data-live] ul::after { transition: transform 300ms var(--ease-out); }+.rail [data-live] ul::after { transition: clip-path 300ms var(--ease-out); }.rail [data-live] li::after { transition: clip-path 140ms ease-out; }.rail [data-live] li:has(> [aria-current])::after { transition: clip-path 220ms var(--ease-out) 160ms; }.rail [data-live] .doc-link::before { transition: transform 120ms ease-out; }@@ -245,64 +248,70 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }.doc-sidebar::-webkit-scrollbar { display: none; }}-/* The hero: each block rises out of a blur, one after another. */-.hero-title { max-width: 16ch; font-size: 44px; font-weight: 500; line-height: 1.02; letter-spacing: -0.045em; text-wrap: balance; }-.hero-title em { font-family: var(--font-serif); font-size: 1.08em; font-weight: 400; letter-spacing: -0.02em; }-.hero-sub { margin-top: 20px; max-width: 44ch; font-size: 18px; line-height: 1.5; color: var(--color-muted); text-wrap: pretty; }-.hero-install { margin-top: 36px; width: 100%; max-width: 460px; }-.hero-actions { margin-top: 20px; display: flex; gap: 8px; }-@media (min-width: 768px) { .hero-title { font-size: 64px; } }-/* The way to the skill: a question, then the command as a prompt waiting to be sent. The ideas it has drawn come in- after it one at a time, each rising out of a blur as the last one leaves upward. */-.hero-skill { margin-top: 44px; display: grid; justify-items: center; gap: 12px; width: 100%; max-width: 460px; }-.hero-skill-ask { font-size: 14px; color: var(--color-muted); }-.prompt { display: flex; align-items: center; gap: 12px; width: 100%; height: 52px; padding: 0 6px 0 16px; border-radius: 14px; background: var(--color-stone); text-align: left; transition: transform 160ms var(--ease-out), background-color 150ms ease; will-change: transform; }-.prompt:active { transform: scale(0.98); }-.prompt-caret { flex: none; font-size: 14px; line-height: 1; color: var(--color-faint); }-.prompt-line { flex: 1; min-width: 0; height: 20px; overflow: hidden; font-size: 14px; line-height: 20px; white-space: nowrap; }-.prompt-line[data-more] { mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }-.prompt-ideas { position: relative; display: inline-block; height: 20px; vertical-align: top; }-.prompt-idea { position: absolute; top: 0; left: 0; opacity: 0; transform: translateY(6px); filter: blur(3px); transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out), filter 260ms var(--ease-out); }-.prompt-idea[data-on] { opacity: 1; transform: none; filter: none; }-.prompt-idea[data-gone] { transform: translateY(-6px); }-.prompt-go { flex: none; display: inline-flex; align-items: center; gap: 8px; margin-right: 6px; font-size: 12.5px; color: var(--color-faint); }-/* a key, not a button: lit from above, it sinks a pixel when the prompt is pressed */-.prompt-key { display: grid; place-items: center; width: 30px; height: 26px; border-radius: 7px; background: #fff; color: var(--color-muted); box-shadow: inset 0 0 0 1px #00000012, 0 1.5px 0 #00000014; transition: transform 120ms var(--ease-out), box-shadow 120ms var(--ease-out), color 150ms ease; }-.prompt:active .prompt-key { transform: translateY(1px); box-shadow: inset 0 0 0 1px #00000012, 0 0.5px 0 #00000014; }+/* The hero, one column: each block rises out of a blur, one after another. */+.hero-title { max-width: 18ch; font-size: clamp(26px, 4vw, 34px); font-weight: 500; line-height: 1.12; letter-spacing: -0.03em; text-wrap: balance; }+.hero-title em { font-family: var(--font-serif); font-size: 1.1em; font-weight: 400; letter-spacing: -0.01em; }+.hero-sub { margin-top: 12px; max-width: 40ch; font-size: 15px; line-height: 1.6; color: var(--color-muted); text-wrap: pretty; }+/* the command and the way in, side by side; on a phone the button goes under the pill. Here the pill is the button's+ size, 36px with its 9px corners, so the two read as one row; the copy keeps a 36px target round a 28px circle. */+.hero-get { margin-top: 28px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; width: 100%; }+.hero-get .pill { flex: 0 1 312px; min-width: 0; height: 36px; gap: 9px; padding: 0 4px 0 13px; border-radius: 9px; font-size: 13px; margin-right: 4px; }+.hero-get .pill-line { line-height: 36px; }+.hero-get .icopy { width: 28px; height: 28px; }+.hero-get .icopy::after { inset: -4px; }++/* The way to the skill: an empty hexagon by the words. A hover draws its three inner edges one after another, and it+ becomes a cube; leaving takes them back faster than they came. */+.hero-skill { margin-top: 22px; }+.skill-link { position: relative; display: inline-flex; align-items: center; gap: 9px; padding: 6px 2px; font-size: 13px; line-height: 1; color: var(--color-muted); transition: color 160ms ease; }+.skill-link::after { content: ""; position: absolute; inset: -8px -6px; }+.skill-link svg { flex: none; overflow: visible; }+.skill-link-hex { stroke: var(--color-faint); transition: stroke 200ms ease; }+.skill-link-edge { stroke: var(--color-ink); stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 160ms ease-out; }@media (hover: hover) {- .prompt:hover { background: #efefef; }- .prompt:hover .prompt-key { color: var(--color-ink); }-}-/* on a phone the prompt wraps as a long prompt would: the idea goes under the command instead of off the edge */-@media (max-width: 480px) {- .prompt { height: auto; padding-block: 12px; }- .prompt-caret { align-self: flex-start; line-height: 20px; }- .prompt-line { height: auto; }- .prompt-ideas { display: block; }- .prompt-go-label { display: none; }+ .skill-link:hover { color: var(--color-ink); }+ .skill-link:hover .skill-link-hex { stroke: var(--color-ink); }+ .skill-link:hover .skill-link-edge { stroke-dashoffset: 0; transition: stroke-dashoffset 360ms var(--ease-out); }+ .skill-link:hover .skill-link-edge:nth-of-type(3) { transition-delay: 70ms; }+ .skill-link:hover .skill-link-edge:nth-of-type(4) { transition-delay: 140ms; }}+.skill-link:focus-visible { color: var(--color-ink); }+.skill-link:focus-visible .skill-link-hex { stroke: var(--color-ink); }+.skill-link:focus-visible .skill-link-edge { stroke-dashoffset: 0; }++/* The reel: the figure on the page itself, six ticks under it, and the caption of the one on show. Every figure is+ 5:4 and the captions share one cell, so a change of figure never moves the page. */+.hero-reel { width: 100%; margin-top: 14px; scroll-margin-top: calc(var(--topbar) + 24px); }+.reel { display: grid; justify-items: center; }+.reel-stage { width: 100%; max-width: 440px; aspect-ratio: 5 / 4; --hairline-plate: var(--color-canvas); }+.reel-stage > div { animation: reel-in 320ms var(--ease-out) both; }+.reel-ticks { display: flex; margin-top: 10px; }+.reel-tick { display: grid; place-items: center; width: 30px; height: 26px; border-radius: 6px; }+.reel-tick::before, .reel-fill { grid-area: 1 / 1; width: 20px; height: 1.5px; border-radius: 1px; }+.reel-tick::before { content: ""; background: rgba(0, 0, 0, 0.12); transition: background-color 150ms ease; }+@media (hover: hover) { .reel-tick:hover::before { background: rgba(0, 0, 0, 0.3); } }+.reel-fill { background: var(--color-ink); transform: scaleX(0); transform-origin: left; }+/* the clock: the fill runs while its figure plays, and its end moves the reel on; a pause only holds it */+.reel[data-playing] .reel-tick[aria-current] .reel-fill { animation: reel-tick 6000ms linear both; }+.reel[data-playing][data-paused] .reel-tick[aria-current] .reel-fill { animation-play-state: paused; }+/* once the reel has stopped, the tick of the figure on show stays drawn */+.reel:not([data-playing]) .reel-tick[aria-current] .reel-fill { transform: none; transition: transform 240ms var(--ease-out); }+.reel-caps { display: grid; width: 100%; max-width: 46ch; margin-top: 4px; font-size: 13.5px; line-height: 1.55; }+.reel-cap { grid-area: 1 / 1; color: var(--color-muted); text-wrap: balance; visibility: hidden; }+.reel-cap[data-on] { visibility: visible; animation: reel-cap 300ms var(--ease-out) both; }+.reel-cap b { font-weight: 500; color: var(--color-ink); }+@keyframes reel-in { from { opacity: 0; filter: blur(4px); } to { opacity: 1; filter: none; } }+@keyframes reel-tick { to { transform: none; } }+@keyframes reel-cap { from { opacity: 0; filter: blur(3px); transform: translateY(3px); } to { opacity: 1; filter: none; transform: none; } }/* Rise, blur and fade end in that order. The rise and the blur end in steps: moving text is drawn on whole devicepixels, so the last pixel of travel lands as a hop, and Chrome draws no blur under 0.4px, so the last of it goesin one frame. The hop comes under the blur, the blur goes while the block still fades in, and the fade ends it. */.hero-rise > * { animation: fade 750ms var(--ease-out) both, unblur 560ms var(--ease-out) both, rise 380ms var(--ease-out) both; animation-delay: calc(var(--i) * 70ms + 60ms); }-.enter { animation: fade 850ms var(--ease-out) both, unblur 640ms var(--ease-out) both, rise 440ms var(--ease-out) both; animation-delay: var(--d, 0ms); }-.enter-hint { animation: hint 220ms var(--ease-out) both; }@keyframes unblur { from { filter: blur(6px); } to { filter: none; } }@keyframes rise { from { transform: translateY(12px); } to { transform: none; } }-@keyframes hint { from { opacity: 0; transform: translateY(2px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }@keyframes fade { from { opacity: 0; } to { opacity: 1; } }-/* A single choice whose highlight slides to the checked option. */-.slide { position: relative; display: flex; isolation: isolate; }-.slide-hl { position: absolute; top: 0; left: 0; z-index: -1; pointer-events: none; }-.slide[data-ready] .slide-hl, .slide[data-ready] .slide-hl::before { transition: transform 200ms var(--ease-out), clip-path 200ms var(--ease-out); }-/* a choice made with the keyboard lands at once */-.slide[data-keyed] .slide-hl, .slide[data-keyed] .slide-hl::before { transition: none; }-.slide-item { position: relative; display: inline-flex; flex: none; align-items: center; justify-content: center; white-space: nowrap; color: var(--color-muted); transition: color 150ms ease; }-.slide-item[aria-checked="true"] { color: var(--color-ink); }-@media (hover: hover) { .slide-item:hover { color: var(--color-ink); } }-/* Copy as an icon: the clipboard blurs and shrinks away as the check grows in. That swap is the one scale a copymakes, so the round button stays still on press instead of shrinking under it. */.icopy { position: relative; flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--color-muted); transition: color 150ms ease, background-color 150ms ease; }@@ -313,44 +322,6 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }.icopy-b, .icopy[data-copied] .icopy-a { opacity: 0; transform: scale(0.25); filter: blur(4px); }.icopy[data-copied] .icopy-b { opacity: 1; transform: none; filter: none; }-/* The inspector's snippet, in greys: only the tag name carries weight. */-.p-code { flex: 1; min-width: 0; margin: 0; overflow-x: auto; font: 400 13px/1.65 var(--font-mono); color: var(--color-ink); white-space: pre; }-.t-kw { color: var(--code-token-keyword); }-.t-str { color: var(--code-token-string); }-.t-tag { color: var(--code-token-constant); font-weight: 500; }-.t-attr { color: var(--code-token-function); }-.t-val { color: var(--code-foreground); }--/* The inspector: the figure on the page itself, one dock under it for every control. */-.s-inspector { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; }-.s-stage { position: relative; display: grid; place-items: center; width: 100%; max-width: 760px; padding: clamp(8px, 4vw, 40px); border-radius: 28px; }-.s-stage > [data-hairline] { width: 100%; max-width: 560px; }-.s-stage[data-dark] { background: #08090a; }-.s-dock { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; max-width: 100%; padding: 6px; border-radius: 16px; background: #fff; box-shadow: inset 0 0 0 1px var(--color-stone), var(--lift-lg); }-.s-figures { min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: none; }-.s-figures::-webkit-scrollbar { display: none; }-.s-figures .slide-item { height: 36px; padding: 0 12px; font-size: 14px; }-.s-figures { --slide-radius: 10px; }-.s-figures .slide-hl { background: var(--color-stone); }-.s-row { display: flex; align-items: center; gap: 12px; padding-left: 12px; border-left: 1px solid var(--color-line); }-.s-range { display: flex; align-items: center; gap: 10px; width: 230px; }-.s-range-label { font-size: 13px; color: var(--color-muted); }-.s-range .slider { flex: 1; min-width: 0; }-.s-value { width: 4ch; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }-.s-themes { padding: 2px; border-radius: 10px; background: var(--color-stone); }-.s-themes .slide-item { width: 36px; height: 36px; }-.s-themes .slide-hl { border-radius: 8px; background: #fff; box-shadow: var(--lift); }-.s-hint { margin-top: 14px; min-height: 1.5em; font-size: 13px; line-height: 1.5; color: var(--color-muted); text-align: center; text-wrap: balance; }-.s-code { margin-top: 28px; display: flex; align-items: flex-start; gap: 8px; width: 100%; max-width: 560px; padding: 6px 6px 6px 0; border-radius: 14px; background: #fff; box-shadow: inset 0 0 0 1px var(--color-stone), var(--lift); }-.s-code .p-code { padding: 10px 0 10px 18px; }--@media (max-width: 760px) {- .s-dock { width: 100%; }- .s-figures { flex: 1 1 100%; }- .s-row { width: 100%; justify-content: space-between; padding: 6px 0 0 10px; border-left: 0; border-top: 1px solid var(--color-line); }- .s-range { flex: 1; width: auto; }-}-/* Inspo, as an essay: the story in the column, each step under its number, the evidence on cards between the prose. */.inspo-label { font: 400 11.5px/1.5 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-muted); }.inspo .col-h1 { margin-top: 10px; }@@ -403,12 +374,12 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }.props[data-tokens] td:nth-child(3) { flex-basis: 100%; margin-top: 6px; }}@media (prefers-reduced-motion: reduce) {- .hero-rise > *, .enter, .enter-hint { animation-name: fade; }- .slide[data-ready] .slide-hl, .slide[data-ready] .slide-hl::before { transition: none; }+ .hero-rise > *, .reel-stage > div, .reel-cap[data-on] { animation-name: fade; }+ .reel[data-playing] .reel-tick[aria-current] .reel-fill { animation: none; }+ .skill-link-hex, .skill-link-edge, .skill-link:hover .skill-link-edge { transition: none; }.icopy-b, .icopy[data-copied] .icopy-a { transform: none; filter: none; }- .prompt-idea { transform: none; filter: none; transition: opacity 200ms ease; }- .prompt:active, .prompt:active .prompt-key { transform: none; }[data-live] > .doc-dot, .doc-strip [data-live] .doc-link[aria-current] > span, .doc-strip [data-live] .doc-link > span { transition: none; }+ .slide[data-ready] .slide-hl, .slide[data-ready] .slide-hl::before { transition: none; }.rail [data-live] ul::after, .rail [data-live] li::after, .rail [data-live] li:has(> [aria-current])::after,.rail [data-live] .doc-link::before, .rail [data-live] .doc-link[aria-current]::before { transition: none; }}@@ -429,8 +400,6 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }.ex { overflow: hidden; margin-top: 4px; }.ex-h { display: flex; align-items: flex-start; gap: 4px; padding: 0 6px 0 2px; border-bottom: 1px solid var(--color-line); }.ex-h .pill { flex: 1; min-width: 0; background: none; box-shadow: none; font-size: 12.5px; }-.ex-open { position: relative; flex: none; display: grid; place-items: center; width: 36px; height: 36px; margin-top: 6px; border-radius: 50%; color: var(--color-muted); transition: color 150ms ease, background-color 150ms ease; }-@media (hover: hover) { .ex-open:hover { color: var(--color-ink); background: var(--color-stone); } }.ex-b { padding: 12px 16px 14px; }.ex-name { font: 500 12px/1.5 var(--font-mono); }.ex-means { margin-top: 2px; font-size: 13px; line-height: 1.55; color: var(--color-muted); text-wrap: pretty; }diff --git a/apps/site/app/page.tsx b/apps/site/app/page.tsxindex a69ae40..663303a 100644--- a/apps/site/app/page.tsx+++ b/apps/site/app/page.tsx@@ -1,10 +1,8 @@import type { CSSProperties } from "react";-import { Footer, GitHub, Topbar } from "@/components/chrome";-import { Inspector } from "@/components/inspector";+import { Footer, Topbar } from "@/components/chrome";import { Install } from "@/components/install";-import { SkillPrompt } from "@/components/skill-prompt";-import { LINKS } from "@/lib/figures";-import { COMMAND, EXAMPLES } from "@/lib/skill";+import { Reel } from "@/components/reel";+import { SkillLink } from "@/components/skill-link";import { install } from "@/lib/snippets";const SITE = process.env.NEXT_PUBLIC_SITE_URL!;@@ -13,31 +11,27 @@ const SITE = process.env.NEXT_PUBLIC_SITE_URL!;const at = (i: number) => ({ "--i": i }) as CSSProperties;/**- * The home: the pitch, then one figure to play with. A Server Component, so- * the figure is the package's React component rendered from here, and every- * deploy runs it through server rendering and hydration. The rest lives on- * /docs.+ * The home, as one column: the pitch, the command with the way in, the way to the+ * skill, then the six figures playing by themselves. A Server Component, so the figures+ * are the package's React components rendered from here, and every deploy+ * runs them through server rendering and hydration. The rest lives on /docs.*/export default function Page() {return (<><Topbar />- <main className="mx-auto grid max-w-[1080px] gap-10 px-[clamp(18px,5vw,28px)] pb-24 pt-16 md:gap-12 md:pt-24 [&>*]:min-w-0">+ <main className="mx-auto max-w-[1080px] px-[clamp(18px,5vw,28px)] pb-24 pt-[clamp(48px,9vh,96px)]"><section aria-labelledby="hairline" className="hero-rise grid grid-cols-[minmax(0,1fr)] justify-items-center text-center"><h1 id="hairline" className="hero-title" style={at(0)}>Line drawings that <em>answer</em> the pointer.</h1><p className="hero-sub" style={at(1)}>Six isometric figures for the web. SVG, no dependencies, React or plain DOM.</p>- <div className="hero-install" style={at(2)}><Install commands={install(SITE)} /></div>- <div className="hero-actions" style={at(3)}>+ <div className="hero-get" style={at(2)}>+ <Install commands={install(SITE)} /><a className="btn btn-primary press" href="/docs">Get started</a>- <a className="btn press" href={LINKS.github}><GitHub /> GitHub</a></div>- <SkillPrompt command={COMMAND} ideas={EXAMPLES.map((e) => e.idea)} style={at(4)} />- </section>-- <section id="try" aria-label="Try it" className="scroll-mt-[calc(var(--topbar)+24px)]">- <Inspector />+ <p className="hero-skill" style={at(3)}><SkillLink /></p>+ <div id="try" className="hero-reel" style={at(4)}><Reel /></div></section></main><Footer />diff --git a/apps/site/app/skill/page.tsx b/apps/site/app/skill/page.tsxindex 4edaa66..ecf02c4 100644--- a/apps/site/app/skill/page.tsx+++ b/apps/site/app/skill/page.tsx@@ -93,11 +93,6 @@ export default function Skill() {<article key={e.file} className="card ex" data-example={e.name} aria-label={e.prompt}><div className="ex-h"><Command code={e.prompt} kind="prompt" label={`Copy prompt: ${e.idea}`} />- <a className="ex-open" href={e.href} target="_blank" rel="noreferrer" aria-label={`Open ${e.file} in a new tab`} title="Open the file">- <svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">- <path d="M6 3.75H4.25a1.5 1.5 0 0 0-1.5 1.5v6.5a1.5 1.5 0 0 0 1.5 1.5h6.5a1.5 1.5 0 0 0 1.5-1.5V10M9 2.75h4.25V7M13 3 7.5 8.5" />- </svg>- </a></div><div className="ex-b"><p className="ex-name">{e.name}</p>diff --git a/apps/site/components/code.tsx b/apps/site/components/code.tsxdeleted file mode 100644index c8008b9..0000000--- a/apps/site/components/code.tsx+++ /dev/null@@ -1,22 +0,0 @@-import type { ReactNode, RefObject } from "react";--const TOKEN = /(\bimport\b|\bfrom\b)|("[^"]*")|(<\/?)([A-Z]\w*)|(\w+)(?==)|(?<==)(\{[^}]*\})/g;--/** The inspector's snippet, coloured by hand: it only ever holds one import and one tag. */-export function Code({ text, codeRef, className = "" }: { text: string; codeRef?: RefObject<HTMLPreElement | null>; className?: string }) {- const parts: ReactNode[] = [];- const body = text.trimEnd();- let last = 0;- for (const m of body.matchAll(TOKEN)) {- if (m.index > last) parts.push(body.slice(last, m.index));- const k = parts.length;- if (m[1]) parts.push(<span key={k} className="t-kw">{m[1]}</span>);- else if (m[2]) parts.push(<span key={k} className="t-str">{m[2]}</span>);- else if (m[4]) parts.push(<span key={k}>{m[3]}<span className="t-tag">{m[4]}</span></span>);- else if (m[5]) parts.push(<span key={k} className="t-attr">{m[5]}</span>);- else if (m[6]) parts.push(<span key={k} className="t-val">{m[6]}</span>);- last = m.index + m[0].length;- }- parts.push(body.slice(last));- return <pre ref={codeRef} className={`p-code ${className}`}>{parts}</pre>;-}diff --git a/apps/site/components/inspector.tsx b/apps/site/components/inspector.tsxdeleted file mode 100644index 079cb75..0000000--- a/apps/site/components/inspector.tsx+++ /dev/null@@ -1,66 +0,0 @@-"use client";--import { useId, useRef, useState, type CSSProperties } from "react";-import { Exploded, Phosphor, Riffle, Slow, Terrain, Turntable } from "@lucasmarkes/hairline/react";-import { FIGURES, type FigureId } from "@/lib/figures";-import { snippet, type Theme } from "@/lib/snippets";-import { Code } from "./code";-import { CopyIcon } from "./copy";-import { Slide, type Option } from "./slide";--const COMPONENTS = { riffle: Riffle, terrain: Terrain, exploded: Exploded, phosphor: Phosphor, slow: Slow, turntable: Turntable };-const FIGURE_OPTIONS: Option<FigureId>[] = FIGURES.map((f) => ({ value: f.id, label: f.name }));--const ICON = { width: 14, height: 14, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.3, "aria-hidden": true } as const;-const THEMES: Option<Theme>[] = [- { value: "auto", name: "Auto", label: <svg {...ICON}><circle cx="8" cy="8" r="5.5" /><path d="M8 2.5v11a5.5 5.5 0 0 0 0-11z" fill="currentColor" stroke="none" /></svg> },- { value: "light", name: "Light", label: <svg {...ICON} strokeLinecap="round"><circle cx="8" cy="8" r="2.75" /><path d="M8 1.75v1.5M8 12.75v1.5M1.75 8h1.5M12.75 8h1.5M3.6 3.6l1.05 1.05M11.35 11.35l1.05 1.05M3.6 12.4l1.05-1.05M11.35 4.65l1.05-1.05" /></svg> },- { value: "dark", name: "Dark", label: <svg {...ICON}><path d="M13.25 9.6A5.5 5.5 0 0 1 6.4 2.75a5.5 5.5 0 1 0 6.85 6.85z" strokeLinejoin="round" /></svg> },-];--/** A CSS custom property in a style object. */-const vars = (v: Record<string, string>) => v as CSSProperties;--/**- * One large figure standing on the page itself, with no card around it, and- * one dock under it for every control: which figure, how intense, which- * theme. The snippet under them is the code for what is on screen.- */-export function Inspector() {- const [id, setId] = useState<FigureId>("terrain");- const [intensity, setIntensity] = useState(0.5);- const [theme, setTheme] = useState<Theme>("auto");- const slider = useId();- const code = useRef<HTMLPreElement>(null);- const doc = FIGURES.find((f) => f.id === id)!;- const Figure = COMPONENTS[id];- const text = snippet(doc.name, { intensity, theme });- const dark = theme === "dark";-- return (- <div className="s-inspector" data-inspector>- {/* off dark, the figure's plate is the page, so it stands without a box */}- <div className="s-stage enter" style={vars({ "--d": "400ms", ...(dark ? {} : { "--hairline-plate": "var(--color-canvas)" }) })} data-figure={id} data-dark={dark || undefined}>- <Figure key={id} intensity={intensity} theme={theme} />- </div>-- <div className="s-dock enter" style={vars({ "--d": "460ms" })}>- <Slide label="Figure" options={FIGURE_OPTIONS} value={id} onChange={setId} clip className="s-figures" />- <div className="s-row">- <div className="s-range">- <label htmlFor={slider} className="s-range-label">Intensity</label>- <input id={slider} type="range" className="slider" min={0} max={1} step={0.05} value={intensity} onChange={(event) => setIntensity(Number(event.target.value))} />- <output htmlFor={slider} className="s-value">{intensity.toFixed(2)}</output>- </div>- <Slide label="Theme" options={THEMES} value={theme} onChange={setTheme} className="s-themes" />- </div>- </div>- <p key={id} className="s-hint enter-hint">{doc.stronger}</p>-- <div className="s-code enter" style={vars({ "--d": "520ms" })} data-snippet>- <Code text={text} codeRef={code} />- <CopyIcon text={text} select={code} label="Copy snippet" className="s-copy" />- </div>- </div>- );-}diff --git a/apps/site/components/rail.tsx b/apps/site/components/rail.tsxindex ac3eb40..42b9da8 100644--- a/apps/site/components/rail.tsx+++ b/apps/site/components/rail.tsx@@ -84,15 +84,21 @@ function place(list: HTMLElement | null, active: string) {}/**- * Draws the rail's line to the marked link: each group's trunk reaches down to the marked row's bend, 6px over its- * centre, or back up to nothing in the other groups. The row's arm and tip take it from there, in CSS.+ * Draws the rail's line to the marked link: each group's trunk reaches down to where the marked row's arm starts to+ * bend (6px over its centre) and a pixel into it, so the two meet with no seam, or back up to nothing in the other+ * groups. The row's arm and tip take it from there, in CSS. Measured in fractions of a pixel, as the arm is placed.*/function reach(nav: HTMLElement | null, active: string) {if (!nav?.clientWidth) return;for (const list of nav.querySelectorAll<HTMLElement>("ul")) {const row = list.querySelector(`a[href="#${active}"]`)?.parentElement;- // the trunk runs from 2px over the list to its foot- const f = row ? (row.offsetTop + row.offsetHeight / 2 - 4) / (list.offsetHeight + 2) : 0;+ let f = 0;+ if (row) {+ const box = list.getBoundingClientRect();+ const at = row.getBoundingClientRect();+ // the trunk runs from 2px over the list to its foot+ f = (at.top - box.top + at.height / 2 - 6 + 1 + 2) / (box.height + 2);+ }list.style.setProperty("--reach", String(f));}live(nav);diff --git a/apps/site/components/reel.tsx b/apps/site/components/reel.tsxnew file mode 100644index 0000000..80d8ad2--- /dev/null+++ b/apps/site/components/reel.tsx@@ -0,0 +1,61 @@+"use client";++import { useEffect, useState, type CSSProperties } from "react";+import { Exploded, Phosphor, Riffle, Slow, Terrain, Turntable } from "@lucasmarkes/hairline/react";+import { FIGURES } from "@/lib/figures";++const COMPONENTS = { riffle: Riffle, terrain: Terrain, exploded: Exploded, phosphor: Phosphor, slow: Slow, turntable: Turntable };++/**+ * The six figures, one at a time, standing on the page with no controls. Each+ * plays for six seconds while its tick fills, then the next comes in. A+ * pointer on the figure pauses the reel, and so does a hidden tab; picking a+ * tick shows that figure and stops the reel for good. Under reduced motion it+ * never starts.+ *+ * The tick's fill is the clock: a CSS animation whose end moves the reel on,+ * so a pause is only `animation-play-state`. Nothing moves the page when the+ * figure changes: every figure is 5:4, and the six captions share one cell,+ * as tall as the longest of them, with only the current one shown.+ */+export function Reel({ style }: { style?: CSSProperties }) {+ const [at, setAt] = useState(0);+ const [playing, setPlaying] = useState(true);+ const [held, setHeld] = useState(false);+ const [hidden, setHidden] = useState(false);+ const Figure = COMPONENTS[FIGURES[at].id];++ useEffect(() => {+ if (matchMedia("(prefers-reduced-motion: reduce)").matches) setPlaying(false);+ const visibility = () => setHidden(document.hidden);+ document.addEventListener("visibilitychange", visibility);+ return () => document.removeEventListener("visibilitychange", visibility);+ }, []);++ const pick = (i: number) => {+ setAt(i);+ setPlaying(false);+ };++ return (+ <div className="reel" style={style} data-reel data-playing={playing ? "" : undefined} data-paused={held || hidden ? "" : undefined}>+ <div className="reel-stage" data-figure={FIGURES[at].id} onPointerEnter={() => setHeld(true)} onPointerLeave={() => setHeld(false)}>+ <Figure key={at} />+ </div>+ <div className="reel-ticks" role="group" aria-label="Figures">+ {FIGURES.map((f, i) => (+ <button key={f.id} type="button" className="reel-tick" aria-label={f.name} title={f.name} aria-current={i === at || undefined} onClick={() => pick(i)}>+ <span className="reel-fill" onAnimationEnd={i === at ? () => setAt((at + 1) % FIGURES.length) : undefined} />+ </button>+ ))}+ </div>+ <div className="reel-caps">+ {FIGURES.map((f, i) => (+ <p key={f.id} className="reel-cap" data-on={i === at ? "" : undefined}>+ <b>{f.name}.</b> {f.summary}+ </p>+ ))}+ </div>+ </div>+ );+}diff --git a/apps/site/components/skill-link.tsx b/apps/site/components/skill-link.tsxnew file mode 100644index 0000000..909a7e1--- /dev/null+++ b/apps/site/components/skill-link.tsx@@ -0,0 +1,18 @@+/**+ * The home's way to the skill: one line by an empty hexagon. A hover draws the+ * hexagon's three inner edges, one after another, and it becomes a cube: the+ * words say "draw your own" and the mark does. CSS only.+ */+export function SkillLink() {+ return (+ <a className="skill-link" href="/skill">+ <svg viewBox="0 0 16 16" width="15" height="15" fill="none" strokeWidth="1.1" strokeLinejoin="round" strokeLinecap="round" aria-hidden="true">+ <path className="skill-link-hex" d="M8 1.5 13.6 4.75v6.5L8 14.5 2.4 11.25v-6.5z" />+ <path className="skill-link-edge" pathLength={1} d="M8 8 2.4 4.75" />+ <path className="skill-link-edge" pathLength={1} d="M8 8l5.6-3.25" />+ <path className="skill-link-edge" pathLength={1} d="M8 8v6.5" />+ </svg>+ <span>Or draw your own with the skill</span>+ </a>+ );+}diff --git a/apps/site/components/skill-prompt.tsx b/apps/site/components/skill-prompt.tsxdeleted file mode 100644index fa6e27c..0000000--- a/apps/site/components/skill-prompt.tsx+++ /dev/null@@ -1,60 +0,0 @@-"use client";--import { type CSSProperties, useEffect, useRef, useState } from "react";--/**- * The home's way to the skill: a question, then the skill's command as a- * prompt waiting to be sent, with the ideas it has drawn typed after it one- * at a time. The whole prompt is the link; the return key says it goes. Under- * reduced motion the first idea stays. An idea wider than the prompt fades at- * the edge, as the install line does.- */-export function SkillPrompt({ command, ideas, style }: { command: string; ideas: string[]; style?: CSSProperties }) {- const [{ at, prev }, setTurn] = useState({ at: 0, prev: -1 });- const line = useRef<HTMLElement>(null);- const [more, setMore] = useState(false);-- useEffect(() => {- if (matchMedia("(prefers-reduced-motion: reduce)").matches) return;- const timer = setInterval(() => setTurn((t) => ({ at: (t.at + 1) % ideas.length, prev: t.at })), 2600);- return () => clearInterval(timer);- }, [ideas.length]);-- useEffect(() => {- const el = line.current;- const idea = el?.querySelector<HTMLElement>(`[data-idea="${at}"]`);- if (!el || !idea) return;- const measure = () => setMore(idea.getBoundingClientRect().right > el.getBoundingClientRect().right + 0.5);- measure();- const resize = new ResizeObserver(measure);- resize.observe(el);- return () => resize.disconnect();- }, [at]);-- return (- <div className="hero-skill" style={style}>- <p className="hero-skill-ask">Need a figure that isn’t one of the six?</p>- <a className="prompt" href="/skill" aria-label="Make your own figure with the hairline-create skill">- <code aria-hidden="true" className="prompt-caret">›</code>- <code ref={line} aria-hidden="true" className="prompt-line" data-more={more ? "" : undefined}>- <span className="text-muted">{command} </span>- <span className="prompt-ideas">- {ideas.map((idea, i) => (- <span key={idea} className="prompt-idea" data-idea={i} data-on={i === at ? "" : undefined} data-gone={i === prev ? "" : undefined}>- {idea}- </span>- ))}- </span>- </code>- <span className="prompt-go" aria-hidden="true">- <span className="prompt-go-label">to draw</span>- <span className="prompt-key">- <svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">- <path d="M12.5 3.5v4a2 2 0 0 1-2 2h-7M6 6.5l-3 3 3 3" />- </svg>- </span>- </span>- </a>- </div>- );-}diff --git a/apps/site/components/slide.tsx b/apps/site/components/slide.tsxdeleted file mode 100644index a15a433..0000000--- a/apps/site/components/slide.tsx+++ /dev/null@@ -1,70 +0,0 @@-"use client";--import { useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent, type ReactNode } from "react";--export type Option<T extends string> = { value: T; label: ReactNode; name?: string };--/**- * A single choice as a radio group, with a highlight that slides to the- * checked option. The slide is turned on after the first paint, so the page- * does not open with it moving. Arrow keys move the choice, and the highlight- * with it at once; only a pointer's choice slides.- *- * The highlight never animates its size. It is moved with transform; where the- * options differ in width (`clip`), it spans the whole row and a clip-path- * cuts it down to the checked option.- */-export function Slide<T extends string>({ options, value, onChange, label, clip = false, className = "" }: { options: Option<T>[]; value: T; onChange: (value: T) => void; label: string; clip?: boolean; className?: string }) {- const group = useRef<HTMLDivElement>(null);- const [box, setBox] = useState<{ x: number; y: number; w: number; h: number; rowW: number; rowH: number } | null>(null);- const [ready, setReady] = useState(false);- const [keyed, setKeyed] = useState(false);-- useLayoutEffect(() => {- const root = group.current;- if (!root) return;- const measure = () => {- const el = root.querySelector<HTMLElement>('[aria-checked="true"]');- const last = root.querySelector<HTMLElement>("[role=radio]:last-of-type");- // the row's extent is read from its options, not the group, which can scroll- if (el && last) setBox({ x: el.offsetLeft, y: el.offsetTop, w: el.offsetWidth, h: el.offsetHeight, rowW: last.offsetLeft + last.offsetWidth, rowH: last.offsetTop + last.offsetHeight });- };- measure();- const resize = new ResizeObserver(measure);- resize.observe(root);- return () => resize.disconnect();- }, [value]);-- useEffect(() => {- let inner = 0;- const outer = requestAnimationFrame(() => (inner = requestAnimationFrame(() => setReady(true))));- return () => {- cancelAnimationFrame(outer);- cancelAnimationFrame(inner);- };- }, []);-- const onKeyDown = (event: KeyboardEvent) => {- const step = event.key === "ArrowRight" || event.key === "ArrowDown" ? 1 : event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 0;- if (!step) return;- event.preventDefault();- setKeyed(true);- const at = options.findIndex((o) => o.value === value);- const next = (at + step + options.length) % options.length;- onChange(options[next].value);- group.current?.querySelectorAll<HTMLButtonElement>("[role=radio]")[next]?.focus();- };-- return (- <div ref={group} role="radiogroup" aria-label={label} className={`slide ${className}`} data-ready={ready || undefined} data-keyed={keyed || undefined} onKeyDown={onKeyDown} onPointerDown={() => setKeyed(false)}>- {box ? <span className="slide-hl" aria-hidden="true" style={clip- ? { width: box.rowW, height: box.rowH, clipPath: `inset(${box.y}px ${box.rowW - box.x - box.w}px ${box.rowH - box.y - box.h}px ${box.x}px round var(--slide-radius))` }- : { width: box.w, height: box.h, transform: `translate(${box.x}px, ${box.y}px)` }} /> : null}- {options.map((o) => (- <button key={o.value} type="button" role="radio" aria-checked={o.value === value} aria-label={o.name} title={o.name} tabIndex={o.value === value ? 0 : -1} className="slide-item" onClick={() => onChange(o.value)}>- {o.label}- </button>- ))}- </div>- );-}diff --git a/apps/site/components/tabs.tsx b/apps/site/components/tabs.tsxindex a2bfcd4..4f90f8c 100644--- a/apps/site/components/tabs.tsx+++ b/apps/site/components/tabs.tsx@@ -14,8 +14,7 @@ const KEY = "hairline:docs-tab";* the first tab; the stored one is read after mount, and storage that throws* (private mode, blocked) leaves the first tab on.*- * The selected tab's plate slides to a tab picked with a pointer, as in Slide:- * it spans the row and a clip-path cuts it down to the tab, so it never+ * The selected tab's plate slides to a tab picked with a pointer. It spans the row and a clip-path cuts it down to the tab, so it never* animates its size. It is turned on after the first paint, and a tab picked* with the arrow keys lands at once.*/diff --git a/apps/site/lib/snippets.ts b/apps/site/lib/snippets.tsindex c19a0b7..6a054b0 100644--- a/apps/site/lib/snippets.ts+++ b/apps/site/lib/snippets.ts@@ -18,22 +18,6 @@ export function install(base: string): { label: string; code: string }[] {];}-export type Theme = "auto" | "light" | "dark";--/**- * The inspector's snippet: the component with only the props that differ- * from the default. The intensity is read to two decimals, the slider's- * precision, so 0.5 and a float a hair away from it both leave it out.- */-export function snippet(name: string, state: { intensity: number; theme: Theme }): string {- const intensity = Math.round(state.intensity * 100) / 100;- const props = [- intensity !== 0.5 ? ` intensity={${intensity}}` : "",- state.theme !== "auto" ? ` theme="${state.theme}"` : "",- ].join("");- return `import { ${name} } from "${PACKAGE}/react";\n\n<${name}${props} />\n`;-}-export const REACT = `import { Terrain } from "${PACKAGE}/react";export default function Page() {diff --git a/apps/site/test/docs.test.ts b/apps/site/test/docs.test.tsindex 72fa457..32ff6d3 100644--- a/apps/site/test/docs.test.ts+++ b/apps/site/test/docs.test.ts@@ -11,7 +11,7 @@ import { llms, scale } from "@/lib/llms";import { tiny } from "@/lib/size";import { COMMAND, EXAMPLES, INSTALL } from "@/lib/skill";import { highlight } from "@/lib/highlight";-import { CDN, CSS, QUICKSTART, REACT, REACT_SIGNATURE, VANILLA, VANILLA_SIGNATURE, install, snippet } from "@/lib/snippets";+import { CDN, CSS, 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. */@@ -39,31 +39,6 @@ describe("the options table", () => {});});-describe("the inspector's snippet", () => {- it("is the bare component at the defaults", () => {- expect(snippet("Terrain", { intensity: 0.5, theme: "auto" })).toContain("<Terrain />");- });-- it("leaves out an intensity that reads as 0.5 at the slider's precision", () => {- expect(snippet("Terrain", { intensity: 0.1 + 0.4, theme: "auto" })).toContain("<Terrain />");- expect(snippet("Terrain", { intensity: 0.5000001, theme: "auto" })).toContain("<Terrain />");- });-- it("shows an intensity of 0, which is not the default", () => {- expect(snippet("Riffle", { intensity: 0, theme: "auto" })).toContain("<Riffle intensity={0} />");- });-- it("shows what differs, intensity first, at two decimals", () => {- expect(snippet("Slow", { intensity: 0.1 + 0.2, theme: "dark" })).toContain('<Slow intensity={0.3} theme="dark" />');- expect(snippet("Slow", { intensity: 0.55, theme: "light" })).toContain('<Slow intensity={0.55} theme="light" />');- expect(snippet("Slow", { intensity: 1, theme: "auto" })).toContain("<Slow intensity={1} />");- });-- it("imports what it renders", () => {- expect(snippet("Exploded", { intensity: 0.5, theme: "auto" })).toMatch(/^import \{ Exploded \} from "@lucasmarkes\/hairline\/react";/);- });-});-describe("the install commands", () => {it("put npm first and install from the address the site is built for", () => {const commands = install("https://example.test");diff --git a/apps/site/test/site.spec.ts b/apps/site/test/site.spec.tsindex 96c9afc..8f86697 100644--- a/apps/site/test/site.spec.ts+++ b/apps/site/test/site.spec.ts@@ -21,10 +21,7 @@ function watch(page: Page): string[] {return noise;}-/** The figure's drawing, without the ids that differ between mounts. */-const drawing = (page: Page) => page.locator("[data-inspector] [data-hairline] > svg").evaluate((svg) => svg.innerHTML.replace(/hl-fd\d+/g, ""));--test("the home prerenders an empty box, then draws the inspector's figure with a clean console", async ({ page, request }) => {+test("the home prerenders an empty box, then draws the reel's figure with a clean console", async ({ page, request }) => {const html = await (await request.get("/")).text();// the figure's box is empty on the serverexpect(html.match(/<div style="aspect-ratio:5 \/ 4"><\/div>/g)).toHaveLength(1);@@ -91,139 +88,98 @@ test("the docs' code is in greys: every token's colour has equal red, green andexpect(tinted).toEqual([]);});-test("the inspector's figure picker picks the figure, and the snippet follows", async ({ page }) => {- await page.goto("/");- const inspector = page.locator("[data-inspector]");- await expect(inspector.locator("[data-snippet] pre")).toContainText("<Terrain />");- const figures = inspector.getByRole("radiogroup", { name: "Figure" });- await figures.getByRole("radio", { name: "Riffle" }).click();- await expect(figures.getByRole("radio", { name: "Riffle" })).toHaveAttribute("aria-checked", "true");- await expect(inspector.locator("[data-figure]")).toHaveAttribute("data-figure", "riffle");- await expect(inspector.locator("[data-hairline]")).toHaveCount(1);- // the arrow keys walk the choice- await figures.getByRole("radio", { name: "Riffle" }).press("ArrowRight");- await expect(inspector.locator("[data-figure]")).toHaveAttribute("data-figure", "terrain");- await expect(figures.getByRole("radio", { name: "Terrain" })).toBeFocused();- await figures.getByRole("radio", { name: "Terrain" }).press("ArrowLeft");- await expect(inspector.locator("[data-snippet] pre")).toContainText('import { Riffle } from "@lucasmarkes/hairline/react";');- await expect(inspector.locator("[data-snippet] pre")).toContainText("<Riffle />");-});--test("the inspector's slider reaches the figure, and the snippet shows it", async ({ page }) => {- await page.goto("/");- const inspector = page.locator("[data-inspector]");- const slider = inspector.getByRole("slider", { name: "Intensity" });- const stage = inspector.locator("[data-hairline]");- // measured at each hover: the slider sits under the figure, and filling it can scroll the page- const hover = async () => {- await stage.scrollIntoViewIfNeeded();- const box = (await stage.boundingBox())!;- await page.mouse.move(box.x + 4, box.y + 4);- await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2, { steps: 4 });- await page.waitForTimeout(1200);- };-- await slider.fill("0");- await expect(inspector.locator("output")).toHaveText("0.00");- await expect(inspector.locator("[data-snippet] pre")).toContainText("<Terrain intensity={0} />");- await hover();- const subtle = await drawing(page);-- await slider.fill("1");- await expect(inspector.locator("[data-snippet] pre")).toContainText("<Terrain intensity={1} />");- await hover();- expect(await drawing(page)).not.toBe(subtle);-- await slider.fill("0.5");- await expect(inspector.locator("[data-snippet] pre")).toContainText("<Terrain />");-});--test("the inspector's theme switch repaints the figure", async ({ page }) => {- await page.goto("/");- const inspector = page.locator("[data-inspector]");- await inspector.getByRole("radio", { name: "Dark" }).click();- await expect(inspector.locator("[data-snippet] pre")).toContainText('<Terrain theme="dark" />');- const plate = () => inspector.locator("[data-hairline] svg path").first().evaluate((el) => getComputedStyle(el).fill);- await expect.poll(plate).toBe("rgb(8, 9, 10)");- await inspector.getByRole("radio", { name: "Auto" }).click();- await expect.poll(plate).toBe("rgb(255, 255, 255)");-});--/** Waits for every transition and entrance on the page to finish. */-const settled = (page: Page) => expect.poll(() => page.evaluate(() => document.getAnimations().filter((a) => a.playState === "running").length)).toBe(0);--/** Where a picker's highlight shows: its box, less what its clip-path cuts from each side. */-const lit = (page: Page, name: string) =>- page.getByRole("radiogroup", { name }).evaluate((group) => {- const hl = group.querySelector<HTMLElement>(".slide-hl")!;- const box = hl.getBoundingClientRect();- const inset = getComputedStyle(hl).clipPath.match(/^inset\((.*?)(?: round .*)?\)$/)?.[1].split(" ").map(parseFloat) ?? [0];- const [t, r = t, b = t, l = r] = inset;- return { left: box.left + l, right: box.right - r, top: box.top + t, bottom: box.bottom - b };- });-const checked = (page: Page, name: string) =>- page.getByRole("radiogroup", { name }).locator('[aria-checked="true"]').evaluate((el) => {- const box = el.getBoundingClientRect();- return { left: box.left, right: box.right, top: box.top, bottom: box.bottom };- });-const near = (a: Record<string, number>, b: Record<string, number>) => {- for (const k of Object.keys(b)) expect(Math.abs(a[k] - b[k]), k).toBeLessThan(0.75);-};--test("a picker's highlight lands on the checked option by moving and clipping, never by animating its size", async ({ page }) => {- await page.goto("/");- await settled(page);- for (const name of ["Figure", "Theme"]) {- const group = page.getByRole("radiogroup", { name });- expect(await group.locator(".slide-hl").evaluate((el) => getComputedStyle(el).transitionProperty)).not.toMatch(/width|height/);- for (const radio of await group.getByRole("radio").all()) {- await radio.click();- await settled(page);- near(await lit(page, name), await checked(page, name));- }- }-});--test("the arrow keys move a picker's highlight at once, and a click still slides it", async ({ page }) => {- await page.goto("/");- await settled(page);- const figures = page.getByRole("radiogroup", { name: "Figure" });- const hl = figures.locator(".slide-hl");- await figures.getByRole("radio", { name: "Terrain" }).press("ArrowRight");- expect(await hl.evaluate((el) => el.getAnimations().length)).toBe(0);- near(await lit(page, "Figure"), await checked(page, "Figure"));- await figures.getByRole("radio", { name: "Riffle" }).click();- expect(await hl.evaluate((el) => el.getAnimations().length)).toBeGreaterThan(0);-});--test("the theme switch repaints the plate in the same frame as the figure", async ({ page }) => {- await page.goto("/");- await settled(page);- const inspector = page.locator("[data-inspector]");- await inspector.getByRole("radio", { name: "Dark" }).click();- // the stage's own entrance has finished; what is left would be a transition- expect(await inspector.locator(".s-stage").evaluate((el) => el.getAnimations().filter((a) => a instanceof CSSTransition).length)).toBe(0);-});+/** Waits for every transition and entrance on the page to finish: all but the reel's clock, which runs as long as the reel plays. */+const settled = (page: Page) =>+ expect.poll(() => page.evaluate(() => document.getAnimations().filter((a) => a.playState === "running" && !(a.effect as KeyframeEffect).target?.closest(".reel-ticks")).length)).toBe(0);test("the home's entrance settles within 1.4s, with its hero blocks 70ms apart", async ({ page }) => {await page.goto("/");const timing = await page.evaluate(() => {const of = (el: Element) => el.getAnimations().map((a) => a.effect!.getComputedTiming());const hero = [...document.querySelectorAll(".hero-rise > *")].map((el) => Math.min(...of(el).map((t) => Number(t.delay))));- const end = Math.max(...[...document.querySelectorAll(".hero-rise > *, .enter")].flatMap((el) => of(el).map((t) => Number(t.endTime))));+ const end = Math.max(...[...document.querySelectorAll(".hero-rise > *")].flatMap((el) => of(el).map((t) => Number(t.endTime))));return { gaps: hero.slice(1).map((d, n) => d - hero[n]), end };});expect(timing.gaps).toEqual([70, 70, 70, 70]);expect(timing.end).toBeLessThanOrEqual(1400);});+test("the reel plays the six figures in turn, holds under the pointer, and stops on a picked tick", async ({ page }) => {+ await page.goto("/");+ const reel = page.locator("[data-reel]");+ const figure = reel.locator(".reel-stage");+ const ticks = reel.getByRole("group", { name: "Figures" }).getByRole("button");+ await expect(ticks).toHaveCount(6);+ await expect(figure).toHaveAttribute("data-figure", "riffle");+ await expect(ticks.first()).toHaveAttribute("aria-current", "true");+ await expect(reel.locator(".reel-cap[data-on]")).toContainText("Riffle.");++ // the tick's fill is the clock: its end moves the reel on+ const fill = reel.locator(".reel-tick[aria-current] .reel-fill");+ await expect.poll(() => fill.evaluate((el) => el.getAnimations().length)).toBe(1);+ await fill.evaluate((el) => el.getAnimations()[0].finish());+ await expect(figure).toHaveAttribute("data-figure", "terrain");+ await expect(reel.locator(".reel-cap[data-on]")).toContainText("Terrain.");++ await figure.hover();+ await expect(reel).toHaveAttribute("data-paused", "");+ await expect(fill).toHaveCSS("animation-play-state", "paused");+ await expect(figure).toHaveAttribute("data-figure", "terrain");+ await page.mouse.move(0, 0);+ await expect(reel).not.toHaveAttribute("data-paused");++ await ticks.nth(4).click();+ await expect(figure).toHaveAttribute("data-figure", "slow");+ await expect(reel).not.toHaveAttribute("data-playing");+ // the clock is gone: no fill runs its keyframes (the picked tick only eases full)+ expect(await reel.locator(".reel-fill").evaluateAll((els) => els.flatMap((el) => el.getAnimations()).filter((a) => a instanceof CSSAnimation).length)).toBe(0);+ await expect(figure).toHaveAttribute("data-figure", "slow");+ await expect(reel.locator("[data-hairline]")).toHaveCount(1);+});++test("under reduced motion the reel never starts", async ({ page }) => {+ await page.emulateMedia({ reducedMotion: "reduce" });+ await page.goto("/");+ await expect(page.locator("[data-reel]")).not.toHaveAttribute("data-playing");+ await expect(page.locator(".reel-stage")).toHaveAttribute("data-figure", "riffle");+});++test("a change of figure never moves the page: the reel and the page hold their height through all six", async ({ page }) => {+ for (const width of [1440, 390, 320]) {+ await page.setViewportSize({ width, height: 800 });+ await page.goto("/");+ const ticks = page.locator(".reel-tick");+ const heights = new Set<string>();+ for (let i = 0; i < 6; i++) {+ await ticks.nth(i).click();+ await expect(page.locator(".reel-stage [data-hairline] > svg")).toHaveCount(1);+ heights.add(await page.evaluate(() => `${document.documentElement.scrollHeight} ${Math.round(document.querySelector(".reel")!.getBoundingClientRect().height)}`));+ }+ expect([...heights], `${width}px`).toHaveLength(1);+ }+});++test("the command and Get started are one height, and on a wide screen they share a line", async ({ page }) => {+ for (const width of [1200, 320]) {+ await page.setViewportSize({ width, height: 800 });+ await page.goto("/");+ // the row has risen into place, so both are read where they come to rest+ await settled(page);+ const pill = (await page.locator(".hero-get .pill").boundingBox())!;+ const button = (await page.locator(".hero-get").getByRole("link", { name: "Get started" }).boundingBox())!;+ expect(pill.height, `${width}px`).toBe(36);+ expect(button.height, `${width}px`).toBe(36);+ if (width === 1200) expect(pill.y).toBeCloseTo(button.y, 0);+ }+});+test("a hero button's text holds still through a press: no jump when its layer comes and goes", async ({ page }) => {await page.goto("/");await settled(page);// the press is what is watched; following the link would end the recordingawait page.evaluate(() => document.addEventListener("click", (e) => e.preventDefault(), true));- for (const name of ["Get started", "GitHub"]) {- const button = page.locator(".hero-actions").getByRole("link", { name });+ for (const name of ["Get started"]) {+ const button = page.locator(".hero-get").getByRole("link", { name });const box = (await button.boundingBox())!;await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);await page.waitForTimeout(100);@@ -260,7 +216,7 @@ test("a hero button's text holds still through a press: no jump when its layer cfor (let k = 0; k < before.length; k += 4) worst = Math.max(worst, Math.abs(before[k] - after[k]));return worst;}, { frames: release.slice(-2), box, viewport });- expect(worst, name).toBeLessThan(64);+ expect(worst, String(name)).toBeLessThan(64);}});@@ -292,10 +248,6 @@ test("without a clipboard, copy selects the text instead and throws nothing", asawait copy.click();await expect(copy).not.toHaveAttribute("data-copied");expect(await page.evaluate(() => window.getSelection()?.toString())).toBe("npm i @lucasmarkes/hairline");-- const snippet = page.locator("[data-snippet]");- await snippet.getByRole("button", { name: "Copy snippet" }).click();- expect(await page.evaluate(() => window.getSelection()?.toString())).toContain("<Terrain />");expect(noise).toEqual([]);});@@ -327,7 +279,7 @@ test("llms.txt and the registry item are served", async ({ request }) => {expect(item.files[0].content).toContain('"use client"');});-test("the page fits a phone, with the longest install command and every control", async ({ page }) => {+test("the page fits a phone, with the longest install command, its buttons and the reel's ticks", async ({ page }) => {await page.setViewportSize({ width: 390, height: 800 });await page.goto("/");const width = () => page.evaluate(() => document.documentElement.scrollWidth);@@ -338,16 +290,14 @@ test("the page fits a phone, with the longest install command and every control"await expect(pill).toHaveAttribute("data-install", "shadcn");expect(await width()).toBeLessThanOrEqual(390);- const inspector = page.locator("[data-inspector]");- for (const name of ["Turntable", "Dark"]) {- const control = inspector.getByRole("radio", { name });- await control.click();+ const controls = page.locator(".hero-get .btn, .reel-tick");+ await expect(controls).toHaveCount(7);+ for (const control of await controls.all()) {const box = (await control.boundingBox())!;expect(box.x).toBeGreaterThanOrEqual(0);expect(box.x + box.width).toBeLessThanOrEqual(390);}- await inspector.getByRole("slider", { name: "Intensity" }).fill("0.85");- await expect(inspector.locator("[data-snippet] pre")).toContainText('<Turntable intensity={0.85} theme="dark" />');+ await page.getByRole("button", { name: "Turntable" }).click();expect(await width()).toBeLessThanOrEqual(390);});@@ -455,7 +405,7 @@ test("the figures' link goes to the home's figure", async ({ page }) => {await page.goto("/docs");await page.getByRole("link", { name: "Try them on the home page →" }).click();await expect(page).toHaveURL(/\/#try$/);- await expect(page.locator("#try [data-inspector]")).toBeInViewport();+ await expect(page.locator("#try [data-reel]")).toBeInViewport();});test("the sidebar's links land on their section under the top bar and mark it, and scrolling moves the mark", async ({ page }) => {@@ -533,7 +483,11 @@ test("the sidebar draws the line to its section in its group's colour, and onlyconst off = nav.querySelector("a:not([aria-current])")!;const group = on.closest(".rail-group")!;const other = nav.querySelector(".rail-group:not(:has([aria-current]))")!;- const scale = (ul: Element) => new DOMMatrixReadOnly(style(ul, "::after").transform).d;+ const scale = (ul: Element) => {+ const after = style(ul, "::after");+ const bottom = after.clipPath.match(/^inset\(\S+ \S+ (\S+)/)?.[1] ?? "0px";+ return 1 - (bottom.endsWith("%") ? parseFloat(bottom) / 100 : parseFloat(bottom) / parseFloat(after.height));+ };return {// the trunk reaches into the marked group alone, and one arm is drawn: the marked row'sreach: [...nav.querySelectorAll("ul")].map((ul) => scale(ul) > 0),@@ -572,7 +526,10 @@ test("the line draws from section to section instead of jumping, and under reducconst ys: number[] = [];const t0 = performance.now();const tick = () => {- ys.push(new DOMMatrixReadOnly(getComputedStyle(ul, "::after").transform).d);+ // 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";+ ys.push(1 - (bottom.endsWith("%") ? parseFloat(bottom) / 100 : parseFloat(bottom) / parseFloat(after.height)));if (performance.now() - t0 < 700) requestAnimationFrame(tick);else done(ys);};@@ -582,7 +539,7 @@ test("the line draws from section to section instead of jumping, and under reduc}));const ys = await flight();const to = ys[ys.length - 1];- expect(to).toBeGreaterThan(0.3);+ expect(to).toBeGreaterThan(0.25);expect(ys.filter((y) => y > 0.02 && y < to - 0.02).length).toBeGreaterThanOrEqual(3);await page.emulateMedia({ reducedMotion: "reduce" });@@ -658,8 +615,8 @@ test.describe("on a 2x screen", () => {// a twitch on a block that looks settled, so both happen while the block is still fading in.test("the home's blocks come home before their blur clears, and clear it while still fading in", async ({ page }) => {await page.goto("/");- const blocks = page.locator(".hero-rise > *, .enter");- expect(await blocks.count()).toBeGreaterThanOrEqual(7);+ const blocks = page.locator(".hero-rise > *");+ expect(await blocks.count()).toBe(5);const late = await blocks.evaluateAll((els) => els.flatMap((el) => {const anims = el.getAnimations();anims.forEach((a) => a.pause());diff --git a/apps/site/test/skill.spec.ts b/apps/site/test/skill.spec.tsindex 1aa4d8b..8c6ab78 100644--- a/apps/site/test/skill.spec.ts+++ b/apps/site/test/skill.spec.ts@@ -212,48 +212,31 @@ test("the top bar fits a 320px screen on one row, the version left out so the naexpect(last.x + last.width).toBeLessThanOrEqual(bar.x + bar.width);});-const PROMPT = "Make your own figure with the hairline-create skill";--test("the home's hero points to the skill with the command as a prompt under its two buttons, and the prompt reaches /skill", async ({ page }) => {+test("the home's hero points to the skill in one line between the buttons and the reel, and it reaches /skill", async ({ page }) => {for (const width of [1200, 320]) {await page.setViewportSize({ width, height: 800 });await page.goto("/");- const link = page.locator(".hero-rise").getByRole("link", { name: PROMPT });+ const link = page.locator(".hero-rise").getByRole("link", { name: "Or draw your own with the skill" });await expect(link).toHaveAttribute("href", "/skill");- await expect(link.locator(".prompt-line")).toContainText("/hairline-create");- await expect(link.locator(".prompt-idea[data-on]")).toHaveText("a sales funnel");expect(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)).toBe(0);- const actions = (await page.locator(".hero-actions").boundingBox())!;- const prompt = (await link.boundingBox())!;- // under the buttons, clear of them, and as wide as the install line above them- expect(prompt.y).toBeGreaterThanOrEqual(actions.y + actions.height);- const install = (await page.locator(".hero-install").boundingBox())!;- expect(Math.abs(prompt.width - install.width)).toBeLessThan(1);- // the idea reads whole, on a phone under the command, and the return key stays inside the prompt- const idea = (await link.locator(".prompt-idea[data-on]").boundingBox())!;- const line = (await link.locator(".prompt-line").boundingBox())!;- expect(idea.x + idea.width).toBeLessThanOrEqual(line.x + line.width);- await expect(link.locator(".prompt-line")).not.toHaveAttribute("data-more");- const key = (await link.locator(".prompt-key").boundingBox())!;- expect(key.x + key.width).toBeLessThanOrEqual(prompt.x + prompt.width);+ const get = (await page.locator(".hero-get").boundingBox())!;+ const box = (await link.boundingBox())!;+ const reel = (await page.locator("[data-reel]").boundingBox())!;+ expect(box.y).toBeGreaterThanOrEqual(get.y + get.height);+ expect(box.y + box.height).toBeLessThanOrEqual(reel.y);}- await page.locator(".hero-rise").getByRole("link", { name: PROMPT }).click();+ await page.locator(".hero-rise").getByRole("link", { name: "Or draw your own with the skill" }).click();await expect(page).toHaveURL(/\/skill$/);await expect(page.getByRole("heading", { level: 1 })).toHaveText("Make your own figure");});-test("the prompt types each idea the skill has drawn in turn, and holds the first under reduced motion", async ({ page }) => {+test("a hover on the skill's link draws the hexagon's three inner edges into a cube", async ({ page }) => {await page.goto("/");- const on = page.locator(".prompt-idea[data-on]");- await expect(on).toHaveText("a sales funnel");- await expect(on).toHaveText("a rate limiter", { timeout: 4000 });- await expect(page.locator(".prompt-idea[data-gone]")).toHaveText("a sales funnel");- await expect(page.locator(".prompt-idea[data-on]")).toHaveCount(1);-- await page.emulateMedia({ reducedMotion: "reduce" });- await page.reload();- await page.waitForTimeout(3000);- await expect(page.locator(".prompt-idea[data-on]")).toHaveText("a sales funnel");+ const edges = page.locator(".skill-link-edge");+ await expect(edges).toHaveCount(3);+ for (const edge of await edges.all()) await expect(edge).toHaveCSS("stroke-dashoffset", "1px");+ await page.locator(".skill-link").hover();+ for (const edge of await edges.all()) await expect(edge).toHaveCSS("stroke-dashoffset", "0px");});const FOLLOW_UPS: Record<string, string | undefined> = {