Skip to content

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

Home: the way to the skill is its command as a prompt, typing each idea the skill has drawn, with a return key to send it

Lucas Marques618a0455e2c7
diff --git a/apps/site/app/globals.css b/apps/site/app/globals.css
index 5383504..0585fee 100644
--- a/apps/site/app/globals.css
+++ b/apps/site/app/globals.css
@@ -185,6 +185,35 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }
.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; }
+@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; }
+}
/* Rise, blur and fade end in that order. The rise and the blur end in steps: moving text is drawn on whole device
pixels, so the last pixel of travel lands as a hop, and Chrome draws no blur under 0.4px, so the last of it goes
@@ -350,6 +379,8 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }
.hero-rise > *, .enter, .enter-hint { animation-name: fade; }
.slide[data-ready] .slide-hl, .slide[data-ready] .slide-hl::before { 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, [data-live] .doc-link > span { transition: none; }
}
diff --git a/apps/site/app/page.tsx b/apps/site/app/page.tsx
index aa908b6..a69ae40 100644
--- a/apps/site/app/page.tsx
+++ b/apps/site/app/page.tsx
@@ -2,7 +2,9 @@ import type { CSSProperties } from "react";
import { Footer, GitHub, Topbar } from "@/components/chrome";
import { Inspector } from "@/components/inspector";
import { Install } from "@/components/install";
+import { SkillPrompt } from "@/components/skill-prompt";
import { LINKS } from "@/lib/figures";
+import { COMMAND, EXAMPLES } from "@/lib/skill";
import { install } from "@/lib/snippets";
const SITE = process.env.NEXT_PUBLIC_SITE_URL!;
@@ -31,10 +33,7 @@ export default function Page() {
<a className="btn btn-primary press" href="/docs">Get started</a>
<a className="btn press" href={LINKS.github}><GitHub /> GitHub</a>
</div>
- {/* a quiet line, not a third button: the two above stay the way in */}
- <p className="mt-5 text-[14px] text-muted" style={at(4)}>
- <a className="hover:text-ink" href="/skill">Or make your own with the skill →</a>
- </p>
+ <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)]">
diff --git a/apps/site/components/skill-prompt.tsx b/apps/site/components/skill-prompt.tsx
new file mode 100644
index 0000000..fa6e27c
--- /dev/null
+++ b/apps/site/components/skill-prompt.tsx
@@ -0,0 +1,60 @@
+"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/test/skill.spec.ts b/apps/site/test/skill.spec.ts
index 7df97de..1aa4d8b 100644
--- a/apps/site/test/skill.spec.ts
+++ b/apps/site/test/skill.spec.ts
@@ -212,26 +212,50 @@ test("the top bar fits a 320px screen on one row, the version left out so the na
expect(last.x + last.width).toBeLessThanOrEqual(bar.x + bar.width);
});
-test("the home's hero points to the skill in one quiet line under its two buttons, and the line reaches /skill", async ({ page }) => {
+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 }) => {
for (const width of [1200, 320]) {
await page.setViewportSize({ width, height: 800 });
await page.goto("/");
- const link = page.locator(".hero-rise").getByRole("link", { name: "Or make your own with the skill →" });
+ const link = page.locator(".hero-rise").getByRole("link", { name: PROMPT });
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 line = (await link.boundingBox())!;
- // under the buttons, clear of them, and on one line
- expect(line.y).toBeGreaterThanOrEqual(actions.y + actions.height);
- expect(line.height).toBeLessThan(28);
- // not a third button
- expect(await link.evaluate((a) => a.classList.contains("btn"))).toBe(false);
+ 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);
}
- await page.locator(".hero-rise").getByRole("link", { name: "Or make your own with the skill →" }).click();
+ await page.locator(".hero-rise").getByRole("link", { name: PROMPT }).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 }) => {
+ 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 FOLLOW_UPS: Record<string, string | undefined> = {
funnel: undefined,
clearance: undefined,