{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"feedback-form-with-radio-rating-scale","type":"registry:component","title":"Feedback Form With Radio Rating Scale","description":"","dependencies":[],"files":[{"path":"components/we-inc/feedback-form-with-radio-rating-scale.tsx","type":"registry:component","content":"import { useState, type FormEvent } from \"react\";\n\n// The scale: change the words and the number of steps here.\nconst SCALE = [\"Poor\", \"Fair\", \"Good\", \"Great\", \"Superb\"];\nconst TOPICS = [\"Delivery time\", \"Packaging\", \"Taste\", \"Price\"];\n\nexport default function FeedbackFormWithRadioRating() {\n  const [rating, setRating] = useState(4);\n  const [topics, setTopics] = useState<string[]>([\"Taste\"]);\n  const [sent, setSent] = useState(false);\n\n  const toggle = (t: string) => setTopics((x) => (x.includes(t) ? x.filter((y) => y !== t) : [...x, t]));\n\n  if (sent) {\n    return (\n      <section className=\"bg-rose-50 px-4 py-16\">\n        <div role=\"status\" className=\"mx-auto max-w-lg rounded-3xl bg-white p-8 text-center ring-1 ring-rose-100\">\n          <h2 className=\"text-xl font-semibold text-stone-900\">Thank you, Sam.</h2>\n          <p className=\"mt-2 text-stone-700\">Your note goes straight to the kitchen team.</p>\n          <button type=\"button\" onClick={() => setSent(false)} className=\"mt-6 h-10 rounded-full border border-stone-300 px-5 text-sm font-medium text-stone-800 hover:bg-stone-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-700\">Edit my answer</button>\n        </div>\n      </section>\n    );\n  }\n\n  return (\n    <section className=\"bg-rose-50 px-4 py-16\">\n      <form onSubmit={(e: FormEvent) => { e.preventDefault(); setSent(true); }} className=\"mx-auto max-w-lg rounded-3xl bg-white p-6 ring-1 ring-rose-100 sm:p-8\">\n        <p className=\"text-sm font-medium text-rose-800\">Order #4471, Pellmell Kitchen</p>\n        <h2 className=\"mt-1 text-xl font-semibold tracking-tight text-stone-900\">How was your dinner box?</h2>\n\n        <fieldset className=\"mt-6\">\n          <legend className=\"text-sm font-medium text-stone-800\">Overall</legend>\n          <div className=\"mt-3 grid grid-cols-5 gap-1.5 rounded-2xl bg-stone-100 p-1.5\">\n            {SCALE.map((word, i) => {\n              const n = i + 1;\n              const on = rating === n;\n              return (\n                <label key={word} className=\"relative cursor-pointer\">\n                  <input type=\"radio\" name=\"rating\" value={n} checked={on} onChange={() => setRating(n)} aria-label={`${n}, ${word}`} className=\"peer sr-only\" />\n                  <span className={`flex h-16 flex-col items-center justify-center rounded-xl text-center transition-colors peer-focus-visible:ring-2 peer-focus-visible:ring-rose-700 peer-focus-visible:ring-offset-2 motion-reduce:transition-none ${on ? \"bg-rose-700 text-white shadow-sm\" : \"text-stone-700 hover:bg-white\"}`}>\n                    <span className=\"text-lg font-semibold tabular-nums\">{n}</span>\n                    <span className=\"text-[11px] font-medium sm:text-xs\">{word}</span>\n                  </span>\n                </label>\n              );\n            })}\n          </div>\n        </fieldset>\n\n        <fieldset className=\"mt-6\">\n          <legend className=\"text-sm font-medium text-stone-800\">What stood out? <span className=\"font-normal text-stone-600\">Pick any</span></legend>\n          <div className=\"mt-3 flex flex-wrap gap-2\">\n            {TOPICS.map((t) => (\n              <label key={t} className=\"relative cursor-pointer\">\n                <input type=\"checkbox\" checked={topics.includes(t)} onChange={() => toggle(t)} aria-label={t} className=\"peer sr-only\" />\n                <span className={`flex h-10 items-center rounded-full border px-4 text-sm font-medium peer-focus-visible:ring-2 peer-focus-visible:ring-rose-700 peer-focus-visible:ring-offset-2 ${topics.includes(t) ? \"border-rose-700 bg-rose-50 text-rose-900\" : \"border-stone-300 text-stone-700 hover:border-stone-400\"}`}>{t}</span>\n              </label>\n            ))}\n          </div>\n        </fieldset>\n\n        <label htmlFor=\"ffrr-note\" className=\"mt-6 block text-sm font-medium text-stone-800\">Anything else?</label>\n        <textarea id=\"ffrr-note\" rows={3} defaultValue=\"The miso aubergine was the best thing we've had all week.\" className=\"mt-1.5 block w-full rounded-xl border border-stone-300 px-3 py-2.5 text-sm text-stone-900 focus:border-rose-700 focus:outline-none focus:ring-2 focus:ring-rose-200\" />\n\n        <button type=\"submit\" className=\"mt-6 h-11 w-full rounded-full bg-stone-900 text-sm font-semibold text-white hover:bg-stone-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-700 focus-visible:ring-offset-2\">Send feedback</button>\n      </form>\n    </section>\n  );\n}\n"}]}
