"use client"; import { Check, ChevronsUpDown, FileText, FolderTree, GitBranch, LogOut, Settings, User, } from "lucide-react"; import * as React from "react"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "@/components/ui/breadcrumb"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Separator } from "@/components/ui/separator"; import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarProvider, SidebarRail, SidebarTrigger, } from "@/components/ui/sidebar"; import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { cn } from "@/lib/utils"; // Base nav item - used by simple sidebars type NavItem = { label: string; icon: React.ComponentType>; href: string; isActive?: boolean; // Optional children for submenus (Sidebar3+) children?: NavItem[]; }; // Nav group with optional collapsible state type NavGroup = { title: string; items: NavItem[]; // Optional: default collapsed state (Sidebar2+) defaultOpen?: boolean; }; // User data for footer (Sidebar6+) type UserData = { name: string; email: string; avatar: string; }; // Workspace data for switcher (Sidebar7+) type Workspace = { id: string; name: string; logo: string; plan: string; }; // Complete sidebar data structure type SidebarData = { // Logo/branding (all sidebars) logo: { src: string; alt: string; title: string; description: string; }; // Main navigation groups (all sidebars) navGroups: NavGroup[]; // Footer navigation group (all sidebars) footerGroup: NavGroup; // User data for user footer (Sidebar6+) user?: UserData; // Workspaces for switcher (Sidebar7+) workspaces?: Workspace[]; // Currently active workspace (Sidebar7+) activeWorkspace?: string; }; // Shared sidebar data - works with all sidebar variations const sidebarData: SidebarData = { logo: { src: "/block-media/shadcnblocks/block/logos/ShadcnBlocks-logo.svg", alt: "وندوک", title: "وندوک", description: "CRM فروش B2B", }, navGroups: [], footerGroup: { title: "پشتیبانی", items: [], }, user: { name: "علی رضایی", email: "ali@example.com", avatar: "/block-media/shadcnblocks/block/avatar-6.webp", }, workspaces: [ { id: "1", name: "ShadcnBlocks", logo: "/block-media/shadcnblocks/block/logos/ShadcnBlocks-logo.svg", plan: "سازمانی", }, { id: "2", name: "قالب‌های وندوک", logo: "/block-media/shadcnblocks/block/logos/ShadcnBlocks-logo.svg", plan: "تیم در حال رشد", }, { id: "3", name: "ماژول‌های وندوک", logo: "/block-media/shadcnblocks/block/logos/ShadcnBlocks-logo.svg", plan: "آزمایشی", }, ], activeWorkspace: "1", }; // Helper to get active workspace const getActiveWorkspace = (data: SidebarData): Workspace | undefined => { return data.workspaces?.find((w) => w.id === data.activeWorkspace); }; // Tab-specific navigation content const filesNavItems: NavItem[] = [ { label: "src", icon: FolderTree, href: "#" }, { label: "components", icon: FolderTree, href: "#" }, { label: "pages", icon: FolderTree, href: "#" }, { label: "lib", icon: FolderTree, href: "#" }, { label: "hooks", icon: FolderTree, href: "#" }, { label: "package.json", icon: FileText, href: "#" }, { label: "tsconfig.json", icon: FileText, href: "#" }, { label: "README.md", icon: FileText, href: "#", isActive: true }, { label: "tailwind.config.ts", icon: FileText, href: "#" }, { label: "next.config.js", icon: FileText, href: "#" }, ]; const gitNavItems: NavItem[] = [ { label: "main", icon: GitBranch, href: "#", isActive: true }, { label: "develop", icon: GitBranch, href: "#" }, { label: "feature/sidebar", icon: GitBranch, href: "#" }, { label: "feature/auth", icon: GitBranch, href: "#" }, { label: "feature/dashboard", icon: GitBranch, href: "#" }, { label: "fix/bug-123", icon: GitBranch, href: "#" }, { label: "fix/styling-issues", icon: GitBranch, href: "#" }, { label: "release/v1.0.0", icon: GitBranch, href: "#" }, ]; const settingsNavItems: NavItem[] = [ { label: "عمومی", icon: Settings, href: "#", isActive: true }, { label: "ظاهر", icon: Settings, href: "#" }, { label: "ویرایشگر فیلد", icon: Settings, href: "#" }, { label: "میانبرها", icon: Settings, href: "#" }, { label: "افزونه‌ها", icon: Settings, href: "#" }, { label: "فضاهای کاری", icon: Settings, href: "#" }, { label: "حریم خصوصی", icon: Settings, href: "#" }, { label: "به‌روزرسانی‌ها", icon: Settings, href: "#" }, ]; const WorkspaceSwitcher = ({ workspaces, activeWorkspace, }: { workspaces: Workspace[]; activeWorkspace: Workspace; }) => { const [selected, setSelected] = React.useState(activeWorkspace); return (
{selected.name}
{selected.name} {selected.plan}
فضاهای کاری {workspaces.map((workspace) => ( setSelected(workspace)} className="gap-2 p-2" >
{workspace.name}
{workspace.name} {workspace.id === selected.id && ( )}
))}
); }; const NavList = ({ items, label }: { items: NavItem[]; label: string }) => { return ( {label} {items.map((item) => { const Icon = item.icon; return ( {item.label} ); })} ); }; const NavUser = ({ user }: { user: UserData }) => { return ( {user.name .split(" ") .map((n) => n[0]) .join("")}
{user.name} {user.email}
{user.name .split(" ") .map((n) => n[0]) .join("")}
{user.name} {user.email}
حساب کاربری خروج
); }; const AppSidebar = ({ ...props }: React.ComponentProps) => { const activeWorkspace = getActiveWorkspace(sidebarData); const [activeTab, setActiveTab] = React.useState("files"); return ( {sidebarData.workspaces && activeWorkspace && ( )} {activeTab === "files" && ( )} {activeTab === "git" && ( )} {activeTab === "settings" && ( )} {sidebarData.user && } ); }; interface Sidebar17Props { className?: string; } const Sidebar17 = ({ className }: Sidebar17Props) => { return (
نمای کلی داشبورد
); }; export { Sidebar17 };