Files
pasargad/src/components/layout/navbar/index.tsx
T

77 lines
2.3 KiB
TypeScript
Raw Normal View History

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 15:25:14 +03:30
import { t } from '@/locales/translates';
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';
import { usePathname } from 'next/navigation';
import { useState } from 'react';
export default function Navbar() {
const [open, setOpen] = useState(false);
const pathname = usePathname();
const links = [
2025-06-02 15:25:14 +03:30
{ href: '/', label: t('pages_home_title') as string },
{ href: '/about', label: t('pages_about_title') as string },
{ href: '/blog', label: t('pages_contact_title') as string },
{ href: '/contact', label: t('pages_contact_title') as string },
{ href: '/product', label: t('pages_product_title') as string },
{ href: '/project', label: t('pages_project_title') as string },
2025-05-31 18:03:15 +03:30
];
const linkClass = (href: string) =>
2025-06-01 17:31:43 +03:30
pathname === href ? ' text-red-500 font-semibold' : 'text-white';
2025-05-31 18:03:15 +03:30
return (
2025-06-01 17:31:43 +03:30
<nav className="bg-transparent container mx-auto py-11 shrink-0 relative z-10 ">
<div className=" flex items-center justify-between">
2025-06-02 15:25:14 +03:30
<Link href="/" className="text-xl font-bold w-auto h-12 ">
<Image alt="logo" src={images.logo} className="w-auto h-full object-contain" />
</Link>
2025-05-31 18:03:15 +03:30
<ul className="hidden md:flex space-x-6">
{links.map(({ href, label }) => (
<li key={href}>
2025-06-02 15:25:14 +03:30
<Link
href={href}
className={`${linkClass(href)} hover:text-primary-light `}
>
2025-05-31 18:03:15 +03:30
{label}
</Link>
</li>
))}
2025-06-01 17:31:43 +03:30
<li>
2025-06-02 15:25:14 +03:30
<a className="flex gap-2 items-center" href="tel:+098123456789">
<span>xx</span>
<p>+098 123456789</p>
2025-06-01 17:31:43 +03:30
</a>
</li>
2025-05-31 18:03:15 +03:30
</ul>
2025-06-02 15:25:14 +03:30
<button
className="md:hidden text-gray-700"
onClick={() => setOpen(!open)}
>
2025-05-31 18:03:15 +03:30
{open ? <p>x</p> : <p>menu</p>}
</button>
</div>
{open && (
<ul className="md:hidden mt-2 space-y-2 px-2">
{links.map(({ href, label }) => (
<li key={href}>
2025-06-02 15:25:14 +03:30
<Link
href={href}
className={linkClass(href)}
onClick={() => setOpen(false)}
>
2025-05-31 18:03:15 +03:30
{label}
</Link>
</li>
))}
</ul>
)}
</nav>
);
}