{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "meter-group-storage-breakdown",
  "title": "Meter Group Storage Breakdown",
  "description": "A storage or quota card that splits usage into categories, turns to a warning near the limit and offers the upgrade action only when it matters.",
  "registryDependencies": [
    "@tealmac/meter-group"
  ],
  "files": [
    {
      "path": "registry/patterns/meter-group-storage-breakdown/meter-group-storage-breakdown.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { MeterGroup, type MeterGroupItem } from \"@/components/ui/meter-group\"\n\nexport interface MeterGroupStorageBreakdownProps {\n  title?: string\n  /** Total capacity in GB. */\n  capacity: number\n  items: MeterGroupItem[]\n  /** Shown when usage reaches `warnAt`. */\n  upgrade?: React.ReactNode\n  /** Fraction of capacity that triggers the warning. Default 0.9. */\n  warnAt?: number\n}\n\n/**\n * Usage is shown by category against the capacity. Below the threshold the\n * card is calm; at or above it, the headline changes to a warning sentence\n * (\"Almost full: 94% used\"), the percentage is announced politely, and the\n * upgrade action appears. Used and free space are written as text.\n */\nexport function MeterGroupStorageBreakdown({\n  title = \"Storage\",\n  capacity,\n  items,\n  upgrade,\n  warnAt = 0.9,\n}: MeterGroupStorageBreakdownProps) {\n  const used = items.reduce((a, i) => a + i.value, 0)\n  const ratio = capacity > 0 ? used / capacity : 0\n  const warn = ratio >= warnAt\n  const pct = Math.round(ratio * 100)\n\n  return (\n    <section\n      aria-label={title}\n      className=\"bg-card w-full max-w-md space-y-3 rounded-xl border p-5\"\n    >\n      <div className=\"flex items-baseline justify-between gap-3\">\n        <h3 className=\"text-base font-semibold\">{title}</h3>\n        <span className=\"text-muted-foreground text-sm tabular-nums\">\n          {used} GB of {capacity} GB\n        </span>\n      </div>\n      <MeterGroup\n        label={`${title} used`}\n        unit=\" GB\"\n        max={capacity}\n        items={items}\n      />\n      <p\n        role=\"status\"\n        className={\n          warn\n            ? \"text-sm font-medium text-amber-800 dark:text-amber-300\"\n            : \"text-muted-foreground text-sm\"\n        }\n      >\n        {warn\n          ? `Almost full: ${pct}% used`\n          : `${Math.max(0, capacity - used)} GB free`}\n      </p>\n      {warn && upgrade ? <div>{upgrade}</div> : null}\n    </section>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}