{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "contribution-graph",
  "title": "Contribution Graph",
  "author": "Ballmac <https://ui.ballmac.com>",
  "description": "A compact daily activity heatmap with token-based intensity and an accessible summary.",
  "registryDependencies": [
    "utils",
    "https://ui.ballmac.com/r/i18n.json"
  ],
  "files": [
    {
      "path": "registry/ballmac/components/contribution-graph.tsx",
      "content": "// Ballmac UI: Contribution Graph. https://ui.ballmac.com/components/contribution-graph\n\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\nimport { useLocale, useMessages } from \"@/lib/ballmac/i18n\"\n\ntype ContributionDay = {\n  /** ISO date (YYYY-MM-DD). */ date: string\n  /** Contribution count. */ count: number\n}\ntype ContributionGraphProps = React.ComponentProps<\"div\"> & {\n  /** Daily values in calendar order. */ data: ContributionDay[]\n  /** Accessible description of the measure. */ label: string\n  /** Number of color levels for nonzero values. */ levels?: 2 | 3 | 4\n}\nfunction ContributionGraph({\n  className,\n  data,\n  label,\n  levels = 4,\n  ...props\n}: ContributionGraphProps) {\n  const msg = useMessages()\n  const locale = useLocale()\n  const total = data.reduce((sum, day) => sum + Math.max(0, day.count), 0)\n  const max = Math.max(1, ...data.map((day) => day.count))\n  return (\n    <div\n      data-slot=\"contribution-graph\"\n      role=\"img\"\n      tabIndex={0}\n      aria-label={data.length ? msg(\"contribution-graph.summaryRange\", { one: \"{label}: {total} total across {count} day, {from} to {to}\", other: \"{label}: {total} total across {count} days, {from} to {to}\" }, { label, total, count: data.length, from: data[0].date, to: data.at(-1)?.date ?? \"\" }) : msg(\"contribution-graph.summary\", \"{label}: {total} total across 0 days\", { label, total })}\n      className={cn(\n        \"min-w-0 max-w-full overflow-x-auto rounded-xl border border-border bg-card p-4\",\n        className,\n      )}\n      {...props}\n    >\n      <div\n        aria-hidden=\"true\"\n        className=\"grid w-max grid-flow-col grid-rows-7 gap-1\"\n      >\n        {data.map((day) => {\n          const level =\n            day.count <= 0\n              ? 0\n              : Math.max(1, Math.ceil((day.count / max) * levels))\n          return (\n            <span\n              key={day.date}\n              data-slot=\"contribution-day\"\n              data-level={level}\n              title={`${day.date}: ${day.count}`}\n              className={cn(\n                \"size-3 rounded-[3px] border border-border/50\",\n                level === 0\n                  ? \"bg-muted\"\n                  : level === 1\n                    ? \"bg-primary/25\"\n                    : level === 2\n                      ? \"bg-primary/45\"\n                      : level === 3\n                        ? \"bg-primary/70\"\n                        : \"bg-primary\",\n              )}\n            />\n          )\n        })}\n      </div>\n      <div className=\"text-muted-foreground mt-3 flex items-center justify-between gap-3 text-xs\">\n        <span>{msg(\"contribution-graph.total\", { one: \"{total} contribution\", other: \"{total} contributions\" }, { count: total, total: total.toLocaleString(locale) })}</span>\n        <span className=\"whitespace-nowrap\">\n          {msg(\"contribution-graph.less\", \"Less\")}{\" \"}\n          <span\n            aria-hidden=\"true\"\n            className=\"bg-muted inline-block size-2 rounded-sm\"\n          />{\" \"}\n          ·{\" \"}\n          <span\n            aria-hidden=\"true\"\n            className=\"bg-primary inline-block size-2 rounded-sm\"\n          />{\" \"}\n          {msg(\"contribution-graph.more\", \"More\")}\n        </span>\n      </div>\n    </div>\n  )\n}\nexport { ContributionGraph, type ContributionGraphProps, type ContributionDay }\n",
      "type": "registry:ui",
      "target": "@components/ballmac/contribution-graph.tsx"
    }
  ],
  "meta": {
    "schema": 1,
    "tier": "free",
    "tags": [
      "heatmap",
      "activity",
      "calendar"
    ],
    "version": "1.0.0",
    "updated": "2026-09-30",
    "ai": {
      "summary": "A compact daily activity heatmap with token-based intensity and an accessible summary.",
      "whenToUse": [
        "Show a daily activity pattern over time"
      ],
      "whenNotToUse": [
        "Use a calendar when dates need interaction"
      ],
      "composesWith": [
        "activity-feed"
      ],
      "a11y": [
        {
          "keys": "Tab / Arrow keys",
          "action": "Focuses and scrolls the heatmap; total and date span are announced"
        }
      ],
      "customization": [
        "Content, layout, and token-based className styling"
      ]
    },
    "examples": [
      "contribution-graph-demo",
      "contribution-graph-states"
    ],
    "url": "https://ui.ballmac.com/components/contribution-graph"
  },
  "categories": [
    "data-display"
  ],
  "type": "registry:ui"
}