diff --git a/src/components/mobile-nav.tsx b/src/components/mobile-nav.tsx new file mode 100644 index 0000000..3eeb6d3 --- /dev/null +++ b/src/components/mobile-nav.tsx @@ -0,0 +1,144 @@ +"use client"; + +import * as React from "react"; +import Link, { LinkProps } from "next/link"; +import { useRouter } from "next/navigation"; + +import { cn } from "@/lib/utils"; +import { Icons } from "@/components/icons"; +import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet"; +import { appNavItems, navItems } from "@/constants/data"; +import { Button } from "./ui/button"; +import { ScrollArea } from "./ui/scroll-area"; +import { NavItem } from "@/types"; +import { AlignRight } from "lucide-react"; + +const mobileNavMenu: NavItem[] = [ + { + title: "Courses", + href: "#", + icon: "dashboard", + label: "Courses", + }, + { + title: "Career Paths", + href: "#", + icon: "shieldQuestion", + label: "Career Paths", + }, + { + title: "Community", + href: "#", + icon: "shieldQuestion", + label: "Community", + }, + + { + title: "Pricing", + href: "/pricing", + icon: "profile", + label: "Pricing", + }, +]; + +export function MobileNav() { + const [open, setOpen] = React.useState(false); + + return ( + + + + + + + + Skilld + + +
+ {appNavItems.mainNav.map( + (item) => + item.href && ( + + {item.title} + + ), + )} +
+
+ {appNavItems.sidebarNav.map((item, index) => ( +
+

{item.title}

+ {item?.items?.length && + item.items.map((item) => ( + + {!item.disabled && + (item.href ? ( + + {item.title} + {item.label && ( + + {item.label} + + )} + + ) : ( + item.title + ))} + + ))} +
+ ))} +
+
+
+
+ ); +} + +interface MobileLinkProps extends LinkProps { + onOpenChange?: (open: boolean) => void; + children: React.ReactNode; + className?: string; +} + +function MobileLink({ + href, + onOpenChange, + className, + children, + ...props +}: MobileLinkProps) { + const router = useRouter(); + return ( + { + router.push(href.toString()); + onOpenChange?.(false); + }} + className={cn(className)} + {...props} + > + {children} + + ); +} diff --git a/src/components/navbar.tsx b/src/components/navbar.tsx index b2dd1ae..66a39ff 100644 --- a/src/components/navbar.tsx +++ b/src/components/navbar.tsx @@ -16,6 +16,17 @@ import { } from "@/components/ui/navigation-menu"; import ThemeToggle from "./layout/ThemeToggle/theme-toggle"; import { buttonVariants } from "./ui/button"; +import { + Sheet, + SheetContent, + SheetDescription, + SheetHeader, + SheetTitle, + SheetTrigger, +} from "@/components/ui/sheet"; +import { AlignRight } from "lucide-react"; +import { NavItem } from "@/types"; +import { MobileNav } from "./mobile-nav"; const careerPaths: { title: string; href: string; description: string }[] = [ { @@ -56,6 +67,8 @@ const careerPaths: { title: string; href: string; description: string }[] = [ }, ]; + + export default function Navbar() { return (
@@ -64,7 +77,7 @@ export default function Navbar() {

Skilld

-
+
@@ -145,6 +158,23 @@ export default function Navbar() {
+ +
+ + {/* + + + + + + Skilld + +
+ +
+
+
*/} +
); diff --git a/src/constants/data.ts b/src/constants/data.ts index 434535f..aa04287 100644 --- a/src/constants/data.ts +++ b/src/constants/data.ts @@ -1,4 +1,5 @@ import { NavItem } from "@/types"; +import { MainNavItem, SidebarNavItem } from "@/types/nav"; export type User = { id: number; @@ -131,3 +132,78 @@ export const questions = [ isNiche: false, }, ]; + +interface AppNavItem { + mainNav: MainNavItem[]; + sidebarNav: SidebarNavItem[]; +} + +export const appNavItems: AppNavItem = { + mainNav: [ + { + title: "Pricing", + href: "/pricing", + }, + { + title: "Community", + href: "#", + }, + ], + sidebarNav: [ + { + title: "Courses", + items: [ + { + title: "Python Programming", + href: "#", + items: [], + }, + { + title: "Web Dev With ReactJS", + href: "#", + items: [], + }, + { + title: "Machine Learning Fundamentals", + href: "#", + items: [], + }, + ], + }, + { + title: "Career Paths", + items: [ + { + title: "Frontend Developer", + href: "#", + items: [], + }, + { + title: "Backend Developer", + href: "#", + items: [], + }, + { + title: "Full Stack Developer", + href: "#", + items: [], + }, + { + title: "Mobile App Developer", + href: "#", + items: [], + }, + { + title: "Game Developer", + href: "#", + items: [], + }, + { + title: "Machine Learning Developer", + href: "#", + items: [], + }, + ], + }, + ], +}; diff --git a/src/types/nav.ts b/src/types/nav.ts new file mode 100644 index 0000000..47899fe --- /dev/null +++ b/src/types/nav.ts @@ -0,0 +1,18 @@ +import { Icons } from "@/components/icons" + +export interface NavItem { + title: string + href?: string + disabled?: boolean + external?: boolean + icon?: keyof typeof Icons + label?: string +} + +export interface NavItemWithChildren extends NavItem { + items: NavItemWithChildren[] +} + +export interface MainNavItem extends NavItem {} + +export interface SidebarNavItem extends NavItemWithChildren {} \ No newline at end of file