{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "expanding-card-navbar",
  "title": "Expanding Card Navbar",
  "description": "A compact navigation card that expands into an editorial grid of links, with controlled or internal open state, numbering and reduced-motion support.",
  "dependencies": [
    "motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/expanding-card-navbar/expanding-card-navbar.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion } from \"motion/react\";\nimport { ArrowUpRight, Plus, Folder, Layers, Grid2X2 } from \"lucide-react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); }\n\nexport type NavbarTheme = \"dark\" | \"light\";\n\nexport interface NavbarLink {\n  /** A stable, unique item identifier. */\n  id: string;\n  label: string;\n  href: string;\n  description?: string;\n  badge?: string;\n  icon?: React.ReactNode;\n}\n\nconst DEFAULT_LINKS: NavbarLink[] = [\n  { id: \"work\", label: \"Work\", href: \"/work\", description: \"A few things, thoughtfully made.\", icon: <Grid2X2 size={16}/> },\n  { id: \"studio\", label: \"Studio\", href: \"/studio\", description: \"The people and the process.\", icon: <Layers size={16}/> },\n  { id: \"journal\", label: \"Journal\", href: \"/journal\", description: \"Notes from the in-between.\", icon: <Folder size={16}/> },\n  { id: \"contact\", label: \"Contact\", href: \"/contact\", description: \"Every good thing starts somewhere.\", icon: <ArrowUpRight size={16}/> },\n];\n\nfunction palette(theme: NavbarTheme): React.CSSProperties & Record<`--${string}`, string> {\n const light=theme===\"light\";\n return {\"--nav-page\":light?\"#f5f4f1\":\"#0e0e0e\",\"--nav-ink\":light?\"#0a0a0a\":\"#f5f4f1\",\"--nav-muted\":light?\"rgba(10,10,10,.52)\":\"rgba(245,244,241,.52)\",\"--nav-line\":light?\"rgba(10,10,10,.1)\":\"rgba(245,244,241,.1)\",\"--nav-soft\":light?\"rgba(10,10,10,.045)\":\"rgba(245,244,241,.045)\",\"--nav-panel\":light?\"rgba(245,244,241,.96)\":\"rgba(14,14,14,.96)\",\"--nav-serif\":\"var(--navbar-serif, 'Instrument Serif', Georgia, serif)\"};\n}\n\nconst focus=\"outline-none focus-visible:ring-2 focus-visible:ring-[var(--nav-ink)]/40 focus-visible:ring-offset-4 focus-visible:ring-offset-[var(--nav-page)]\";\n\nconst muted=\"text-[color:var(--nav-muted)]\";\n\nconst serif=\"font-[family-name:var(--nav-serif)] font-normal tracking-[-.035em]\";\n\nconst EASE=[.16,1,.3,1] as const;\n\nfunction useDisclosure(value: boolean|undefined, defaultValue: boolean, onChange?: (open:boolean)=>void) {\n const [internal,setInternal]=React.useState(defaultValue);const open=value??internal;\n const setOpen=React.useCallback((next:boolean)=>{if(value===undefined)setInternal(next);onChange?.(next);},[value,onChange]);\n return [open,setOpen] as const;\n}\n\nfunction useDismiss(root: React.RefObject<HTMLElement|null>, open:boolean, close:()=>void, trigger?:React.RefObject<HTMLButtonElement|null>) {\n React.useEffect(()=>{if(!open)return;const pointer=(e:PointerEvent)=>{if(root.current&&!root.current.contains(e.target as Node))close();};const key=(e:KeyboardEvent)=>{if(e.key===\"Escape\"){e.preventDefault();close();trigger?.current?.focus();}};const focusOut=(e:FocusEvent)=>{if(root.current&&!root.current.contains(e.target as Node))close();};document.addEventListener(\"pointerdown\",pointer);document.addEventListener(\"keydown\",key);document.addEventListener(\"focusin\",focusOut);return()=>{document.removeEventListener(\"pointerdown\",pointer);document.removeEventListener(\"keydown\",key);document.removeEventListener(\"focusin\",focusOut);};},[open,close,root,trigger]);\n}\n\nfunction subscribeReducedMotion(onChange:()=>void){const query=window.matchMedia(\"(prefers-reduced-motion: reduce)\");query.addEventListener(\"change\",onChange);return()=>query.removeEventListener(\"change\",onChange);}\n\nfunction reducedMotionSnapshot(){return window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;}\n\nfunction serverReducedMotionSnapshot(){return false;}\n\nfunction useReducedMotion(){return React.useSyncExternalStore(subscribeReducedMotion,reducedMotionSnapshot,serverReducedMotionSnapshot);}\n\nexport interface ExpandingCardNavbarProps extends Omit<React.ComponentPropsWithoutRef<\"nav\">,\"onChange\">{\n theme?:NavbarTheme;\n logo?:React.ReactNode;\n logoHref?:string;\n items?:NavbarLink[];\n tagline?:string;\n open?:boolean;\n defaultOpen?:boolean;\n onOpenChange?:(open:boolean)=>void;\n showNumbers?:boolean;\n columns?:1|2;\n onNavigate?:(item:NavbarLink,event:React.MouseEvent<HTMLAnchorElement>)=>void;\n}\nexport function ExpandingCardNavbar({theme=\"dark\",logo=\"Forme.\",logoHref=\"/\",items=DEFAULT_LINKS,tagline=\"Independent minds. Considered work.\",open:controlledOpen,defaultOpen=false,onOpenChange,showNumbers=true,columns=2,onNavigate,className,style,...props}:ExpandingCardNavbarProps){\n const[open,setOpen]=useDisclosure(controlledOpen,defaultOpen,onOpenChange);const reduce=useReducedMotion();const root=React.useRef<HTMLElement>(null);const trigger=React.useRef<HTMLButtonElement>(null);const menu=React.useRef<HTMLDivElement>(null);const id=React.useId();const close=React.useCallback(()=>setOpen(false),[setOpen]);useDismiss(root,open,close,trigger);\n const previousOpen=React.useRef(open);React.useEffect(()=>{const opening=open&&!previousOpen.current;previousOpen.current=open;if(opening)menu.current?.querySelector<HTMLElement>(\"a\")?.focus();},[open]);\n return <nav ref={root} {...props} aria-label={props[\"aria-label\"]??\"Card navigation\"} data-theme={theme} className={cn(\"@container relative z-20 mx-auto max-w-full rounded-[24px] border border-[var(--nav-line)] bg-[var(--nav-panel)] text-[color:var(--nav-ink)] shadow-[0_16px_60px_rgba(0,0,0,.12)] backdrop-blur-xl transition-[width] duration-500 motion-reduce:transition-none\",className)} style={{...palette(theme),width:open?\"100%\":\"min(100%, 360px)\",maxWidth:760,transitionTimingFunction:\"cubic-bezier(.16,1,.3,1)\",...style}}><div className=\"flex min-h-[76px] items-center justify-between gap-4 px-5 @[560px]:px-7\"><a href={logoHref} className={cn(serif,\"text-[30px]\",focus)}>{logo}</a><button ref={trigger} aria-label={open?\"Close card navigation\":\"Open card navigation\"} aria-expanded={open} aria-controls={id} onClick={()=>setOpen(!open)} className={cn(\"flex cursor-pointer items-center gap-3 rounded-full border border-[var(--nav-line)] px-4 py-2.5 text-xs hover:bg-[var(--nav-soft)]\",focus)}>{open?\"Close\":\"Explore\"}<motion.span initial={false} animate={{rotate:open?45:0}} transition={{duration:reduce?0:.25,ease:EASE}}><Plus size={15}/></motion.span></button></div><motion.div ref={menu} id={id} initial={false} animate={{height:open?\"auto\":0,opacity:open?1:0}} transition={{duration:reduce?0:.35,ease:EASE}} inert={!open} aria-hidden={!open} className=\"overflow-hidden\"><div className=\"border-t border-[var(--nav-line)] p-3 @[560px]:p-4\"><div className={cn(\"grid gap-2.5\",columns===2&&\"@[500px]:grid-cols-2\")}>{items.map((item,index)=><motion.a key={item.id} href={item.href} onClick={e=>{onNavigate?.(item,e);setOpen(false);trigger.current?.focus();}} whileHover={reduce?undefined:{y:-2}} transition={{duration:.2,ease:EASE}} className={cn(\"group flex min-h-[152px] flex-col justify-between rounded-[18px] border border-[var(--nav-line)] bg-[var(--nav-soft)] p-5 transition-colors hover:border-[var(--nav-muted)]\",focus)}><div className={cn(\"flex justify-between text-[10px]\",muted)}><span>{showNumbers?`0${index+1}`:\"✦\"}</span>{item.badge?<span className=\"rounded-full border border-[var(--nav-line)] px-2 py-0.5 text-[8px]\">{item.badge}</span>:<ArrowUpRight size={14}/>}</div><div className=\"mt-5\"><span className={cn(serif,\"block text-[32px]\")}>{item.label}</span>{item.description&&<span className={cn(\"mt-2 block text-[11px] leading-5\",muted)}>{item.description}</span>}</div></motion.a>)}</div><div className={cn(\"flex flex-wrap items-center justify-between gap-3 px-2 pt-5 pb-2 text-[10px]\",muted)}><span>{tagline}</span><span>Good things start with a hello.</span></div></div></motion.div></nav>;\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}