mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-10-05 12:28:22 +00:00
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
'use client';
|
|
|
|
import Link from 'next/link';
|
|
import { type LucideIcon } from 'lucide-react';
|
|
import { usePathname } from 'next/navigation';
|
|
|
|
import {
|
|
SidebarGroup,
|
|
SidebarGroupContent,
|
|
SidebarMenu,
|
|
SidebarMenuButton,
|
|
SidebarMenuItem,
|
|
} from '@/components/ui/sidebar';
|
|
|
|
export function NavMain({
|
|
items,
|
|
}: {
|
|
items: {
|
|
title: string;
|
|
url: string;
|
|
icon: LucideIcon;
|
|
}[];
|
|
}) {
|
|
const pathname = usePathname();
|
|
|
|
return (
|
|
<SidebarGroup className='px-0'>
|
|
<SidebarGroupContent>
|
|
<SidebarMenu className='gap-1.5'>
|
|
{items.map((item) => (
|
|
<SidebarMenuItem key={item.title}>
|
|
<SidebarMenuButton
|
|
tooltip={item.title}
|
|
asChild
|
|
className='h-11 rounded-xl px-3 text-[0.95rem]'
|
|
isActive={
|
|
item.url === '/'
|
|
? pathname === '/'
|
|
: pathname === item.url ||
|
|
pathname.startsWith(`${item.url}/`)
|
|
}
|
|
>
|
|
<Link href={item.url}>
|
|
<item.icon />
|
|
<span>{item.title}</span>
|
|
</Link>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
))}
|
|
</SidebarMenu>
|
|
</SidebarGroupContent>
|
|
</SidebarGroup>
|
|
);
|
|
}
|