2025-05-31 18:03:15 +03:30
|
|
|
'use client';
|
|
|
|
|
|
2025-06-01 17:31:43 +03:30
|
|
|
import images from '@/assets/images/images';
|
2025-06-02 18:36:20 +03:30
|
|
|
import { Icon } from '@/components/uikit/icons';
|
2025-06-01 17:31:43 +03:30
|
|
|
import Image from 'next/image';
|
2025-05-31 18:03:15 +03:30
|
|
|
import Link from 'next/link';
|
2025-06-07 16:31:52 +03:30
|
|
|
import { usePathname, useParams } from 'next/navigation';
|
2025-05-31 18:03:15 +03:30
|
|
|
import { useState } from 'react';
|
2025-06-02 18:36:20 +03:30
|
|
|
import HamburgerMenu from '../hamburgerMenu';
|
2025-06-07 16:31:52 +03:30
|
|
|
import { useTranslations } from 'next-intl';
|
2025-06-05 16:03:59 +03:30
|
|
|
import routeFactory from '@/assets/constants/routeFactory';
|
2025-05-31 18:03:15 +03:30
|
|
|
|
|
|
|
|
export default function Navbar() {
|
2025-06-08 15:52:05 +03:30
|
|
|
const [open, setOpen] = useState<boolean>(false);
|
2025-05-31 18:03:15 +03:30
|
|
|
const pathname = usePathname();
|
2025-06-07 16:31:52 +03:30
|
|
|
const params = useParams();
|
|
|
|
|
const locale = params.locale as string;
|
|
|
|
|
const t = useTranslations();
|
2025-05-31 18:03:15 +03:30
|
|
|
|
2025-06-07 16:31:52 +03:30
|
|
|
// Get localized routes
|
|
|
|
|
const routes = routeFactory(t, locale);
|
2025-05-31 18:03:15 +03:30
|
|
|
const links = [
|
2025-06-07 16:31:52 +03:30
|
|
|
routes.home,
|
|
|
|
|
routes.productCategories,
|
|
|
|
|
routes.projects,
|
|
|
|
|
routes.blog,
|
|
|
|
|
routes.about,
|
|
|
|
|
routes.contact,
|
2025-05-31 18:03:15 +03:30
|
|
|
];
|
2025-06-07 16:31:52 +03:30
|
|
|
|
2025-06-16 14:02:21 +03:30
|
|
|
const linkClass = (href: string) => {
|
|
|
|
|
let isActive = false;
|
|
|
|
|
if (href === '/' || href === `/${locale}`) {
|
|
|
|
|
isActive = pathname === '/' || pathname === `/${locale}`;
|
|
|
|
|
} else {
|
|
|
|
|
isActive = pathname.startsWith(href);
|
|
|
|
|
}
|
|
|
|
|
return isActive ? 'text-primary font-semibold' : 'text-white';
|
|
|
|
|
};
|
2025-05-31 18:03:15 +03:30
|
|
|
|
|
|
|
|
return (
|
2025-06-02 18:36:20 +03:30
|
|
|
<>
|
2025-06-16 15:21:44 +03:30
|
|
|
<nav className="relative z-50 bg-gradient-to-b from-black to-black/0 pt-7 md:pt-11">
|
|
|
|
|
<div className="container mx-auto flex items-center justify-between border-b-0 border-white/10 pb-6">
|
2025-06-07 16:31:52 +03:30
|
|
|
<Link href={`/${locale}`} className="h-12 w-auto">
|
2025-06-02 18:36:20 +03:30
|
|
|
<Image
|
|
|
|
|
alt="logo"
|
|
|
|
|
src={images.logo}
|
|
|
|
|
className="h-full w-auto object-contain"
|
|
|
|
|
/>
|
|
|
|
|
</Link>
|
|
|
|
|
|
2025-06-19 15:48:47 +03:30
|
|
|
<ul className="hidden space-x-6 text-sm lg:flex lg:text-base">
|
2025-06-05 16:03:59 +03:30
|
|
|
{links.map(({ route, title }) => (
|
|
|
|
|
<li key={route()}>
|
2025-06-02 18:36:20 +03:30
|
|
|
<Link
|
2025-06-05 16:03:59 +03:30
|
|
|
href={route()}
|
|
|
|
|
className={`${linkClass(route())} hover:text-primary-light`}
|
2025-06-02 18:36:20 +03:30
|
|
|
>
|
2025-06-05 16:03:59 +03:30
|
|
|
{title}
|
2025-06-02 18:36:20 +03:30
|
|
|
</Link>
|
|
|
|
|
</li>
|
|
|
|
|
))}
|
|
|
|
|
<li>
|
|
|
|
|
<a className="flex items-center gap-2" href="tel:+098123456789">
|
|
|
|
|
<Icon name="phone" className="text-primary" />
|
|
|
|
|
<p>+098 123456789</p>
|
|
|
|
|
</a>
|
2025-05-31 18:03:15 +03:30
|
|
|
</li>
|
2025-06-02 18:36:20 +03:30
|
|
|
</ul>
|
2025-05-31 18:03:15 +03:30
|
|
|
|
2025-06-02 18:36:20 +03:30
|
|
|
{!open && (
|
|
|
|
|
<button
|
2025-06-19 15:48:47 +03:30
|
|
|
className="text-white lg:hidden"
|
2025-06-02 18:36:20 +03:30
|
|
|
onClick={() => setOpen(true)}
|
|
|
|
|
>
|
|
|
|
|
<Icon name="menu" className="h-6 w-6" />
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</nav>
|
2025-05-31 18:03:15 +03:30
|
|
|
|
2025-06-02 18:36:20 +03:30
|
|
|
<HamburgerMenu isOpen={open} onClose={() => setOpen(false)} />
|
|
|
|
|
</>
|
2025-05-31 18:03:15 +03:30
|
|
|
);
|
|
|
|
|
}
|