46 lines
No EOL
1.4 KiB
TypeScript
46 lines
No EOL
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
import { useSidebarStore } from "@/lib/stores/sidebar-store";
|
|
import { usePathname } from "next/navigation";
|
|
import { NavTree } from "./nav-tree";
|
|
import { SidebarHeader } from "./sidebar-header";
|
|
import ChatSidebar from "../chat/ChatSidebar";
|
|
|
|
export function Sidebar({
|
|
onOpenSearch,
|
|
onQuickAction,
|
|
}: {
|
|
onOpenSearch?: () => void;
|
|
onQuickAction?: (type: string) => void;
|
|
}) {
|
|
const pathname = usePathname();
|
|
const isChatRoute = pathname.startsWith("/") && pathname.includes("/chat/");
|
|
const collapsed = useSidebarStore((s) => s.isCollapsed);
|
|
|
|
return (
|
|
<aside
|
|
className={cn(
|
|
"flex h-full shrink-0 flex-col overflow-hidden border-r border-sidebar-border bg-sidebar text-sidebar-foreground transition-[width] duration-200 ease-out",
|
|
collapsed ? "w-12" : "w-[240px]",
|
|
)}
|
|
>
|
|
<SidebarHeader
|
|
collapsed={collapsed}
|
|
onOpenSearch={onOpenSearch}
|
|
onQuickAction={onQuickAction}
|
|
/>
|
|
<div className="min-h-0 flex-1 overflow-hidden">
|
|
{isChatRoute ? (
|
|
<ChatSidebar
|
|
favorites={useSidebarStore.getState().favorites}
|
|
channels={useSidebarStore.getState().channels}
|
|
dms={useSidebarStore.getState().dms}
|
|
/>
|
|
) : (
|
|
<NavTree collapsed={collapsed} />
|
|
)}
|
|
</div>
|
|
</aside>
|
|
);
|
|
} |