{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"sweep-menu","type":"registry:ui","title":"Sweep Menu","description":"Menu button that sweeps staggered colored layers across the screen before a panel of oversized links rises into place.","dependencies":["motion"],"registryDependencies":["utils"],"files":[{"path":"registry/ui/sweep-menu.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useId, useRef, useState, type ReactNode } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface SweepMenuLink {\n  label: string;\n  href: string;\n}\n\nexport interface SweepMenuProps {\n  items: SweepMenuLink[];\n  /** Small links at the bottom of the panel. */\n  socials?: SweepMenuLink[];\n  /** Brand shown at the top left. */\n  logo?: ReactNode;\n  /** Colors of the layers that sweep in before the panel. */\n  layerColors?: string[];\n  /** Numbers, hover color and toggle icon color. */\n  accentColor?: string;\n  /** Edge the panel slides in from. */\n  side?: \"left\" | \"right\";\n  /** `fixed` covers the viewport, `absolute` stays inside the nearest positioned parent. */\n  position?: \"fixed\" | \"absolute\";\n  /** Show 01, 02… next to each link. */\n  numbered?: boolean;\n  /** Seconds between each layer and each link. */\n  stagger?: number;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  className?: string;\n}\n\nconst ease = [0.76, 0, 0.24, 1] as const;\n\nexport function SweepMenu({\n  items,\n  socials = [],\n  logo,\n  layerColors = [\"#c6ff3d\", \"#5b3df5\"],\n  accentColor = \"#5b3df5\",\n  side = \"right\",\n  position = \"fixed\",\n  numbered = true,\n  stagger = 0.08,\n  defaultOpen = false,\n  onOpenChange,\n  className,\n}: SweepMenuProps) {\n  const [open, setOpen] = useState(defaultOpen);\n  const reduce = useReducedMotion();\n  const toggle = useRef<HTMLButtonElement>(null);\n  const firstLink = useRef<HTMLAnchorElement>(null);\n  const panelId = useId();\n  const pos = position === \"fixed\" ? \"fixed\" : \"absolute\";\n  const off = side === \"right\" ? \"100%\" : \"-100%\";\n  const s = reduce ? 0 : stagger;\n  const panelDelay = layerColors.length * s;\n\n  const set = (next: boolean) => {\n    setOpen(next);\n    onOpenChange?.(next);\n  };\n\n  useEffect(() => {\n    if (!open) return;\n    const t = setTimeout(() => firstLink.current?.focus({ preventScroll: true }), (panelDelay + 0.3) * 1000);\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key !== \"Escape\") return;\n      setOpen(false);\n      onOpenChange?.(false);\n      toggle.current?.focus();\n    };\n    window.addEventListener(\"keydown\", onKey);\n    return () => {\n      clearTimeout(t);\n      window.removeEventListener(\"keydown\", onKey);\n    };\n  }, [open, panelDelay, onOpenChange]);\n\n  return (\n    <div className={cn(\"contents\", className)}>\n      <header className={`${pos} inset-x-0 top-0 z-50 flex items-center justify-between p-5 sm:p-7`}>\n        <div className=\"text-lg font-semibold tracking-tight text-foreground\">{logo}</div>\n        <button\n          ref={toggle}\n          type=\"button\"\n          aria-expanded={open}\n          aria-controls={panelId}\n          onClick={() => set(!open)}\n          className=\"group flex items-center gap-3 rounded-full px-3 py-2 text-sm font-semibold uppercase tracking-[0.18em] text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n        >\n          {/* Rolling label: Menu slides up, Close rolls in. */}\n          <span className=\"relative block h-5 overflow-hidden\">\n            <motion.span\n              className=\"flex flex-col\"\n              animate={{ y: open ? \"-50%\" : \"0%\" }}\n              transition={{ duration: reduce ? 0 : 0.5, ease }}\n            >\n              <span className=\"h-5 leading-5\">Menu</span>\n              <span className=\"h-5 leading-5\">Close</span>\n            </motion.span>\n          </span>\n          <motion.span\n            aria-hidden\n            className=\"relative grid size-5 place-items-center\"\n            style={{ color: open ? accentColor : undefined }}\n            animate={{ rotate: open ? 225 : 0 }}\n            transition={{ duration: reduce ? 0 : 0.6, ease }}\n          >\n            <span className=\"absolute h-[2px] w-4 rounded-full bg-current\" />\n            <span className=\"absolute h-4 w-[2px] rounded-full bg-current\" />\n          </motion.span>\n        </button>\n      </header>\n\n      <AnimatePresence>\n        {open && (\n          <div key=\"menu\" className={`${pos} inset-0 z-40 overflow-hidden`}>\n            <motion.button\n              type=\"button\"\n              tabIndex={-1}\n              aria-label=\"Close menu\"\n              className=\"absolute inset-0 cursor-default bg-black/40\"\n              initial={{ opacity: 0 }}\n              animate={{ opacity: 1 }}\n              exit={{ opacity: 0, transition: { duration: 0.3, delay: 0.2 } }}\n              onClick={() => set(false)}\n            />\n            {layerColors.map((c, i) => (\n              <motion.div\n                key={c + i}\n                aria-hidden\n                className={`absolute inset-y-0 ${side === \"right\" ? \"right-0\" : \"left-0\"} w-full sm:w-[min(30rem,100%)]`}\n                style={{ background: c }}\n                initial={{ x: off }}\n                animate={{ x: \"0%\", transition: { duration: reduce ? 0 : 0.6, ease, delay: i * s } }}\n                exit={{ x: off, transition: { duration: reduce ? 0 : 0.5, ease, delay: (layerColors.length - i) * s * 0.5 } }}\n              />\n            ))}\n            <motion.nav\n              id={panelId}\n              aria-label=\"Menu\"\n              className={`absolute inset-y-0 ${side === \"right\" ? \"right-0\" : \"left-0\"} flex w-full flex-col justify-between bg-card px-8 pb-8 pt-24 text-card-foreground sm:w-[min(30rem,100%)] sm:px-10`}\n              initial={{ x: off }}\n              animate={{ x: \"0%\", transition: { duration: reduce ? 0 : 0.65, ease, delay: panelDelay } }}\n              exit={{ x: off, transition: { duration: reduce ? 0 : 0.5, ease } }}\n            >\n              <ul>\n                {items.map((item, i) => (\n                  <li key={item.href + item.label} className=\"-m-1 overflow-hidden p-1\">\n                    <motion.a\n                      ref={i === 0 ? firstLink : undefined}\n                      href={item.href}\n                      onClick={() => set(false)}\n                      className=\"group flex items-start gap-3 rounded-lg text-5xl font-semibold uppercase leading-[1.05] tracking-tight text-foreground outline-none transition-colors duration-300 hover:text-[var(--sm-accent)] focus-visible:text-[var(--sm-accent)] sm:text-6xl\"\n                      style={{ [\"--sm-accent\" as string]: accentColor }}\n                      initial={reduce ? { opacity: 0 } : { y: \"110%\", rotate: 6 }}\n                      animate={\n                        reduce\n                          ? { opacity: 1 }\n                          : { y: \"0%\", rotate: 0, transition: { duration: 0.8, ease: [0.22, 1, 0.36, 1], delay: panelDelay + 0.15 + i * s } }\n                      }\n                    >\n                      <span className=\"transition-transform duration-300 group-hover:translate-x-2 group-focus-visible:translate-x-2\">{item.label}</span>\n                      {numbered && (\n                        <span className=\"mt-1 text-sm font-medium tracking-normal\" style={{ color: accentColor }}>\n                          {String(i + 1).padStart(2, \"0\")}\n                        </span>\n                      )}\n                    </motion.a>\n                  </li>\n                ))}\n              </ul>\n\n              {socials.length > 0 && (\n                <motion.div\n                  initial={{ opacity: 0, y: 12 }}\n                  animate={{ opacity: 1, y: 0, transition: { delay: reduce ? 0 : panelDelay + 0.3 + items.length * s, duration: 0.5 } }}\n                >\n                  <p className=\"mb-3 text-xs font-medium uppercase tracking-[0.25em]\" style={{ color: accentColor }}>\n                    Socials\n                  </p>\n                  <ul className=\"flex flex-wrap gap-x-6 gap-y-2\">\n                    {socials.map((l) => (\n                      <li key={l.href + l.label}>\n                        <a\n                          href={l.href}\n                          className=\"text-base font-medium text-foreground underline-offset-4 outline-none hover:underline focus-visible:underline\"\n                        >\n                          {l.label}\n                        </a>\n                      </li>\n                    ))}\n                  </ul>\n                </motion.div>\n              )}\n            </motion.nav>\n          </div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n"}]}