@@ -5,7 +5,6 @@ import { cva, VariantProps } from "class-variance-authority"
55
66import { cn } from "@/lib/utils"
77import {
8- NavigationMenu as ShadcnNavigationMenu ,
98 NavigationMenuContent as ShadcnNavigationMenuContent ,
109 NavigationMenuIndicator as ShadcnNavigationMenuIndicator ,
1110 NavigationMenuItem as ShadcnNavigationMenuItem ,
@@ -35,11 +34,8 @@ export const navigationMenuVariants = cva("", {
3534
3635type FontVariantProps = VariantProps < typeof navigationMenuVariants >
3736
38- export interface BitNavigationMenuProps
39- extends React . ComponentProps < typeof ShadcnNavigationMenu > ,
40- VariantProps < typeof navigationMenuVariants > {
41- asChild ?: boolean
42- }
37+ const getFontClassName = ( font : FontVariantProps [ "font" ] ) =>
38+ navigationMenuVariants ( { font } )
4339
4440function NavigationMenu ( {
4541 className,
@@ -56,7 +52,7 @@ function NavigationMenu({
5652 data-viewport = { viewport }
5753 className = { cn (
5854 "group/navigation-menu relative flex max-w-max flex-1 items-center justify-center" ,
59- font !== "normal" && pressStart . className ,
55+ getFontClassName ( font ) ,
6056 className
6157 ) }
6258 { ...props }
@@ -75,7 +71,7 @@ function NavigationMenuList({
7571 VariantProps < typeof navigationMenuVariants > ) {
7672 return (
7773 < ShadcnNavigationMenuList
78- className = { cn ( font !== "normal" && pressStart . className , className ) }
74+ className = { cn ( getFontClassName ( font ) , className ) }
7975 { ...props }
8076 />
8177 )
@@ -88,11 +84,7 @@ function NavigationMenuItem({
8884} : React . ComponentProps < typeof ShadcnNavigationMenuItem > & FontVariantProps ) {
8985 return (
9086 < ShadcnNavigationMenuItem
91- className = { cn (
92- "static" ,
93- font !== "normal" && pressStart . className ,
94- className
95- ) }
87+ className = { cn ( "static" , getFontClassName ( font ) , className ) }
9688 { ...props }
9789 />
9890 )
@@ -106,7 +98,7 @@ function NavigationMenuTrigger({
10698 FontVariantProps ) {
10799 return (
108100 < ShadcnNavigationMenuTrigger
109- className = { cn ( font !== "normal" && pressStart . className , className ) }
101+ className = { cn ( getFontClassName ( font ) , className ) }
110102 { ...props }
111103 />
112104 )
@@ -121,7 +113,7 @@ function NavigationMenuContent({
121113 FontVariantProps ) {
122114 return (
123115 < ShadcnNavigationMenuContent
124- className = { cn ( font !== "normal" && pressStart . className , className ) }
116+ className = { cn ( getFontClassName ( font ) , className ) }
125117 { ...props }
126118 >
127119 { children }
@@ -144,7 +136,7 @@ function NavigationMenuViewport({
144136 data-slot = "navigation-menu-viewport"
145137 className = { cn (
146138 "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 ,
139+ getFontClassName ( font ) ,
148140 "shadow-border" ,
149141 className
150142 ) }
@@ -161,7 +153,7 @@ function NavigationMenuLink({
161153} : React . ComponentProps < typeof ShadcnNavigationMenuLink > & FontVariantProps ) {
162154 return (
163155 < ShadcnNavigationMenuLink
164- className = { cn ( font !== "normal" && pressStart . className , className ) }
156+ className = { cn ( getFontClassName ( font ) , className ) }
165157 { ...props }
166158 />
167159 )
@@ -178,7 +170,7 @@ function NavigationMenuIndicator({
178170 data-slot = "navigation-menu-indicator"
179171 className = { cn (
180172 "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 ,
173+ getFontClassName ( font ) ,
182174 className
183175 ) }
184176 { ...props }
0 commit comments