svrjs-nextjs-website/app/(auth)/_components/Sidebar.tsx

66 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-06-20 17:02:11 +02:00
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { AdminLinks } from "@/constants";
import Logo from "@/components/shared/Logo";
2024-06-20 17:02:11 +02:00
const Sidebar = () => {
2024-07-17 20:33:43 +02:00
const pathname = usePathname();
return (
<>
<aside className="sidebar">
<div className="flex size-full flex-col gap-4">
<Link href="/" className="sidebar-logo">
<Logo width={180} height={28} />
2024-07-17 20:33:43 +02:00
</Link>
2024-06-20 17:02:11 +02:00
2024-07-17 20:33:43 +02:00
<nav className="sidebar-nav">
<ul className="sidebar-nav_elements">
2024-07-25 22:09:06 +02:00
{AdminLinks.slice(0, 5).map((link) => {
2024-07-17 20:33:43 +02:00
const isActive = link.url === pathname;
2024-06-20 17:02:11 +02:00
2024-07-17 20:33:43 +02:00
return (
<li
key={link.url}
className={`sidebar-nav_element group ${
isActive ? "bg-white/5" : "text-muted-foreground"
}`}
>
<Link className="sidebar-link" href={link.url}>
<link.icon />
{link.name}
</Link>
</li>
);
})}
</ul>
2024-06-20 17:02:11 +02:00
2024-07-17 20:33:43 +02:00
<ul className="sidebar-nav_elements">
2024-07-25 22:09:06 +02:00
{AdminLinks.slice(5).map((link) => {
2024-07-17 20:33:43 +02:00
const isActive = link.url === pathname;
2024-06-20 17:02:11 +02:00
2024-07-17 20:33:43 +02:00
return (
<li
key={link.url}
className={`sidebar-nav_element group ${
isActive ? "bg-purple-gradient" : "text-muted-foreground"
}`}
>
<Link className="sidebar-link" href={link.url}>
<link.icon />
{link.name}
</Link>
</li>
);
})}
</ul>
</nav>
</div>
</aside>
</>
);
2024-06-20 17:02:11 +02:00
};
export default Sidebar;