{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"single-open-react-accordion-with-aria-controls","type":"registry:block","title":"Single-Open React Accordion With aria-controls","description":"","dependencies":[],"files":[{"path":"components/we-inc/single-open-react-accordion-with-aria-controls.tsx","type":"registry:component","content":"import { useId, useState } from \"react\";\n\nconst sections = [\n  { title: \"Return window\", body: \"Unused gear can come back within 60 days of delivery. Tents and sleeping bags that have been slept in once are still accepted if they are clean and dry.\" },\n  { title: \"Repairs before replacements\", body: \"Torn seams, stuck zips and snapped poles are fixed free in our Kendal workshop for the life of the product. Most repairs are posted back inside ten working days.\" },\n  { title: \"How refunds are paid\", body: \"Refunds go back to the card you paid with within three working days of the parcel reaching us. Store credit is added instantly if you prefer it.\" },\n  { title: \"Items we cannot take back\", body: \"Worn base layers, opened gas canisters and anything cut to length, such as guy line or webbing, cannot be returned for hygiene and safety reasons.\" },\n];\n\nexport default function SingleOpenReactAccordionWithAriaControls() {\n  const [open, setOpen] = useState<number | null>(0);\n  const base = useId();\n  return (\n    <section className=\"soa bg-white px-5 py-16 sm:py-20\">\n      <style>{`\n        .soa-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s cubic-bezier(.2,.7,.2,1); }\n        .soa-panel[data-open] { grid-template-rows: 1fr; }\n        @media (prefers-reduced-motion: reduce) { .soa-panel, .soa-chev { transition: none !important; } }\n      `}</style>\n      <div className=\"mx-auto max-w-2xl\">\n        <h2 className=\"text-2xl font-semibold tracking-tight text-slate-900 sm:text-3xl\">Returns and repairs</h2>\n        <p className=\"mt-2 text-[15px] text-slate-600\">Fellside Outfitters. One section opens at a time.</p>\n        <div className=\"mt-8 space-y-3\">\n          {sections.map((s, i) => {\n            const isOpen = open === i;\n            const btn = `${base}-b${i}`;\n            const panel = `${base}-p${i}`;\n            return (\n              <div key={s.title} className={`rounded-xl border transition-colors ${isOpen ? \"border-emerald-600 bg-emerald-50/60\" : \"border-slate-200 bg-white\"}`}>\n                <h3>\n                  <button\n                    id={btn}\n                    type=\"button\"\n                    aria-expanded={isOpen}\n                    aria-controls={panel}\n                    onClick={() => setOpen(isOpen ? null : i)}\n                    className=\"flex min-h-[56px] w-full items-center justify-between gap-4 rounded-xl px-5 py-4 text-left text-base font-semibold text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-700\"\n                  >\n                    {s.title}\n                    <svg className={`soa-chev h-5 w-5 shrink-0 transition-transform duration-300 ${isOpen ? \"rotate-180 text-emerald-700\" : \"text-slate-500\"}`} viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" aria-hidden=\"true\"><path d=\"M5 7.5l5 5 5-5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n                  </button>\n                </h3>\n                <div id={panel} role=\"region\" aria-labelledby={btn} data-open={isOpen ? \"\" : undefined} className=\"soa-panel\">\n                  <div className=\"overflow-hidden\" {...(isOpen ? {} : { inert: \"\" })}>\n                    <p className=\"px-5 pb-5 text-[15px] leading-relaxed text-slate-700\">{s.body}</p>\n                  </div>\n                </div>\n              </div>\n            );\n          })}\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
