{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tally-budget-demo",
  "type": "registry:block",
  "title": "Tally: Budget Split",
  "description": "Animated Dot Chart example, Budget Split: One monthly ad budget split three ways. Switching plans moves the dollars between channels instead of redrawing the chart. A take on the chart (graph). Fits stats, app UI and about sections.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "stats",
    "app-ui",
    "about",
    "chart",
    "particle-effect",
    "data",
    "canvas"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/tally#tally-budget-demo",
  "registryDependencies": [
    "https://keyframeui.com/r/tally.json"
  ],
  "files": [
    {
      "path": "components/tally-budget-demo.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { Tally } from \"@/components/ui/tally\";\n\nconst CHANNELS = [\n  { id: \"search\", label: \"Search\", color: \"text-[#2f45e8] dark:text-[#8b98ff]\" },\n  { id: \"social\", label: \"Social\", color: \"text-[#ff2d87] dark:text-[#ff5ca8]\" },\n  { id: \"video\", label: \"Video\", color: \"text-[#f59e0b] dark:text-[#fbbf24]\" },\n  { id: \"podcasts\", label: \"Podcasts\", color: \"text-[#7c3aed] dark:text-[#a78bfa]\" },\n];\n\n// Fieldnote's monthly ad budget: the same $48,000 split three ways.\nconst PLANS = [\n  { id: \"launch\", label: \"Launch\", note: \"Loud for six weeks: social and video carry the news.\", split: { search: 12000, social: 18000, video: 14000, podcasts: 4000 } },\n  { id: \"steady\", label: \"Steady\", note: \"Catch the people already looking: most of it goes to search.\", split: { search: 24000, social: 10000, video: 8000, podcasts: 6000 } },\n  { id: \"brand\", label: \"Brand\", note: \"Be remembered: long video and podcast reads.\", split: { search: 8000, social: 10000, video: 18000, podcasts: 12000 } },\n] as const;\n\nconst usd = new Intl.NumberFormat(\"en-US\", { style: \"currency\", currency: \"USD\", maximumFractionDigits: 0 });\nconst format = (value: number) => usd.format(value);\n\nexport function TallyBudgetDemo() {\n  const [planId, setPlanId] = React.useState<(typeof PLANS)[number][\"id\"]>(\"steady\");\n  const plan = PLANS.find((p) => p.id === planId) ?? PLANS[1];\n  const items = React.useMemo(\n    () =>\n      CHANNELS.map((c) => ({\n        id: c.id,\n        label: c.label,\n        value: plan.split[c.id as keyof typeof plan.split],\n        dotClassName: c.color,\n      })),\n    [plan],\n  );\n\n  const onKeyDown = (event: React.KeyboardEvent) => {\n    const step = event.key === \"ArrowRight\" || event.key === \"ArrowDown\" ? 1 : event.key === \"ArrowLeft\" || event.key === \"ArrowUp\" ? -1 : 0;\n    if (!step) return;\n    event.preventDefault();\n    const i = PLANS.findIndex((p) => p.id === planId);\n    const next = PLANS[(i + step + PLANS.length) % PLANS.length];\n    setPlanId(next.id);\n    document.getElementById(`tally-budget-${next.id}`)?.focus();\n  };\n\n  return (\n    <div className=\"w-full max-w-3xl overflow-hidden rounded-2xl border border-zinc-950/10 bg-white text-zinc-950 dark:border-white/10 dark:bg-zinc-950 dark:text-white\">\n      <div className=\"flex flex-col gap-4 px-5 pt-5 sm:flex-row sm:items-start sm:justify-between\">\n        <div>\n          <p className=\"font-mono text-[11px] tracking-wide text-zinc-500 uppercase dark:text-zinc-400\">Fieldnote · monthly ads</p>\n          <h3 className=\"mt-1 text-[17px] font-medium tracking-tight\">$48,000, three ways</h3>\n        </div>\n        <div\n          role=\"radiogroup\"\n          aria-label=\"Budget plan\"\n          onKeyDown={onKeyDown}\n          className=\"flex shrink-0 self-start rounded-full border border-zinc-950/10 p-1 dark:border-white/10\"\n        >\n          {PLANS.map((p) => (\n            <button\n              key={p.id}\n              id={`tally-budget-${p.id}`}\n              type=\"button\"\n              role=\"radio\"\n              aria-checked={p.id === planId}\n              tabIndex={p.id === planId ? 0 : -1}\n              onClick={() => setPlanId(p.id)}\n              className=\"rounded-full px-3.5 py-1.5 font-mono text-xs text-zinc-500 transition-colors hover:text-zinc-950 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#2f45e8] aria-checked:bg-zinc-950 aria-checked:text-white dark:text-zinc-400 dark:hover:text-white dark:focus-visible:outline-[#8b98ff] dark:aria-checked:bg-white dark:aria-checked:text-zinc-950\"\n            >\n              {p.label}\n            </button>\n          ))}\n        </div>\n      </div>\n\n      <Tally items={items} per={100} format={format} label=\"Monthly ad budget by channel\" className=\"mx-5 mt-4 h-[24rem] sm:h-72\" />\n\n      <p aria-live=\"polite\" className=\"mt-2 border-t border-zinc-950/10 px-5 py-4 font-mono text-xs leading-relaxed text-zinc-600 dark:border-white/10 dark:text-zinc-400\">\n        {plan.note}\n      </p>\n    </div>\n  );\n}\n"
    }
  ]
}