next-enterprise/components/Navbar/Navbar.tsx

107 lines
3 KiB
TypeScript
Raw Normal View History

2023-08-02 12:26:35 +02:00
"use client"
import {
2023-12-12 13:05:09 +01:00
BriefcaseIcon,
EnvelopeIcon,
HomeIcon,
UsersIcon,
} from "@heroicons/react/24/outline"
import {
2023-08-02 12:26:35 +02:00
Navbar,
NavbarBrand,
NavbarContent,
NavbarItem,
NavbarMenu,
NavbarMenuItem,
NavbarMenuToggle,
} from "@nextui-org/react"
2023-12-12 13:05:09 +01:00
2023-08-02 12:26:35 +02:00
import Image from "next/image"
2023-07-28 15:33:57 +02:00
import Link from "next/link"
2023-08-02 12:26:35 +02:00
import { usePathname } from "next/navigation"
import { useState } from "react"
2023-07-28 15:33:57 +02:00
2023-12-12 13:05:09 +01:00
2023-08-02 12:26:35 +02:00
export default function Nav() {
const [isMenuOpen, setIsMenuOpen] = useState<boolean | undefined>(false)
const currentRoute = usePathname()
const menuItems = [
{
label: "Home",
href: "/",
current: currentRoute === "/",
2023-12-12 13:05:09 +01:00
icon: <HomeIcon className="h-6 w-6"/>
2023-08-02 12:26:35 +02:00
},
2023-08-11 17:21:43 +02:00
{
2023-08-25 14:04:07 +02:00
label: "Team",
href: "/team",
current: currentRoute === "/team",
2023-12-12 13:05:09 +01:00
icon: <UsersIcon className="h-6 w-6"/>
2023-08-11 17:21:43 +02:00
},
2023-08-02 12:26:35 +02:00
{
2023-08-25 13:15:58 +02:00
label: "Services",
href: "/services",
current: currentRoute === "/services",
2023-12-12 13:05:09 +01:00
icon: <BriefcaseIcon className="h-6 w-6"/>
2023-08-02 12:26:35 +02:00
},
2023-08-02 15:16:52 +02:00
{
label: "Contact",
href: "/contact",
current: currentRoute === "/contact",
2023-12-12 13:05:09 +01:00
icon: <EnvelopeIcon className="h-6 w-6"/>
2023-08-02 15:16:52 +02:00
},
2023-08-02 12:26:35 +02:00
]
2023-07-12 15:47:01 +02:00
2023-08-02 12:26:35 +02:00
return (
2023-08-25 16:47:43 +02:00
<>
<Navbar
className={`relative ${
isMenuOpen ? "" : "rounded-b-full"
} bg-primary-800 text-primary-50 shadow-sm shadow-primary-600 sm:rounded-b-none`}
isMenuOpen={isMenuOpen || false}
onMenuOpenChange={setIsMenuOpen}
>
<NavbarMenuToggle className="absolute left-8 flex md:hidden" />
<NavbarMenu>
{menuItems.map((item) => (
2023-12-12 16:32:43 +01:00
<NavbarMenuItem key={item.href} className="text-left">
2023-08-25 16:47:43 +02:00
<Link
href={item.href}
aria-current={item.current ? "page" : undefined}
onClick={() => setIsMenuOpen(false)}
>
2023-12-12 16:32:43 +01:00
<div className="flex-row flex my-6 ml-2 space-x-3">
2023-12-12 13:05:09 +01:00
{item.icon}
<span>{item.label}</span>
</div>
2023-08-25 16:47:43 +02:00
</Link>
</NavbarMenuItem>
))}
</NavbarMenu>
<NavbarBrand className="hidden md:flex">
<Image src="/Isacon logo RGB_1.png" alt="Isacon" width={50} height={50} />
</NavbarBrand>
<NavbarContent className="w-full md:hidden" justify="center">
<NavbarBrand className="justify-center md:hidden">
<Image src="/Isacon logo RGB_1.png" alt="Isacon" width={50} height={50} />
</NavbarBrand>
</NavbarContent>
<NavbarContent className="hidden gap-16 md:flex" justify="center">
{menuItems.map((item) => (
<NavbarItem key={item.href} isActive={item.current}>
<Link
className={item.current ? "border-b-2 border-b-primary-50" : ""}
href={item.href}
aria-current={item.current ? "page" : undefined}
>
{item.label}
</Link>
</NavbarItem>
))}
</NavbarContent>
</Navbar>
</>
2023-07-12 15:47:01 +02:00
)
}