{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"hero-stats","type":"registry:block","title":"Stats hero","description":"The promise and actions, then three numbers that count up, each with its trend.","dependencies":["lucide-react"],"registryDependencies":["https://dashral.com/r/utils.json","https://dashral.com/r/lib-motion.json","https://dashral.com/r/badge.json","https://dashral.com/r/button.json","https://dashral.com/r/sparkline.json"],"files":[{"path":"registry/dashral/blocks/hero-stats.tsx","type":"registry:file","target":"components/dashral/blocks/hero-stats.tsx","content":"\"use client\"\n\nimport { ArrowRight, ArrowUpRight } from \"lucide-react\"\nimport { Badge } from \"../badge\"\nimport { Button } from \"../button\"\nimport { Sparkline } from \"../sparkline\"\nimport { enterMotion, stagger, useCountTo } from \"../lib/motion\"\nimport { cn } from \"../lib/utils\"\n\n/** A button: a link with href, or your handler with onClick. */\nexport type BlockAction = { label: string; href?: string; onClick?: () => void }\nexport type HeroStat = { label: string; value: number; format?: Intl.NumberFormatOptions; suffix?: string; change?: string; trend?: number[] }\n\nconst sampleStats: HeroStat[] = [\n  { label: \"Events tracked every day\", value: 48_200_000, format: { notation: \"compact\", maximumFractionDigits: 1 }, change: \"+18%\", trend: [20, 24, 23, 29, 31, 30, 36, 41, 44, 49] },\n  { label: \"Teams on Acme\", value: 2400, format: { maximumFractionDigits: 0 }, suffix: \"+\", change: \"+320 this quarter\", trend: [8, 9, 11, 12, 14, 15, 17, 19, 21, 24] },\n  { label: \"Median query time\", value: 120, format: { maximumFractionDigits: 0 }, suffix: \" ms\", change: \"35% faster this year\", trend: [190, 184, 176, 170, 161, 150, 142, 133, 126, 120] },\n]\n\n/** A number that counts up from zero when the block first shows. */\nfunction CountingNumber({ value, format = { maximumFractionDigits: 0 }, suffix }: { value: number; format?: Intl.NumberFormatOptions; suffix?: string }) {\n  const shown = useCountTo(value, true)\n  return (\n    <>\n      <span aria-hidden>\n        {new Intl.NumberFormat(\"en-US\", format).format(shown)}\n        {suffix}\n      </span>\n      <span className=\"sr-only\">\n        {new Intl.NumberFormat(\"en-US\", format).format(value)}\n        {suffix}\n      </span>\n    </>\n  )\n}\n\n/**\n * A hero that leads with proof: the promise and actions on top, then three numbers that count up, each with its trend.\n * Every part comes from props; with reduced motion the numbers are simply there.\n */\nexport function HeroStats({\n  status = \"All systems normal\",\n  title = \"Numbers your whole company can trust\",\n  description = \"One source of truth from the first event to the board deck. Built for scale, priced for teams of five.\",\n  primary = { label: \"Get started\", href: \"#\" },\n  secondary = { label: \"See customer stories\", href: \"#\" },\n  stats = sampleStats,\n}: {\n  /** The badge above the headline; none hides it. */\n  status?: React.ReactNode\n  title?: React.ReactNode\n  description?: React.ReactNode\n  primary?: BlockAction\n  /** The second button; null hides it. */\n  secondary?: BlockAction | null\n  stats?: HeroStat[]\n}) {\n  return (\n    <section className=\"relative isolate overflow-hidden bg-background px-4 py-16 sm:px-6 sm:py-24\">\n      <div className=\"mx-auto max-w-6xl\">\n        <div className=\"flex flex-col gap-8 lg:flex-row lg:items-end lg:justify-between\">\n          <div className=\"max-w-2xl\">\n            {status && (\n              <Badge variant=\"soft\" color=\"success\" className={cn(enterMotion, \"mb-5 gap-1.5 rounded-[calc(var(--radius)*11/14)]\")} style={stagger(0, 80)}>\n                <span aria-hidden className=\"size-1.5 rounded-full bg-success\" /> {status}\n              </Badge>\n            )}\n            <h1 className={cn(enterMotion, \"text-4xl leading-[1.06] font-semibold tracking-[-0.04em] text-balance sm:text-6xl\")} style={stagger(1, 80)}>\n              {title}\n            </h1>\n            {description && (\n              <p className={cn(enterMotion, \"mt-5 max-w-xl text-base leading-relaxed text-muted-foreground sm:text-lg\")} style={stagger(2, 80)}>\n                {description}\n              </p>\n            )}\n          </div>\n          <div className={cn(enterMotion, \"flex flex-wrap gap-3\")} style={stagger(3, 80)}>\n            <Action action={primary}>\n              {primary.label} <ArrowRight aria-hidden />\n            </Action>\n            {secondary && (\n              <Action action={secondary} variant=\"outline\">\n                {secondary.label}\n              </Action>\n            )}\n          </div>\n        </div>\n\n        <dl className=\"mt-14 grid overflow-hidden rounded-2xl border bg-card sm:grid-cols-[repeat(var(--count),minmax(0,1fr))]\" style={{ \"--count\": stats.length } as React.CSSProperties}>\n          {stats.map((stat, i) => (\n            <div key={stat.label} className={cn(enterMotion, \"flex flex-col gap-4 p-6 not-first:border-t sm:p-8 sm:not-first:border-t-0 sm:not-first:border-s\")} style={stagger(4 + i, 80)}>\n              <dt className=\"text-sm text-muted-foreground\">{stat.label}</dt>\n              <dd className=\"order-first text-4xl font-semibold tracking-[-0.03em] tabular-nums sm:text-5xl\">\n                <CountingNumber value={stat.value} format={stat.format} suffix={stat.suffix} />\n              </dd>\n              {(stat.change || stat.trend) && (\n                <dd className=\"flex items-end justify-between gap-4\">\n                  {stat.change && (\n                    <span className=\"inline-flex items-center gap-1 text-xs font-medium text-success-text\">\n                      <ArrowUpRight className=\"size-3.5\" aria-hidden /> {stat.change}\n                    </span>\n                  )}\n                  {stat.trend && <Sparkline data={stat.trend} variant=\"area\" className=\"ms-auto h-10 w-28 text-primary\" aria-label={`${stat.label}: trend`} />}\n                </dd>\n              )}\n            </div>\n          ))}\n        </dl>\n      </div>\n    </section>\n  )\n}\n\n/** A large button that follows its action: a link, or a handler. */\nfunction Action({ action, variant, className, children }: { action: BlockAction; variant?: \"outline\"; className?: string; children: React.ReactNode }) {\n  return action.href ? (\n    <Button size=\"lg\" variant={variant} className={className} asChild>\n      <a href={action.href}>{children}</a>\n    </Button>\n  ) : (\n    <Button size=\"lg\" variant={variant} className={className} onClick={action.onClick}>\n      {children}\n    </Button>\n  )\n}\n"}],"cssVars":{"theme":{"color-success":"var(--success)","color-success-foreground":"var(--success-foreground)","color-success-text":"var(--success-text)"},"light":{"success":"oklch(0.508 0.118 165.612)","success-foreground":"oklch(0.985 0 0)","success-text":"oklch(0.432 0.095 166.913)"},"dark":{"success":"oklch(0.696 0.17 162.48)","success-foreground":"oklch(0.2 0.04 160)","success-text":"oklch(0.765 0.177 163.223)"}}}