A placeholder that explains an empty view and fills it
Press the action or the ghost row to fill it; Tab reaches the action
pnpm dlx shadcn@latest add https://notchset.dev/r/empty-state.jsonWhat goes here, and the one way to fill it.
Every shadcn style · one file
Import it and pass your content. The props that matter most are listed next.
"use client";
import * as React from "react";
import { Check, File as FileIcon, FileImage, FileText, FolderOpen, NotebookPen, Plus, ReceiptText, RotateCw, SearchX, TriangleAlert, X } from "@/lib/notchset/icons";
import { Badge } from "@/components/ui/notchset/badge";
import { Button } from "@/components/ui/notchset/button";
import { Card } from "@/components/ui/notchset/card";
import { CompanyMark } from "@/components/ui/notchset/company-mark";
import { brandGlyph } from "./brands";
import { EmptyState } from "@/components/ui/notchset/empty-state";
import { formatBytes, useFileTarget } from "@/components/ui/notchset/file-drop";
import { useLessMotion } from "@/lib/notchset/motion";
import { pressIn, useSelfPlay } from "./self-play";
/*
* An empty state exists to be left behind: its one action fills the place, the empty state steps aside for what it
* made, and its undo (Remove, Filter again) brings it back, so both ends of the piece are in one demo. The three sizes do different jobs:
* a page (the first run of Files, which also offers to import from Google Drive, or a load that failed), a section where the rows were (invoices filtered to
* nothing, naming the search and the filters) and a line inside a short list (notes). The knobs pick the kind of
* empty (nothing yet, a filter that leaves nothing, a load that failed, with its quotable code) and the size. Used
* in: a list with nothing yet, no files in a folder and a search with no results.
* The first run of Files takes real files: Upload a file opens your own machine's picker, and a file dropped on the
* card lifts the ghost rows to meet it. Each file takes the first ghost's place: its bar fills, its name resolves in,
* and it lands with a green tick, or a red cross and the reason when it is over the 10 MB limit.
*/
const LIMIT = 10_000_000;
type Up = { key: number; file: File; p: number; why?: string | undefined };
let seq = 0;
/* one file going up in the first ghost's place: tinted Signature, then green with a tick or red with a cross */
function UploadRow({ it, onRemove }: { it: Up; onRemove: () => void }) {
const done = it.p >= 1;
const tone = it.why ? "var(--ns-bad)" : done ? "var(--ns-ok)" : "var(--ns-signal)";
const Glyph = it.file.type.startsWith("image/") ? FileImage : /pdf|text/.test(it.file.type) ? FileText : FileIcon;
const ended = done || !!it.why;
return (
<li data-state={it.why ? "failed" : done ? "done" : "uploading"} data-ns-moves="" className={"flex h-12 items-center gap-3 px-5 " + (it.why ? "[animation:ns-play-shake_360ms_var(--ns-ease)]" : "")}>
<span aria-hidden className="grid size-7 shrink-0 place-items-center rounded-[var(--ns-radius-sm)] [transition:background-color_var(--ns-time-color),color_var(--ns-time-color)]" style={{ background: `color-mix(in oklab, ${tone} 16%, transparent)`, color: tone }}>
{ended ? (
<span data-ns-play="" className="grid size-5 place-items-center rounded-full text-[var(--ns-panel)] [animation:ns-play-spring_380ms_var(--ns-ease)]" style={{ background: tone }}>
{it.why ? <X className="size-3" strokeWidth={3} /> : <Check className="size-3" strokeWidth={3} />}
</span>
) : (
<Glyph className="size-4" />
)}
</span>
{ended ? (
/* the name resolves in: it unblurs and slides a few pixels as the bar it replaces fades */
<span data-ns-moves="" className="flex min-w-0 flex-1 flex-col [animation:ns-play-swap-in_420ms_var(--ns-ease)]">
<span className="truncate text-[length:var(--ns-text-small)] text-[var(--ns-ink)]">{it.file.name}</span>
{it.why && <span role="status" className="truncate text-[length:var(--ns-text-meta)] text-[var(--ns-bad-ink)]">{it.why}</span>}
</span>
) : (
<span role="progressbar" aria-label={it.file.name} aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.round(it.p * 100)} className="h-2.5 flex-1 overflow-hidden rounded-full bg-[var(--ns-well)]">
<span data-ns-glide="" className="block h-full rounded-full bg-[linear-gradient(90deg,color-mix(in_oklab,var(--ns-signal)_45%,transparent),var(--ns-signal))] shadow-[0_0_10px_color-mix(in_oklab,var(--ns-signal)_60%,transparent)] [transition:width_200ms_linear]" style={{ width: `${it.p * 100}%` }} />
</span>
)}
<span className="text-[length:var(--ns-text-meta)] text-[var(--ns-ink-3)] tabular-nums">{formatBytes(it.file.size, "en-US")}</span>
<Button intent="ghost" size="sm" aria-label={`Remove ${it.file.name}`} onClick={onRemove}>
<X />
</Button>
</li>
);
}
/* the first run of Files: a list with ghost rows that takes files from the visitor's own machine */
function FirstFiles({ title, body, verb }: { title: string; body: string; verb: string }) {
const [ups, setUps] = React.useState<Up[]>([]);
const timers = React.useRef(new Set<number>());
const card = React.useRef<HTMLDivElement>(null);
const handoff = React.useRef(false);
/* the button that was pressed is gone with its state; the first one now there gets focus */
const none = ups.length === 0;
React.useEffect(() => {
if (handoff.current) card.current?.querySelector("button")?.focus({ preventScroll: true });
handoff.current = false;
}, [none]);
React.useEffect(() => {
const own = timers.current;
return () => own.forEach((t) => window.clearInterval(t));
}, []);
const add = (files: File[]) => {
handoff.current = true;
const next = files.map((file) => ({ key: ++seq, file, p: 0, why: undefined as string | undefined }));
setUps((cur) => [...next, ...cur]);
for (const it of next) {
const over = it.file.size > LIMIT;
const t = window.setInterval(() => {
setUps((cur) =>
cur.map((x) => {
if (x.key !== it.key) return x;
const p = Math.min(1, x.p + 0.08 + Math.random() * 0.1);
/* a file over the limit is refused part-way, with the reason */
if (over && p >= 0.35) return { ...x, p: 0.35, why: `${formatBytes(it.file.size, "en-US")}, over the 10 MB limit` };
return { ...x, p };
}),
);
}, 140);
timers.current.add(t);
window.setTimeout(() => (window.clearInterval(t), timers.current.delete(t)), 3000);
}
};
const drop = useFileTarget({ onFiles: add });
/* a sample stands in for a file from Drive or a big one, its size said as the real one would be */
const sample = (name: string, size: number, type: string) => Object.defineProperty(new File([""], name, { type }), "size", { value: size });
const big = () => add([sample("Site walkthrough.mov", 48_200_000, "video/quicktime")]);
const over = drop.over != null;
return (
<div {...drop.target} ref={card} className="rounded-[var(--ns-radius-card)] [transition:box-shadow_var(--ns-time-color)]" style={over ? { boxShadow: "0 0 0 2px var(--ns-signal)" } : undefined}>
<Card inset aria-label="Files">
{drop.picker}
<header className="flex h-10 items-center text-[length:var(--ns-text-meta)] text-[var(--ns-ink-3)] shadow-[inset_0_-1px_0_var(--ns-line-soft)]">
<span className="flex-1">Files · Renewal 2027</span>
<span>Size</span>
</header>
{ups.length === 0 ? (
<EmptyState
size="page"
className="py-3 phone:py-3"
ghosts={3}
over={over}
title={over ? "Let go to add it" : title}
action={
<>
<Button intent="primary" onClick={drop.open}>
<Plus />
{verb}
</Button>
<Button intent="ghost" onClick={() => add([sample("Q3 plan.pdf", 2_400_000, "application/pdf")])}>
<CompanyMark name="Google Drive" color="#4285f4" glyph={brandGlyph("Google Drive")} size="xs" />
Import from Google Drive
</Button>
</>
}
>
{over ? "Drop it on this list." : `${body} Or drop one here.`}
</EmptyState>
) : (
<>
<ul className="m-0 -mx-5 list-none p-0">
{ups.map((it) => (
<UploadRow key={it.key} it={it} onRemove={() => ((handoff.current = true), setUps((c) => c.filter((x) => x.key !== it.key)))} />
))}
</ul>
<div className="-mx-5 -mb-5 flex shadow-[inset_0_1px_0_var(--ns-line-soft)]">
<button type="button" onClick={drop.open} className="flex h-11 flex-1 cursor-pointer items-center gap-2 px-4 text-[length:var(--ns-text-small)] text-[var(--ns-ink-2)] outline-hidden hover:bg-[var(--ns-hover)] focus-visible:outline-2 focus-visible:outline-[var(--ns-signal)]">
<Plus aria-hidden className="size-4" /> Add another
</button>
<Button intent="ghost" size="sm" className="my-auto me-2" onClick={big}>
Try a 48 MB one
</Button>
</div>
</>
)}
</Card>
</div>
);
}
type Kind = "empty" | "filtered" | "failed" | "first" | "results" | "done";
type Size = "page" | "section" | "inline";
const WORDS = {
empty: { title: "No files yet", body: "Files you upload or share show up here." },
filtered: { title: "No files match “invoice”", body: "Try another word, or clear the filter to see all 24 files." },
failed: { title: "Couldn't load your files", body: "The file service didn't answer. Nothing was lost; try again in a moment." },
};
const SECTION = {
empty: { title: "No invoices yet", body: "Invoices you send show up here." },
filtered: { title: "No unpaid invoices match “Stripe”", body: "Try another name, or clear the filters to see all 38." },
failed: { title: "Couldn't load invoices", body: "Billing didn't answer. Nothing was lost; try again in a moment." },
};
const INLINE = { empty: "No notes on Shopify yet", filtered: "No notes match “renewal”", failed: "Couldn't load the notes" };
const VERB = {
empty: { page: "Upload a file", section: "Create an invoice", inline: "Add a note" },
filtered: { page: "Clear filter", section: "Clear filters", inline: "Clear search" },
failed: { page: "Retry", section: "Retry", inline: "Retry" },
};
/* what the action fills the place with */
const FILLED = {
page: { Icon: FileText, name: "Q3 plan.pdf", meta: "2.4 MB · added just now", undo: "Remove" },
section: { Icon: ReceiptText, name: "INV-1042 · Stripe", meta: "$4,200 · due Nov 14", undo: "Filter again" },
inline: { Icon: NotebookPen, name: "Renewal call moved to Friday", meta: "Added just now", undo: "Remove" },
};
const SECTION_FILTERS = ["Unpaid", "“Stripe”"];
/* The row form, as a list's own empty. First one: "Nothing here yet", the ghost row and Add the first one; a press (on
the button or the ghost row) adds the Revolut row with the green tick, the heading rolls to "1 company". No results:
the two filters as chips, two ghost rows, Clear filters; the chips leave and the two rows drop in. All done: nothing
left today, the ghost row ticked, no action. On arrival the ghost takes its first item once (First one) or the
filters clear (No results); All done is already its end. */
const ROW = {
first: { title: "Nothing here yet", line: "Companies you add land here, with their status and value.", verb: "Add the first one", done: "1 company", said: "Revolut added" },
results: { title: "Nothing matches Berlin · Active", line: "2 match one filter but not both.", verb: "Clear filters", done: "2 companies", said: "Filters cleared, 2 companies", city: "City · Berlin", stage: "Status · Active" },
done: { title: "Nothing left today", line: "All 6 tasks are done. New ones land here." },
deal: { revolut: "Revolut", revolutLine: "Toronto · Priya Raman", revolutWhere: "Berlin · Priya Raman", vercel: "Vercel", vercelLine: "London · Ines Duarte", proposal: "Active", qualified: "Trial" },
};
function DealRow({ name, brand, color, line, stage, tone, amount }: { name: string; brand: string; color: string; line: string; stage: string; tone: "signal" | "neutral"; amount: string }) {
return (
<>
<CompanyMark name={name} color={color} glyph={brandGlyph(brand)} size="md" />
<span className="flex min-w-0 flex-1 flex-col">
<span className="truncate text-[length:var(--ns-text-body)] font-[number:var(--ns-weight-medium)] text-[var(--ns-ink)]">{name}</span>
<span className="truncate text-[length:var(--ns-text-small)] text-[var(--ns-ink-3)]">{line}</span>
</span>
<Badge tone={tone} variant="dot" size="sm">{stage}</Badge>
<span className="shrink-0 text-[length:var(--ns-text-body)] font-[number:var(--ns-weight-medium)] text-[var(--ns-ink)] tabular-nums">{amount}</span>
</>
);
}
function RowScene({ kind }: { kind: "first" | "results" | "done" }) {
const W = ROW;
const [filled, setFilled] = React.useState(false);
const [was, setWas] = React.useState(kind);
if (was !== kind) {
setWas(kind);
setFilled(false);
}
const root = React.useRef<HTMLDivElement>(null);
const less = useLessMotion();
const play = useSelfPlay(root, { beats: [0], off: less, hold: kind === "done" });
React.useEffect(() => {
if (play.step === 0) pressIn(root.current, "button", kind === "first" ? W.first.verb : W.results.verb);
}, [play.step, kind, W]);
const first = <DealRow name={W.deal.revolut} brand="revolut" color="#191c1f" line={kind === "first" ? W.deal.revolutLine : W.deal.revolutWhere} stage={kind === "first" ? W.deal.proposal : W.deal.qualified} tone={kind === "first" ? "signal" : "neutral"} amount="$48,000" />;
const vercel = <DealRow name={W.deal.vercel} brand="vercel" color="#000000" line={W.deal.vercelLine} stage={W.deal.proposal} tone="signal" amount="$120,000" />;
return (
<div ref={root} onPointerDownCapture={play.handOver} onKeyDownCapture={play.handOver} className="flex w-[400px] max-w-full flex-col items-start gap-3">
{kind === "done" ? (
<EmptyState size="row" title={W.done.title} ghost={["done", "lines", "figure"]}>{W.done.line}</EmptyState>
) : kind === "first" ? (
<EmptyState size="row" title={W.first.title} doneTitle={W.first.done} filled={filled} added filledRows={[first]} announce={W.first.said} action={<Button intent="primary" onClick={() => setFilled(true)}><Plus aria-hidden />{W.first.verb}</Button>}>
{W.first.line}
</EmptyState>
) : (
<EmptyState size="row" title={W.results.title} doneTitle={W.results.done} filled={filled} ghostRows={2} chips={[W.results.city, W.results.stage]} filledRows={[first, vercel]} announce={W.results.said} action={<Button intent="primary" onClick={() => setFilled(true)}>{W.results.verb}</Button>}>
{W.results.line}
</EmptyState>
)}
</div>
);
}
export default function EmptyStateDemo() {
const kind = "first" as Kind;
if (kind === "first" || kind === "results" || kind === "done") return <RowScene kind={kind} />;
return <AreaDemo kind={kind} />;
}
function AreaDemo({ kind }: { kind: Exclude<Kind, "first" | "results" | "done"> }) {
const size = "page" as Size;
const words = WORDS;
const [filled, setFilled] = React.useState(false);
const place = React.useRef<HTMLDivElement>(null);
const handoff = React.useRef(false);
/* the button that was pressed is gone with its state; the one that took its place gets focus */
React.useEffect(() => {
if (handoff.current) place.current?.querySelector("button")?.focus({ preventScroll: true });
handoff.current = false;
}, [filled]);
const set = (v: boolean) => {
handoff.current = true;
setFilled(v);
};
const verb = VERB[kind][size];
const first = (
<Button intent={kind === "empty" && size === "page" ? "primary" : size === "inline" ? "ghost" : "secondary"} size={size === "inline" ? "sm" : "md"} onClick={() => set(true)}>
{kind === "empty" ? <Plus /> : kind === "filtered" ? <X /> : <RotateCw />}
{verb}
</Button>
);
/* the first run of a page has a second, quieter way in, so it is not one lone button */
const action =
kind === "empty" && size === "page" ? (
<>
{first}
<Button intent="ghost" onClick={() => set(true)}>
<CompanyMark name="Google Drive" color="#4285f4" glyph={brandGlyph("Google Drive")} size="xs" />
Import from Google Drive
</Button>
</>
) : (
first
);
const here = FILLED[size];
const done = (
<div className="flex items-center gap-2.5 rounded-[var(--ns-radius)] bg-[var(--ns-raised)] px-3 py-2.5 shadow-[var(--ns-bezel)] [animation:ns-fade_var(--ns-time-color)_var(--ns-ease)]">
<here.Icon aria-hidden className="size-4 text-[var(--ns-ink-3)]" />
<span className="flex min-w-0 flex-1 flex-col">
<span className="truncate font-[number:var(--ns-weight-medium)] text-[var(--ns-ink)]">{here.name}</span>
<span className="text-[length:var(--ns-text-meta)] text-[var(--ns-ink-3)] tabular-nums">{here.meta}</span>
</span>
<Button intent="ghost" size="sm" onClick={() => set(false)}>
{here.undo}
</Button>
</div>
);
const empty =
size === "inline" ? (
<EmptyState size="inline" action={action}>
{INLINE[kind]}
</EmptyState>
) : (
<EmptyState
size={size}
/* in its card, the page size keeps the card's own air rather than a whole page's */
className={size === "section" ? "border-b-0" : "py-3 phone:py-3"}
icon={kind === "empty" ? (size === "page" ? <FolderOpen /> : <ReceiptText />) : kind === "filtered" ? <SearchX /> : <TriangleAlert />}
title={(size === "page" ? words : SECTION)[kind].title}
action={action}
code={kind === "failed" ? "503 · files.list · 14:20 · req 7f3a91" : undefined}
>
{(size === "page" ? words : SECTION)[kind].body}
</EmptyState>
);
if (size === "page" && kind === "empty")
return (
<div className="w-[var(--ns-width-md)] max-w-full">
<FirstFiles title={words.empty.title} body={words.empty.body} verb={verb} />
</div>
);
if (size === "page")
return (
<div ref={place} className="w-[var(--ns-width-md)] max-w-full">
<Card inset>
{filled ? <div className="mx-auto w-full py-10">{done}</div> : empty}
</Card>
</div>
);
return (
<div ref={place} className="w-[var(--ns-width-md)] max-w-full">
<Card inset aria-label={size === "section" ? "Invoices" : "Notes"}>
<header className="flex h-10 items-center gap-2 text-[length:var(--ns-text-small)] shadow-[inset_0_-1px_0_var(--ns-line-soft)]">
<span className="font-[number:var(--ns-weight-medium)] text-[var(--ns-ink)]">{size === "section" ? "Invoices" : "Notes"}</span>
{size === "section" && kind === "filtered" && !filled && SECTION_FILTERS.map((f) => <Badge key={f} variant="open">{f}</Badge>)}
</header>
{filled ? <div className="p-2">{done}</div> : empty}
</Card>
</div>
);
}"use client";
import * as React from "react";
import { Check, File as FileIcon, FileImage, FileText, FolderOpen, NotebookPen, Plus, ReceiptText, RotateCw, SearchX, TriangleAlert, X } from "@/lib/notchset/icons";
import { Badge } from "@/components/ui/notchset/badge";
import { Button } from "@/components/ui/notchset/button";
import { Card } from "@/components/ui/notchset/card";
import { CompanyMark } from "@/components/ui/notchset/company-mark";
import { brandGlyph } from "./brands";
import { EmptyState } from "@/components/ui/notchset/empty-state";
import { formatBytes, useFileTarget } from "@/components/ui/notchset/file-drop";
import { useLessMotion } from "@/lib/notchset/motion";
import { pressIn, useSelfPlay } from "./self-play";
/*
* An empty state exists to be left behind: its one action fills the place, the empty state steps aside for what it
* made, and its undo (Remove, Filter again) brings it back, so both ends of the piece are in one demo. The three sizes do different jobs:
* a page (the first run of Files, which also offers to import from Google Drive, or a load that failed), a section where the rows were (invoices filtered to
* nothing, naming the search and the filters) and a line inside a short list (notes). The knobs pick the kind of
* empty (nothing yet, a filter that leaves nothing, a load that failed, with its quotable code) and the size. Used
* in: a list with nothing yet, no files in a folder and a search with no results.
* The first run of Files takes real files: Upload a file opens your own machine's picker, and a file dropped on the
* card lifts the ghost rows to meet it. Each file takes the first ghost's place: its bar fills, its name resolves in,
* and it lands with a green tick, or a red cross and the reason when it is over the 10 MB limit.
*/
const LIMIT = 10_000_000;
type Up = { key: number; file: File; p: number; why?: string | undefined };
let seq = 0;
/* one file going up in the first ghost's place: tinted Signature, then green with a tick or red with a cross */
function UploadRow({ it, onRemove }: { it: Up; onRemove: () => void }) {
const done = it.p >= 1;
const tone = it.why ? "var(--ns-bad)" : done ? "var(--ns-ok)" : "var(--ns-signal)";
const Glyph = it.file.type.startsWith("image/") ? FileImage : /pdf|text/.test(it.file.type) ? FileText : FileIcon;
const ended = done || !!it.why;
return (
<li data-state={it.why ? "failed" : done ? "done" : "uploading"} data-ns-moves="" className={"flex h-12 items-center gap-3 px-5 " + (it.why ? "[animation:ns-play-shake_360ms_var(--ns-ease)]" : "")}>
<span aria-hidden className="grid size-7 shrink-0 place-items-center rounded-[var(--ns-radius-sm)] [transition:background-color_var(--ns-time-color),color_var(--ns-time-color)]" style={{ background: `color-mix(in oklab, ${tone} 16%, transparent)`, color: tone }}>
{ended ? (
<span data-ns-play="" className="grid size-5 place-items-center rounded-full text-[var(--ns-panel)] [animation:ns-play-spring_380ms_var(--ns-ease)]" style={{ background: tone }}>
{it.why ? <X className="size-3" strokeWidth={3} /> : <Check className="size-3" strokeWidth={3} />}
</span>
) : (
<Glyph className="size-4" />
)}
</span>
{ended ? (
/* the name resolves in: it unblurs and slides a few pixels as the bar it replaces fades */
<span data-ns-moves="" className="flex min-w-0 flex-1 flex-col [animation:ns-play-swap-in_420ms_var(--ns-ease)]">
<span className="truncate text-[length:var(--ns-text-small)] text-[var(--ns-ink)]">{it.file.name}</span>
{it.why && <span role="status" className="truncate text-[length:var(--ns-text-meta)] text-[var(--ns-bad-ink)]">{it.why}</span>}
</span>
) : (
<span role="progressbar" aria-label={it.file.name} aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.round(it.p * 100)} className="h-2.5 flex-1 overflow-hidden rounded-full bg-[var(--ns-well)]">
<span data-ns-glide="" className="block h-full rounded-full bg-[linear-gradient(90deg,color-mix(in_oklab,var(--ns-signal)_45%,transparent),var(--ns-signal))] shadow-[0_0_10px_color-mix(in_oklab,var(--ns-signal)_60%,transparent)] [transition:width_200ms_linear]" style={{ width: `${it.p * 100}%` }} />
</span>
)}
<span className="text-[length:var(--ns-text-meta)] text-[var(--ns-ink-3)] tabular-nums">{formatBytes(it.file.size, "en-US")}</span>
<Button intent="ghost" size="sm" aria-label={`Remove ${it.file.name}`} onClick={onRemove}>
<X />
</Button>
</li>
);
}
/* the first run of Files: a list with ghost rows that takes files from the visitor's own machine */
function FirstFiles({ title, body, verb }: { title: string; body: string; verb: string }) {
const [ups, setUps] = React.useState<Up[]>([]);
const timers = React.useRef(new Set<number>());
const card = React.useRef<HTMLDivElement>(null);
const handoff = React.useRef(false);
/* the button that was pressed is gone with its state; the first one now there gets focus */
const none = ups.length === 0;
React.useEffect(() => {
if (handoff.current) card.current?.querySelector("button")?.focus({ preventScroll: true });
handoff.current = false;
}, [none]);
React.useEffect(() => {
const own = timers.current;
return () => own.forEach((t) => window.clearInterval(t));
}, []);
const add = (files: File[]) => {
handoff.current = true;
const next = files.map((file) => ({ key: ++seq, file, p: 0, why: undefined as string | undefined }));
setUps((cur) => [...next, ...cur]);
for (const it of next) {
const over = it.file.size > LIMIT;
const t = window.setInterval(() => {
setUps((cur) =>
cur.map((x) => {
if (x.key !== it.key) return x;
const p = Math.min(1, x.p + 0.08 + Math.random() * 0.1);
/* a file over the limit is refused part-way, with the reason */
if (over && p >= 0.35) return { ...x, p: 0.35, why: `${formatBytes(it.file.size, "en-US")}, over the 10 MB limit` };
return { ...x, p };
}),
);
}, 140);
timers.current.add(t);
window.setTimeout(() => (window.clearInterval(t), timers.current.delete(t)), 3000);
}
};
const drop = useFileTarget({ onFiles: add });
/* a sample stands in for a file from Drive or a big one, its size said as the real one would be */
const sample = (name: string, size: number, type: string) => Object.defineProperty(new File([""], name, { type }), "size", { value: size });
const big = () => add([sample("Site walkthrough.mov", 48_200_000, "video/quicktime")]);
const over = drop.over != null;
return (
<div {...drop.target} ref={card} className="rounded-[var(--ns-radius-card)] [transition:box-shadow_var(--ns-time-color)]" style={over ? { boxShadow: "0 0 0 2px var(--ns-signal)" } : undefined}>
<Card inset aria-label="Files">
{drop.picker}
<header className="flex h-10 items-center text-[length:var(--ns-text-meta)] text-[var(--ns-ink-3)] shadow-[inset_0_-1px_0_var(--ns-line-soft)]">
<span className="flex-1">Files · Renewal 2027</span>
<span>Size</span>
</header>
{ups.length === 0 ? (
<EmptyState
size="page"
className="py-3 phone:py-3"
ghosts={3}
over={over}
title={over ? "Let go to add it" : title}
action={
<>
<Button intent="primary" onClick={drop.open}>
<Plus />
{verb}
</Button>
<Button intent="ghost" onClick={() => add([sample("Q3 plan.pdf", 2_400_000, "application/pdf")])}>
<CompanyMark name="Google Drive" color="#4285f4" glyph={brandGlyph("Google Drive")} size="xs" />
Import from Google Drive
</Button>
</>
}
>
{over ? "Drop it on this list." : `${body} Or drop one here.`}
</EmptyState>
) : (
<>
<ul className="m-0 -mx-5 list-none p-0">
{ups.map((it) => (
<UploadRow key={it.key} it={it} onRemove={() => ((handoff.current = true), setUps((c) => c.filter((x) => x.key !== it.key)))} />
))}
</ul>
<div className="-mx-5 -mb-5 flex shadow-[inset_0_1px_0_var(--ns-line-soft)]">
<button type="button" onClick={drop.open} className="flex h-11 flex-1 cursor-pointer items-center gap-2 px-4 text-[length:var(--ns-text-small)] text-[var(--ns-ink-2)] outline-hidden hover:bg-[var(--ns-hover)] focus-visible:outline-2 focus-visible:outline-[var(--ns-signal)]">
<Plus aria-hidden className="size-4" /> Add another
</button>
<Button intent="ghost" size="sm" className="my-auto me-2" onClick={big}>
Try a 48 MB one
</Button>
</div>
</>
)}
</Card>
</div>
);
}
type Kind = "empty" | "filtered" | "failed" | "first" | "results" | "done";
type Size = "page" | "section" | "inline";
const WORDS = {
empty: { title: "No files yet", body: "Files you upload or share show up here." },
filtered: { title: "No files match “invoice”", body: "Try another word, or clear the filter to see all 24 files." },
failed: { title: "Couldn't load your files", body: "The file service didn't answer. Nothing was lost; try again in a moment." },
};
const SECTION = {
empty: { title: "No invoices yet", body: "Invoices you send show up here." },
filtered: { title: "No unpaid invoices match “Stripe”", body: "Try another name, or clear the filters to see all 38." },
failed: { title: "Couldn't load invoices", body: "Billing didn't answer. Nothing was lost; try again in a moment." },
};
const INLINE = { empty: "No notes on Shopify yet", filtered: "No notes match “renewal”", failed: "Couldn't load the notes" };
const VERB = {
empty: { page: "Upload a file", section: "Create an invoice", inline: "Add a note" },
filtered: { page: "Clear filter", section: "Clear filters", inline: "Clear search" },
failed: { page: "Retry", section: "Retry", inline: "Retry" },
};
/* what the action fills the place with */
const FILLED = {
page: { Icon: FileText, name: "Q3 plan.pdf", meta: "2.4 MB · added just now", undo: "Remove" },
section: { Icon: ReceiptText, name: "INV-1042 · Stripe", meta: "$4,200 · due Nov 14", undo: "Filter again" },
inline: { Icon: NotebookPen, name: "Renewal call moved to Friday", meta: "Added just now", undo: "Remove" },
};
const SECTION_FILTERS = ["Unpaid", "“Stripe”"];
/* The row form, as a list's own empty. First one: "Nothing here yet", the ghost row and Add the first one; a press (on
the button or the ghost row) adds the Revolut row with the green tick, the heading rolls to "1 company". No results:
the two filters as chips, two ghost rows, Clear filters; the chips leave and the two rows drop in. All done: nothing
left today, the ghost row ticked, no action. On arrival the ghost takes its first item once (First one) or the
filters clear (No results); All done is already its end. */
const ROW = {
first: { title: "Nothing here yet", line: "Companies you add land here, with their status and value.", verb: "Add the first one", done: "1 company", said: "Revolut added" },
results: { title: "Nothing matches Berlin · Active", line: "2 match one filter but not both.", verb: "Clear filters", done: "2 companies", said: "Filters cleared, 2 companies", city: "City · Berlin", stage: "Status · Active" },
done: { title: "Nothing left today", line: "All 6 tasks are done. New ones land here." },
deal: { revolut: "Revolut", revolutLine: "Toronto · Priya Raman", revolutWhere: "Berlin · Priya Raman", vercel: "Vercel", vercelLine: "London · Ines Duarte", proposal: "Active", qualified: "Trial" },
};
function DealRow({ name, brand, color, line, stage, tone, amount }: { name: string; brand: string; color: string; line: string; stage: string; tone: "signal" | "neutral"; amount: string }) {
return (
<>
<CompanyMark name={name} color={color} glyph={brandGlyph(brand)} size="md" />
<span className="flex min-w-0 flex-1 flex-col">
<span className="truncate text-[length:var(--ns-text-body)] font-[number:var(--ns-weight-medium)] text-[var(--ns-ink)]">{name}</span>
<span className="truncate text-[length:var(--ns-text-small)] text-[var(--ns-ink-3)]">{line}</span>
</span>
<Badge tone={tone} variant="dot" size="sm">{stage}</Badge>
<span className="shrink-0 text-[length:var(--ns-text-body)] font-[number:var(--ns-weight-medium)] text-[var(--ns-ink)] tabular-nums">{amount}</span>
</>
);
}
function RowScene({ kind }: { kind: "first" | "results" | "done" }) {
const W = ROW;
const [filled, setFilled] = React.useState(false);
const [was, setWas] = React.useState(kind);
if (was !== kind) {
setWas(kind);
setFilled(false);
}
const root = React.useRef<HTMLDivElement>(null);
const less = useLessMotion();
const play = useSelfPlay(root, { beats: [0], off: less, hold: kind === "done" });
React.useEffect(() => {
if (play.step === 0) pressIn(root.current, "button", kind === "first" ? W.first.verb : W.results.verb);
}, [play.step, kind, W]);
const first = <DealRow name={W.deal.revolut} brand="revolut" color="#191c1f" line={kind === "first" ? W.deal.revolutLine : W.deal.revolutWhere} stage={kind === "first" ? W.deal.proposal : W.deal.qualified} tone={kind === "first" ? "signal" : "neutral"} amount="$48,000" />;
const vercel = <DealRow name={W.deal.vercel} brand="vercel" color="#000000" line={W.deal.vercelLine} stage={W.deal.proposal} tone="signal" amount="$120,000" />;
return (
<div ref={root} onPointerDownCapture={play.handOver} onKeyDownCapture={play.handOver} className="flex w-[400px] max-w-full flex-col items-start gap-3">
{kind === "done" ? (
<EmptyState size="row" title={W.done.title} ghost={["done", "lines", "figure"]}>{W.done.line}</EmptyState>
) : kind === "first" ? (
<EmptyState size="row" title={W.first.title} doneTitle={W.first.done} filled={filled} added filledRows={[first]} announce={W.first.said} action={<Button intent="primary" onClick={() => setFilled(true)}><Plus aria-hidden />{W.first.verb}</Button>}>
{W.first.line}
</EmptyState>
) : (
<EmptyState size="row" title={W.results.title} doneTitle={W.results.done} filled={filled} ghostRows={2} chips={[W.results.city, W.results.stage]} filledRows={[first, vercel]} announce={W.results.said} action={<Button intent="primary" onClick={() => setFilled(true)}>{W.results.verb}</Button>}>
{W.results.line}
</EmptyState>
)}
</div>
);
}
export default function EmptyStateDemo() {
const kind = "first" as Kind;
if (kind === "first" || kind === "results" || kind === "done") return <RowScene kind={kind} />;
return <AreaDemo kind={kind} />;
}
function AreaDemo({ kind }: { kind: Exclude<Kind, "first" | "results" | "done"> }) {
const size = "page" as Size;
const words = WORDS;
const [filled, setFilled] = React.useState(false);
const place = React.useRef<HTMLDivElement>(null);
const handoff = React.useRef(false);
/* the button that was pressed is gone with its state; the one that took its place gets focus */
React.useEffect(() => {
if (handoff.current) place.current?.querySelector("button")?.focus({ preventScroll: true });
handoff.current = false;
}, [filled]);
const set = (v: boolean) => {
handoff.current = true;
setFilled(v);
};
const verb = VERB[kind][size];
const first = (
<Button intent={kind === "empty" && size === "page" ? "primary" : size === "inline" ? "ghost" : "secondary"} size={size === "inline" ? "sm" : "md"} onClick={() => set(true)}>
{kind === "empty" ? <Plus /> : kind === "filtered" ? <X /> : <RotateCw />}
{verb}
</Button>
);
/* the first run of a page has a second, quieter way in, so it is not one lone button */
const action =
kind === "empty" && size === "page" ? (
<>
{first}
<Button intent="ghost" onClick={() => set(true)}>
<CompanyMark name="Google Drive" color="#4285f4" glyph={brandGlyph("Google Drive")} size="xs" />
Import from Google Drive
</Button>
</>
) : (
first
);
const here = FILLED[size];
const done = (
<div className="flex items-center gap-2.5 rounded-[var(--ns-radius)] bg-[var(--ns-raised)] px-3 py-2.5 shadow-[var(--ns-bezel)] [animation:ns-fade_var(--ns-time-color)_var(--ns-ease)]">
<here.Icon aria-hidden className="size-4 text-[var(--ns-ink-3)]" />
<span className="flex min-w-0 flex-1 flex-col">
<span className="truncate font-[number:var(--ns-weight-medium)] text-[var(--ns-ink)]">{here.name}</span>
<span className="text-[length:var(--ns-text-meta)] text-[var(--ns-ink-3)] tabular-nums">{here.meta}</span>
</span>
<Button intent="ghost" size="sm" onClick={() => set(false)}>
{here.undo}
</Button>
</div>
);
const empty =
size === "inline" ? (
<EmptyState size="inline" action={action}>
{INLINE[kind]}
</EmptyState>
) : (
<EmptyState
size={size}
/* in its card, the page size keeps the card's own air rather than a whole page's */
className={size === "section" ? "border-b-0" : "py-3 phone:py-3"}
icon={kind === "empty" ? (size === "page" ? <FolderOpen /> : <ReceiptText />) : kind === "filtered" ? <SearchX /> : <TriangleAlert />}
title={(size === "page" ? words : SECTION)[kind].title}
action={action}
code={kind === "failed" ? "503 · files.list · 14:20 · req 7f3a91" : undefined}
>
{(size === "page" ? words : SECTION)[kind].body}
</EmptyState>
);
if (size === "page" && kind === "empty")
return (
<div className="w-[var(--ns-width-md)] max-w-full">
<FirstFiles title={words.empty.title} body={words.empty.body} verb={verb} />
</div>
);
if (size === "page")
return (
<div ref={place} className="w-[var(--ns-width-md)] max-w-full">
<Card inset>
{filled ? <div className="mx-auto w-full py-10">{done}</div> : empty}
</Card>
</div>
);
return (
<div ref={place} className="w-[var(--ns-width-md)] max-w-full">
<Card inset aria-label={size === "section" ? "Invoices" : "Notes"}>
<header className="flex h-10 items-center gap-2 text-[length:var(--ns-text-small)] shadow-[inset_0_-1px_0_var(--ns-line-soft)]">
<span className="font-[number:var(--ns-weight-medium)] text-[var(--ns-ink)]">{size === "section" ? "Invoices" : "Notes"}</span>
{size === "section" && kind === "filtered" && !filled && SECTION_FILTERS.map((f) => <Badge key={f} variant="open">{f}</Badge>)}
</header>
{filled ? <div className="p-2">{done}</div> : empty}
</Card>
</div>
);
}/*
* The demos' real companies' own marks for CompanyMark's glyph: 24×24 paths, one copy, so every demo that shows one
* of these companies draws the same mark. Sample content, copied with a demo's usage; a buyer's app passes its own
* companies' marks: <CompanyMark name="Stripe" color="#635bff" glyph={brandGlyph("Stripe")} />
*/
const BRAND_GLYPHS = {
anthropic: "M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z",
airtable: "M11.992 1.966c-.434 0-.87.086-1.28.257L1.779 5.917c-.503.208-.49.908.012 1.116l8.982 3.558a3.266 3.266 0 0 0 2.454 0l8.982-3.558c.503-.196.503-.908.012-1.116l-8.957-3.694a3.255 3.255 0 0 0-1.272-.257zM23.4 8.056a.589.589 0 0 0-.222.045l-10.012 3.877a.612.612 0 0 0-.38.564v8.896a.6.6 0 0 0 .821.552L23.62 18.1a.583.583 0 0 0 .38-.551V8.653a.6.6 0 0 0-.6-.596zM.676 8.095a.644.644 0 0 0-.48.19C.086 8.396 0 8.53 0 8.69v8.355c0 .442.515.737.908.54l6.27-3.006.307-.147 2.969-1.436c.466-.22.43-.908-.061-1.092L.883 8.138a.57.57 0 0 0-.207-.044z",
calendly: "M19.655 14.262c.281 0 .557.023.828.064 0 .005-.005.01-.005.014-.105.267-.234.534-.381.786l-1.219 2.106c-1.112 1.936-3.177 3.127-5.411 3.127h-2.432c-2.23 0-4.294-1.191-5.412-3.127l-1.218-2.106a6.251 6.251 0 0 1 0-6.252l1.218-2.106C6.736 4.832 8.8 3.641 11.035 3.641h2.432c2.23 0 4.294 1.191 5.411 3.127l1.219 2.106c.147.252.271.519.381.786 0 .004.005.009.005.014-.267.041-.543.064-.828.064-1.816 0-2.501-.607-3.291-1.306-.764-.676-1.711-1.517-3.44-1.517h-1.029c-1.251 0-2.387.455-3.2 1.278-.796.805-1.233 1.904-1.233 3.099v1.411c0 1.196.437 2.295 1.233 3.099.813.823 1.949 1.278 3.2 1.278h1.034c1.729 0 2.676-.841 3.439-1.517.791-.703 1.471-1.306 3.287-1.301Zm.005-3.237c.399 0 .794-.036 1.179-.11-.002-.004-.002-.01-.002-.014-.073-.414-.193-.823-.349-1.218.731-.12 1.407-.396 1.986-.819 0-.004-.005-.013-.005-.018-.331-1.085-.832-2.101-1.489-3.03-.649-.915-1.435-1.719-2.331-2.395-1.867-1.398-4.088-2.138-6.428-2.138-1.448 0-2.855.28-4.175.841-1.273.543-2.423 1.315-3.407 2.299S2.878 6.552 2.341 7.83c-.557 1.324-.842 2.726-.842 4.175 0 1.448.281 2.855.842 4.174.542 1.274 1.314 2.423 2.298 3.407s2.129 1.761 3.407 2.299c1.324.556 2.727.841 4.175.841 2.34 0 4.561-.74 6.428-2.137a10.815 10.815 0 0 0 2.331-2.396c.652-.929 1.158-1.949 1.489-3.03 0-.004.005-.014.005-.018-.579-.423-1.255-.699-1.986-.819.161-.395.276-.804.349-1.218.005-.009.005-.014.005-.023.869.166 1.692.506 2.404 1.035.685.505.552 1.075.446 1.416C22.184 20.437 17.619 24 12.221 24c-6.625 0-12-5.375-12-12s5.37-12 12-12c5.398 0 9.963 3.563 11.471 8.464.106.341.239.915-.446 1.421-.717.529-1.535.873-2.404 1.034.128.716.128 1.45 0 2.166-.387-.074-.782-.11-1.182-.11-4.184 0-3.968 2.823-6.736 2.823h-1.029c-1.899 0-3.15-1.357-3.15-3.095v-1.411c0-1.738 1.251-3.094 3.15-3.094h1.034c2.768 0 2.552 2.823 6.731 2.827Z",
dropbox: "M6 1.807L0 5.629l6 3.822 6.001-3.822L6 1.807zM18 1.807l-6 3.822 6 3.822 6-3.822-6-3.822zM0 13.274l6 3.822 6.001-3.822L6 9.452l-6 3.822zM18 9.452l-6 3.822 6 3.822 6-3.822-6-3.822zM6 18.371l6.001 3.822 6-3.822-6-3.822L6 18.371z",
"google drive": "M12.01 1.485c-2.082 0-3.754.02-3.743.047.01.02 1.708 3.001 3.774 6.62l3.76 6.574h3.76c2.081 0 3.753-.02 3.742-.047-.005-.02-1.708-3.001-3.775-6.62l-3.76-6.574zm-4.76 1.73a789.828 789.861 0 0 0-3.63 6.319L0 15.868l1.89 3.298 1.885 3.297 3.62-6.335 3.618-6.33-1.88-3.287C8.1 4.704 7.255 3.22 7.25 3.214zm2.259 12.653-.203.348c-.114.198-.96 1.672-1.88 3.287a423.93 423.948 0 0 1-1.698 2.97c-.01.026 3.24.042 7.222.042h7.244l1.796-3.157c.992-1.734 1.85-3.23 1.906-3.323l.104-.167h-7.249z",
figma: "M15.852 8.981h-4.588V0h4.588c2.476 0 4.49 2.014 4.49 4.49s-2.014 4.491-4.49 4.491zM12.735 7.51h3.117c1.665 0 3.019-1.355 3.019-3.019s-1.355-3.019-3.019-3.019h-3.117V7.51zm0 1.471H8.148c-2.476 0-4.49-2.014-4.49-4.49S5.672 0 8.148 0h4.588v8.981zm-4.587-7.51c-1.665 0-3.019 1.355-3.019 3.019s1.354 3.02 3.019 3.02h3.117V1.471H8.148zm4.587 15.019H8.148c-2.476 0-4.49-2.014-4.49-4.49s2.014-4.49 4.49-4.49h4.588v8.98zM8.148 8.981c-1.665 0-3.019 1.355-3.019 3.019s1.355 3.019 3.019 3.019h3.117V8.981H8.148zM8.172 24c-2.489 0-4.515-2.014-4.515-4.49s2.014-4.49 4.49-4.49h4.588v4.441c0 2.503-2.047 4.539-4.563 4.539zm-.024-7.51a3.023 3.023 0 0 0-3.019 3.019c0 1.665 1.365 3.019 3.044 3.019 1.705 0 3.093-1.376 3.093-3.068v-2.97H8.148zm7.704 0h-.098c-2.476 0-4.49-2.014-4.49-4.49s2.014-4.49 4.49-4.49h.098c2.476 0 4.49 2.014 4.49 4.49s-2.014 4.49-4.49 4.49zm-.097-7.509c-1.665 0-3.019 1.355-3.019 3.019s1.355 3.019 3.019 3.019h.098c1.665 0 3.019-1.355 3.019-3.019s-1.355-3.019-3.019-3.019h-.098z",
framer: "M4 0h16v8h-8zM4 8h8l8 8H4zM4 16h8v8z",
linear: "M2.886 4.18A11.982 11.982 0 0 1 11.99 0C18.624 0 24 5.376 24 12.009c0 3.64-1.62 6.903-4.18 9.105L2.887 4.18ZM1.817 5.626l16.556 16.556c-.524.33-1.075.62-1.65.866L.951 7.277c.247-.575.537-1.126.866-1.65ZM.322 9.163l14.515 14.515c-.71.172-1.443.282-2.195.322L0 11.358a12 12 0 0 1 .322-2.195Zm-.17 4.862 9.823 9.824a12.02 12.02 0 0 1-9.824-9.824Z",
notion: "M4.459 4.208c.746.606 1.026.56 2.428.466l13.215-.793c.28 0 .047-.28-.046-.326L17.86 1.968c-.42-.326-.981-.7-2.055-.607L3.01 2.295c-.466.046-.56.28-.374.466zm.793 3.08v13.904c0 .747.373 1.027 1.214.98l14.523-.84c.841-.046.935-.56.935-1.167V6.354c0-.606-.233-.933-.748-.887l-15.177.887c-.56.047-.747.327-.747.933zm14.337.745c.093.42 0 .84-.42.888l-.7.14v10.264c-.608.327-1.168.514-1.635.514-.748 0-.935-.234-1.495-.933l-4.577-7.186v6.952L12.21 19s0 .84-1.168.84l-3.222.186c-.093-.186 0-.653.327-.746l.84-.233V9.854L7.822 9.76c-.094-.42.14-1.026.793-1.073l3.456-.233 4.764 7.279v-6.44l-1.215-.139c-.093-.514.28-.887.747-.933zM1.936 1.035l13.31-.98c1.634-.14 2.055-.047 3.082.7l4.249 2.986c.7.513.934.653.934 1.213v16.378c0 1.026-.373 1.634-1.68 1.726l-15.458.934c-.98.047-1.448-.093-1.962-.747l-3.129-4.06c-.56-.747-.793-1.306-.793-1.96V2.667c0-.839.374-1.54 1.447-1.632z",
openai: "M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z",
posthog: "M9.854 14.5 5 9.647.854 5.5A.5.5 0 0 0 0 5.854V8.44a.5.5 0 0 0 .146.353L5 13.647l.147.146L9.854 18.5l.146.147v-.049c.065.03.134.049.207.049h2.586a.5.5 0 0 0 .353-.854L9.854 14.5zm0-5-4-4a.487.487 0 0 0-.409-.144.515.515 0 0 0-.356.21.493.493 0 0 0-.089.288V8.44a.5.5 0 0 0 .147.353l9 9a.5.5 0 0 0 .853-.354v-2.585a.5.5 0 0 0-.146-.354l-5-5zm1-4a.5.5 0 0 0-.854.354V8.44a.5.5 0 0 0 .147.353l4 4a.5.5 0 0 0 .853-.354V9.854a.5.5 0 0 0-.146-.354l-4-4zm12.647 11.515a3.863 3.863 0 0 1-2.232-1.1l-4.708-4.707a.5.5 0 0 0-.854.354v6.585a.5.5 0 0 0 .5.5H23.5a.5.5 0 0 0 .5-.5v-.6c0-.276-.225-.497-.499-.532zm-5.394.032a.8.8 0 1 1 0-1.6.8.8 0 0 1 0 1.6zM.854 15.5a.5.5 0 0 0-.854.354v2.293a.5.5 0 0 0 .5.5h2.293c.222 0 .39-.135.462-.309a.493.493 0 0 0-.109-.545L.854 15.501zM5 14.647.854 10.5a.5.5 0 0 0-.854.353v2.586a.5.5 0 0 0 .146.353L4.854 18.5l.146.147h2.793a.5.5 0 0 0 .353-.854L5 14.647z",
raycast: "M6.004 15.492v2.504L0 11.992l1.258-1.249Zm2.504 2.504H6.004L12.008 24l1.253-1.253zm14.24-4.747L24 11.997 12.003 0 10.75 1.251 15.491 6h-2.865L9.317 2.692 8.065 3.944l2.06 2.06H8.691v9.31H18v-1.432l2.06 2.06 1.252-1.252-3.312-3.32V8.506ZM6.63 5.372 5.38 6.625l1.342 1.343 1.251-1.253Zm10.655 10.655-1.247 1.251 1.342 1.343 1.253-1.251zM3.944 8.059 2.692 9.31l3.312 3.314v-2.506zm9.936 9.937h-2.504l3.314 3.312 1.25-1.252z",
revolut: "M20.9133 6.9566C20.9133 3.1208 17.7898 0 13.9503 0H2.424v3.8605h10.9782c1.7376 0 3.177 1.3651 3.2087 3.043.016.84-.2994 1.633-.8878 2.2324-.5886.5998-1.375.9303-2.2144.9303H9.2322a.2756.2756 0 0 0-.2755.2752v3.431c0 .0585.018.1142.052.1612L16.2646 24h5.3114l-7.2727-10.094c3.6625-.1838 6.61-3.2612 6.61-6.9494zM6.8943 5.9229H2.424V24h4.4704z",
sentry: "M13.91 2.505c-.873-1.448-2.972-1.448-3.844 0L6.904 7.92a15.478 15.478 0 0 1 8.53 12.811h-2.221A13.301 13.301 0 0 0 5.784 9.814l-2.926 5.06a7.65 7.65 0 0 1 4.435 5.848H2.194a.365.365 0 0 1-.298-.534l1.413-2.402a5.16 5.16 0 0 0-1.614-.913L.296 19.275a2.182 2.182 0 0 0 .812 2.999 2.24 2.24 0 0 0 1.086.288h6.983a9.322 9.322 0 0 0-3.845-8.318l1.11-1.922a11.47 11.47 0 0 1 4.95 10.24h5.915a17.242 17.242 0 0 0-7.885-15.28l2.244-3.845a.37.37 0 0 1 .504-.13c.255.14 9.75 16.708 9.928 16.9a.365.365 0 0 1-.327.543h-2.287c.029.612.029 1.223 0 1.831h2.297a2.206 2.206 0 0 0 1.922-3.31z",
shopify: "M15.337 23.979l7.216-1.561s-2.604-17.613-2.625-17.73c-.018-.116-.114-.192-.211-.192s-1.929-.136-1.929-.136-1.275-1.274-1.439-1.411c-.045-.037-.075-.057-.121-.074l-.914 21.104h.023zM11.71 11.305s-.81-.424-1.774-.424c-1.447 0-1.504.906-1.504 1.141 0 1.232 3.24 1.715 3.24 4.629 0 2.295-1.44 3.76-3.406 3.76-2.354 0-3.54-1.465-3.54-1.465l.646-2.086s1.245 1.066 2.28 1.066c.675 0 .975-.545.975-.932 0-1.619-2.654-1.694-2.654-4.359-.034-2.237 1.571-4.416 4.827-4.416 1.257 0 1.875.361 1.875.361l-.945 2.715-.02.01zM11.17.83c.136 0 .271.038.405.135-.984.465-2.064 1.639-2.508 3.992-.656.213-1.293.405-1.889.578C7.697 3.75 8.951.84 11.17.84V.83zm1.235 2.949v.135c-.754.232-1.583.484-2.394.736.466-1.777 1.333-2.645 2.085-2.971.193.501.309 1.176.309 2.1zm.539-2.234c.694.074 1.141.867 1.429 1.755-.349.114-.735.231-1.158.366v-.252c0-.752-.096-1.371-.271-1.871v.002zm2.992 1.289c-.02 0-.06.021-.078.021s-.289.075-.714.21c-.423-1.233-1.176-2.37-2.508-2.37h-.115C12.135.209 11.669 0 11.265 0 8.159 0 6.675 3.877 6.21 5.846c-1.194.365-2.063.636-2.16.674-.675.213-.694.232-.772.87-.075.462-1.83 14.063-1.83 14.063L15.009 24l.927-21.166z",
slack: "M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z",
snowflake: "M24 3.459c0 .646-.418 1.18-1.141 1.18-.723 0-1.142-.534-1.142-1.18 0-.647.419-1.18 1.142-1.18.723 0 1.141.533 1.141 1.18zm-.228 0c0-.533-.38-.951-.913-.951s-.913.38-.913.95c0 .533.38.952.913.952.57 0 .913-.419.913-.951zm-1.37-.533h.495c.266 0 .456.152.456.38 0 .153-.076.229-.19.305l.19.266v.038h-.266l-.19-.266h-.229v.266h-.266zm.495.228h-.229v.267h.229c.114 0 .152-.038.152-.114.038-.077-.038-.153-.152-.153zM7.602 12.4c.038-.151.076-.304.076-.456 0-.114-.038-.228-.038-.342-.114-.343-.304-.647-.646-.838l-4.87-2.777c-.685-.38-1.56-.152-1.94.533-.381.685-.153 1.56.532 1.94l2.701 1.56-2.701 1.56c-.685.38-.913 1.256-.533 1.94.38.685 1.256.914 1.94.533l4.832-2.777c.343-.267.571-.533.647-.876zm1.332 2.626c-.266-.038-.57.038-.837.19l-4.832 2.777c-.685.38-.913 1.256-.532 1.94.38.686 1.255.914 1.94.533l2.701-1.56v3.12c0 .8.647 1.408 1.446 1.408.799 0 1.407-.647 1.407-1.408v-5.592c0-.761-.57-1.37-1.293-1.408zm4.946-6.088c.266.038.57-.038.837-.19l4.832-2.777c.685-.38.913-1.256.532-1.94-.38-.686-1.255-.914-1.94-.533l-2.701 1.56V1.975c0-.799-.647-1.408-1.446-1.408-.799 0-1.446.609-1.446 1.408V7.53c0 .76.609 1.37 1.332 1.407zM3.265 5.97l4.832 2.777c.266.152.533.19.837.19.723-.038 1.331-.684 1.331-1.407V1.975c0-.799-.646-1.408-1.407-1.408-.799 0-1.446.647-1.446 1.408v3.12l-2.701-1.56c-.685-.38-1.56-.152-1.94.533-.419.646-.19 1.521.494 1.902zm9.093 6.011a.412.412 0 00-.114-.266l-.57-.571a.346.346 0 00-.267-.114.412.412 0 00-.266.114l-.571.57a.411.411 0 00-.114.267c0 .076.038.19.114.267l.57.57a.345.345 0 00.267.114c.076 0 .19-.038.266-.114l.571-.57a.412.412 0 00.114-.267zm1.598.533L11.94 14.53c-.039.038-.153.114-.229.114h-.608a.411.411 0 01-.267-.114L8.82 12.514a.408.408 0 01-.076-.229v-.608c0-.076.038-.19.114-.267l2.016-2.016a.41.41 0 01.267-.114h.608a.41.41 0 01.267.114l2.016 2.016a.347.347 0 01.114.267v.608c-.076.077-.114.19-.19.229zm5.593 5.44l-4.832-2.777c-.266-.152-.57-.19-.837-.152-.723.038-1.332.684-1.332 1.408v5.554c0 .8.647 1.408 1.408 1.408.799 0 1.446-.647 1.446-1.408v-3.12l2.7 1.56c.686.38 1.561.152 1.941-.533.419-.646.19-1.521-.494-1.94zm2.549-7.533l-2.701 1.56 2.7 1.56c.686.38.914 1.256.533 1.94-.38.685-1.255.913-1.94.533l-4.832-2.778a1.644 1.644 0 01-.647-.798c-.037-.153-.076-.305-.076-.457 0-.114.039-.228.039-.342.114-.343.342-.647.646-.837l4.832-2.778c.685-.38 1.56-.152 1.94.533.457.609.19 1.484-.494 1.864",
strava: "M15.387 17.944l-2.089-4.116h-3.065L15.387 24l5.15-10.172h-3.066m-7.008-5.599l2.836 5.598h4.172L10.463 0l-7 13.828h4.169",
stripe: "M13.976 9.15c-2.172-.806-3.356-1.426-3.356-2.409 0-.831.683-1.305 1.901-1.305 2.227 0 4.515.858 6.09 1.631l.89-5.494C18.252.975 15.697 0 12.165 0 9.667 0 7.589.654 6.104 1.872 4.56 3.147 3.757 4.992 3.757 7.218c0 4.039 2.467 5.76 6.476 7.219 2.585.92 3.445 1.574 3.445 2.583 0 .98-.84 1.545-2.354 1.545-1.875 0-4.965-.921-6.99-2.109l-.9 5.555C5.175 22.99 8.385 24 11.714 24c2.641 0 4.843-.624 6.328-1.813 1.664-1.305 2.525-3.236 2.525-5.732 0-4.128-2.524-5.851-6.594-7.305h.003z",
vercel: "m12 1.608 12 20.784H0Z",
visa: "M9.112 8.262L5.97 15.758H3.92L2.374 9.775c-.094-.368-.175-.503-.461-.658C1.447 8.864.677 8.627 0 8.479l.046-.217h3.3a.904.904 0 01.894.764l.817 4.338 2.018-5.102zm8.033 5.049c.008-1.979-2.736-2.088-2.717-2.972.006-.269.262-.555.822-.628a3.66 3.66 0 011.913.336l.34-1.59a5.207 5.207 0 00-1.814-.333c-1.917 0-3.266 1.02-3.278 2.479-.012 1.079.963 1.68 1.698 2.04.756.367 1.01.603 1.006.931-.005.504-.602.725-1.16.734-.975.015-1.54-.263-1.992-.473l-.351 1.642c.453.208 1.289.39 2.156.398 2.037 0 3.37-1.006 3.377-2.564m5.061 2.447H24l-1.565-7.496h-1.656a.883.883 0 00-.826.55l-2.909 6.946h2.036l.405-1.12h2.488zm-2.163-2.656l1.02-2.815.588 2.815zm-8.16-4.84l-1.603 7.496H8.34l1.605-7.496z",
/* Zoom's app icon: its camera (the body and the lens), drawn on Zoom's blue tile; the wordmark is unreadable at 16px */
zoom: "M6.5 7h7A2.5 2.5 0 0 1 16 9.5v5a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 4 14.5v-5A2.5 2.5 0 0 1 6.5 7Zm10.5 3.6 2.4-1.75c.66-.48 1.6-.01 1.6.81v6.68c0 .82-.94 1.29-1.6.81L17 15.4Z",
webflow: "m24 4.515-7.658 14.97H9.149l3.205-6.204h-.144C9.566 16.713 5.621 18.973 0 19.485v-6.118s3.596-.213 5.71-2.435H0V4.515h6.417v5.278l.144-.001 2.622-5.277h4.854v5.244h.144l2.72-5.244H24Z",
yelp: "m7.6885 15.1415-3.6715.8483c-.3769.0871-.755.183-1.1452.155-.2611-.0188-.5122-.0414-.7606-.213a1.179 1.179 0 0 1-.331-.3594c-.3486-.5519-.3656-1.3661-.3697-2.0004a6.2874 6.2874 0 0 1 .3314-2.0642 1.857 1.857 0 0 1 .1073-.2474 2.3426 2.3426 0 0 1 .1255-.2165 2.4572 2.4572 0 0 1 .1563-.1975 1.1736 1.1736 0 0 1 .399-.2831 1.082 1.082 0 0 1 .4592-.0837c.2355.0016.5139.052.91.1734.0555.0191.1237.0382.1856.0572.3277.1013.7048.2404 1.1499.3987.6863.2404 1.3663.487 2.0463.7397l1.2117.4423c.2217.0807.4363.18.6412.297.174.0984.3273.2298.4512.387a1.217 1.217 0 0 1 .192.4309 1.2205 1.2205 0 0 1-.872 1.4522c-.0468.0151-.0852.0239-.1085.0293l-1.105.2553-.0031-.001zM18.8208 7.565a1.8506 1.8506 0 0 0-.2042-.1754 2.4082 2.4082 0 0 0-.2077-.1394 2.3607 2.3607 0 0 0-.2269-.109 1.1705 1.1705 0 0 0-.482-.0796 1.0862 1.0862 0 0 0-.4498.1263c-.2107.1048-.4388.2732-.742.5551-.042.0417-.0947.0886-.142.133-.2502.2351-.5286.5252-.8599.863a114.6363 114.6363 0 0 0-1.5166 1.5629l-.8962.9293a4.1897 4.1897 0 0 0-.4466.5483 1.541 1.541 0 0 0-.2364.5459 1.2199 1.2199 0 0 0 .0107.4518l.0046.02a1.218 1.218 0 0 0 1.4184.923 1.162 1.162 0 0 0 .1105-.0213l4.7781-1.104c.3766-.087.7587-.1667 1.097-.3631.2269-.1316.4428-.262.5909-.5252a1.1793 1.1793 0 0 0 .1405-.4683c.0733-.6512-.2668-1.3908-.5403-1.963a6.2792 6.2792 0 0 0-1.2001-1.7103zM8.9703.0754a8.6724 8.6724 0 0 0-.83.1564c-.2754.066-.548.1383-.8146.2236-.868.2844-2.0884.8063-2.295 1.8065-.1165.5655.1595 1.1439.3737 1.66.2595.6254.614 1.1889.9373 1.7777.8543 1.5545 1.7245 3.0993 2.5922 4.6457.259.4617.5416 1.0464 1.043 1.2856a1.058 1.058 0 0 0 .1013.0383c.2248.0851.4699.1016.7041.0471a4.3015 4.3015 0 0 0 .0418-.0097 1.2136 1.2136 0 0 0 .5658-.3397 1.1033 1.1033 0 0 0 .079-.0822c.3463-.435.3454-1.0833.3764-1.6134.1042-1.771.2139-3.5423.3009-5.3142.0332-.6712.1055-1.3333.0655-2.0096-.0328-.5579-.0368-1.1984-.3891-1.6563-.6218-.8073-1.9476-.741-2.8523-.6158zm2.084 15.9505a1.1053 1.1053 0 0 0-1.2306-.4145 1.1398 1.1398 0 0 0-.1526.0633 1.4806 1.4806 0 0 0-.2171.1354c-.1992.1475-.3668.3392-.5196.5315-.0386.049-.074.1143-.12.1562l-.7686 1.0573a113.9168 113.9168 0 0 0-1.2913 1.789c-.278.3895-.5184.7184-.7083 1.0094-.036.0547-.0734.116-.1075.1647-.2277.3522-.3566.6092-.4228.8381a1.0945 1.0945 0 0 0-.046.4721c.0211.1655.0768.3246.1635.467.046.0715.0957.1406.1487.207a2.334 2.334 0 0 0 .1754.1825 1.843 1.843 0 0 0 .2108.1732c.5304.369 1.1112.6342 1.722.8391a6.0958 6.0958 0 0 0 1.5716.3004c.091.0046.1821.0025.2728-.006a2.3878 2.3878 0 0 0 .2506-.0351 2.3862 2.3862 0 0 0 .2447-.071 1.1927 1.1927 0 0 0 .4175-.2658c.1127-.113.1994-.249.2541-.3989.0889-.2214.1473-.5026.1857-.92.0034-.0593.0118-.1305.0177-.1958.0304-.3463.0443-.7531.0666-1.2315.0375-.7357.067-1.4681.0903-2.2026 0 0 .0495-1.3053.0494-1.306.0113-.3008.002-.6342-.0814-.9336a1.396 1.396 0 0 0-.1756-.4054zm8.6754 2.0439c-.1605-.176-.3878-.3514-.7462-.5682-.0518-.0288-.1124-.0674-.1684-.1009-.2985-.1795-.658-.3684-1.078-.5965a120.7615 120.7615 0 0 0-1.9427-1.042l-1.1515-.6107c-.0597-.0175-.1203-.0607-.1766-.0878-.2212-.1058-.4558-.2045-.6992-.2498a1.4915 1.4915 0 0 0-.2545-.0265 1.1527 1.1527 0 0 0-.1648.01 1.1077 1.1077 0 0 0-.9227.9133 1.4186 1.4186 0 0 0 .0159.439c.0563.3065.1932.6096.3346.875l.615 1.1526c.3422.65.6884 1.2963 1.0435 1.9406.229.4202.4196.7799.5982 1.078.0338.056.0721.1163.1011.1682.2173.3584.392.584.569.7458.1146.1107.252.195.4026.247.1583.0525.326.071.4919.0546a2.368 2.368 0 0 0 .251-.0435c.0817-.022.1622-.048.241-.0784a1.863 1.863 0 0 0 .2475-.1143 6.1018 6.1018 0 0 0 1.2818-.9597c.4596-.4522.8659-.9454 1.182-1.51.044-.08.0819-.163.1138-.2483a2.49 2.49 0 0 0 .0773-.2411c.0186-.083.033-.1669.0429-.2513a1.188 1.188 0 0 0-.0565-.491 1.0933 1.0933 0 0 0-.248-.4041zm2.86 3.742a.8523.8523 0 0 1-.111.4236c-.074.132-.178.2377-.3115.3172a.8428.8428 0 0 1-.4385.119.847.847 0 0 1-.4373-.1179.8526.8526 0 0 1-.3125-.3171.8548.8548 0 0 1-.111-.4248c0-.1526.038-.2958.1143-.4294a.8405.8405 0 0 1 .315-.3159.849.849 0 0 1 .4315-.1156.8514.8514 0 0 1 .4294.1144.84.84 0 0 1 .316.3148.8494.8494 0 0 1 .1156.4317zm-.1202 0c0-.1328-.0332-.256-.0996-.3698s-.1564-.2038-.2702-.2702a.7125.7125 0 0 0-.371-.1007.7204.7204 0 0 0-.3698.0996.7487.7487 0 0 0-.2713.2702.7181.7181 0 0 0-.0996.3709c0 .132.0332.2557.0996.371a.7355.7355 0 0 0 .2713.2713.7354.7354 0 0 0 .3698.0985.7205.7205 0 0 0 .3698-.0996.7423.7423 0 0 0 .2702-.2691.7186.7186 0 0 0 .1008-.3721zm-.577.0584.2724.4522h-.1922l-.237-.4052h-.1546v.4052h-.1695v-1.02h.2988c.1268 0 .2195.0247.2783.0744.0595.0496.0892.1252.0892.2267a.2785.2785 0 0 1-.0492.1625c-.032.0466-.0775.0813-.1362.1042zm-.0412-.1408a.1532.1532 0 0 0 .056-.1214c0-.0573-.0164-.0981-.0491-.1225-.0329-.0251-.0847-.0377-.1557-.0377h-.1214v.3285h.1237c.061 0 .1098-.0157.1465-.047z",
} as const satisfies Record<string, string>;
type BrandName = keyof typeof BRAND_GLYPHS;
/** A real company's mark by its name, case-insensitive ("Stripe", "stripe"); undefined for one with none, which then shows its initial. */
const brandGlyph = (name: string): string | undefined => BRAND_GLYPHS[name.trim().toLowerCase() as BrandName];
export { BRAND_GLYPHS, brandGlyph };"use client";
import * as React from "react";
/*
* A demo that plays itself until the first touch: the script lives in the demo, never in the piece, which only gets
* the props a person would give it. It moves 0.4 s after the piece is first seen, then takes each step on its beat;
* off screen or paused it waits. The first press, key or focus on the piece (bind `handOver` to it; a scroll over it never counts) makes it the
* visitor's for good and drops every queued step; with less motion (`off`) it never plays and rests in its first frame.
* A host can hand it over from outside the piece too (a settings panel beside it the visitor has used): under
* <HandedOver value>, it never plays, a remount included.
*
* const play = useSelfPlay(root, { beats: [2800, 2800], loop: true, off: less });
* <div ref={root} onPointerDownCapture={play.handOver} onKeyDownCapture={play.handOver} onFocusCapture={play.handOver}>
* play.step // the step it is at, -1 before its first
* play.control // "pause" while it plays, "play" once paused (a new take), "replay" once it is over or yours
*
* Each step presses the piece's own controls (pressIn), so the script shows exactly what a hand can do.
*
* A host that shows the piece once (<PlayOnce value={{ settle }}>) changes three things: the script starts when the
* piece is first half in view and never again on coming back, it never loops, and with less motion (or `settle`) it
* takes every step at once, so the piece rests on the END of its moment. `hold` is a reason not to play at all that is
* not motion (a mode with nothing to show): it holds in every host. Under <PlayOnce value={{ active: false }}> (a look
* that is mounted but not shown) it waits until it is shown.
*/
type SelfPlayOptions = {
/** how long each step waits after the one before it, in ms; the first step waits 0.4 s after the piece is seen */
beats: readonly number[];
/** starts over after the last step; without it the script plays once and rests */
loop?: boolean | undefined;
/** no self-play at all (less motion): the piece is the visitor's from the start */
off: boolean;
/** no self-play for a reason other than motion (a mode with nothing to show), in every host */
hold?: boolean | undefined;
};
/** How a host shows the piece: once on arrival (see useSelfPlay). */
type PlayOnceHost = {
/** rest on the end at once, without playing (less motion, or a reset) */
settle?: boolean | undefined;
/** false while the piece is mounted but not shown: it waits */
active?: boolean | undefined;
};
const START = 400;
/**
* Whether a demo plays itself at all. Off: every piece rests in its first frame and is
* the visitor's from the start; nothing presses its controls for them.
*/
const SELF_PLAY: boolean = false;
/** True where the visitor has already taken the piece from outside it: nothing under it plays itself. */
const HandedOver = React.createContext(false);
/** A host that shows the piece once: play once on arrival, rest on the end (null: play as the demo asks). */
const PlayOnce = React.createContext<PlayOnceHost | null>(null);
function useSelfPlay(root: React.RefObject<Element | null>, { beats, loop: looped = false, off: still, hold = false }: SelfPlayOptions) {
const once = React.useContext(PlayOnce);
const active = once?.active !== false;
/* shown once: less motion (or a settled host) takes every step at once and rests on the end */
const quick = once != null && (still || Boolean(once.settle));
const loop = once == null && looped;
/* the first touch hands it over for good */
const [mine, setMine] = React.useState(false);
const handOver = React.useCallback(() => setMine(true), []);
const handedOver = React.useContext(HandedOver);
const off = !SELF_PLAY || hold || (quick ? false : still) || mine || (handedOver && !quick);
const [seen, setSeen] = React.useState(false);
const [paused, setPaused] = React.useState(false);
const [taken, setTaken] = React.useState(0);
const n = Math.max(1, beats.length);
const done = !loop && taken >= n;
React.useEffect(() => {
const el = root.current;
if (!active) return;
/* without an observer (an old browser, a test) it counts as seen */
if (!el || typeof IntersectionObserver === "undefined" || quick) {
const t = window.setTimeout(() => setSeen(true));
return () => window.clearTimeout(t);
}
/* shown once: first half in view starts it, and leaving never stops or restarts it */
const io = once
? new IntersectionObserver((es) => {
if (es.some((e) => e.isIntersecting && e.intersectionRatio >= 0.5)) {
setSeen(true);
io.disconnect();
}
}, { threshold: 0.5 })
: new IntersectionObserver((es) => setSeen(es.some((e) => e.isIntersecting)));
io.observe(el);
return () => io.disconnect();
}, [root, active, once, quick]);
const playing = !off && seen && active && !paused && !done;
const delay = quick ? 0 : taken === 0 ? START : (beats[taken % n] ?? START);
React.useEffect(() => {
if (!playing) return;
const t = window.setTimeout(() => setTaken((k) => k + 1), delay);
return () => window.clearTimeout(t);
}, [playing, taken, delay]);
/* one control in one place: Pause while it plays, Play (a new take) once paused, Replay once it is over or yours */
/* self-play off: never "over", so a demo rests in its FIRST frame, not its end frame */
const control: "pause" | "play" | "replay" = paused || !SELF_PLAY ? "play" : off || done ? "replay" : "pause";
return { step: taken === 0 ? -1 : (taken - 1) % n, taken, playing, control, mine, handOver, pause: () => setPaused(true) };
}
/**
* Presses a real control inside `root`, as the visitor would: the first match of `selector`, or the one whose text is
* `text`. A click only, so it never counts as the visitor's touch.
*/
function pressIn(root: Element | null, selector: string, text?: string) {
const all = [...(root?.querySelectorAll<HTMLElement>(selector) ?? [])];
(text == null ? all[0] : all.find((el) => el.textContent?.trim() === text))?.click();
}
export { HandedOver, PlayOnce, pressIn, useSelfPlay, type PlayOnceHost, type SelfPlayOptions };This example also uses Badge, Button, Card, Company mark, File drop. This command installs them with it, so the example pastes as it is:
pnpm dlx shadcn@latest add https://notchset.dev/r/empty-state.json https://notchset.dev/r/badge.json https://notchset.dev/r/button.json https://notchset.dev/r/card.json https://notchset.dev/r/company-mark.json https://notchset.dev/r/file-drop.jsoncomponents/ui/notchset/empty-state.tsx
LevelAtom: uses no other piece.
Made ofNothing else from the library: the foundation alone.
Free, no account or key. One command for every shadcn style. With the @notchset registry added, @notchset/<name> works too.
Works with React 18.3 or 19 on Tailwind CSS v4, in any shadcn project. What's tested
pnpm add lucide-react@^1The CLI adds the styles to the CSS file named in components.json (tailwind.css). Check that it points at your global stylesheet, that the project uses Tailwind CSS v4, and that the file is imported in your root layout. Installed by hand: paste styles.css into that file.
title–
React.ReactNodewhat is empty, in a few words
icon–
React.ReactNodeA Lucide glyph: drawn on its own on a page, in a quiet tile in a section.
action–
React.ReactNodethe one way to fill it: a Button
code–
React.ReactNodeThe mono line a person can quote to support (a failure's status · code · time · request id).
size–
"page" | "section" | "inline" | "row"Leave it out to let the space decide (page when 360px tall or more, else section). "row": a list's own empty, left-aligned in its card: the heading, a line, ghost rows in the real row's shape (a target: a press on one is the action), and the action; `filled` swaps the ghosts for the real rows.
ghost–
EmptyGhostPart[]row: the parts of a ghost row, in the real row's order
ghostRows–
numberrow: how many ghost rows (1 by default)
chips–
React.ReactNode[]row: the filters that emptied it, as chips above the heading; they leave when it fills
filled–
booleanrow: the list has its rows now (`filledRows`): the ghosts give way, the heading rolls to doneTitle
filledRows–
React.ReactNode[]row: the real rows, one node each, shown once filled
doneTitle–
React.ReactNoderow: the heading once filled ("1 deal in Berlin")
added–
booleanrow: the first row was just added: the green tick lands on its corner
announce–
stringrow: said aloud once filled ("Airtable deal added")
live–
booleanrow: its own live region (default true); false when the page says `announce` in its one region
ghosts–
numberQuiet rows in a list's shape above the words (3 reads well).
over–
booleanSomething is held over to drop: the ghosts lift.
Three usesa pipeline with no deals yet · a folder with no files · a search with no results
Give your coding assistant the Markdown guide instead of screenshots.
https://notchset.dev/api/mcp (setup)v1.2.0 · 2026-11-17
Ships button-class.ts (QUIET_PILL, buttonBase, buttonIntents, buttonResults, buttonSizes, buttonSquare), which it now uses. Ships button-move.ts (ButtonRoll, buttonRollLayer, play, ButtonRollState, useButtonRoll), which it now uses. Internal files split; installs smaller; no change to the piece's own API.
v1.1.0 · 2026-11-17
New props: added, announce, chips, doneTitle, filled, filledRows, ghost, ghostRows, ghosts, live, over. Ships button-look.ts (ButtonBin, ButtonBusy, ButtonPlane, ButtonPuff, ButtonRoll, ButtonSparks, ButtonTick, EdgeBurst, QUIET_PILL, buttonBase, buttonIntents, buttonResults, buttonRollLayer, buttonSizes, buttonSquare, play, ButtonRollState, useButtonRoll), which it now uses. empty-state.tsx now exports EmptyGhostPart. Ships hit-area.ts (HIT_AREA), which it now uses.
v1.0.0 · 2026-11-09
Released free with the Notchset system.