{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "storage-meter",
  "type": "registry:block",
  "title": "Storage meter",
  "description": "See what is using your space, and how much is left.",
  "categories": [
    "blocks"
  ],
  "dependencies": [],
  "registryDependencies": [
    "card"
  ],
  "files": [
    {
      "path": "src/registry/overtrue/storage-meter.tsx",
      "type": "registry:component",
      "target": "components/overtrue/storage-meter.tsx",
      "content": "import { ChartLegend } from \"./chart-legend\";\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\";\nexport interface StorageSegment {\n  label: string;\n  value: number;\n  color: string;\n}\nexport function StorageMeter({\n  segments,\n  capacity,\n  unit = \"GB\",\n}: {\n  segments: StorageSegment[];\n  capacity: number;\n  unit?: string;\n}) {\n  const safeCapacity = Number.isFinite(capacity) ? Math.max(0, capacity) : 0;\n  const safeSegments = segments.map((segment) => ({\n    ...segment,\n    value: Number.isFinite(segment.value) ? Math.max(0, segment.value) : 0,\n  }));\n  const used = safeSegments.reduce((sum, segment) => sum + segment.value, 0);\n  const denominator = Math.max(safeCapacity, used, 1);\n  return (\n    <Card\n      data-slot=\"storage-meter\"\n      className=\"gap-0 rounded-lg border bg-card py-0 shadow-none\"\n    >\n      <CardHeader className=\"px-5 pt-5 pb-0\">\n        <CardTitle className=\"text-sm font-semibold\">\n          Storage overview\n        </CardTitle>\n      </CardHeader>\n      <CardContent className=\"p-5\">\n        <p className=\"mb-4 text-sm text-muted-foreground\">\n          <strong className=\"font-semibold text-card-foreground\">\n            {used.toLocaleString()} {unit}\n          </strong>{\" \"}\n          of {safeCapacity.toLocaleString()} {unit} used\n        </p>\n        <div\n          role=\"img\"\n          aria-label={`${used} of ${safeCapacity} ${unit} used`}\n          className=\"flex h-2.5 gap-0.5 overflow-hidden rounded-full bg-muted\"\n        >\n          {safeSegments.map((segment) => (\n            <span\n              key={segment.label}\n              style={{\n                width: `${(segment.value / denominator) * 100}%`,\n                backgroundColor: segment.color,\n              }}\n            />\n          ))}\n        </div>\n        <ChartLegend\n          className=\"mt-5\"\n          label=\"Storage categories\"\n          items={safeSegments.map((segment) => ({\n            label: segment.label,\n            color: segment.color,\n            value: `${segment.value} ${unit}`,\n          }))}\n        />\n      </CardContent>\n    </Card>\n  );\n}\n"
    },
    {
      "path": "src/registry/overtrue/chart-legend.tsx",
      "type": "registry:component",
      "target": "components/overtrue/chart-legend.tsx",
      "content": "import type { ReactNode } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface ChartLegendItem {\n  label: string;\n  color: string;\n  value?: ReactNode;\n  dashed?: boolean;\n}\nexport function ChartLegend({\n  items,\n  label = \"Chart legend\",\n  layout = \"vertical\",\n  className,\n}: {\n  items: readonly ChartLegendItem[];\n  label?: string;\n  layout?: \"horizontal\" | \"vertical\";\n  className?: string;\n}) {\n  return (\n    <ul\n      data-slot=\"chart-legend\"\n      data-layout={layout}\n      aria-label={label}\n      className={cn(\n        \"m-0 list-none p-0 text-xs\",\n        layout === \"horizontal\"\n          ? \"flex flex-wrap items-center gap-x-4 gap-y-2\"\n          : \"grid gap-3\",\n        className,\n      )}\n    >\n      {items.map((item) => (\n        <li\n          key={item.label}\n          data-slot=\"chart-legend-item\"\n          className=\"flex min-w-0 items-center gap-2\"\n        >\n          {item.dashed ? (\n            <svg\n              aria-hidden=\"true\"\n              data-slot=\"chart-legend-swatch\"\n              viewBox=\"0 0 14 2\"\n              className=\"h-0.5 w-3.5 shrink-0 overflow-visible\"\n            >\n              <line\n                x1=\"1\"\n                y1=\"1\"\n                x2=\"13\"\n                y2=\"1\"\n                stroke={item.color}\n                strokeWidth=\"2\"\n                strokeLinecap=\"round\"\n                strokeDasharray=\"2 4\"\n              />\n            </svg>\n          ) : (\n            <span\n              aria-hidden=\"true\"\n              data-slot=\"chart-legend-swatch\"\n              className=\"size-2 shrink-0 rounded-full\"\n              style={{\n                backgroundColor: item.color,\n                boxShadow: `0 0 0 2px color-mix(in oklab, ${item.color} 16%, transparent)`,\n              }}\n            />\n          )}\n          <span className=\"min-w-0 break-words text-muted-foreground\">\n            {item.label}\n          </span>\n          {item.value != null && (\n            <span className=\"ms-auto ps-3 font-medium text-foreground tabular-nums\">\n              {item.value}\n            </span>\n          )}\n        </li>\n      ))}\n    </ul>\n  );\n}\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/blocks/storage-meter. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
