{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"stats-band","type":"registry:block","title":"Stats band","description":"Band of four big animated numbers with labels, trends and hairlines that draw in on view.","dependencies":["lucide-react","motion"],"registryDependencies":["utils"],"files":[{"path":"registry/items/stats-band/stats-band.tsx","type":"registry:block","target":"components/facade/stats-band.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { animate, motion, useInView, useReducedMotion } from \"motion/react\";\nimport { TrendingUp } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface StatsBandItem {\n  value: number;\n  prefix?: string;\n  suffix?: string;\n  decimals?: number;\n  label: string;\n  /** Short trend text, e.g. \"+18% vs 2024\". */\n  trend?: string;\n  /** Direction of the trend. \"down\" can still be positive (e.g. response time). */\n  trendDirection?: \"up\" | \"down\";\n  /** Whether the trend is good news. Defaults to true. */\n  trendPositive?: boolean;\n}\n\nexport interface StatsBandProps {\n  eyebrow?: string;\n  title?: string;\n  stats?: StatsBandItem[];\n  /** Renders the band on an inverted (primary) surface. */\n  inverted?: boolean;\n  className?: string;\n}\n\nconst EASE = [0.16, 1, 0.3, 1] as const;\n\nconst DEFAULT_STATS: StatsBandItem[] = [\n  { value: 12480, suffix: \"+\", label: \"Jobs completed in Central Texas\", trend: \"+18% vs last year\" },\n  { value: 4.9, decimals: 1, suffix: \"/5\", label: \"Average rating across 1,200 reviews\", trend: \"+0.2 this year\" },\n  { value: 47, suffix: \" min\", label: \"Average arrival time for same-day calls\", trend: \"-9 min faster\", trendDirection: \"down\" },\n  { value: 98, suffix: \"%\", label: \"Customers who would book us again\", trend: \"+3 pts\" },\n];\n\nfunction AnimatedNumber({ item, delay }: { item: StatsBandItem; delay: number }) {\n  const ref = React.useRef<HTMLSpanElement>(null);\n  const inView = useInView(ref, { once: true, margin: \"-80px 0px\" });\n  const reduce = useReducedMotion();\n  const decimals = item.decimals ?? 0;\n\n  const format = React.useCallback(\n    (n: number) =>\n      n.toLocaleString(\"en-US\", {\n        minimumFractionDigits: decimals,\n        maximumFractionDigits: decimals,\n      }),\n    [decimals],\n  );\n\n  React.useEffect(() => {\n    const node = ref.current;\n    if (!node || !inView) return;\n    if (reduce) {\n      node.textContent = format(item.value);\n      return;\n    }\n    const c = animate(0, item.value, {\n      duration: 2.2,\n      delay,\n      ease: EASE,\n      onUpdate: (v) => {\n        node.textContent = format(v);\n      },\n    });\n    return () => c.stop();\n  }, [inView, reduce, item.value, delay, format]);\n\n  return (\n    <span className=\"tabular-nums\">\n      {item.prefix}\n      <span ref={ref}>{format(0)}</span>\n      {item.suffix && <span className=\"text-[0.5em] font-medium text-muted-foreground\">{item.suffix}</span>}\n    </span>\n  );\n}\n\nexport function StatsBand({\n  eyebrow = \"By the numbers\",\n  title = \"Fifteen years of showing up on time.\",\n  stats = DEFAULT_STATS,\n  inverted = false,\n  className,\n}: StatsBandProps) {\n  const ref = React.useRef<HTMLDivElement>(null);\n  const inView = useInView(ref, { once: true, margin: \"-80px 0px\" });\n  const reduce = useReducedMotion();\n\n  return (\n    <section\n      className={cn(\n        \"relative overflow-hidden py-20 sm:py-28\",\n        inverted ? \"bg-primary text-primary-foreground\" : \"bg-background text-foreground\",\n        className,\n      )}\n    >\n      <div className=\"mx-auto max-w-[1120px] px-6\">\n        {(eyebrow || title) && (\n          <div className=\"mb-12 max-w-2xl sm:mb-16\">\n            {eyebrow && (\n              <p className={cn(\"text-[13px] font-medium uppercase tracking-[0.08em]\", inverted ? \"text-primary-foreground/60\" : \"text-muted-foreground\")}>\n                {eyebrow}\n              </p>\n            )}\n            {title && (\n              <h2 className=\"mt-3 font-display text-[34px] font-semibold leading-[1.05] tracking-[-0.035em] text-balance sm:text-[48px]\">\n                {title}\n              </h2>\n            )}\n          </div>\n        )}\n\n        <div ref={ref} className=\"relative\">\n          {/* Top rule drawing in */}\n          <motion.div\n            aria-hidden\n            className={cn(\"absolute inset-x-0 top-0 h-px origin-left\", inverted ? \"bg-primary-foreground/15\" : \"bg-foreground/[0.1]\")}\n            initial={{ scaleX: reduce ? 1 : 0 }}\n            animate={inView ? { scaleX: 1 } : undefined}\n            transition={{ duration: 1.2, ease: EASE }}\n          />\n          <ul className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4\">\n            {stats.map((s, i) => {\n              const positive = s.trendPositive ?? true;\n              return (\n                <li key={s.label} className=\"relative px-0 py-8 sm:px-8 lg:py-10 lg:first:pl-0 lg:last:pr-0\">\n                  {/* Vertical divider drawing in (desktop) */}\n                  {i > 0 && (\n                    <motion.span\n                      aria-hidden\n                      className={cn(\n                        \"absolute left-0 top-10 bottom-10 hidden w-px origin-top lg:block\",\n                        inverted ? \"bg-primary-foreground/15\" : \"bg-foreground/[0.1]\",\n                      )}\n                      initial={{ scaleY: reduce ? 1 : 0 }}\n                      animate={inView ? { scaleY: 1 } : undefined}\n                      transition={{ duration: 0.9, delay: 0.3 + i * 0.12, ease: EASE }}\n                    />\n                  )}\n                  {/* Horizontal divider on small screens */}\n                  {i > 0 && (\n                    <motion.span\n                      aria-hidden\n                      className={cn(\n                        \"absolute inset-x-0 top-0 h-px origin-left lg:hidden\",\n                        i === 1 && \"sm:hidden\",\n                        inverted ? \"bg-primary-foreground/15\" : \"bg-foreground/[0.1]\",\n                      )}\n                      initial={{ scaleX: reduce ? 1 : 0 }}\n                      animate={inView ? { scaleX: 1 } : undefined}\n                      transition={{ duration: 0.9, delay: 0.2 + i * 0.1, ease: EASE }}\n                    />\n                  )}\n                  <motion.div\n                    initial={{ opacity: 0, y: 14 }}\n                    animate={inView ? { opacity: 1, y: 0 } : undefined}\n                    transition={{ duration: 0.8, delay: 0.15 + i * 0.1, ease: EASE }}\n                    className=\"flex flex-col-reverse\"\n                  >\n                    <p\n                      className={cn(\n                        \"mt-3 min-h-[2.75rem] max-w-[15rem] text-[15px] leading-[1.45]\",\n                        inverted ? \"text-primary-foreground/70\" : \"text-muted-foreground\",\n                      )}\n                    >\n                      {s.label}\n                    </p>\n                    <p className=\"font-display text-[48px] font-semibold leading-none tracking-[-0.04em] sm:text-[56px]\">\n                      <AnimatedNumber item={s} delay={0.2 + i * 0.1} />\n                    </p>\n                  </motion.div>\n                  {s.trend && (\n                    <motion.p\n                      initial={{ opacity: 0 }}\n                      animate={inView ? { opacity: 1 } : undefined}\n                      transition={{ duration: 0.6, delay: 1.4 + i * 0.1 }}\n                      className={cn(\n                        \"mt-4 inline-flex items-center gap-1 text-[13px] font-medium\",\n                        positive ? \"text-success\" : \"text-destructive\",\n                      )}\n                    >\n                      <TrendingUp\n                        className={cn(\"size-3.5\", s.trendDirection === \"down\" && \"-scale-y-100\")}\n                        aria-hidden\n                      />\n                      {s.trend}\n                    </motion.p>\n                  )}\n                </li>\n              );\n            })}\n          </ul>\n          <motion.div\n            aria-hidden\n            className={cn(\"absolute inset-x-0 bottom-0 h-px origin-right\", inverted ? \"bg-primary-foreground/15\" : \"bg-foreground/[0.1]\")}\n            initial={{ scaleX: reduce ? 1 : 0 }}\n            animate={inView ? { scaleX: 1 } : undefined}\n            transition={{ duration: 1.2, delay: 0.2, ease: EASE }}\n          />\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default StatsBand;\n"}],"categories":["sections"],"meta":{"tier":"free","demo":"import { StatsBand } from \"./stats-band\";\n\nexport default function Demo() {\n  return <StatsBand />;\n}\n"}}