Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.
feat: add sidebar composition components for navigation, user menu, and team switcher
valzor285c4a0c4ac3
diff --git a/frontend/src/components/app-sidebar.jsx b/frontend/src/components/app-sidebar.jsxnew file mode 100644index 0000000..22db388--- /dev/null+++ b/frontend/src/components/app-sidebar.jsx@@ -0,0 +1,192 @@+import * as React from "react"++import { NavMain } from "@/components/nav-main"+import { NavProjects } from "@/components/nav-projects"+import { NavSecondary } from "@/components/nav-secondary"+import { NavUser } from "@/components/nav-user"+import {+ Sidebar,+ SidebarContent,+ SidebarFooter,+ SidebarHeader,+ SidebarMenu,+ SidebarMenuButton,+ SidebarMenuItem,+} from "@/components/ui/sidebar"+import { TerminalSquareIcon, BotIcon, BookOpenIcon, Settings2Icon, LifeBuoyIcon, SendIcon, FrameIcon, PieChartIcon, MapIcon, TerminalIcon } from "lucide-react"++const data = {+ user: {+ name: "shadcn",+ email: "[email protected]",+ avatar: "/avatars/shadcn.jpg",+ },+ navMain: [+ {+ title: "Playground",+ url: "#",+ icon: (+ <TerminalSquareIcon />+ ),+ isActive: true,+ items: [+ {+ title: "History",+ url: "#",+ },+ {+ title: "Starred",+ url: "#",+ },+ {+ title: "Settings",+ url: "#",+ },+ ],+ },+ {+ title: "Models",+ url: "#",+ icon: (+ <BotIcon />+ ),+ items: [+ {+ title: "Genesis",+ url: "#",+ },+ {+ title: "Explorer",+ url: "#",+ },+ {+ title: "Quantum",+ url: "#",+ },+ ],+ },+ {+ title: "Documentation",+ url: "#",+ icon: (+ <BookOpenIcon />+ ),+ items: [+ {+ title: "Introduction",+ url: "#",+ },+ {+ title: "Get Started",+ url: "#",+ },+ {+ title: "Tutorials",+ url: "#",+ },+ {+ title: "Changelog",+ url: "#",+ },+ ],+ },+ {+ title: "Settings",+ url: "#",+ icon: (+ <Settings2Icon />+ ),+ items: [+ {+ title: "General",+ url: "#",+ },+ {+ title: "Team",+ url: "#",+ },+ {+ title: "Billing",+ url: "#",+ },+ {+ title: "Limits",+ url: "#",+ },+ ],+ },+ ],+ navSecondary: [+ {+ title: "Support",+ url: "#",+ icon: (+ <LifeBuoyIcon />+ ),+ },+ {+ title: "Feedback",+ url: "#",+ icon: (+ <SendIcon />+ ),+ },+ ],+ projects: [+ {+ name: "Design Engineering",+ url: "#",+ icon: (+ <FrameIcon />+ ),+ },+ {+ name: "Sales & Marketing",+ url: "#",+ icon: (+ <PieChartIcon />+ ),+ },+ {+ name: "Travel",+ url: "#",+ icon: (+ <MapIcon />+ ),+ },+ ],+}+export function AppSidebar({+ ...props+}) {+ return (+ <Sidebar+ className="top-(--header-height) h-[calc(100svh-var(--header-height))]!"+ {...props}>+ <SidebarHeader>+ <SidebarMenu>+ <SidebarMenuItem>+ <SidebarMenuButton size="lg" render={<a href="#" />}>+ <div+ className="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">+ <TerminalIcon className="size-4" />+ </div>+ <div className="grid flex-1 text-left text-sm leading-tight">+ <span className="truncate font-medium">Acme Inc</span>+ <span className="truncate text-xs">Enterprise</span>+ </div>+ </SidebarMenuButton>+ </SidebarMenuItem>+ </SidebarMenu>+ </SidebarHeader>+ <SidebarContent>+ <NavMain items={data.navMain} />+ <NavProjects projects={data.projects} />+ <NavSecondary items={data.navSecondary} className="mt-auto" />+ </SidebarContent>+ <SidebarFooter>+ <NavUser user={data.user} />+ </SidebarFooter>+ </Sidebar>+ );+}diff --git a/frontend/src/components/nav-main.jsx b/frontend/src/components/nav-main.jsxnew file mode 100644index 0000000..0ec80d4--- /dev/null+++ b/frontend/src/components/nav-main.jsx@@ -0,0 +1,56 @@+import {+ Collapsible,+ CollapsibleContent,+ CollapsibleTrigger,+} from "@/components/ui/collapsible"+import {+ SidebarGroup,+ SidebarGroupLabel,+ SidebarMenu,+ SidebarMenuAction,+ SidebarMenuButton,+ SidebarMenuItem,+ SidebarMenuSub,+ SidebarMenuSubButton,+ SidebarMenuSubItem,+} from "@/components/ui/sidebar"+import { ChevronRightIcon } from "lucide-react"++export function NavMain({+ items+}) {+ return (+ <SidebarGroup>+ <SidebarGroupLabel>Platform</SidebarGroupLabel>+ <SidebarMenu>+ {items.map((item) => (+ <Collapsible key={item.title} defaultOpen={item.isActive} render={<SidebarMenuItem />}>+ <SidebarMenuButton tooltip={item.title} render={<a href={item.url} />}>+ {item.icon}+ <span>{item.title}</span>+ </SidebarMenuButton>+ {item.items?.length ? (+ <>+ <SidebarMenuAction render={<CollapsibleTrigger />} className="aria-expanded:rotate-90">+ <ChevronRightIcon />+ <span className="sr-only">Toggle</span>+ </SidebarMenuAction>+ <CollapsibleContent>+ <SidebarMenuSub>+ {item.items?.map((subItem) => (+ <SidebarMenuSubItem key={subItem.title}>+ <SidebarMenuSubButton render={<a href={subItem.url} />}>+ <span>{subItem.title}</span>+ </SidebarMenuSubButton>+ </SidebarMenuSubItem>+ ))}+ </SidebarMenuSub>+ </CollapsibleContent>+ </>+ ) : null}+ </Collapsible>+ ))}+ </SidebarMenu>+ </SidebarGroup>+ );+}diff --git a/frontend/src/components/nav-projects.jsx b/frontend/src/components/nav-projects.jsxnew file mode 100644index 0000000..853abe5--- /dev/null+++ b/frontend/src/components/nav-projects.jsx@@ -0,0 +1,71 @@+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu"+import {+ SidebarGroup,+ SidebarGroupLabel,+ SidebarMenu,+ SidebarMenuAction,+ SidebarMenuButton,+ SidebarMenuItem,+ useSidebar,+} from "@/components/ui/sidebar"+import { MoreHorizontalIcon, FolderIcon, ShareIcon, Trash2Icon } from "lucide-react"++export function NavProjects({+ projects+}) {+ const { isMobile } = useSidebar()+ return (+ <SidebarGroup className="group-data-[collapsible=icon]:hidden">+ <SidebarGroupLabel>Projects</SidebarGroupLabel>+ <SidebarMenu>+ {projects.map((item) => (+ <SidebarMenuItem key={item.name}>+ <SidebarMenuButton render={<a href={item.url} />}>+ {item.icon}+ <span>{item.name}</span>+ </SidebarMenuButton>+ <DropdownMenu>+ <DropdownMenuTrigger+ render={+ <SidebarMenuAction showOnHover className="aria-expanded:bg-muted" />+ }>+ <MoreHorizontalIcon />+ <span className="sr-only">More</span>+ </DropdownMenuTrigger>+ <DropdownMenuContent+ className="w-48"+ side={isMobile ? "bottom" : "right"}+ align={isMobile ? "end" : "start"}>+ <DropdownMenuItem>+ <FolderIcon className="text-muted-foreground" />+ <span>View Project</span>+ </DropdownMenuItem>+ <DropdownMenuItem>+ <ShareIcon className="text-muted-foreground" />+ <span>Share Project</span>+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ <DropdownMenuItem>+ <Trash2Icon className="text-muted-foreground" />+ <span>Delete Project</span>+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ </SidebarMenuItem>+ ))}+ <SidebarMenuItem>+ <SidebarMenuButton>+ <MoreHorizontalIcon />+ <span>More</span>+ </SidebarMenuButton>+ </SidebarMenuItem>+ </SidebarMenu>+ </SidebarGroup>+ );+}diff --git a/frontend/src/components/nav-secondary.jsx b/frontend/src/components/nav-secondary.jsxnew file mode 100644index 0000000..850d4a7--- /dev/null+++ b/frontend/src/components/nav-secondary.jsx@@ -0,0 +1,31 @@+import * as React from "react"++import {+ SidebarGroup,+ SidebarGroupContent,+ SidebarMenu,+ SidebarMenuButton,+ SidebarMenuItem,+} from "@/components/ui/sidebar"++export function NavSecondary({+ items,+ ...props+}) {+ return (+ <SidebarGroup {...props}>+ <SidebarGroupContent>+ <SidebarMenu>+ {items.map((item) => (+ <SidebarMenuItem key={item.title}>+ <SidebarMenuButton size="sm" render={<a href={item.url} />}>+ {item.icon}+ <span>{item.title}</span>+ </SidebarMenuButton>+ </SidebarMenuItem>+ ))}+ </SidebarMenu>+ </SidebarGroupContent>+ </SidebarGroup>+ );+}diff --git a/frontend/src/components/nav-user.jsx b/frontend/src/components/nav-user.jsxnew file mode 100644index 0000000..bac81f9--- /dev/null+++ b/frontend/src/components/nav-user.jsx@@ -0,0 +1,100 @@+import {+ Avatar,+ AvatarFallback,+ AvatarImage,+} from "@/components/ui/avatar"+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuGroup,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu"+import {+ SidebarMenu,+ SidebarMenuButton,+ SidebarMenuItem,+ useSidebar,+} from "@/components/ui/sidebar"+import { ChevronsUpDownIcon, SparklesIcon, BadgeCheckIcon, CreditCardIcon, BellIcon, LogOutIcon } from "lucide-react"++export function NavUser({+ user+}) {+ const { isMobile } = useSidebar()+ return (+ <SidebarMenu>+ <SidebarMenuItem>+ <DropdownMenu>+ <DropdownMenuTrigger+ render={+ <SidebarMenuButton+ size="lg"+ className="aria-expanded:bg-muted aria-expanded:text-foreground" />+ }>+ <Avatar>+ <AvatarImage src={user.avatar} alt={user.name} />+ <AvatarFallback>CN</AvatarFallback>+ </Avatar>+ <div className="grid flex-1 text-left text-sm leading-tight">+ <span className="truncate font-medium">{user.name}</span>+ <span className="truncate text-xs">{user.email}</span>+ </div>+ <ChevronsUpDownIcon className="ml-auto size-4" />+ </DropdownMenuTrigger>+ <DropdownMenuContent+ className="min-w-56 rounded-lg"+ side={isMobile ? "bottom" : "right"}+ align="end"+ sideOffset={4}>+ <DropdownMenuGroup>+ <DropdownMenuLabel className="p-0 font-normal">+ <div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">+ <Avatar>+ <AvatarImage src={user.avatar} alt={user.name} />+ <AvatarFallback>CN</AvatarFallback>+ </Avatar>+ <div className="grid flex-1 text-left text-sm leading-tight">+ <span className="truncate font-medium">{user.name}</span>+ <span className="truncate text-xs">{user.email}</span>+ </div>+ </div>+ </DropdownMenuLabel>+ </DropdownMenuGroup>+ <DropdownMenuSeparator />+ <DropdownMenuGroup>+ <DropdownMenuItem>+ <SparklesIcon />+ Upgrade to Pro+ </DropdownMenuItem>+ </DropdownMenuGroup>+ <DropdownMenuSeparator />+ <DropdownMenuGroup>+ <DropdownMenuItem>+ <BadgeCheckIcon />+ Account+ </DropdownMenuItem>+ <DropdownMenuItem>+ <CreditCardIcon />+ Billing+ </DropdownMenuItem>+ <DropdownMenuItem>+ <BellIcon />+ Notifications+ </DropdownMenuItem>+ </DropdownMenuGroup>+ <DropdownMenuSeparator />+ <DropdownMenuGroup>+ <DropdownMenuItem>+ <LogOutIcon />+ Log out+ </DropdownMenuItem>+ </DropdownMenuGroup>+ </DropdownMenuContent>+ </DropdownMenu>+ </SidebarMenuItem>+ </SidebarMenu>+ );+}diff --git a/frontend/src/components/search-form.jsx b/frontend/src/components/search-form.jsxnew file mode 100644index 0000000..6d73802--- /dev/null+++ b/frontend/src/components/search-form.jsx@@ -0,0 +1,20 @@+import { Label } from "@/components/ui/label"+import { SidebarInput } from "@/components/ui/sidebar"+import { SearchIcon } from "lucide-react"++export function SearchForm({+ ...props+}) {+ return (+ <form {...props}>+ <div className="relative">+ <Label htmlFor="search" className="sr-only">+ Search+ </Label>+ <SidebarInput id="search" placeholder="Type to search..." className="h-8 pl-7" />+ <SearchIcon+ className="pointer-events-none absolute top-1/2 left-2 size-4 -translate-y-1/2 opacity-50 select-none" />+ </div>+ </form>+ );+}diff --git a/frontend/src/components/site-header.jsx b/frontend/src/components/site-header.jsxnew file mode 100644index 0000000..2ed589e--- /dev/null+++ b/frontend/src/components/site-header.jsx@@ -0,0 +1,43 @@+import { SearchForm } from "@/components/search-form"+import {+ Breadcrumb,+ BreadcrumbItem,+ BreadcrumbLink,+ BreadcrumbList,+ BreadcrumbPage,+ BreadcrumbSeparator,+} from "@/components/ui/breadcrumb"+import { Button } from "@/components/ui/button"+import { Separator } from "@/components/ui/separator"+import { useSidebar } from "@/components/ui/sidebar"+import { PanelLeftIcon } from "lucide-react"++export function SiteHeader() {+ const { toggleSidebar } = useSidebar()++ return (+ <header+ className="sticky top-0 z-50 flex w-full items-center border-b bg-background">+ <div className="flex h-(--header-height) w-full items-center gap-2 px-4">+ <Button className="h-8 w-8" variant="ghost" size="icon" onClick={toggleSidebar}>+ <PanelLeftIcon />+ </Button>+ <Separator+ orientation="vertical"+ className="mr-2 data-vertical:h-4 data-vertical:self-auto" />+ <Breadcrumb className="hidden sm:block">+ <BreadcrumbList>+ <BreadcrumbItem>+ <BreadcrumbLink href="#">Build Your Application</BreadcrumbLink>+ </BreadcrumbItem>+ <BreadcrumbSeparator />+ <BreadcrumbItem>+ <BreadcrumbPage>Data Fetching</BreadcrumbPage>+ </BreadcrumbItem>+ </BreadcrumbList>+ </Breadcrumb>+ <SearchForm className="w-full sm:ml-auto sm:w-auto" />+ </div>+ </header>+ );+}diff --git a/frontend/src/components/team-switcher.jsx b/frontend/src/components/team-switcher.jsxnew file mode 100644index 0000000..f274072--- /dev/null+++ b/frontend/src/components/team-switcher.jsx@@ -0,0 +1,85 @@+import * as React from "react"++import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuGroup,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuSeparator,+ DropdownMenuShortcut,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu"+import {+ SidebarMenu,+ SidebarMenuButton,+ SidebarMenuItem,+ useSidebar,+} from "@/components/ui/sidebar"+import { ChevronsUpDownIcon, PlusIcon } from "lucide-react"++export function TeamSwitcher({+ teams+}) {+ const { isMobile } = useSidebar()+ const [activeTeam, setActiveTeam] = React.useState(teams[0])+ if (!activeTeam) {+ return null+ }+ return (+ <SidebarMenu>+ <SidebarMenuItem>+ <DropdownMenu>+ <DropdownMenuTrigger+ render={+ <SidebarMenuButton+ size="lg"+ className="data-open:bg-sidebar-accent data-open:text-sidebar-accent-foreground" />+ }>+ <div+ className="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">+ {activeTeam.logo}+ </div>+ <div className="grid flex-1 text-left text-sm leading-tight">+ <span className="truncate font-medium">{activeTeam.name}</span>+ <span className="truncate text-xs">{activeTeam.plan}</span>+ </div>+ <ChevronsUpDownIcon className="ml-auto" />+ </DropdownMenuTrigger>+ <DropdownMenuContent+ className="w-fit"+ align="start"+ side={isMobile ? "bottom" : "right"}+ sideOffset={4}>+ <DropdownMenuGroup>+ <DropdownMenuLabel className="text-xs text-muted-foreground">+ Teams+ </DropdownMenuLabel>+ {teams.map((team, index) => (+ <DropdownMenuItem key={team.name} onClick={() => setActiveTeam(team)} className="gap-2 p-2">+ <div className="flex size-6 items-center justify-center rounded-md border">+ {team.logo}+ </div>+ {team.name}+ <DropdownMenuShortcut>⌘{index + 1}</DropdownMenuShortcut>+ </DropdownMenuItem>+ ))}+ </DropdownMenuGroup>+ <DropdownMenuSeparator />+ <DropdownMenuGroup>+ <DropdownMenuItem className="gap-2 p-2">+ <div+ className="flex size-6 items-center justify-center rounded-md border bg-transparent">+ <PlusIcon className="size-4" />+ </div>+ <div className="font-medium text-muted-foreground">+ Add team+ </div>+ </DropdownMenuItem>+ </DropdownMenuGroup>+ </DropdownMenuContent>+ </DropdownMenu>+ </SidebarMenuItem>+ </SidebarMenu>+ );+}