diff --git a/libs/shared/ui/src/cuHacking/components/navigation-menu/index.ts b/libs/shared/ui/src/cuHacking/components/navigation-menu/index.ts new file mode 100644 index 00000000..8b3bb7af --- /dev/null +++ b/libs/shared/ui/src/cuHacking/components/navigation-menu/index.ts @@ -0,0 +1 @@ +export { NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, navigationMenuTriggerStyle, NavigationMenuViewport } from './navigation-menu' diff --git a/libs/shared/ui/src/cuHacking/components/navigation-menu/navigation-menu.stories.tsx b/libs/shared/ui/src/cuHacking/components/navigation-menu/navigation-menu.stories.tsx new file mode 100644 index 00000000..d7d32cfa --- /dev/null +++ b/libs/shared/ui/src/cuHacking/components/navigation-menu/navigation-menu.stories.tsx @@ -0,0 +1,42 @@ +import type { Meta, StoryObj } from '@storybook/react' +import React from 'react' +import { + NavigationMenu, + NavigationMenuContent, + NavigationMenuItem, + NavigationMenuLink, + NavigationMenuList, + NavigationMenuTrigger, +} from './navigation-menu' + +const meta = { + title: 'cuHacking Design System/Navigation Menu', + component: NavigationMenu, + tags: ['autodocs'], + parameters: { + layout: 'centered', + }, + args: { + children: ( + + + Products + + View Products + + + + About + + + ), + }, + argTypes: { + children: { control: { disable: true } }, + }, +} satisfies Meta + +export default meta +type Story = StoryObj + +export const Default: Story = {} diff --git a/libs/shared/ui/src/cuHacking/components/navigation-menu/navigation-menu.tsx b/libs/shared/ui/src/cuHacking/components/navigation-menu/navigation-menu.tsx new file mode 100644 index 00000000..0a3ecd58 --- /dev/null +++ b/libs/shared/ui/src/cuHacking/components/navigation-menu/navigation-menu.tsx @@ -0,0 +1,129 @@ +import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu' +import { cn } from '@shadcn/lib/utils' +import { cva } from 'class-variance-authority' +import { ChevronDown } from 'lucide-react' +import * as React from 'react' + +const NavigationMenuViewport = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( +
+ +
+)) +NavigationMenuViewport.displayName + = NavigationMenuPrimitive.Viewport.displayName + +const NavigationMenu = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + {children} + + +)) +NavigationMenu.displayName = NavigationMenuPrimitive.Root.displayName + +const NavigationMenuList = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName + +const NavigationMenuItem = NavigationMenuPrimitive.Item + +const navigationMenuTriggerStyle = cva( + 'group inline-flex h-10 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', +) + +const NavigationMenuTrigger = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + {children} + {' '} + +)) +NavigationMenuTrigger.displayName = NavigationMenuPrimitive.Trigger.displayName + +const NavigationMenuContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +NavigationMenuContent.displayName = NavigationMenuPrimitive.Content.displayName + +const NavigationMenuLink = NavigationMenuPrimitive.Link + +const NavigationMenuIndicator = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +
+ +)) +NavigationMenuIndicator.displayName + = NavigationMenuPrimitive.Indicator.displayName + +export { + NavigationMenu, + NavigationMenuContent, + NavigationMenuIndicator, + NavigationMenuItem, + NavigationMenuLink, + NavigationMenuList, + NavigationMenuTrigger, + // eslint-disable-next-line react-refresh/only-export-components + navigationMenuTriggerStyle, // generated from shadcn + NavigationMenuViewport, +}