AniX/app/components/Navbar/Navbar.jsx

72 lines
2.3 KiB
JavaScript

"use client"
import Link from "next/link";
import { usePathname } from "next/navigation";
export const Navbar = () => {
const pathname = usePathname();
const isNotAuthorizedStyle = "text-gray-700"
const navLinks = [
{
id: 1,
icon: "material-symbols--home-outline",
iconActive: "material-symbols--home",
title: "Домашняя",
href: "/",
withAuthOnly: false,
mobileMenu: false
},
{
id: 2,
icon: "material-symbols--search",
iconActive: "material-symbols--search",
title: "Поиск",
href: "/search",
withAuthOnly: false,
mobileMenu: false
},
{
id: 3,
icon: "material-symbols--bookmarks-outline",
iconActive: "material-symbols--bookmarks",
title: "Закладки",
href: "/bookmarks",
withAuthOnly: true,
mobileMenu: true
},
{
id: 4,
icon: "material-symbols--favorite-outline",
iconActive: "material-symbols--favorite",
title: "Избранное",
href: "/favorites",
withAuthOnly: true,
mobileMenu: true
},
{
id: 5,
icon: "material-symbols--history",
iconActive: "material-symbols--history",
title: "История",
href: "/history",
withAuthOnly: true,
mobileMenu: true
},
];
return (
<header className="fixed bottom-0 left-0 z-50 w-full text-white bg-black sm:sticky sm:top-0">
<div className="flex items-center justify-between px-4 py-4">
<nav className="flex gap-4">
{navLinks.map((link) => {
return <Link key={link.id} href={link.href} className={`flex-col items-center sm:flex-row ${link.mobileMenu ? "hidden sm:flex" : "flex"}`}><span className={`iconify ${pathname == link.href ? link.iconActive : link.icon} w-6 h-6`}></span><span className={`${pathname == link.href ? "font-bold" : ""} text-xs sm:text-base`}>{link.title}</span></Link>;
})}
</nav>
<Link href="/login" className="flex flex-col items-center gap-1 justify-cen ter sm:flex-row">
<span className={`w-6 h-6 iconify ${pathname == "/login" ? "mdi--user-circle" : "mdi--user-circle-outline"}`}></span>
<span className={`${pathname == "/login" ? "font-bold" : ""} text-xs sm:text-base`}>Войти</span>
</Link>
</div>
</header>
);
};