mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 22:16:15 +00:00
135 lines
4.6 KiB
TypeScript
135 lines
4.6 KiB
TypeScript
import { NavUser } from '@/components/nav-user';
|
|
import {
|
|
Sidebar,
|
|
SidebarContent,
|
|
SidebarFooter,
|
|
SidebarGroup,
|
|
SidebarGroupContent,
|
|
SidebarHeader,
|
|
SidebarMenu,
|
|
SidebarMenuButton,
|
|
SidebarMenuItem,
|
|
} from '@/components/ui/sidebar';
|
|
import { type NavItem } from '@/types';
|
|
import { Link } from '@inertiajs/react';
|
|
import { BookOpen, CogIcon, Folder, ServerIcon } from 'lucide-react';
|
|
import AppLogo from './app-logo';
|
|
import { Icon } from '@/components/icon';
|
|
|
|
const mainNavItems: NavItem[] = [
|
|
{
|
|
title: 'Servers',
|
|
href: route('servers'),
|
|
icon: ServerIcon,
|
|
},
|
|
{
|
|
title: 'Settings',
|
|
href: route('profile'),
|
|
icon: CogIcon,
|
|
},
|
|
];
|
|
|
|
const footerNavItems: NavItem[] = [
|
|
{
|
|
title: 'Repository',
|
|
href: 'https://github.com/vitodeploy/vito',
|
|
icon: Folder,
|
|
},
|
|
{
|
|
title: 'Documentation',
|
|
href: 'https://vitodeploy.com',
|
|
icon: BookOpen,
|
|
},
|
|
];
|
|
|
|
export function AppSidebar({ secondNavItems, secondNavTitle }: { secondNavItems?: NavItem[]; secondNavTitle?: string }) {
|
|
return (
|
|
<Sidebar collapsible="icon" className="overflow-hidden [&>[data-sidebar=sidebar]]:flex-row">
|
|
{/* This is the first sidebar */}
|
|
{/* We disable collapsible and adjust width to icon. */}
|
|
{/* This will make the sidebar appear as icons. */}
|
|
<Sidebar collapsible="none" className="h-auto !w-[calc(var(--sidebar-width-icon)_+_1px)] border-r">
|
|
<SidebarHeader>
|
|
<SidebarMenu>
|
|
<SidebarMenuItem>
|
|
<SidebarMenuButton size="lg" asChild className="md:h-8 md:p-0">
|
|
<Link href={route('servers')} prefetch>
|
|
<AppLogo />
|
|
</Link>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
</SidebarMenu>
|
|
</SidebarHeader>
|
|
<SidebarContent>
|
|
<SidebarGroup>
|
|
<SidebarGroupContent className="md:px-0">
|
|
<SidebarMenu>
|
|
{mainNavItems.map((item) => (
|
|
<SidebarMenuItem key={item.title}>
|
|
<SidebarMenuButton
|
|
asChild
|
|
isActive={window.location.href.startsWith(item.href)}
|
|
tooltip={{ children: item.title, hidden: false }}
|
|
>
|
|
<Link href={item.href} prefetch>
|
|
{item.icon && <item.icon />}
|
|
<span>{item.title}</span>
|
|
</Link>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
))}
|
|
</SidebarMenu>
|
|
</SidebarGroupContent>
|
|
</SidebarGroup>
|
|
</SidebarContent>
|
|
<SidebarFooter className="hidden md:flex">
|
|
<SidebarMenu>
|
|
{footerNavItems.map((item) => (
|
|
<SidebarMenuItem key={item.title}>
|
|
<SidebarMenuButton asChild tooltip={{ children: item.title, hidden: false }}>
|
|
<a href={item.href} target="_blank" rel="noopener noreferrer">
|
|
{item.icon && <Icon iconNode={item.icon} />}
|
|
<span className="sr-only">{item.title}</span>
|
|
</a>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
))}
|
|
</SidebarMenu>
|
|
<NavUser />
|
|
</SidebarFooter>
|
|
</Sidebar>
|
|
|
|
{/* This is the second sidebar */}
|
|
{/* We enable collapsible and adjust width to icon. */}
|
|
{/* This will make the sidebar appear as icons. */}
|
|
{secondNavItems && secondNavItems.length > 0 && (
|
|
<Sidebar collapsible="none" className="flex flex-1">
|
|
<SidebarHeader className="hidden h-12 border-b p-0 md:flex">
|
|
<div className="flex h-full items-center p-2">
|
|
<span className="max-w-[200px] truncate overflow-ellipsis">{secondNavTitle}</span>
|
|
</div>
|
|
</SidebarHeader>
|
|
<SidebarContent>
|
|
<SidebarGroup>
|
|
<SidebarGroupContent>
|
|
<SidebarMenu>
|
|
{secondNavItems.map((item) => (
|
|
<SidebarMenuItem key={item.title}>
|
|
<SidebarMenuButton asChild isActive={window.location.href.startsWith(item.href)}>
|
|
<Link href={item.href} prefetch>
|
|
{item.icon && <item.icon />}
|
|
<span>{item.title}</span>
|
|
</Link>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
))}
|
|
</SidebarMenu>
|
|
</SidebarGroupContent>
|
|
</SidebarGroup>
|
|
</SidebarContent>
|
|
</Sidebar>
|
|
)}
|
|
</Sidebar>
|
|
);
|
|
}
|