{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"onboarding-checklist","type":"registry:block","title":"Getting started","description":"Steps to a working setup with progress and time left; the next step unfolds, and finishing celebrates.","dependencies":["lucide-react"],"registryDependencies":["https://dashral.com/r/utils.json","https://dashral.com/r/button.json","https://dashral.com/r/progress.json"],"files":[{"path":"registry/dashral/blocks/onboarding-checklist.tsx","type":"registry:file","target":"components/dashral/blocks/onboarding-checklist.tsx","content":"\"use client\"\n\nimport { useId, useState } from \"react\"\nimport { Check, ChevronDown, PartyPopper, X } from \"lucide-react\"\nimport { Button } from \"../button\"\nimport { Progress } from \"../progress\"\nimport { cn } from \"../lib/utils\"\n\n// The products named here are real ones, as examples: their names are their owners' trademarks, no affiliation implied. Put in the tools your product really works with.\nconst brands = { payments: \"Stripe\", store: \"Shopify\", chat: \"Slack\" }\n\n/** A step: what it is, its action's label (and where it goes, or onAction hears it), and about how long it takes. */\nexport type Task = { id: string; title: string; text: string; action: string; href?: string; minutes: number }\n\nconst sampleTasks: Task[] = [\n  { id: \"account\", title: \"Create your workspace\", text: \"Name it and pick your time zone, so every report starts its day when yours does.\", action: \"Open settings\", minutes: 1 },\n  { id: \"source\", title: \"Connect a data source\", text: `${brands.payments}, ${brands.store} or Postgres. We backfill the last 12 months, so your charts aren't empty.`, action: `Connect ${brands.payments}`, minutes: 2 },\n  { id: \"dashboard\", title: \"Build your first dashboard\", text: \"Start from a template or drag charts onto a blank board. You can change everything later.\", action: \"Choose a template\", minutes: 5 },\n  { id: \"team\", title: \"Invite your team\", text: \"Teammates see the same numbers and can comment on any chart. Viewers are always free.\", action: \"Invite people\", minutes: 1 },\n  { id: \"alert\", title: \"Set up an alert\", text: `Get one message when a number moves, in email or ${brands.chat}, instead of checking all day.`, action: \"Create an alert\", minutes: 2 },\n]\n\n/**\n * A getting-started card: the steps to a working setup, with progress. Tick a step, or do it from its action;\n * the next open step unfolds. Finishing them all shows a small celebration, and the card can be hidden and\n * brought back. Every part comes from props: your steps, which are done (controllable), and handlers for each step's\n * action and for hiding the card.\n */\nexport function OnboardingChecklist({\n  title = \"Get started with Acme\",\n  tasks = sampleTasks,\n  done: doneProp,\n  onDoneChange,\n  onAction,\n  hidden: hiddenProp,\n  onHiddenChange,\n  finished: finishedText = { title: \"You're all set\", description: \"Your workspace is ready. Here's to fewer spreadsheets.\", note: \"Five steps, done. Your first weekly report goes out on Monday at 9 AM.\" },\n  hiddenNote = \"Getting started is hidden. It's in Help whenever you want it.\",\n}: {\n  title?: React.ReactNode\n  tasks?: Task[]\n  /** The steps done, by id (the card keeps them without it). */\n  done?: string[]\n  onDoneChange?: (done: string[]) => void\n  /** A step's action button: go do it. Without it (and without an href), the button marks the step done. */\n  onAction?: (task: Task) => void\n  hidden?: boolean\n  onHiddenChange?: (hidden: boolean) => void\n  finished?: { title: string; description: string; note?: string }\n  hiddenNote?: string\n}) {\n  const [ownDone, setOwnDone] = useState<string[]>([\"account\"])\n  const done = doneProp ?? ownDone\n  const setDone = (next: string[]) => {\n    setOwnDone(next)\n    onDoneChange?.(next)\n  }\n  const [open, setOpen] = useState<string | null>(() => tasks.find((task) => !done.includes(task.id))?.id ?? null)\n  const [ownHidden, setOwnHidden] = useState(false)\n  const hidden = hiddenProp ?? ownHidden\n  const setHidden = (next: boolean) => {\n    setOwnHidden(next)\n    onHiddenChange?.(next)\n  }\n  const id = useId()\n\n  const count = tasks.filter((task) => done.includes(task.id)).length\n  const finished = count === tasks.length\n  const minutesLeft = tasks.filter((task) => !done.includes(task.id)).reduce((sum, task) => sum + task.minutes, 0)\n\n  function toggle(taskId: string) {\n    const next = done.includes(taskId) ? done.filter((d) => d !== taskId) : [...done, taskId]\n    setDone(next)\n    // Ticking a step moves you on to the next one still open.\n    if (!done.includes(taskId)) setOpen(tasks.find((task) => !next.includes(task.id))?.id ?? null)\n  }\n\n  if (hidden)\n    return (\n      <section className=\"bg-background p-4 sm:p-6\">\n        <div className=\"mx-auto flex max-w-xl items-center justify-between gap-3 rounded-xl border border-dashed px-4 py-3 text-sm text-muted-foreground\">\n          <span>{hiddenNote}</span>\n          <Button size=\"sm\" variant=\"ghost\" onClick={() => setHidden(false)}>\n            Show again\n          </Button>\n        </div>\n      </section>\n    )\n\n  return (\n    <section aria-labelledby={`${id}-title`} className=\"bg-background p-4 sm:p-6\">\n      <div className=\"mx-auto max-w-xl overflow-hidden rounded-xl border bg-card\">\n        <div className=\"flex items-start justify-between gap-3 p-5 pb-4\">\n          <div>\n            <h2 id={`${id}-title`} className=\"font-semibold\">\n              {finished ? finishedText.title : title}\n            </h2>\n            <p className=\"mt-0.5 text-sm text-muted-foreground\">\n              {finished ? finishedText.description : `${count} of ${tasks.length} done · about ${minutesLeft} minutes left`}\n            </p>\n          </div>\n          <Button variant=\"ghost\" size=\"icon-sm\" aria-label=\"Hide getting started\" className=\"-me-1.5 -mt-1\" onClick={() => setHidden(true)}>\n            <X />\n          </Button>\n        </div>\n        <Progress value={(count / tasks.length) * 100} color={finished ? \"success\" : \"primary\"} className=\"mx-5 h-1.5 w-auto\" aria-label={`${count} of ${tasks.length} steps done`} />\n\n        {finished ? (\n          <div className=\"grid justify-items-center gap-3 px-5 py-10 text-center\">\n            <span className=\"grid size-12 place-items-center rounded-full bg-success/15 text-success-text animate-in zoom-in-75 fade-in-0 duration-(--duration-considered) ease-enter motion-reduce:animate-none\">\n              <PartyPopper className=\"size-6\" aria-hidden />\n            </span>\n            {finishedText.note && <p className=\"max-w-xs text-sm text-muted-foreground\">{finishedText.note}</p>}\n            <Button size=\"sm\" variant=\"outline\" onClick={() => setHidden(true)}>\n              Hide this card\n            </Button>\n          </div>\n        ) : (\n          <ol className=\"mt-3 border-t\">\n            {tasks.map((task, i) => {\n              const isDone = done.includes(task.id)\n              const isOpen = open === task.id\n              return (\n                <li key={task.id} className=\"border-b last:border-b-0\">\n                  <div className=\"flex items-center gap-3 px-5 py-3\">\n                    <button\n                      type=\"button\"\n                      onClick={() => toggle(task.id)}\n                      aria-label={isDone ? `Mark \"${task.title}\" as not done` : `Mark \"${task.title}\" as done`}\n                      aria-pressed={isDone}\n                      className={cn(\n                        \"grid size-5 shrink-0 place-items-center rounded-full border transition-[background-color,border-color] duration-(--duration-fast) outline-none focus-visible:ring-2 focus-visible:ring-ring/50\",\n                        isDone ? \"border-primary bg-primary text-primary-foreground\" : \"border-muted-foreground/40 border-dashed hover:border-primary\"\n                      )}\n                    >\n                      <Check className={cn(\"size-3 transition-[opacity,scale] duration-(--duration-fast)\", isDone ? \"scale-100 opacity-100\" : \"scale-50 opacity-0\")} strokeWidth={3} aria-hidden />\n                    </button>\n                    <button\n                      type=\"button\"\n                      onClick={() => setOpen(isOpen ? null : task.id)}\n                      aria-expanded={isOpen}\n                      aria-controls={`${id}-${task.id}`}\n                      className=\"flex min-w-0 flex-1 items-center gap-3 rounded-md text-start text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring/50\"\n                    >\n                      <span className={cn(\"flex-1 font-medium transition-colors\", isDone && \"text-muted-foreground line-through decoration-muted-foreground/50\")}>\n                        <span className=\"sr-only\">Step {i + 1}: </span>\n                        {task.title}\n                      </span>\n                      <span className=\"text-xs text-muted-foreground tabular-nums\">{task.minutes} min</span>\n                      <ChevronDown className={cn(\"size-4 text-muted-foreground transition-transform duration-(--duration-considered) ease-standard\", isOpen && \"rotate-180\")} aria-hidden />\n                    </button>\n                  </div>\n                  {/* Unfolds by its own height: the row's track grows from 0fr to 1fr. */}\n                  <div\n                    id={`${id}-${task.id}`}\n                    className={cn(\"grid transition-[grid-template-rows] duration-(--duration-considered) ease-standard\", isOpen ? \"grid-rows-[1fr]\" : \"grid-rows-[0fr]\")}\n                    inert={!isOpen}\n                  >\n                    <div className=\"overflow-hidden\">\n                      <div className=\"ps-13 pe-5 pb-4\">\n                        <p className=\"text-sm text-muted-foreground\">{task.text}</p>\n                        <div className=\"mt-3 flex gap-2\">\n                          {isDone ? (\n                            <Button size=\"sm\" variant=\"outline\" onClick={() => toggle(task.id)}>\n                              Mark as not done\n                            </Button>\n                          ) : (\n                            <>\n                              {task.href ? (\n                                <Button size=\"sm\" asChild>\n                                  <a href={task.href}>{task.action}</a>\n                                </Button>\n                              ) : (\n                                <Button size=\"sm\" onClick={() => (onAction ? onAction(task) : toggle(task.id))}>\n                                  {task.action}\n                                </Button>\n                              )}\n                              <Button size=\"sm\" variant=\"ghost\" onClick={() => toggle(task.id)}>\n                                Skip\n                              </Button>\n                            </>\n                          )}\n                        </div>\n                      </div>\n                    </div>\n                  </div>\n                </li>\n              )\n            })}\n          </ol>\n        )}\n      </div>\n    </section>\n  )\n}\n"}],"cssVars":{"theme":{"color-success":"var(--success)","color-success-foreground":"var(--success-foreground)","color-success-text":"var(--success-text)","ease-standard":"var(--ease-standard)","ease-enter":"var(--ease-enter)","ease-exit":"var(--ease-exit)","ease-spring":"var(--ease-spring)"},"light":{"success":"oklch(0.508 0.118 165.612)","success-foreground":"oklch(0.985 0 0)","success-text":"oklch(0.432 0.095 166.913)","duration-fast":"160ms","duration-standard":"240ms","duration-considered":"480ms","ease-standard":"cubic-bezier(0.2, 0, 0, 1)","ease-enter":"cubic-bezier(0, 0, 0, 1)","ease-exit":"cubic-bezier(0.3, 0, 1, 1)","ease-spring":"linear(0, 0.071 4%, 0.234 8%, 0.433 12%, 0.626 17%, 0.791 21%, 0.917 25%, 1.004 29%, 1.055 33%, 1.079 38%, 1.083 42%, 1.075 46%, 1.06 50%, 1.043 54%, 1.027 58%, 1.015 62%, 1.005 67%, 0.998 71%, 0.995 75%, 0.993 79%, 0.993 83%, 0.994 88%, 0.995 92%, 0.997 96%, 1)"},"dark":{"success":"oklch(0.696 0.17 162.48)","success-foreground":"oklch(0.2 0.04 160)","success-text":"oklch(0.765 0.177 163.223)"}}}