{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sparkline",
  "title": "Sparkline",
  "description": "A trend with no axes, for a table cell or a stat card.",
  "registryDependencies": [
    "https://creance.pages.dev/r/creance-base.json"
  ],
  "files": [
    {
      "path": "sparkline/Sparkline.css",
      "content": ".cr-sparkline {\n  display: block;\n  flex: none;\n  overflow: visible;\n  color: var(--cr-color-text-default);\n}\n\n.cr-sparkline__line {\n  fill: none;\n  stroke: currentColor;\n  stroke-width: 1.8;\n  stroke-linecap: round;\n  stroke-linejoin: round;\n}\n\n.cr-sparkline__area {\n  fill: currentColor;\n  opacity: 0.1;\n}\n\n.cr-sparkline__dot {\n  fill: currentColor;\n}\n\n.cr-sparkline__bar {\n  fill: currentColor;\n  opacity: 0.3;\n}\n\n.cr-sparkline__bar[data-last] {\n  opacity: 1;\n}\n",
      "type": "registry:file",
      "target": "@components/creance/sparkline/Sparkline.css"
    },
    {
      "path": "sparkline/Sparkline.tsx",
      "content": "import { cx } from '@/lib/creance/cx';\nimport './Sparkline.css';\n\nexport interface SparklineProps {\n  values: number[];\n  /** What the trend is, for screen readers: \"Tokens per day, last 14 days\". */\n  label: string;\n  /** `area` is a line with a soft fill. Default `line`. */\n  variant?: 'line' | 'area' | 'bars';\n  width?: number;\n  height?: number;\n  className?: string;\n}\n\n/** A trend with no axes, for a table cell or a stat card. The last point is marked. */\nexport function Sparkline({ values, label, variant = 'line', width = 120, height = 36, className }: SparklineProps) {\n  const pad = 3;\n  const lo = variant === 'bars' ? 0 : Math.min(...values);\n  const span = Math.max(...values) - lo || 1;\n  const y = (v: number) => height - pad - ((v - lo) / span) * (height - 2 * pad);\n  const common = { className: cx('cr-sparkline', className), width, height, viewBox: `0 0 ${width} ${height}`, role: 'img', 'aria-label': label, 'data-variant': variant };\n\n  if (variant === 'bars') {\n    const slot = width / values.length;\n    return (\n      <svg {...common}>\n        {values.map((v, i) => {\n          const h = Math.max(2, height - y(v) - pad);\n          return <rect key={i} className=\"cr-sparkline__bar\" data-last={i === values.length - 1 || undefined} x={i * slot + 1.5} y={height - h} width={Math.max(1, slot - 3)} height={h} rx=\"2\" />;\n        })}\n      </svg>\n    );\n  }\n\n  const step = values.length > 1 ? (width - 2 * pad) / (values.length - 1) : 0;\n  const points = values.map((v, i) => [pad + i * step, y(v)] as const);\n  const line = points.map(([px, py], i) => `${i ? 'L' : 'M'}${px.toFixed(1)} ${py.toFixed(1)}`).join(' ');\n  const last = points[points.length - 1];\n  return (\n    <svg {...common}>\n      {variant === 'area' && last && <path className=\"cr-sparkline__area\" d={`${line} L${last[0].toFixed(1)} ${height} L${pad} ${height} Z`} />}\n      <path className=\"cr-sparkline__line\" d={line} />\n      {last && <circle className=\"cr-sparkline__dot\" cx={last[0]} cy={last[1]} r=\"2.6\" />}\n    </svg>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/creance/sparkline/Sparkline.tsx"
    }
  ],
  "categories": [
    "atom",
    "charts"
  ],
  "type": "registry:ui"
}