{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"hamburger-menu-with-slide-in-drawer-from-the-right","type":"registry:component","title":"Hamburger Menu With Slide-In Drawer From the Right","description":"","dependencies":[],"files":[{"path":"components/we-inc/hamburger-menu-with-slide-in-drawer-from-the-right.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\n// Grouped links for the drawer. Change labels and groups here.\nconst groups = [\n  { title: \"Treatments\", links: [\"Sports injuries\", \"Back and neck pain\", \"Pre and post surgery\", \"Pilates classes\"] },\n  { title: \"Clinic\", links: [\"Our physios\", \"Prices\", \"Contact\"] },\n];\n\nexport default function HamburgerMenuWithSlideInDrawerFromTheRight() {\n  const [open, setOpen] = useState(true);\n  const opener = useRef<HTMLButtonElement>(null);\n  const drawer = useRef<HTMLDivElement>(null);\n\n  const close = () => {\n    setOpen(false);\n    opener.current?.focus();\n  };\n\n  useEffect(() => {\n    if (!open) return;\n    const panel = drawer.current;\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") close();\n      if (e.key !== \"Tab\" || !panel) return;\n      // Keep Tab inside the drawer while it covers the page.\n      const items = panel.querySelectorAll<HTMLElement>(\"a, button\");\n      const first = items[0];\n      const last = items[items.length - 1];\n      if (!panel.contains(document.activeElement)) return;\n      if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }\n      else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }\n    };\n    document.addEventListener(\"keydown\", onKey);\n    return () => document.removeEventListener(\"keydown\", onKey);\n  }, [open]);\n\n  return (\n    <div className=\"bg-teal-50 px-4 py-10 sm:px-8\">\n      <div className=\"relative mx-auto h-[480px] max-w-4xl overflow-hidden rounded-2xl bg-white shadow-sm ring-1 ring-teal-900/10\">\n        <header className=\"flex h-16 items-center justify-between px-5\">\n          <a href=\"#\" className=\"rounded text-base font-bold tracking-tight text-teal-950 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600\">Northpoint Physio</a>\n          <button\n            ref={opener}\n            type=\"button\"\n            aria-expanded={open}\n            aria-controls=\"hmd-drawer\"\n            onClick={() => setOpen(true)}\n            className=\"flex h-11 items-center gap-2 rounded-full border border-teal-200 px-4 text-sm font-medium text-teal-950 hover:bg-teal-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600\"\n          >\n            <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\"><path d=\"M4 7h16M4 12h16M4 17h16\" /></svg>\n            Menu\n          </button>\n        </header>\n        <div className=\"px-5 pt-10 sm:px-12\">\n          <p className=\"text-sm font-semibold uppercase tracking-widest text-teal-700\">Same-week appointments</p>\n          <h2 className=\"mt-3 max-w-md text-3xl font-semibold tracking-tight text-teal-950 sm:text-4xl\">Get moving again without the waiting list</h2>\n          <p className=\"mt-4 max-w-sm text-slate-600\">Assessment and a treatment plan in your first 45-minute session.</p>\n        </div>\n\n        <div\n          aria-hidden=\"true\"\n          onClick={close}\n          className={`absolute inset-0 bg-teal-950/40 transition-opacity duration-300 motion-reduce:transition-none ${open ? \"opacity-100\" : \"pointer-events-none opacity-0\"}`}\n        />\n        <div\n          ref={drawer}\n          id=\"hmd-drawer\"\n          role=\"dialog\"\n          aria-modal=\"true\"\n          aria-labelledby=\"hmd-title\"\n          className={`absolute inset-y-0 right-0 flex w-[300px] max-w-[86%] flex-col bg-white shadow-2xl transition duration-300 ease-out motion-reduce:transition-none ${open ? \"visible translate-x-0\" : \"invisible translate-x-full\"}`}\n        >\n          <div className=\"flex h-16 items-center justify-between border-b border-slate-100 px-5\">\n            <h2 id=\"hmd-title\" className=\"text-sm font-semibold text-teal-950\">Menu</h2>\n            <button type=\"button\" onClick={close} aria-label=\"Close menu\" className=\"grid h-10 w-10 place-items-center rounded-full text-slate-600 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600\">\n              <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\"><path d=\"M6 6l12 12M18 6L6 18\" /></svg>\n            </button>\n          </div>\n          <nav aria-label=\"Main\" className=\"flex-1 overflow-y-auto px-3 py-4\">\n            {groups.map((g) => (\n              <div key={g.title} className=\"mb-4\">\n                <p className=\"px-3 pb-1 text-xs font-semibold uppercase tracking-wider text-slate-600\">{g.title}</p>\n                <ul>\n                  {g.links.map((l) => (\n                    <li key={l}>\n                      <a href=\"#\" className=\"flex h-10 items-center rounded-lg px-3 text-[15px] text-slate-800 hover:bg-teal-50 hover:text-teal-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600\">{l}</a>\n                    </li>\n                  ))}\n                </ul>\n              </div>\n            ))}\n          </nav>\n          <div className=\"border-t border-slate-100 p-4\">\n            <a href=\"#\" className=\"flex h-11 items-center justify-center rounded-full bg-teal-700 text-sm font-semibold text-white hover:bg-teal-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 focus-visible:ring-offset-2\">Book a session</a>\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n"}]}
