From 43347836f7587bd92691d89a97ba552ac646b518 Mon Sep 17 00:00:00 2001 From: munneth Date: Sun, 2 Mar 2025 13:25:50 -0800 Subject: [PATCH 1/3] added component --- components/ui/navigation-menu.tsx | 128 ++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 components/ui/navigation-menu.tsx diff --git a/components/ui/navigation-menu.tsx b/components/ui/navigation-menu.tsx new file mode 100644 index 0000000..b709c4d --- /dev/null +++ b/components/ui/navigation-menu.tsx @@ -0,0 +1,128 @@ +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, + 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 NavigationMenuViewport = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( +
+ +
+)); +NavigationMenuViewport.displayName = + NavigationMenuPrimitive.Viewport.displayName; + +const NavigationMenuIndicator = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +
+ +)); +NavigationMenuIndicator.displayName = + NavigationMenuPrimitive.Indicator.displayName; + +export { + navigationMenuTriggerStyle, + NavigationMenu, + NavigationMenuList, + NavigationMenuItem, + NavigationMenuContent, + NavigationMenuTrigger, + NavigationMenuLink, + NavigationMenuIndicator, + NavigationMenuViewport, +}; From 9e67c6f2964c0a860edcfa17323ae36dcbe2d31b Mon Sep 17 00:00:00 2001 From: munneth Date: Sun, 2 Mar 2025 13:31:38 -0800 Subject: [PATCH 2/3] added storybook --- .../NavigationMenu/NavigationMenu.stories.tsx | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 stories/NavigationMenu/NavigationMenu.stories.tsx diff --git a/stories/NavigationMenu/NavigationMenu.stories.tsx b/stories/NavigationMenu/NavigationMenu.stories.tsx new file mode 100644 index 0000000..17caaf1 --- /dev/null +++ b/stories/NavigationMenu/NavigationMenu.stories.tsx @@ -0,0 +1,117 @@ +import type { Meta, StoryObj } from "@storybook/react"; +import { + NavigationMenu, + NavigationMenuContent, + NavigationMenuItem, + NavigationMenuLink, + NavigationMenuList, + NavigationMenuTrigger, +} from "@/components/ui/navigation-menu"; + +const meta = { + title: "Navigation/NavigationMenu", + component: NavigationMenu, + parameters: { + layout: "centered", + }, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +const drop1 = [ + { title: "Content 1", href: "#", description: "Short description 1" }, + { title: "Content 2", href: "#", description: "Short description 2" }, + { title: "Content 3", href: "#", description: "Short description 3" }, + { title: "Content 4", href: "#", description: "Short description 4" }, + { title: "Content 5", href: "#", description: "Short description 5" }, +]; + +const drop2 = [ + { title: "Content 1", href: "#", description: "Short description 1" }, + { title: "Content 2", href: "#", description: "Short description 2" }, + { title: "Content 3", href: "#", description: "Short description 3" }, + { title: "Content 4", href: "#", description: "Short description 4" }, + { title: "Content 5", href: "#", description: "Short description 5" }, +]; + +const drop3 = [ + { title: "Content 1", href: "#", description: "Short description 1" }, + { title: "Content 2", href: "#", description: "Short description 2" }, + { title: "Content 3", href: "#", description: "Short description 3" }, + { title: "Content 4", href: "#", description: "Short description 4" }, + { title: "Content 5", href: "#", description: "Short description 5" }, +]; + +export const Default: Story = { + render: () => ( + + + + Drop 1 + +
    + {drop1.map((item) => ( + + {item.description} + + ))} +
+
+
+ + + Drop 2 + +
    + {drop2.map((item) => ( + + {item.description} + + ))} +
+
+
+ + + Drop 3 + +
    + {drop3.map((item) => ( + + {item.description} + + ))} +
+
+
+
+
+ ), +}; + +const ListItem = ({ + title, + children, + href, +}: { + title: string; + children: React.ReactNode; + href: string; +}) => { + return ( +
  • + + +
    {title}
    +

    + {children} +

    +
    +
    +
  • + ); +}; From 37c6592dd3c4ba023d4b13a123a9a11297030ba8 Mon Sep 17 00:00:00 2001 From: munneth Date: Sun, 2 Mar 2025 13:34:11 -0800 Subject: [PATCH 3/3] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9c4e2e0..391bcff 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ next-env.d.ts # test directory in app app/test +package-lock.json