@@ -2,6 +2,8 @@ import * as React from 'react';
22import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu' ;
33import { cva } from 'class-variance-authority' ;
44import { RxChevronDown } from 'react-icons/rx' ;
5+ import Link from 'next/link' ;
6+ import Image from 'next/image' ;
57
68import { cn } from '~/lib/utils' ;
79
@@ -41,13 +43,13 @@ NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName;
4143const NavigationMenuItem = NavigationMenuPrimitive . Item ;
4244
4345const navigationMenuTriggerStyle = cva (
44- 'hover:text-gray-900 focus:bg-gray-100 focus:text-gray-900 group flex max-w-fit rounded-md bg-background transition-colors hover:bg-neutral-100 focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-neutral-100/50 data-[state=open]:bg-neutral-100/50'
46+ 'hover:text-gray-900 focus:bg-gray-100 focus:text-gray-900 group flex max-w-fit rounded-md bg-background transition-colors hover:bg-neutral-100 focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-neutral-100/50 data-[state=open]:bg-neutral-100/50 lg:text-lg '
4547) ;
4648
4749const NavigationMenuTrigger = React . forwardRef <
4850 React . ElementRef < typeof NavigationMenuPrimitive . Trigger > ,
4951 React . ComponentPropsWithoutRef < typeof NavigationMenuPrimitive . Trigger >
50- > ( ( { className, children, title , ...props } , ref ) => (
52+ > ( ( { className, children, ...props } , ref ) => (
5153 < NavigationMenuPrimitive . Trigger
5254 ref = { ref }
5355 className = { cn ( navigationMenuTriggerStyle ( ) , 'group' , className ) }
@@ -86,7 +88,7 @@ const NavigationMenuViewport = React.forwardRef<
8688 < div className = { cn ( 'absolute left-0 top-full flex justify-center' ) } >
8789 < NavigationMenuPrimitive . Viewport
8890 className = { cn (
89- 'origin-top-center border-gray-200 bg-white text-gray -950 relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]' ,
91+ 'origin-top-center text-neutral -950 relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-xl border border-neutral-200 bg-shade-light shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]' ,
9092 className
9193 ) }
9294 ref = { ref }
@@ -109,17 +111,94 @@ const NavigationMenuIndicator = React.forwardRef<
109111 ) }
110112 { ...props }
111113 >
112- < div className = "bg-gray-200 relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md" />
114+ < div className = "relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-neutral-200 shadow-md" />
113115 </ NavigationMenuPrimitive . Indicator >
114116) ) ;
115117NavigationMenuIndicator . displayName =
116118 NavigationMenuPrimitive . Indicator . displayName ;
117119
120+ const NavigationMenuCustomListItem = React . forwardRef <
121+ React . ElementRef < typeof NavigationMenuPrimitive . Item > ,
122+ React . ComponentPropsWithoutRef < typeof NavigationMenuPrimitive . Item > & {
123+ imageDetails ?: {
124+ src : string ;
125+ alt : string ;
126+ href : string ;
127+ } ;
128+ listItems : {
129+ title : string ;
130+ description : string ;
131+ href : string ;
132+ } [ ] ;
133+ triggerName : string ;
134+ }
135+ > ( ( { imageDetails, listItems, triggerName, ...props } , ref ) => {
136+ const imageHeight = listItems . length > 4 ? 4 : listItems . length ;
137+ return (
138+ < NavigationMenuItem { ...props } ref = { ref } >
139+ < NavigationMenuTrigger > { triggerName } </ NavigationMenuTrigger >
140+ < NavigationMenuContent className = "flex gap-4 p-6 xl:gap-6 2xl:gap-8" >
141+ { imageDetails && (
142+ < Link href = { imageDetails . href } passHref legacyBehavior >
143+ < NavigationMenuLink
144+ className = "group relative flex select-none flex-col justify-end overflow-hidden rounded-xl no-underline outline-none"
145+ style = { { minWidth : `${ 70 * imageHeight } px` } }
146+ >
147+ < Image
148+ className = "absolute inset-0 z-0 h-full w-full object-cover transition-transform duration-500 ease-in-out group-hover:scale-125"
149+ alt = ""
150+ src = { imageDetails . src }
151+ width = { 0 }
152+ height = { 0 }
153+ />
154+ < section className = "relative z-30 flex h-3/4 w-full flex-col justify-end bg-gradient-to-b from-primary-500/25 to-primary-500 p-2 focus:shadow-md" >
155+ < h5 className = "!mb-0 origin-bottom-left text-shade-light transition-transform duration-500 ease-in-out group-hover:scale-150" >
156+ { imageDetails . alt + '→' }
157+ </ h5 >
158+ </ section >
159+ </ NavigationMenuLink >
160+ </ Link >
161+ ) }
162+ < ul
163+ className = { cn (
164+ 'grid grid-flow-col auto-rows-max gap-4 xl:gap-6 2xl:gap-8'
165+ ) }
166+ style = { {
167+ gridTemplateRows : `repeat(${ imageHeight } , minmax(0, 1fr))` ,
168+ } }
169+ >
170+ { listItems . map ( ( { title, description, href } , index ) => (
171+ < li key = { index } >
172+ < NavigationMenuLink asChild >
173+ < Link
174+ className = { cn (
175+ 'group block min-w-[12rem] select-none space-y-1 rounded-xl p-3 leading-none no-underline outline-none transition-colors transition-transform duration-500 ease-in-out hover:scale-110 hover:bg-neutral-50 focus:bg-neutral-50'
176+ ) }
177+ href = { href }
178+ >
179+ < h6 className = "font-sans font-semibold leading-none text-shade-dark group-hover:text-primary-500 group-focus:text-primary-500" >
180+ { title }
181+ </ h6 >
182+ < p className = "line-clamp-3 text-sm leading-snug text-neutral-700 group-hover:text-primary-500 group-focus:text-primary-500" >
183+ { description }
184+ </ p >
185+ </ Link >
186+ </ NavigationMenuLink >
187+ </ li >
188+ ) ) }
189+ </ ul >
190+ </ NavigationMenuContent >
191+ </ NavigationMenuItem >
192+ ) ;
193+ } ) ;
194+ NavigationMenuCustomListItem . displayName = 'NavigationMenuCustomListItem' ;
195+
118196export {
119197 navigationMenuTriggerStyle ,
120198 NavigationMenu ,
121199 NavigationMenuList ,
122200 NavigationMenuItem ,
201+ NavigationMenuCustomListItem ,
123202 NavigationMenuContent ,
124203 NavigationMenuTrigger ,
125204 NavigationMenuLink ,
0 commit comments