2023-12-31 05:41:55 -05:00
|
|
|
import * as React from "react"
|
|
|
|
import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu"
|
|
|
|
import { cva } from "class-variance-authority"
|
|
|
|
import { ChevronDown } from "lucide-react"
|
|
|
|
|
|
|
|
import { cn } from "@/lib/utils"
|
|
|
|
|
|
|
|
const NavigationMenu = React.forwardRef<
|
|
|
|
React.ElementRef<typeof NavigationMenuPrimitive.Root>,
|
|
|
|
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Root>
|
|
|
|
>(({ className, children, ...props }, ref) => (
|
|
|
|
<NavigationMenuPrimitive.Root
|
|
|
|
ref={ref}
|
|
|
|
className={cn(
|
|
|
|
"relative z-10 flex max-w-max flex-1 items-center justify-center",
|
|
|
|
className
|
|
|
|
)}
|
|
|
|
{...props}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</NavigationMenuPrimitive.Root>
|
|
|
|
))
|
|
|
|
NavigationMenu.displayName = NavigationMenuPrimitive.Root.displayName
|
|
|
|
|
|
|
|
const NavigationMenuList = React.forwardRef<
|
|
|
|
React.ElementRef<typeof NavigationMenuPrimitive.List>,
|
|
|
|
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.List>
|
|
|
|
>(({ className, ...props }, ref) => (
|
|
|
|
<NavigationMenuPrimitive.List
|
|
|
|
ref={ref}
|
|
|
|
className={cn(
|
2024-08-14 16:33:40 -04:00
|
|
|
"group/navList flex flex-1 list-none items-center justify-center space-x-1",
|
2023-12-31 05:41:55 -05:00
|
|
|
className
|
|
|
|
)}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName
|
|
|
|
|
|
|
|
const NavigationMenuItem = NavigationMenuPrimitive.Item
|
|
|
|
|
|
|
|
const navigationMenuTriggerStyle = cva(
|
2024-08-14 16:33:40 -04:00
|
|
|
"group/navTrig inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50"
|
2023-12-31 05:41:55 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
const NavigationMenuTrigger = React.forwardRef<
|
|
|
|
React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
|
|
|
|
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Trigger>
|
|
|
|
>(({ className, children, ...props }, ref) => (
|
|
|
|
<NavigationMenuPrimitive.Trigger
|
|
|
|
ref={ref}
|
2024-08-14 16:33:40 -04:00
|
|
|
className={cn(navigationMenuTriggerStyle(), "group/navTrig", className)}
|
2023-12-31 05:41:55 -05:00
|
|
|
{...props}
|
|
|
|
>
|
|
|
|
{children}{" "}
|
|
|
|
<ChevronDown
|
2024-08-14 16:33:40 -04:00
|
|
|
className="relative top-[1px] ml-1 h-3 w-3 transition duration-300 group-data-[state=open]/navTrig:rotate-180"
|
2023-12-31 05:41:55 -05:00
|
|
|
aria-hidden="true"
|
|
|
|
/>
|
|
|
|
</NavigationMenuPrimitive.Trigger>
|
|
|
|
))
|
|
|
|
NavigationMenuTrigger.displayName = NavigationMenuPrimitive.Trigger.displayName
|
|
|
|
|
|
|
|
const NavigationMenuContent = React.forwardRef<
|
|
|
|
React.ElementRef<typeof NavigationMenuPrimitive.Content>,
|
|
|
|
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Content>
|
|
|
|
>(({ className, ...props }, ref) => (
|
|
|
|
<NavigationMenuPrimitive.Content
|
|
|
|
ref={ref}
|
|
|
|
className={cn(
|
2024-08-14 16:33:40 -04:00
|
|
|
"bg-background rounded-xl mt-1 top-full w-auto data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto",
|
|
|
|
+ "origin-top-center relative mt-2.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow 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)]",
|
2023-12-31 05:41:55 -05:00
|
|
|
className
|
|
|
|
)}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
NavigationMenuContent.displayName = NavigationMenuPrimitive.Content.displayName
|
|
|
|
|
|
|
|
const NavigationMenuLink = NavigationMenuPrimitive.Link
|
|
|
|
|
|
|
|
const NavigationMenuViewport = React.forwardRef<
|
|
|
|
React.ElementRef<typeof NavigationMenuPrimitive.Viewport>,
|
|
|
|
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Viewport>
|
|
|
|
>(({ className, ...props }, ref) => (
|
2024-08-14 16:33:40 -04:00
|
|
|
<div className={cn("absolute left-0 z-30 top-full flex justify-center")}>
|
2023-12-31 05:41:55 -05:00
|
|
|
<NavigationMenuPrimitive.Viewport
|
|
|
|
className={cn(
|
2024-08-14 16:33:40 -04:00
|
|
|
"z-10 origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground 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)]",
|
2023-12-31 05:41:55 -05:00
|
|
|
className
|
|
|
|
)}
|
|
|
|
ref={ref}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
))
|
|
|
|
NavigationMenuViewport.displayName =
|
|
|
|
NavigationMenuPrimitive.Viewport.displayName
|
|
|
|
|
|
|
|
const NavigationMenuIndicator = React.forwardRef<
|
|
|
|
React.ElementRef<typeof NavigationMenuPrimitive.Indicator>,
|
|
|
|
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Indicator>
|
|
|
|
>(({ className, ...props }, ref) => (
|
|
|
|
<NavigationMenuPrimitive.Indicator
|
|
|
|
ref={ref}
|
|
|
|
className={cn(
|
|
|
|
"top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",
|
|
|
|
className
|
|
|
|
)}
|
|
|
|
{...props}
|
|
|
|
>
|
|
|
|
<div className="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" />
|
|
|
|
</NavigationMenuPrimitive.Indicator>
|
|
|
|
))
|
|
|
|
NavigationMenuIndicator.displayName =
|
|
|
|
NavigationMenuPrimitive.Indicator.displayName
|
|
|
|
|
|
|
|
export {
|
|
|
|
navigationMenuTriggerStyle,
|
|
|
|
NavigationMenu,
|
|
|
|
NavigationMenuList,
|
|
|
|
NavigationMenuItem,
|
|
|
|
NavigationMenuContent,
|
|
|
|
NavigationMenuTrigger,
|
|
|
|
NavigationMenuLink,
|
|
|
|
NavigationMenuIndicator,
|
|
|
|
NavigationMenuViewport,
|
|
|
|
}
|