{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"circular-svg-progress-ring-with-percentage","type":"registry:component","title":"Circular SVG Progress Ring With Percentage","description":"","dependencies":[],"files":[{"path":"components/we-inc/circular-svg-progress-ring-with-percentage.tsx","type":"registry:component","content":"import { useEffect, useState } from \"react\";\n\nconst R = 52; // ring radius in SVG units\nconst C = 2 * Math.PI * R; // circumference\n// Goals shown on the card: label, value done and target.\nconst GOALS = [\n  { label: \"Distance\", done: 27.4, target: 40, unit: \"km\" },\n  { label: \"Active days\", done: 4, target: 5, unit: \"days\" },\n];\n\nexport default function CircularProgressRing() {\n  const [i, setI] = useState(0);\n  const [shown, setShown] = useState(0);\n  const g = GOALS[i];\n  const pct = Math.round((g.done / g.target) * 100);\n\n  // fill from empty on first view and whenever the goal changes\n  useEffect(() => {\n    setShown(0);\n    const t = setTimeout(() => setShown(pct), 120);\n    return () => clearTimeout(t);\n  }, [pct]);\n\n  return (\n    <section className=\"bg-gradient-to-br from-cyan-950 to-slate-950 px-4 py-16\">\n      <div className=\"mx-auto max-w-sm rounded-3xl bg-white/[0.04] p-6 ring-1 ring-white/10 sm:p-8\">\n        <div className=\"flex items-center justify-between\">\n          <h2 id=\"cspr-label\" className=\"text-base font-semibold text-white\">This week&rsquo;s {g.label.toLowerCase()}</h2>\n          <span className=\"text-xs text-cyan-200\">Mon 26 Oct to Sun 1 Nov</span>\n        </div>\n\n        <div\n          role=\"progressbar\"\n          aria-labelledby=\"cspr-label\"\n          aria-valuemin={0}\n          aria-valuemax={100}\n          aria-valuenow={pct}\n          aria-valuetext={`${g.done} of ${g.target} ${g.unit}, ${pct} percent`}\n          className=\"relative mx-auto mt-6 h-48 w-48\"\n        >\n          <svg viewBox=\"0 0 120 120\" className=\"h-full w-full -rotate-90\" aria-hidden=\"true\">\n            <circle cx=\"60\" cy=\"60\" r={R} fill=\"none\" stroke=\"rgba(255,255,255,0.08)\" strokeWidth=\"10\" />\n            <circle\n              cx=\"60\" cy=\"60\" r={R} fill=\"none\" stroke=\"#22d3ee\" strokeWidth=\"10\" strokeLinecap=\"round\"\n              strokeDasharray={C}\n              strokeDashoffset={C * (1 - Math.min(shown, 100) / 100)}\n              className=\"transition-[stroke-dashoffset] duration-1000 ease-out motion-reduce:transition-none\"\n            />\n          </svg>\n          <div className=\"absolute inset-0 flex flex-col items-center justify-center\" aria-hidden=\"true\">\n            <span className=\"text-4xl font-semibold tabular-nums tracking-tight text-white\">{pct}%</span>\n            <span className=\"mt-1 text-sm text-slate-300\">{g.done} / {g.target} {g.unit}</span>\n          </div>\n        </div>\n\n        <div className=\"mt-6 grid grid-cols-2 gap-1 rounded-full bg-white/5 p-1\" role=\"group\" aria-label=\"Choose goal\">\n          {GOALS.map((x, k) => (\n            <button key={x.label} type=\"button\" aria-pressed={k === i} onClick={() => setI(k)} className={`h-10 rounded-full text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300 ${k === i ? \"bg-cyan-300 text-slate-950\" : \"text-slate-200 hover:bg-white/10\"}`}>{x.label}</button>\n          ))}\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
