{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stats-02",
  "title": "Results section",
  "description": "A dark section with a mission line, three results that count up once with what each is compared to, and a card set at an angle whose ring closes as its score rolls.",
  "dependencies": [],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/replay-button.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-autoplay.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json",
    "https://ui.ndekocode.dev/r/wash.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/stats/stats-02/index.tsx",
      "content": "'use client';\n\nimport { useState } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { useAutoplay } from '@/registry/ndeko/hooks/use-autoplay';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { TrendingUpIcon } from '@/registry/ndeko/lib/icons';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\n\nimport { RESULTS, SECTION, type Result } from './data';\nimport { ScoreCard } from './score-card';\n\nconst ARRIVES_AFTER_MS = 500;\n\nfunction formatOf(fractionDigits: number): Intl.NumberFormatOptions {\n  return {\n    minimumFractionDigits: fractionDigits,\n    maximumFractionDigits: fractionDigits,\n  };\n}\n\nfunction shownOf(isRolled: boolean, value: number) {\n  if (isRolled) {\n    return value;\n  }\n  return 0;\n}\n\ntype ResultItemProps = {\n  result: Result;\n  isRolled: boolean;\n};\n\nfunction ResultItem({ result, isRolled }: ResultItemProps) {\n  return (\n    <li className='bg-foreground/[0.05] flex min-w-0 flex-col gap-3 rounded-xl p-5'>\n      <p className='flex'>\n        <MotionNumber\n          value={shownOf(isRolled, result.value)}\n          format={formatOf(result.fractionDigits)}\n          suffix={result.suffix}\n          className='text-4xl font-semibold @2xl:text-5xl'\n        />\n      </p>\n      <div className='flex flex-col gap-1'>\n        <p className='text-[13px] font-medium'>{result.label}</p>\n        <p className='text-muted-foreground text-xs text-pretty'>\n          {result.compare}\n        </p>\n      </div>\n    </li>\n  );\n}\n\nexport default function Stats02() {\n  const [hasArrived, setHasArrived] = useState(false);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const steps = [{ after: ARRIVES_AFTER_MS, run: () => setHasArrived(true) }];\n  const { ref, isAutoplaying, restart } = useAutoplay<HTMLElement>(steps, {\n    onReset: () => setHasArrived(false),\n  });\n  const isTakenOver = !isAutoplaying;\n  const isRolled = hasArrived || isTakenOver;\n  const canReplay = isRolled && !shouldReduceMotion;\n\n  return (\n    <section\n      ref={ref}\n      className='dark bg-sidebar text-foreground @container w-full'\n    >\n      <div className='mx-auto flex max-w-6xl flex-col gap-12 px-4 py-16 @2xl:px-6 @2xl:py-24 @5xl:px-8'>\n        <header className='flex flex-wrap items-center justify-between gap-x-4 gap-y-2'>\n          <p className='text-primary-ink flex items-center gap-1.5 text-[13px] font-medium'>\n            <TrendingUpIcon className='size-4' />\n            {SECTION.label}\n          </p>\n          <div className='flex items-center gap-2'>\n            <ReplayButton\n              isShown={canReplay}\n              onReplay={restart}\n              label='Replay'\n            />\n            <Badge variant='secondary'>Illustrative</Badge>\n          </div>\n        </header>\n        <div className='grid items-center gap-12 @4xl:grid-cols-[minmax(0,1fr)_18rem]'>\n          <div className='flex flex-col gap-10'>\n            <h2 className='max-w-3xl text-3xl font-semibold text-balance @2xl:text-5xl'>\n              {SECTION.mission}\n            </h2>\n            <ul className='grid gap-3 @2xl:grid-cols-3'>\n              {RESULTS.map((result) => (\n                <ResultItem\n                  key={result.id}\n                  result={result}\n                  isRolled={isRolled}\n                />\n              ))}\n            </ul>\n            <p className='text-muted-foreground text-xs'>{SECTION.note}</p>\n          </div>\n          <ScoreCard isRolled={isRolled} />\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/stats-02/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/stats/stats-02/score-card.tsx",
      "content": "'use client';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { Wash } from '@/registry/ndeko/ui/wash';\n\nimport { SCORE } from './data';\nimport { ScoreRing } from './score-ring';\n\nconst MAX_SCORE = 100;\n\ntype ScoreCardProps = {\n  /** The score reads zero until the section has arrived, then rolls to its value as the ring closes. */\n  isRolled: boolean;\n};\n\nfunction shownOf(isRolled: boolean) {\n  if (isRolled) {\n    return SCORE.value;\n  }\n  return 0;\n}\n\nexport function ScoreCard({ isRolled }: ScoreCardProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const score = shownOf(isRolled);\n\n  return (\n    <article\n      aria-label={`${SCORE.title}: ${SCORE.value} out of ${MAX_SCORE}`}\n      className='surface-brand relative isolate mx-auto flex w-full max-w-72 -rotate-3 flex-col gap-5 rounded-2xl p-5 @4xl:mx-0'\n    >\n      <Wash shape='top' />\n      <header className='flex items-baseline justify-between gap-3'>\n        <h3 className='text-sm font-medium'>{SCORE.title}</h3>\n        <p className='text-muted-foreground text-xs'>{SCORE.period}</p>\n      </header>\n      <div className='flex items-center gap-4'>\n        <ScoreRing\n          score={score}\n          max={MAX_SCORE}\n          shouldReduceMotion={shouldReduceMotion}\n        >\n          <span className='flex flex-col items-center leading-none'>\n            <MotionNumber value={score} className='text-4xl font-semibold' />\n            <span className='text-muted-foreground mt-1 text-[11px]'>\n              out of {MAX_SCORE}\n            </span>\n          </span>\n        </ScoreRing>\n        <p className='text-muted-foreground text-xs text-pretty'>\n          {SCORE.caption}\n        </p>\n      </div>\n    </article>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/stats-02/score-card.tsx"
    },
    {
      "path": "registry/ndeko/blocks/stats/stats-02/score-ring.tsx",
      "content": "import { cn } from '@/registry/ndeko/lib/utils';\n\nconst VIEW = 120;\n\nconst CENTRE = VIEW / 2;\n\nconst RADIUS = 52;\n\nconst STROKE_WIDTH = 8;\n\nconst CIRCUMFERENCE = 2 * Math.PI * RADIUS;\n\nfunction openLengthOf(score: number, max: number) {\n  const ratio = score / max;\n  const atLeastNone = Math.max(0, ratio);\n  const share = Math.min(1, atLeastNone);\n  const open = 1 - share;\n  return CIRCUMFERENCE * open;\n}\n\nfunction easedOf(shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return 'transition-none';\n  }\n  return 'transition-[stroke-dashoffset] duration-[1100ms] ease-(--ease-out-strong)';\n}\n\ntype ScoreRingProps = {\n  score: number;\n  max: number;\n  shouldReduceMotion: boolean;\n  className?: string;\n  children?: React.ReactNode;\n};\n\n/** The stroke is the only thing that moves: it closes to its length once, as the score in the middle rolls. */\nexport function ScoreRing({\n  score,\n  max,\n  shouldReduceMotion,\n  className,\n  children,\n}: ScoreRingProps) {\n  return (\n    <span\n      className={cn(\n        'relative inline-flex size-32 shrink-0 items-center justify-center',\n        className\n      )}\n    >\n      <svg\n        aria-hidden='true'\n        viewBox={`0 0 ${VIEW} ${VIEW}`}\n        className='absolute inset-0 size-full -rotate-90'\n      >\n        <circle\n          cx={CENTRE}\n          cy={CENTRE}\n          r={RADIUS}\n          fill='none'\n          strokeWidth={STROKE_WIDTH}\n          className='stroke-foreground/10'\n        />\n        <circle\n          cx={CENTRE}\n          cy={CENTRE}\n          r={RADIUS}\n          fill='none'\n          strokeWidth={STROKE_WIDTH}\n          strokeLinecap='round'\n          strokeDasharray={CIRCUMFERENCE}\n          strokeDashoffset={openLengthOf(score, max)}\n          className={cn('stroke-primary', easedOf(shouldReduceMotion))}\n        />\n      </svg>\n      {children}\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/stats-02/score-ring.tsx"
    },
    {
      "path": "registry/ndeko/blocks/stats/stats-02/data.ts",
      "content": "export const SECTION = {\n  label: 'Results',\n  mission:\n    'We write the first draft of every reply, so people spend their week on the judgment calls.',\n  note: 'Every figure here is illustrative',\n};\n\nexport type ResultId = 'handoff' | 'reply' | 'hours';\n\nexport type Result = {\n  id: ResultId;\n  value: number;\n  fractionDigits: number;\n  suffix: string;\n  label: string;\n  /** What the figure is measured against. A result without it would be a number floating in space. */\n  compare: string;\n};\n\nexport const RESULTS: Result[] = [\n  {\n    id: 'handoff',\n    value: 62,\n    fractionDigits: 0,\n    suffix: '%',\n    label: 'Fewer tickets handed over',\n    compare: 'Compared with the quarter before the agents',\n  },\n  {\n    id: 'reply',\n    value: 3.4,\n    fractionDigits: 1,\n    suffix: '×',\n    label: 'Faster first reply',\n    compare: 'Compared with a queue answered only by people',\n  },\n  {\n    id: 'hours',\n    value: 38,\n    fractionDigits: 0,\n    suffix: ' h',\n    label: 'Saved every week',\n    compare: 'Compared with the hours spent drafting by hand',\n  },\n];\n\nexport const SCORE = {\n  value: 87,\n  title: 'Draft quality',\n  period: 'Last 30 days',\n  caption: 'Drafts sent as written, weighted by how much was edited',\n};\n",
      "type": "registry:component",
      "target": "components/blocks/stats-02/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "stats"
  ],
  "type": "registry:block"
}