11import * as React from "react"
22import { Press_Start_2P } from "next/font/google"
3+ import { Indicator , Root , Viewport } from "@radix-ui/react-navigation-menu"
34import { cva , VariantProps } from "class-variance-authority"
45
56import { cn } from "@/lib/utils"
@@ -11,7 +12,6 @@ import {
1112 NavigationMenuLink as ShadcnNavigationMenuLink ,
1213 NavigationMenuList as ShadcnNavigationMenuList ,
1314 NavigationMenuTrigger as ShadcnNavigationMenuTrigger ,
14- NavigationMenuViewport as ShadcnNavigationMenuViewport ,
1515} from "@/components/ui/navigation-menu"
1616
1717export { navigationMenuTriggerStyle } from "@/components/ui/navigation-menu"
@@ -44,13 +44,26 @@ export interface BitNavigationMenuProps
4444function NavigationMenu ( {
4545 className,
4646 font,
47+ children,
48+ viewport = true ,
4749 ...props
48- } : React . ComponentProps < typeof ShadcnNavigationMenu > & FontVariantProps ) {
50+ } : React . ComponentProps < typeof Root > & {
51+ viewport ?: boolean
52+ } & FontVariantProps ) {
4953 return (
50- < ShadcnNavigationMenu
51- className = { cn ( font !== "normal" && pressStart . className , className ) }
54+ < Root
55+ data-slot = "navigation-menu"
56+ data-viewport = { viewport }
57+ className = { cn (
58+ "group/navigation-menu relative flex max-w-max flex-1 items-center justify-center" ,
59+ font !== "normal" && pressStart . className ,
60+ className
61+ ) }
5262 { ...props }
53- />
63+ >
64+ { children }
65+ { viewport && < NavigationMenuViewport /> }
66+ </ Root >
5467 )
5568}
5669
@@ -120,13 +133,24 @@ function NavigationMenuViewport({
120133 className,
121134 font,
122135 ...props
123- } : React . ComponentProps < typeof ShadcnNavigationMenuViewport > &
124- FontVariantProps ) {
136+ } : React . ComponentProps < typeof Viewport > & FontVariantProps ) {
125137 return (
126- < ShadcnNavigationMenuViewport
127- className = { cn ( font !== "normal" && pressStart . className , className ) }
128- { ...props }
129- />
138+ < div
139+ className = { cn (
140+ "absolute top-full left-0 isolate z-50 flex justify-center"
141+ ) }
142+ >
143+ < Viewport
144+ data-slot = "navigation-menu-viewport"
145+ className = { cn (
146+ "origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-3 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--radix-navigation-menu-viewport-width)]" ,
147+ font !== "normal" && pressStart . className ,
148+ "shadow-border" ,
149+ className
150+ ) }
151+ { ...props }
152+ />
153+ </ div >
130154 )
131155}
132156
@@ -150,10 +174,17 @@ function NavigationMenuIndicator({
150174} : React . ComponentProps < typeof ShadcnNavigationMenuIndicator > &
151175 FontVariantProps ) {
152176 return (
153- < ShadcnNavigationMenuIndicator
154- className = { cn ( font !== "normal" && pressStart . className , className ) }
177+ < Indicator
178+ data-slot = "navigation-menu-indicator"
179+ className = { cn (
180+ "data-[state=visible]:animate-in data-[state=hidden]:fade-out data-[state=visible]:fade-in top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden" ,
181+ font !== "normal" && pressStart . className ,
182+ className
183+ ) }
155184 { ...props }
156- />
185+ >
186+ < div className = "bg-foreground dark:bg-ring relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md" />
187+ </ Indicator >
157188 )
158189}
159190
0 commit comments