|
| 1 | +import { Link, Outlet } from "@tanstack/react-router"; |
| 2 | + |
| 3 | +import { Icon, type IconName } from "@/components/ui/icon"; |
| 4 | +import { BlockStack, InlineStack } from "@/components/ui/layout"; |
| 5 | +import { Heading, Text } from "@/components/ui/typography"; |
| 6 | +import { cn } from "@/lib/utils"; |
| 7 | + |
| 8 | +interface SidebarItem { |
| 9 | + to: string; |
| 10 | + label: string; |
| 11 | + icon: IconName; |
| 12 | +} |
| 13 | + |
| 14 | +const SIDEBAR_ITEMS: SidebarItem[] = [ |
| 15 | + { to: "/dashboard/runs", label: "Runs", icon: "Play" }, |
| 16 | + { to: "/dashboard/pipelines", label: "Pipelines", icon: "GitBranch" }, |
| 17 | + { to: "/dashboard/components", label: "Components", icon: "Package" }, |
| 18 | + { to: "/dashboard/favorites", label: "Favorites", icon: "Star" }, |
| 19 | + { to: "/dashboard/recently-viewed", label: "Recently Viewed", icon: "Clock" }, |
| 20 | +]; |
| 21 | + |
| 22 | +export function DashboardLayout() { |
| 23 | + return ( |
| 24 | + <div className="container mx-auto p-6 max-w-6xl"> |
| 25 | + <BlockStack gap="6"> |
| 26 | + <InlineStack gap="2" blockAlign="center"> |
| 27 | + <Heading level={1}>Dashboard</Heading> |
| 28 | + <Text |
| 29 | + as="span" |
| 30 | + size="xs" |
| 31 | + weight="semibold" |
| 32 | + className="px-2 py-1 rounded-full bg-amber-100 text-amber-800" |
| 33 | + > |
| 34 | + Beta |
| 35 | + </Text> |
| 36 | + </InlineStack> |
| 37 | + |
| 38 | + <InlineStack gap="8" blockAlign="start" className="w-full min-h-100"> |
| 39 | + <BlockStack |
| 40 | + gap="1" |
| 41 | + className="w-48 shrink-0 border-r border-border pr-4" |
| 42 | + > |
| 43 | + {SIDEBAR_ITEMS.map((item) => ( |
| 44 | + <Link |
| 45 | + key={item.to} |
| 46 | + to={item.to} |
| 47 | + className="w-full" |
| 48 | + activeProps={{ className: "is-active" }} |
| 49 | + > |
| 50 | + {({ isActive }) => ( |
| 51 | + <div |
| 52 | + className={cn( |
| 53 | + "flex items-center gap-2 w-full px-3 py-2 rounded-md text-sm cursor-pointer hover:bg-accent", |
| 54 | + isActive && "bg-accent font-medium", |
| 55 | + )} |
| 56 | + > |
| 57 | + <Icon name={item.icon} size="sm" /> |
| 58 | + <Text size="sm">{item.label}</Text> |
| 59 | + </div> |
| 60 | + )} |
| 61 | + </Link> |
| 62 | + ))} |
| 63 | + </BlockStack> |
| 64 | + |
| 65 | + <BlockStack className="flex-1 min-w-0"> |
| 66 | + <Outlet /> |
| 67 | + </BlockStack> |
| 68 | + </InlineStack> |
| 69 | + </BlockStack> |
| 70 | + </div> |
| 71 | + ); |
| 72 | +} |
0 commit comments