{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "feedback-rating-card",
  "title": "Feedback Rating Card",
  "description": "An in-app feedback card with an NPS 0–10 or five-face satisfaction scale: colors that show detractors, passives and promoters as you hover, a follow-up question that depends on the score, quick-pick tags, a comment with a counter, permission to follow up, a thank-you that asks happy users for a review, and Not now that tucks it into a pill.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/feedback-rating-card/feedback-rating-card.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface FeedbackRatingCardProps {\n  product?: string;\n  scale?: \"nps\" | \"csat\";\n  onSubmit?: (data: { score: number; tags: string[]; comment: string; followUp: boolean }) => Promise<void> | void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.62)\", faint: \"rgba(245,244,241,0.36)\", card: \"#141414\", border: \"rgba(255,255,255,0.09)\", input: \"#0E0E0E\", chip: \"rgba(255,255,255,0.06)\", on: \"#F5F4F1\", onText: \"#0A0A0A\", red: \"#F87171\", amber: \"#FBBF24\", green: \"#4ADE80\", ring: \"rgba(245,244,241,0.6)\" },\n  light: { bg: \"#F4F4F1\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.62)\", faint: \"rgba(10,10,10,0.42)\", card: \"#FFFFFF\", border: \"rgba(10,10,10,0.1)\", input: \"#FAFAF8\", chip: \"rgba(10,10,10,0.05)\", on: \"#0A0A0A\", onText: \"#FAFAF8\", red: \"#DC2626\", amber: \"#B45309\", green: \"#15803D\", ring: \"rgba(10,10,10,0.5)\" },\n};\nconst TAGS_GOOD = [\"Easy to use\", \"Fast\", \"Great support\", \"Saves me time\", \"Looks great\"];\nconst TAGS_BAD = [\"Too slow\", \"Hard to find things\", \"Missing features\", \"Price\", \"Bugs\"];\nconst FACES = [\n  { label: \"Very unhappy\", mouth: \"M8 16.5c1.2-1.6 2.6-2.3 4-2.3s2.8.7 4 2.3\" },\n  { label: \"Unhappy\", mouth: \"M8.5 16c1-.9 2.2-1.3 3.5-1.3s2.5.4 3.5 1.3\" },\n  { label: \"Neutral\", mouth: \"M8.5 15.5h7\" },\n  { label: \"Happy\", mouth: \"M8.5 14.5c1 1 2.2 1.5 3.5 1.5s2.5-.5 3.5-1.5\" },\n  { label: \"Very happy\", mouth: \"M8 14c1.1 1.6 2.5 2.4 4 2.4s2.9-.8 4-2.4\" },\n];\n\nexport function FeedbackRatingCard({ product = \"Nexora\", scale = \"nps\", onSubmit, theme = \"dark\", className }: FeedbackRatingCardProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [score, setScore] = React.useState<number | null>(null);\n  const [hover, setHover] = React.useState<number | null>(null);\n  const [step, setStep] = React.useState<1 | 2 | 3>(1);\n  const [tags, setTags] = React.useState<string[]>([]);\n  const [comment, setComment] = React.useState(\"\");\n  const [followUp, setFollowUp] = React.useState(true);\n  const [sending, setSending] = React.useState(false);\n  const [dismissed, setDismissed] = React.useState(false);\n  const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n  const focusOnce = React.useCallback((el: HTMLElement | null) => el?.focus({ preventScroll: true }), []);\n\n  React.useEffect(\n    () => () => {\n      if (timer.current) clearTimeout(timer.current);\n    },\n    [],\n  );\n\n  const nps = scale === \"nps\";\n  const shown = hover ?? score;\n  const band = (s: number) => (nps ? (s <= 6 ? \"detractor\" : s <= 8 ? \"passive\" : \"promoter\") : s <= 2 ? \"detractor\" : s === 3 ? \"passive\" : \"promoter\");\n  const color = (s: number) => ({ detractor: p.red, passive: p.amber, promoter: p.green })[band(s)];\n  const good = score !== null && band(score) === \"promoter\";\n  const question = score === null ? \"\" : good ? \"What do you like most?\" : band(score) === \"passive\" ? \"What would make it a 10?\" : \"What's the one thing we should fix?\";\n  const tagList = good ? TAGS_GOOD : TAGS_BAD;\n\n  const choose = (s: number) => {\n    setScore(s);\n    setTags([]);\n    timer.current = setTimeout(() => setStep(2), reduce ? 0 : 350);\n  };\n  const submit = () => {\n    if (score === null || sending) return;\n    setSending(true);\n    const done = () => {\n      setSending(false);\n      setStep(3);\n    };\n    const r = onSubmit?.({ score, tags, comment: comment.trim(), followUp });\n    if (r instanceof Promise) r.then(done, () => setSending(false));\n    else timer.current = setTimeout(done, reduce ? 0 : 800);\n  };\n  const reset = () => {\n    setStep(1);\n    setScore(null);\n    setTags([]);\n    setComment(\"\");\n  };\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.card } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n\n  return (\n    <section className={cn(\"@container grid min-h-[560px] w-full place-items-center px-4 py-12\", className)} style={{ background: p.bg, color: p.text }}>\n      <AnimatePresence mode=\"popLayout\" initial={false}>\n        {dismissed ? (\n          <motion.button key=\"pill\" type=\"button\" onClick={() => setDismissed(false)} initial={reduce ? false : { opacity: 0, scale: 0.8 }} animate={{ opacity: 1, scale: 1 }} exit={reduce ? undefined : { opacity: 0, scale: 0.8 }} className={cn(\"flex h-10 cursor-pointer items-center gap-2 rounded-full border px-4 text-[13px] font-medium\", focus)} style={{ background: p.card, borderColor: p.border, color: p.text, ...ring }}>\n            <svg width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.9\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M4 5h16v11H8l-4 4V5Z\" />\n            </svg>\n            Give feedback\n          </motion.button>\n        ) : (\n          <motion.div key=\"card\" layout={!reduce} initial={reduce ? false : { opacity: 0, y: 12 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0, scale: 0.9 }} transition={{ type: \"spring\", stiffness: 420, damping: 36 }} className=\"w-full max-w-[480px] overflow-hidden rounded-2xl border\" style={{ background: p.card, borderColor: p.border }} role=\"region\" aria-labelledby={`${uid}-q`}>\n            <div className=\"flex items-center justify-between px-5 pt-4\">\n              <span className=\"flex gap-1\" aria-label={`Step ${Math.min(step, 2)} of 2`}>\n                {[1, 2].map((s) => (\n                  <motion.span key={s} className=\"h-1 rounded-full\" initial={false} animate={{ width: step >= s ? 20 : 10, backgroundColor: step >= s ? p.on : p.border }} />\n                ))}\n              </span>\n              {step < 3 && (\n                <button type=\"button\" onClick={() => setDismissed(true)} className={cn(\"cursor-pointer rounded border-0 bg-transparent p-0 text-[12.5px]\", focus)} style={{ color: p.faint, ...ring }}>\n                  Not now\n                </button>\n              )}\n            </div>\n            <motion.div layout={!reduce ? \"position\" : false} className=\"px-5 pt-3 pb-5\">\n              {step === 1 && (\n                <motion.div key=\"s1\" initial={reduce ? false : { opacity: 0, x: -10 }} animate={{ opacity: 1, x: 0 }}>\n                  <h2 id={`${uid}-q`} className=\"m-0 text-[17px] font-semibold tracking-[-0.01em]\">\n                    {nps ? `How likely are you to recommend ${product} to a colleague?` : `How was your experience with ${product} today?`}\n                  </h2>\n                  <div role=\"radiogroup\" aria-labelledby={`${uid}-q`} className={cn(\"mt-5 grid gap-1.5\", nps ? \"grid-cols-11\" : \"grid-cols-5\")} onMouseLeave={() => setHover(null)}>\n                    {Array.from({ length: nps ? 11 : 5 }, (_, i) => {\n                      const s = nps ? i : i + 1;\n                      const lit = shown !== null && (nps ? s <= shown : s === shown);\n                      const c = shown !== null ? color(shown) : p.on;\n                      return (\n                        <motion.button\n                          key={s}\n                          type=\"button\"\n                          role=\"radio\"\n                          aria-checked={score === s}\n                          aria-label={nps ? `${s}` : FACES[i].label}\n                          onMouseEnter={() => setHover(s)}\n                          onFocus={() => setHover(s)}\n                          onBlur={() => setHover(null)}\n                          onClick={() => choose(s)}\n                          whileTap={reduce ? undefined : { scale: 0.92 }}\n                          className={cn(\"grid cursor-pointer place-items-center rounded-lg border text-[13px] font-medium tabular-nums transition-colors\", focus, nps ? \"h-10\" : \"h-14\")}\n                          style={{ borderColor: lit ? c : p.border, background: lit ? `${c}22` : \"transparent\", color: lit ? c : p.muted, ...ring }}\n                        >\n                          {nps ? (\n                            s\n                          ) : (\n                            <svg width=\"28\" height=\"28\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                              <circle cx=\"12\" cy=\"12\" r=\"9\" />\n                              <path d=\"M9 10h.01M15 10h.01\" strokeWidth=\"2.4\" />\n                              <path d={FACES[i].mouth} />\n                            </svg>\n                          )}\n                        </motion.button>\n                      );\n                    })}\n                  </div>\n                  <div className=\"mt-2 flex justify-between text-[11.5px]\" style={{ color: p.faint }}>\n                    <span>{nps ? \"Not likely\" : \"Very unhappy\"}</span>\n                    <span aria-live=\"polite\" style={{ color: shown !== null ? color(shown) : p.faint }}>\n                      {shown !== null ? (nps ? `${shown} · ${band(shown) === \"promoter\" ? \"Would recommend\" : band(shown) === \"passive\" ? \"Maybe\" : \"Unlikely\"}` : FACES[shown - 1].label) : \"\"}\n                    </span>\n                    <span>{nps ? \"Very likely\" : \"Very happy\"}</span>\n                  </div>\n                </motion.div>\n              )}\n\n              {step === 2 && score !== null && (\n                <motion.form\n                  key=\"s2\"\n                  initial={reduce ? false : { opacity: 0, x: 12 }}\n                  animate={{ opacity: 1, x: 0 }}\n                  onSubmit={(e) => {\n                    e.preventDefault();\n                    submit();\n                  }}\n                >\n                  <div className=\"flex items-center gap-2.5\">\n                    <button type=\"button\" onClick={() => setStep(1)} aria-label=\"Change score\" className={cn(\"grid h-9 min-w-9 cursor-pointer place-items-center rounded-lg border px-2 text-[14px] font-semibold tabular-nums\", focus)} style={{ borderColor: color(score), background: `${color(score)}22`, color: color(score), ...ring }}>\n                      {nps ? score : `${score}/5`}\n                    </button>\n                    <h2 id={`${uid}-q`} className=\"m-0 text-[17px] font-semibold tracking-[-0.01em]\">\n                      {question}\n                    </h2>\n                  </div>\n                  <div className=\"mt-4 flex flex-wrap gap-1.5\" role=\"group\" aria-label=\"Quick picks\">\n                    {tagList.map((t) => {\n                      const on = tags.includes(t);\n                      return (\n                        <motion.button key={t} type=\"button\" aria-pressed={on} onClick={() => setTags((x) => (on ? x.filter((y) => y !== t) : [...x, t]))} whileTap={reduce ? undefined : { scale: 0.95 }} className={cn(\"h-8 cursor-pointer rounded-full border px-3 text-[12.5px]\", focus)} style={{ borderColor: on ? color(score) : p.border, background: on ? `${color(score)}1f` : \"transparent\", color: on ? p.text : p.muted, ...ring }}>\n                          {on && \"✓ \"}\n                          {t}\n                        </motion.button>\n                      );\n                    })}\n                  </div>\n                  <label htmlFor={`${uid}-c`} className=\"sr-only\">\n                    Comment\n                  </label>\n                  <textarea id={`${uid}-c`} ref={focusOnce} value={comment} onChange={(e) => setComment(e.target.value)} maxLength={500} rows={3} placeholder={good ? \"Tell us more (optional)\" : \"What happened? The more detail, the better (optional)\"} className={cn(\"mt-3 block w-full resize-none rounded-xl border px-3 py-2.5 text-[13.5px] leading-[1.5]\", focus)} style={{ borderColor: p.border, background: p.input, color: p.text, ...ring }} />\n                  <div className=\"mt-1.5 flex items-center justify-between text-[12px]\" style={{ color: p.faint }}>\n                    <label className=\"flex cursor-pointer items-center gap-2 has-[:focus-visible]:underline\">\n                      <input type=\"checkbox\" checked={followUp} onChange={(e) => setFollowUp(e.target.checked)} className=\"h-4 w-4 cursor-pointer\" style={{ accentColor: p.on }} />\n                      You can contact me about this\n                    </label>\n                    <span className=\"tabular-nums\">{comment.length}/500</span>\n                  </div>\n                  <div className=\"mt-4 flex justify-end gap-2\">\n                    <button type=\"button\" onClick={() => setStep(1)} className={cn(\"h-9 cursor-pointer rounded-lg border bg-transparent px-3.5 text-[13px]\", focus)} style={{ borderColor: p.border, color: p.text, ...ring }}>\n                      Back\n                    </button>\n                    <button type=\"submit\" disabled={sending} className={cn(\"flex h-9 min-w-[110px] cursor-pointer items-center justify-center gap-2 rounded-lg border-0 px-3.5 text-[13px] font-medium disabled:cursor-wait\", focus)} style={{ background: p.on, color: p.onText, ...ring }}>\n                      {sending && <motion.span className=\"h-3.5 w-3.5 rounded-full border-2 border-current border-t-transparent\" animate={reduce ? undefined : { rotate: 360 }} transition={{ repeat: Infinity, duration: 0.7, ease: \"linear\" }} aria-hidden=\"true\" />}\n                      {sending ? \"Sending…\" : \"Send feedback\"}\n                    </button>\n                  </div>\n                </motion.form>\n              )}\n\n              {step === 3 && score !== null && (\n                <motion.div key=\"s3\" initial={reduce ? false : { opacity: 0, scale: 0.97 }} animate={{ opacity: 1, scale: 1 }} className=\"py-3 text-center\" role=\"status\">\n                  <motion.span className=\"mx-auto grid h-12 w-12 place-items-center rounded-full\" style={{ background: `${p.green}22`, color: p.green }} initial={reduce ? false : { scale: 0.5, rotate: -20 }} animate={{ scale: 1, rotate: 0 }} transition={{ type: \"spring\", stiffness: 380, damping: 14 }}>\n                    <svg width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                      <path d=\"m5 12.5 4.5 4.5L19 7.5\" />\n                    </svg>\n                  </motion.span>\n                  <h2 className=\"m-0 mt-4 text-[18px] font-semibold\">{good ? \"Thank you, that made our day\" : \"Thanks for being honest\"}</h2>\n                  <p className=\"m-0 mx-auto mt-1.5 max-w-[340px] text-[13.5px] leading-[1.55]\" style={{ color: p.muted }}>\n                    {good ? `Would you share it publicly? A short review helps other teams find ${product}.` : followUp ? \"Someone from the product team will read this and may reach out within two working days.\" : \"Every response is read by the product team.\"}\n                  </p>\n                  <div className=\"mt-5 flex justify-center gap-2\">\n                    {good && (\n                      <a href=\"#\" className={cn(\"flex h-9 items-center rounded-lg border-0 px-3.5 text-[13px] font-medium no-underline\", focus)} style={{ background: p.on, color: p.onText, ...ring }}>\n                        Write a review\n                      </a>\n                    )}\n                    <button type=\"button\" onClick={reset} className={cn(\"h-9 cursor-pointer rounded-lg border bg-transparent px-3.5 text-[13px]\", focus)} style={{ borderColor: p.border, color: p.text, ...ring }}>\n                      Done\n                    </button>\n                  </div>\n                </motion.div>\n              )}\n            </motion.div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </section>\n  );\n}\n\nexport default FeedbackRatingCard;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}