Isometric line figures that answer the pointer. For React and for anything with a DOM.
Site: the top bar's four items share one height, type and spacing, so llms.txt no longer stands apart as a white pill
Lucas Marques4e7f13b84a95
diff --git a/apps/site/app/globals.css b/apps/site/app/globals.cssindex d8d2921..7fcdc8a 100644--- a/apps/site/app/globals.css+++ b/apps/site/app/globals.css@@ -47,17 +47,18 @@ em { font-style: italic; }backdrop-filter: blur(12px);}+/* the top bar's items, alike: muted 13px text, or a 16px icon, each 10px clear of its neighbours */+.topbar-link { display: inline-flex; align-items: center; height: 30px; padding: 0 10px; border-radius: 8px; font-size: 13px; line-height: 1; color: var(--color-muted); }+:is(a, button).topbar-link:hover { color: var(--color-ink); }+.btn {display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;border-radius: 9px; font-size: 14px; font-weight: 500;background: #fff; box-shadow: inset 0 0 0 1px var(--color-stone), var(--lift);}.btn-primary { background: var(--color-ink); color: #fff; box-shadow: var(--lift); }-.btn-quiet { height: 30px; padding: 0 10px; font-size: 13px; line-height: 1; color: var(--color-muted); }.press { transition: transform 160ms var(--ease-out); }.press:active { transform: scale(0.96); }-.btn-quiet:hover, .icon-link:hover { color: var(--color-ink); }-.icon-link { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: var(--color-muted); }.pill {display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 6px 0 16px;diff --git a/apps/site/components/chrome.tsx b/apps/site/components/chrome.tsxindex d62f399..310df10 100644--- a/apps/site/components/chrome.tsx+++ b/apps/site/components/chrome.tsx@@ -17,11 +17,11 @@ export function Topbar() {return (<header className="topbar"><a href="/" className="text-[15px] font-medium tracking-[-0.02em]">hairline</a>- <nav className="flex items-center gap-1">- <a className="btn-quiet inline-flex items-center" href="/docs">Docs</a>- <span className="px-2 text-[13px] text-muted tabular-nums" data-version>v{pkg.version}</span>- <a className="icon-link" href={LINKS.github} aria-label="GitHub"><GitHub /></a>- <CopyButton text={`${SITE}/llms.txt`} open="/llms.txt" label="llms.txt" className="btn btn-quiet" />+ <nav className="flex items-center">+ <a className="topbar-link" href="/docs">Docs</a>+ <span className="topbar-link tabular-nums" data-version>v{pkg.version}</span>+ <a className="topbar-link" href={LINKS.github} aria-label="GitHub"><GitHub /></a>+ <CopyButton text={`${SITE}/llms.txt`} open="/llms.txt" label="llms.txt" className="topbar-link" /></nav></header>);diff --git a/apps/site/components/copy.tsx b/apps/site/components/copy.tsxindex 1758906..bbe757d 100644--- a/apps/site/components/copy.tsx+++ b/apps/site/components/copy.tsx@@ -41,7 +41,7 @@ export function useCopy(): [copied: boolean, copy: (text: string, fallback?: Ele* at, or opens `open` for a button with no text of its own on the page. `text`* can be a function, read at the click, for text the button does not own.*/-export function CopyButton({ text, select, open, label = "Copy", className = "btn btn-quiet" }: { text: string | (() => string); select?: RefObject<Element | null>; open?: string; label?: string; className?: string }) {+export function CopyButton({ text, select, open, label = "Copy", className = "btn" }: { text: string | (() => string); select?: RefObject<Element | null>; open?: string; label?: string; className?: string }) {const [copied, copy] = useCopy();const click = async () => {if (!(await copy(typeof text === "function" ? text() : text, select?.current)) && open) window.location.assign(open);diff --git a/apps/site/test/site.spec.ts b/apps/site/test/site.spec.tsindex 71963ea..ff45c22 100644--- a/apps/site/test/site.spec.ts+++ b/apps/site/test/site.spec.ts@@ -39,6 +39,25 @@ test("the home prerenders an empty box, then draws the inspector's figure with aexpect(noise).toEqual([]);});+test("the top bar's links sit as one row: one height, one centre line, one type, even spaces between them", async ({ page }) => {+ await page.goto("/");+ const items = await page.locator(".topbar nav > *").evaluateAll((els) => els.map((el) => {+ const box = el.getBoundingClientRect();+ const range = document.createRange();+ range.selectNodeContents(el);+ // what the eye reads as the item: its text, or its icon+ const ink = (el.querySelector("svg") ?? range).getBoundingClientRect();+ const style = getComputedStyle(el);+ return { height: box.height, middle: box.top + box.height / 2, left: ink.left, right: ink.right, type: [style.fontSize, style.fontWeight, style.color, style.backgroundColor].join(" ") };+ }));+ expect(items).toHaveLength(4);+ expect(new Set(items.map((i) => i.height)).size).toBe(1);+ for (const i of items) expect(Math.abs(i.middle - items[0].middle)).toBeLessThan(0.5);+ expect(new Set(items.map((i) => i.type)).size).toBe(1);+ const spaces = items.slice(1).map((i, n) => i.left - items[n].right);+ for (const s of spaces) expect(Math.abs(s - spaces[0])).toBeLessThan(1.5);+});+test("the docs prerender six empty boxes, 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(6);