{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "gauge-03",
  "description": "CPU, memory and disk as small gauges, each in the colour of its band with warning and critical thresholds marked.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/gauge.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/gauge/gauge-03.tsx",
      "content": "'use client'\n\nimport {\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  SkeletonText,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  Gauge,\n  type GaugeBand,\n  GaugeLegend,\n  GaugeToneLabel,\n  GaugeValue,\n  getGaugeBand,\n} from '@/registry/components/dashboardblocks/gauge'\nimport { formatPercent } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Resource {\n  detail: string\n  label: string\n  /** Percent used, 0–100. */\n  value: number\n}\n\ninterface Gauge3Props extends BlockStateProps {\n  description: string\n  /** How many gauges to sketch while loading. @default 3 */\n  placeholders?: number\n  /** Leave out, or pass none, to show the empty state. */\n  resources?: Resource[]\n  /** Percent used at which each resource turns to warning, then critical. */\n  thresholds: { critical: number; warning: number }\n  title: string\n}\n\nconst exampleProps: Gauge3Props = {\n  description: 'prod-web-03 in us-east-1, over the last 5 minutes.',\n  resources: [\n    { detail: '8 cores, load 5.1', label: 'CPU', value: 64 },\n    { detail: '25.0 of 32 GB', label: 'Memory', value: 78 },\n    { detail: '465 of 500 GB', label: 'Disk', value: 93 },\n  ],\n  thresholds: { critical: 90, warning: 70 },\n  title: 'System load',\n}\n\nconst formatShare = (value: number) => formatPercent(value / 100)\n\nconst Gauge3 = (props: Gauge3Props) => {\n  const {\n    description,\n    placeholders = 3,\n    resources = [],\n    errorMessage,\n    status,\n    thresholds,\n    title,\n  } = props\n  const state = getBlockState(status, resources)\n  const bands: GaugeBand[] = [\n    { from: 0, label: 'Normal', to: thresholds.warning, tone: 'positive' },\n    {\n      from: thresholds.warning,\n      label: 'Warning',\n      to: thresholds.critical,\n      tone: 'caution',\n    },\n    { from: thresholds.critical, label: 'Critical', to: 100, tone: 'critical' },\n  ]\n  const busiest = resources.reduce<Resource | undefined>(\n    (top, resource) => (!top || resource.value > top.value ? resource : top),\n    undefined,\n  )\n  const worst = busiest ? getGaugeBand(busiest.value, bands) : undefined\n\n  return (\n    <Card>\n      <CardContent>\n        <BlockStateProvider errorMessage={errorMessage} state={state}>\n          <section className='@container flex flex-col gap-4'>\n            <header className='flex items-start justify-between gap-3'>\n              <div className='flex min-w-0 flex-col gap-0.5'>\n                <h2 className='font-semibold tracking-tight'>{title}</h2>\n                <p className='text-muted-foreground text-sm'>{description}</p>\n              </div>\n              {!state && busiest && worst && worst.tone !== 'positive' && (\n                <GaugeToneLabel\n                  className='mt-0.5'\n                  label={`${busiest.label} ${worst.label.toLowerCase()}`}\n                  tone={worst.tone}\n                />\n              )}\n            </header>\n            {state === 'loading' && (\n              <ul aria-hidden className='grid grid-cols-3 gap-3 border-t pt-5 @md:gap-6'>\n                {Array.from({ length: placeholders }, (_, index) => (\n                  <li\n                    key={index}\n                    className='flex min-w-0 flex-col items-center gap-1 text-center'\n                  >\n                    <Gauge\n                      className='mb-1 w-full max-w-32'\n                      label=''\n                      sweep={270}\n                      thickness={11}\n                      value={0}\n                    >\n                      <GaugeValue className='text-lg @sm:text-2xl'>0</GaugeValue>\n                    </Gauge>\n                    <span className='w-full text-sm'>\n                      <SkeletonText className='w-1/2' />\n                    </span>\n                    <span className='w-full text-xs'>\n                      <SkeletonText className='w-2/3' />\n                    </span>\n                  </li>\n                ))}\n              </ul>\n            )}\n            {(state === 'empty' || state === 'error') && (\n              <BlockStateRows className='border-t pt-4' />\n            )}\n            {!state && (\n              <ul className='grid grid-cols-3 gap-3 border-t pt-5 @md:gap-6'>\n                {resources.map((resource) => {\n                  const band = getGaugeBand(resource.value, bands)\n                  return (\n                    <li\n                      key={resource.label}\n                      className='flex min-w-0 flex-col items-center gap-1 text-center'\n                    >\n                      <Gauge\n                        bands={bands}\n                        className='mb-1 w-full max-w-32'\n                        colorByBand\n                        label={resource.label}\n                        sweep={270}\n                        thickness={11}\n                        value={resource.value}\n                        valueText={`${formatShare(resource.value)}${band ? `, ${band.label.toLowerCase()}` : ''}`}\n                      >\n                        <GaugeValue className='text-lg @sm:text-2xl'>\n                          {formatShare(resource.value)}\n                        </GaugeValue>\n                      </Gauge>\n                      <span className='text-sm font-medium'>{resource.label}</span>\n                      {band && (\n                        <GaugeToneLabel\n                          className='text-xs'\n                          label={band.label}\n                          tone={band.tone}\n                        />\n                      )}\n                      <span className='text-muted-foreground text-xs text-balance tabular-nums'>\n                        {resource.detail}\n                      </span>\n                    </li>\n                  )\n                })}\n              </ul>\n            )}\n            <GaugeLegend bands={bands} className='border-t pt-4' format={formatShare} />\n          </section>\n        </BlockStateProvider>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport { Gauge3, exampleProps as gauge3ExampleProps, type Gauge3Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/gauge/gauge-03.tsx"
    }
  ],
  "meta": {
    "shows": "CPU, memory and disk as small gauges, each in the colour of its band with warning and critical thresholds marked.",
    "size": "half",
    "usedWith": [
      "realtime-01",
      "status-02",
      "alerts-01"
    ],
    "component": "Gauge3",
    "props": "{ description: string; placeholders?: number; resources?: { detail: string; label: string; value: number }[]; thresholds: { critical: number; warning: number }; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
