{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-signup-conversion",
  "title": "Signup conversion",
  "author": "andongmin94",
  "description": "Cohort conversion with stage losses, conversion rates, and an exact data table.",
  "dependencies": [
    "recharts@^3.10.1"
  ],
  "registryDependencies": [
    "https://neobrutal-ui.andongmin.com/r/chart.json",
    "https://neobrutal-ui.andongmin.com/r/card.json"
  ],
  "files": [
    {
      "path": "src/components/ui/chart-signup-conversion.tsx",
      "content": "\"use client\";\n\nimport { useState } from \"react\";\nimport { Bar, BarChart, CartesianGrid, XAxis, YAxis } from \"recharts\";\n\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from \"@/components/ui/card\";\nimport {\n  ChartContainer,\n  ChartSelect,\n  ChartTooltip,\n  ChartTooltipContent,\n  type ChartConfig,\n} from \"@/components/ui/chart\";\n\nconst cohorts = {\n  \"Self-serve\": [4800, 1800, 840, 520],\n  \"Sales-led\": [1600, 960, 650, 470],\n} as const;\nconst stages = [\"Visited\", \"Signed up\", \"Activated\", \"Paid\"];\nconst config = { people: { label: \"People\", color: \"var(--chart-2)\" } } satisfies ChartConfig;\nconst number = new Intl.NumberFormat(\"en-US\");\n\nexport default function Component() {\n  const [cohort, setCohort] = useState<keyof typeof cohorts>(\"Self-serve\");\n  const counts = cohorts[cohort];\n  const data = stages.map((stage, index) => ({ stage, people: counts[index] }));\n  const drops = data.slice(1).map((row, index) => ({\n    from: stages[index],\n    to: row.stage,\n    lost: counts[index] - row.people,\n  }));\n  const largestDrop = drops.reduce((largest, drop) => (drop.lost > largest.lost ? drop : largest));\n\n  return (\n    <Card className=\"h-full min-w-0\" data-chart-recipe=\"conversion\">\n      <CardHeader>\n        <p className=\"font-mono text-xs uppercase tracking-widest\">02 / Find the friction</p>\n        <CardTitle>\n          <h3>Signup conversion</h3>\n        </CardTitle>\n        <CardDescription>\n          One sample cohort through four stages. Counts are people, not events.\n        </CardDescription>\n      </CardHeader>\n      <CardContent className=\"grid min-w-0 gap-6\">\n        <ChartSelect\n          label=\"Acquisition cohort\"\n          value={cohort}\n          onValueChange={(value) => setCohort(value as keyof typeof cohorts)}\n          options={Object.keys(cohorts).map((value) => ({ value, label: value }))}\n        />\n        <dl className=\"grid grid-cols-2 gap-4 border-y-2 border-border py-4\" aria-live=\"polite\">\n          <div>\n            <dt className=\"text-xs text-foreground/75\">Visit to paid</dt>\n            <dd className=\"mt-1 text-2xl font-heading tabular-nums\">\n              {((counts[3] / counts[0]) * 100).toFixed(1)}%\n            </dd>\n          </div>\n          <div>\n            <dt className=\"text-xs text-foreground/75\">Paid customers</dt>\n            <dd className=\"mt-1 text-2xl font-heading tabular-nums\">{number.format(counts[3])}</dd>\n          </div>\n        </dl>\n        <figure className=\"min-w-0\" aria-label=\"People remaining at each signup stage\">\n          <ChartContainer config={config} className=\"h-64 w-full min-w-0 aspect-auto\">\n            <BarChart\n              accessibilityLayer\n              data={data}\n              layout=\"vertical\"\n              margin={{ top: 0, right: 12, bottom: 0, left: 0 }}\n            >\n              <CartesianGrid horizontal={false} />\n              <XAxis\n                type=\"number\"\n                domain={[0, counts[0]]}\n                tickLine={false}\n                axisLine={false}\n                tickFormatter={(value) => number.format(Number(value))}\n              />\n              <YAxis type=\"category\" dataKey=\"stage\" width={72} tickLine={false} axisLine={false} />\n              <ChartTooltip\n                content={\n                  <ChartTooltipContent\n                    formatter={(value) => `${number.format(Number(value))} people`}\n                  />\n                }\n              />\n              <Bar\n                dataKey=\"people\"\n                fill=\"var(--color-people)\"\n                radius={[0, 3, 3, 0]}\n                maxBarSize={36}\n                isAnimationActive={false}\n              />\n            </BarChart>\n          </ChartContainer>\n        </figure>\n        <output className=\"border-l-4 border-main pl-3 text-sm leading-6\">\n          Largest drop: {largestDrop.from} → {largestDrop.to}. {number.format(largestDrop.lost)}{\" \"}\n          people did not reach the next stage.\n        </output>\n        <details className=\"min-w-0 border-t-2 border-border pt-4\">\n          <summary className=\"cursor-pointer text-sm font-heading\">View conversion data</summary>\n          <table className=\"mt-3 w-full text-left text-xs tabular-nums\">\n            <caption className=\"pb-3 text-left text-foreground/75\">\n              {cohort}. Step conversion uses the previous stage as its denominator.\n            </caption>\n            <thead>\n              <tr>\n                {[\"Stage\", \"People\", \"From previous\"].map((label) => (\n                  <th key={label} scope=\"col\" className=\"border-b-2 border-border py-2 pr-3\">\n                    {label}\n                  </th>\n                ))}\n              </tr>\n            </thead>\n            <tbody>\n              {data.map((row, index) => (\n                <tr key={row.stage}>\n                  <th scope=\"row\" className=\"py-2 pr-3\">\n                    {row.stage}\n                  </th>\n                  <td className=\"pr-3\">{number.format(row.people)}</td>\n                  <td>\n                    {index === 0 ? \"—\" : `${((row.people / counts[index - 1]) * 100).toFixed(1)}%`}\n                  </td>\n                </tr>\n              ))}\n            </tbody>\n          </table>\n        </details>\n      </CardContent>\n    </Card>\n  );\n}\n",
      "type": "registry:ui"
    }
  ],
  "categories": [
    "data-display",
    "data-visualization",
    "recipe"
  ],
  "type": "registry:component"
}