{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-metric",
  "type": "registry:ui",
  "title": "Chart Metric",
  "description": "Chart Metric is a labeled value with an optional directional delta, for use above a chart or standalone — the delta's direction drives only its icon, never a color.",
  "author": "Skrewww",
  "dependencies": [
    "@phosphor-icons/react"
  ],
  "registryDependencies": [
    "@skrewww/foundation"
  ],
  "docs": "Host requirements (assumed already present, not installed by this command): react, react-dom.",
  "files": [
    {
      "path": "components/ui/ChartMetric.tsx",
      "content": "/** @skrewww-component chart-metric */\nimport { ArrowDown, ArrowUp, Minus } from \"@phosphor-icons/react/dist/ssr\";\nimport { cn } from \"@/lib/cn\";\nimport styles from \"@/components/ui/chart-metric.module.css\";\n\nexport type ChartMetricDeltaDirection = \"up\" | \"down\" | \"flat\";\n\nexport type ChartMetricDelta = {\n  /** Which way the value moved — drives only the icon, never a color. */\n  direction: ChartMetricDeltaDirection;\n  /** Pre-formatted delta text (e.g. \"+4.2%\") — formatting is the consumer's responsibility. */\n  value: string;\n  /** Optional comparison context, e.g. \"vs last 30 days\". */\n  label?: string;\n};\n\nexport type ChartMetricProps = {\n  label: string;\n  /** Pre-formatted value (e.g. \"$4,231.09\") — formatting is the consumer's responsibility. */\n  value: string;\n  delta?: ChartMetricDelta;\n  className?: string;\n};\n\nconst DIRECTION_ICON: Record<ChartMetricDeltaDirection, typeof ArrowUp> = {\n  up: ArrowUp,\n  down: ArrowDown,\n  flat: Minus,\n};\n\nconst DIRECTION_WORD: Record<ChartMetricDeltaDirection, string> = {\n  up: \"Increased\",\n  down: \"Decreased\",\n  flat: \"Unchanged\",\n};\n\n/**\n * A labeled value with an optional directional delta, for use above a chart\n * (in `ChartCard` or standalone). Extracted from three independent, ad hoc\n * reimplementations of the same value typography that existed before CH-3:\n * `BankingAccountCard`'s `.balance`, `BankingBalanceSummary`'s `.totalValue`\n * (byte-identical CSS to `.balance`), and the Reference App overview page's\n * raw Tailwind `text-3xl font-semibold tabular-nums`.\n *\n * `delta.direction` is a real design decision, not a placeholder: it drives\n * only the icon (an arrow or a dash), never a color. There is no green-is-\n * good/red-is-bad rule here — an \"increase\" is not always a good outcome\n * (spend, churn, error rate), so this component makes no sentiment claim.\n * The direction is also announced in words (\"Increased\"/\"Decreased\"/\n * \"Unchanged\") via visually-hidden text, so it is never conveyed by the icon\n * or color alone.\n */\nexport function ChartMetric({ label, value, delta, className }: ChartMetricProps) {\n  const DeltaIcon = delta ? DIRECTION_ICON[delta.direction] : null;\n\n  return (\n    <div className={cn(styles.root, className)}>\n      <p className={styles.label}>{label}</p>\n      <p className={styles.value}>\n        {value}\n        {delta && DeltaIcon ? (\n          <span className={styles.delta}>\n            <DeltaIcon aria-hidden=\"true\" className={styles.deltaIcon} />\n            <span className=\"sr-only\">{DIRECTION_WORD[delta.direction]} </span>\n            {delta.value}\n            {delta.label ? <span className={styles.deltaLabel}> {delta.label}</span> : null}\n          </span>\n        ) : null}\n      </p>\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/ChartMetric.tsx"
    },
    {
      "path": "components/ui/chart-metric.module.css",
      "content": ".root {\n  display: block;\n}\n\n.label {\n  margin: 0;\n  font-size: 0.8125rem;\n  color: var(--semantic-text-secondary);\n}\n\n.value {\n  display: flex;\n  flex-wrap: wrap;\n  align-items: baseline;\n  column-gap: 0.5rem;\n  margin: 0.125rem 0 0;\n  font-size: 1.5rem;\n  font-weight: 700;\n  line-height: 1.2;\n  font-variant-numeric: tabular-nums;\n  color: var(--semantic-text-primary);\n}\n\n/*\n * Neutral by design: this is the same --semantic-text-secondary used for\n * .label, never --semantic-feedback-success / --semantic-feedback-error.\n * See ChartMetric.tsx for why direction never implies sentiment.\n */\n.delta {\n  display: inline-flex;\n  align-items: center;\n  gap: 0.25rem;\n  font-size: 0.8125rem;\n  font-weight: 500;\n  font-variant-numeric: tabular-nums;\n  color: var(--semantic-text-secondary);\n}\n\n.deltaIcon {\n  width: 1em;\n  height: 1em;\n  flex: none;\n}\n\n.deltaLabel {\n  font-weight: 400;\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/chart-metric.module.css"
    },
    {
      "path": "lib/cn.ts",
      "content": "export function cn(...classes: Array<string | false | null | undefined>): string {\n  return classes.filter(Boolean).join(\" \");\n}\n",
      "type": "registry:lib",
      "target": "~/lib/cn.ts"
    }
  ]
}
