mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-10-30 07:37:39 +00:00
59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
'use client';
|
|
|
|
import * as React from 'react';
|
|
import Link from 'next/link';
|
|
import { LucideIcon } from 'lucide-react';
|
|
import { usePathname } from 'next/navigation';
|
|
|
|
import {
|
|
SidebarGroup,
|
|
SidebarGroupContent,
|
|
SidebarMenu,
|
|
SidebarMenuButton,
|
|
SidebarMenuItem,
|
|
} from '@/components/ui/sidebar';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
export function NavSecondary({
|
|
items,
|
|
className,
|
|
...props
|
|
}: {
|
|
items: {
|
|
title: string;
|
|
url: string;
|
|
icon: LucideIcon;
|
|
}[];
|
|
} & React.ComponentPropsWithoutRef<typeof SidebarGroup>) {
|
|
const pathname = usePathname();
|
|
|
|
return (
|
|
<SidebarGroup className={cn('px-0', className)} {...props}>
|
|
<SidebarGroupContent>
|
|
<SidebarMenu className='gap-1.5'>
|
|
{items.map((item) => (
|
|
<SidebarMenuItem key={item.title}>
|
|
<SidebarMenuButton
|
|
asChild
|
|
tooltip={item.title}
|
|
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>
|
|
);
|
|
}
|