{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "goal-ring",
  "type": "registry:ui",
  "title": "Goal Ring",
  "description": "How far today is toward a daily goal: a ring that fills as points come in, the count in its middle, and a check once the goal is met. It is a `meter`, so assistive tech reads \"15 of 20 XP\" without the ring.",
  "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/cn.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/games/goal-ring.tsx",
      "target": "components/ui/games/goal-ring.tsx",
      "type": "registry:ui",
      "content": "import * as React from 'react';\n\n// @interlace/goal-ring v1.0.0 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/goal-ring\n// What changed since: https://ds.interlace.tools/c/goal-ring#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui — GoalRing\n *\n * How far today is toward a daily goal: a ring that fills as points come\n * in, the count in its middle, and a check once the goal is met. It is a\n * `meter`, so assistive tech reads \"15 of 20 XP\" without the ring.\n *\n * ## Anatomy\n *\n *   GoalRing                       (div role=\"meter\" — data-slot=\"goal-ring\", data-state=progress|met)\n *     ├─ svg aria-hidden           (data-slot=\"goal-ring-track\" and \"goal-ring-fill\" circles)\n *     └─ span                      (data-slot=\"goal-ring-label\": the count, or a check when met)\n *\n * ## Motion\n *\n * The fill draws from empty on first paint and moves to each new value\n * (`stroke-dashoffset`, `--duration-slow`, `ease-move`); a met goal's check\n * scales in once. All of it sits behind `motion-safe:`, so under reduced\n * motion the ring is simply drawn at its value. CSS only, so it renders on\n * the server.\n *\n * ## MIN_VIEWPORT — 320\n *\n * | Rule | Concept                   | Where in this file                            |\n * | ---- | ------------------------- | --------------------------------------------- |\n * | R4   | Extends native el         | `React.ComponentProps<'div'>`                 |\n * | R6   | data-slot per part        | goal-ring / -track / -fill / -label           |\n * | R7   | cn + ...rest              | `cn(…, className)` + `{...props}`             |\n * | R8   | Enums, not booleans       | `size`                                        |\n * | R14  | Declares min viewport     | `data-min-viewport` + exported const          |\n * | R19  | Tokens only               | primary, border, foreground                   |\n * | R26  | A11y                      | role=\"meter\" with a value text                |\n */\n\nimport { Check } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\n\nexport const MIN_VIEWPORT = 320 as const;\n\nexport type GoalRingSize = 'sm' | 'default' | 'lg';\n\nconst SIZE: Record<GoalRingSize, { box: string; count: string; unit: string; icon: string; stroke: number }> = {\n  sm: { box: 'size-12', count: 'text-sm', unit: 'hidden', icon: 'size-5', stroke: 5 },\n  default: { box: 'size-20', count: 'text-lg', unit: 'text-xs', icon: 'size-7', stroke: 4.5 },\n  lg: { box: 'size-28', count: 'text-h3', unit: 'text-sm', icon: 'size-10', stroke: 4 },\n};\n\ninterface GoalRingLabels {\n  /** Names the meter. @default 'Daily goal' */\n  name?: string;\n  /** The value read aloud. @default (v, g, unit) => `${v} of ${g} ${unit}` */\n  value?: (value: string, goal: string, unit: string) => string;\n  /** Said once the goal is met, after the value. @default 'Goal met.' */\n  met?: string;\n}\n\ntype GoalRingProps = Omit<React.ComponentProps<'div'>, 'children'> & {\n  /** Earned so far today. */\n  value: number;\n  /** The day's goal. */\n  goal: number;\n  /** The unit after the numbers. @default 'XP' */\n  unit?: string;\n  /** @default 'default' */\n  size?: GoalRingSize;\n  /** BCP 47 locale for the numbers. */\n  locale?: string;\n  labels?: GoalRingLabels;\n};\n\nfunction GoalRing({\n  value,\n  goal,\n  unit = 'XP',\n  size = 'default',\n  locale,\n  labels,\n  className,\n  ...props\n}: GoalRingProps) {\n  const v = Number.isFinite(value) && value > 0 ? value : 0;\n  const g = Number.isFinite(goal) && goal > 0 ? goal : 0;\n  const met = g === 0 || v >= g;\n  const pct = g === 0 ? 100 : Math.min(100, (v / g) * 100);\n  const nf = new Intl.NumberFormat(locale);\n  const s = SIZE[size];\n  const valueText = (labels?.value ?? ((a: string, b: string, u: string) => `${a} of ${b} ${u}`))(\n    nf.format(v),\n    nf.format(g),\n    unit,\n  );\n  const r = 18 - s.stroke / 2;\n\n  return (\n    <div\n      role=\"meter\"\n      aria-label={labels?.name ?? 'Daily goal'}\n      aria-valuemin={0}\n      aria-valuemax={g}\n      aria-valuenow={Math.min(v, g)}\n      aria-valuetext={met ? `${valueText}. ${labels?.met ?? 'Goal met.'}` : valueText}\n      data-slot=\"goal-ring\"\n      data-state={met ? 'met' : 'progress'}\n      data-size={size}\n      data-min-viewport={String(MIN_VIEWPORT)}\n      className={cn('relative inline-grid shrink-0 place-items-center', s.box, className)}\n      {...props}\n    >\n      <svg aria-hidden viewBox=\"0 0 36 36\" className=\"col-start-1 row-start-1 size-full -rotate-90 rtl:scale-y-[-1]\">\n        <circle\n          data-slot=\"goal-ring-track\"\n          cx=\"18\"\n          cy=\"18\"\n          r={r}\n          fill=\"none\"\n          strokeWidth={s.stroke}\n          className=\"stroke-border\"\n        />\n        <circle\n          data-slot=\"goal-ring-fill\"\n          cx=\"18\"\n          cy=\"18\"\n          r={r}\n          fill=\"none\"\n          strokeWidth={s.stroke}\n          strokeLinecap=\"round\"\n          pathLength={100}\n          strokeDasharray=\"100 100\"\n          style={{ strokeDashoffset: 100 - pct }}\n          className={cn(\n            'stroke-primary',\n            pct === 0 && 'opacity-0',\n            'motion-safe:transition-[stroke-dashoffset] motion-safe:duration-(--duration-slow) motion-safe:ease-move motion-safe:starting:[stroke-dashoffset:100]',\n          )}\n        />\n      </svg>\n      <span\n        aria-hidden\n        data-slot=\"goal-ring-label\"\n        className=\"col-start-1 row-start-1 grid place-items-center leading-none tabular-nums\"\n      >\n        {met ? (\n          <Check\n            strokeWidth={3}\n            className={cn(\n              'text-primary',\n              s.icon,\n              'motion-safe:transition-[scale,opacity] motion-safe:duration-(--duration-medium) motion-safe:ease-enter motion-safe:starting:scale-50 motion-safe:starting:opacity-0',\n            )}\n          />\n        ) : (\n          <>\n            <span className={cn('font-semibold', s.count)}>{nf.format(v)}</span>\n            <span className={cn('text-muted-foreground', s.unit)}>/{nf.format(g)}</span>\n          </>\n        )}\n      </span>\n    </div>\n  );\n}\nGoalRing.displayName = 'GoalRing';\n\nexport { GoalRing };\nexport type { GoalRingProps, GoalRingLabels };\n"
    }
  ],
  "meta": {
    "tier": "game",
    "client": false,
    "minViewport": 320,
    "loading": false,
    "version": "1.0.0",
    "since": "2.0.0"
  },
  "docs": "## @interlace/goal-ring\n\nInstalled to `components/ui/games/goal-ring.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/games/goal-ring';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/goal-ring\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
