{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "round-summary",
  "type": "registry:ui",
  "title": "Round Summary",
  "description": "The moment a round ends: what the player earned, where today's goal stands, the streak it kept, and anything new they reached (a milestone, a level). Then the next step, which the app passes as children: share, play on, come back tomorrow. It celebrates…",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "games",
    "game"
  ],
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "https://ds.interlace.tools/r/interlace-base.json",
    "https://ds.interlace.tools/r/celebrate.json",
    "https://ds.interlace.tools/r/cn.json",
    "https://ds.interlace.tools/r/count-up.json",
    "https://ds.interlace.tools/r/goal-ring.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/games/round-summary.tsx",
      "target": "components/ui/games/round-summary.tsx",
      "type": "registry:ui",
      "content": "'use client';\n\nimport * as React from 'react';\n\n// @interlace/round-summary v1.0.1 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/round-summary\n// What changed since: https://ds.interlace.tools/c/round-summary#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui — RoundSummary\n *\n * The moment a round ends: what the player earned, where today's goal\n * stands, the streak it kept, and anything new they reached (a milestone,\n * a level). Then the next step, which the app passes as children: share,\n * play on, come back tomorrow. It celebrates once, quietly, and gets out of\n * the way.\n *\n * ## Anatomy\n *\n *   RoundSummary                   (section — data-slot=\"round-summary\", labelled by its heading)\n *     ├─ h2…h4                     (data-slot=\"round-summary-title\", focusable with focusOnMount)\n *     ├─ p                         (data-slot=\"round-summary-description\")\n *     ├─ dl                        (data-slot=\"round-summary-stats\", a container-query grid)\n *     │   ├─ div                   (data-slot=\"round-summary-stat\", data-stat=\"xp\": +XP counted up)\n *     │   ├─ div                   (data-stat=\"goal\": a small GoalRing and what is left)\n *     │   └─ div                   (data-stat=\"streak\": the count, burst when it grew)\n *     ├─ div role=\"status\"         (data-slot=\"round-summary-highlight\": a check and the news)\n *     └─ div                       (data-slot=\"round-summary-actions\": children)\n *\n * Every stat is optional; leave one out and the grid closes up.\n *\n * ## When it celebrates\n *\n * The XP counts up, the streak and the highlight play a short burst, once,\n * after mount, and only with `celebrate` (default true). Pass\n * `celebrate={false}` when showing a round finished earlier, so a reload\n * does not replay it. Under reduced motion the numbers land at once and no\n * burst plays; the words are the same.\n *\n * ## MIN_VIEWPORT — 320\n *\n * Stats stack below a 28rem container and sit in a row above it.\n *\n * | Rule | Concept                   | Where in this file                                     |\n * | ---- | ------------------------- | ------------------------------------------------------ |\n * | R4   | Extends native el         | `React.ComponentProps<'section'>`                      |\n * | R6   | data-slot per part        | round-summary / -title / -description / -stats / -stat / -highlight / -actions |\n * | R7   | cn + ...rest              | `cn(…, className)` + `{...props}`                      |\n * | R14  | Declares min viewport     | `data-min-viewport` + exported const                   |\n * | R19  | Tokens only               | card, border, primary, muted-foreground                |\n * | R25  | Client component          | the count and the burst run in the browser             |\n * | R26  | A11y                      | a labelled section; stats as a description list; the news as a status |\n */\n\nimport { Flame } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\nimport { Celebrate, CelebrateCheck } from '@/components/ui/effects/celebrate';\nimport { CountUp } from '@/components/ui/effects/count-up';\nimport { GoalRing } from '@/components/ui/games/goal-ring';\n\nexport const MIN_VIEWPORT = 320 as const;\n\ninterface RoundSummaryLabels {\n  /** @default 'XP earned' */\n  xp?: string;\n  /** @default 'Daily goal' */\n  goal?: string;\n  /** @default 'Goal met' */\n  goalMet?: string;\n  /** @default n => `${n} XP to go` */\n  goalLeft?: (xp: string) => string;\n  /** @default 'Day streak' */\n  streak?: string;\n  /** Said after the streak count when it grew today. @default 'Kept today' */\n  streakKept?: string;\n}\n\ntype RoundSummaryProps = Omit<React.ComponentProps<'section'>, 'title'> & {\n  title: React.ReactNode;\n  /** The heading's level. @default 2 */\n  headingLevel?: 2 | 3 | 4;\n  /** A line under the title: how the round went, in words. */\n  description?: React.ReactNode;\n  /** XP this round earned. */\n  xp?: number;\n  /** Today's XP (this round included) and the goal. */\n  goal?: { earned: number; goal: number; unit?: string };\n  /** The streak now, and whether this round extended it. */\n  streak?: { current: number; extended?: boolean };\n  /** News worth a moment: a milestone, a new level. Announced politely. */\n  highlight?: React.ReactNode;\n  /** Play the count and the bursts once after mount. @default true */\n  celebrate?: boolean;\n  /** Move focus to the title on mount, for a screen that replaces the round. @default false */\n  focusOnMount?: boolean;\n  /** BCP 47 locale for the numbers. */\n  locale?: string;\n  labels?: RoundSummaryLabels;\n  /** The next step: share, play again, come back tomorrow. */\n  children?: React.ReactNode;\n};\n\nconst STAT = 'grid content-start justify-items-start gap-1.5 rounded-xl border border-border bg-card p-4';\n\nfunction RoundSummary({\n  title,\n  headingLevel = 2,\n  description,\n  xp,\n  goal,\n  streak,\n  highlight,\n  celebrate = true,\n  focusOnMount = false,\n  locale,\n  labels,\n  className,\n  children,\n  ...props\n}: RoundSummaryProps) {\n  const id = React.useId();\n  const headingRef = React.useRef<HTMLHeadingElement>(null);\n  const [shown, setShown] = React.useState(false);\n  React.useEffect(() => {\n    setShown(true);\n    if (focusOnMount) headingRef.current?.focus();\n  }, [focusOnMount]);\n  const play = celebrate && shown;\n  const Heading = `h${headingLevel}` as 'h2';\n  const nf = new Intl.NumberFormat(locale);\n  const goalMet = goal ? goal.goal <= 0 || goal.earned >= goal.goal : false;\n\n  return (\n    <section\n      aria-labelledby={`${id}-title`}\n      data-slot=\"round-summary\"\n      data-min-viewport={String(MIN_VIEWPORT)}\n      className={cn('@container grid gap-5', className)}\n      {...props}\n    >\n      <div className=\"grid gap-1.5\">\n        <Heading\n          ref={headingRef}\n          id={`${id}-title`}\n          tabIndex={focusOnMount ? -1 : undefined}\n          data-slot=\"round-summary-title\"\n          className=\"font-heading text-h2 font-semibold text-balance focus-visible:outline-hidden\"\n        >\n          {title}\n        </Heading>\n        {description ? (\n          <p data-slot=\"round-summary-description\" className=\"text-muted-foreground text-pretty\">\n            {description}\n          </p>\n        ) : null}\n      </div>\n\n      {xp !== undefined || goal || streak ? (\n        <dl data-slot=\"round-summary-stats\" className=\"grid gap-3 @md:auto-cols-fr @md:grid-flow-col\">\n          {xp !== undefined ? (\n            <div data-slot=\"round-summary-stat\" data-stat=\"xp\" className={STAT}>\n              <dt className=\"text-muted-foreground text-sm\">{labels?.xp ?? 'XP earned'}</dt>\n              <dd className=\"font-heading text-section text-primary leading-none font-semibold tabular-nums\">\n                <span aria-hidden>+</span>\n                {play ? (\n                  <CountUp value={xp} start=\"mount\" duration={700} locale={locale} />\n                ) : (\n                  nf.format(xp)\n                )}\n              </dd>\n            </div>\n          ) : null}\n          {goal ? (\n            <div data-slot=\"round-summary-stat\" data-stat=\"goal\" className={cn(STAT, 'grid-cols-[auto_1fr] items-center gap-x-3')}>\n              <dt className=\"sr-only\">{labels?.goal ?? 'Daily goal'}</dt>\n              <dd className=\"contents\">\n                <GoalRing\n                  size=\"sm\"\n                  value={goal.earned}\n                  goal={goal.goal}\n                  unit={goal.unit}\n                  locale={locale}\n                  labels={{ name: labels?.goal ?? 'Daily goal' }}\n                />\n                <span className=\"grid gap-0.5\">\n                  <span className=\"text-muted-foreground text-sm\" aria-hidden>\n                    {labels?.goal ?? 'Daily goal'}\n                  </span>\n                  <span className=\"font-semibold\">\n                    {goalMet\n                      ? (labels?.goalMet ?? 'Goal met')\n                      : (labels?.goalLeft ?? ((n: string) => `${n} XP to go`))(nf.format(goal.goal - goal.earned))}\n                  </span>\n                </span>\n              </dd>\n            </div>\n          ) : null}\n          {streak ? (\n            <div data-slot=\"round-summary-stat\" data-stat=\"streak\" className={STAT}>\n              <dt className=\"text-muted-foreground text-sm\">{labels?.streak ?? 'Day streak'}</dt>\n              <dd className=\"flex items-center gap-2\">\n                <Celebrate play={play && streak.extended ? 'streak' : null} tone=\"primary\" rays={10}>\n                  <Flame\n                    aria-hidden\n                    className={cn('size-7', streak.extended ? 'text-primary' : 'text-muted-foreground')}\n                  />\n                </Celebrate>\n                <span className=\"font-heading text-section leading-none font-semibold tabular-nums\">\n                  {nf.format(streak.current)}\n                </span>\n                {streak.extended ? (\n                  <span className=\"text-muted-foreground self-end text-sm\">{labels?.streakKept ?? 'Kept today'}</span>\n                ) : null}\n              </dd>\n            </div>\n          ) : null}\n        </dl>\n      ) : null}\n\n      {highlight ? (\n        <div\n          role=\"status\"\n          data-slot=\"round-summary-highlight\"\n          className=\"border-primary/30 bg-primary/5 flex items-center gap-3 rounded-xl border p-4\"\n        >\n          <Celebrate play={play ? 'highlight' : null} tone=\"primary\">\n            <CelebrateCheck tone=\"primary\" animate={celebrate} />\n          </Celebrate>\n          <div className=\"min-w-0 font-medium text-pretty\">{highlight}</div>\n        </div>\n      ) : null}\n\n      {children ? (\n        <div data-slot=\"round-summary-actions\" className=\"grid gap-3\">\n          {children}\n        </div>\n      ) : null}\n    </section>\n  );\n}\nRoundSummary.displayName = 'RoundSummary';\n\nexport { RoundSummary };\nexport type { RoundSummaryProps, RoundSummaryLabels };\n"
    }
  ],
  "meta": {
    "tier": "game",
    "client": true,
    "minViewport": 320,
    "loading": false,
    "version": "1.0.1",
    "since": "2.0.0"
  },
  "docs": "## @interlace/round-summary\n\nInstalled to `components/ui/games/round-summary.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/games/round-summary';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/round-summary\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
