Open History to see the last commit
1import type { ComponentType } from "react";
2import { ArchiveIcon, ArrowLeftIcon, Link2Icon, Settings2Icon } from "lucide-react";
3import { useNavigate } from "@tanstack/react-router";
4
5import {
6 SidebarContent,
7 SidebarFooter,
8 SidebarGroup,
9 SidebarMenu,
10 SidebarMenuButton,
11 SidebarMenuItem,
12 SidebarSeparator,
13} from "../ui/sidebar";
14
15export type SettingsSectionPath =
16 | "/settings/general"
17 | "/settings/connections"
18 | "/settings/archived";
19
20export const SETTINGS_NAV_ITEMS: ReadonlyArray<{
21 label: string;
22 to: SettingsSectionPath;
23 icon: ComponentType<{ className?: string }>;
24}> = [
25 { label: "General", to: "/settings/general", icon: Settings2Icon },
26 { label: "Connections", to: "/settings/connections", icon: Link2Icon },
27 { label: "Archive", to: "/settings/archived", icon: ArchiveIcon },
28];
29
30export function SettingsSidebarNav({ pathname }: { pathname: string }) {
31 const navigate = useNavigate();
32
33 return (
34 <>
35 <SidebarContent className="overflow-x-hidden">
36 <SidebarGroup className="px-2 py-3">
37 <SidebarMenu>
38 {SETTINGS_NAV_ITEMS.map((item) => {
39 const Icon = item.icon;
40 const isActive = pathname === item.to;
41 return (
42 <SidebarMenuItem key={item.to}>
43 <SidebarMenuButton
44 size="sm"
45 isActive={isActive}
46 className={
47 isActive
48 ? "gap-2.5 px-2.5 py-2 text-left text-[13px] font-medium text-foreground"
49 : "gap-2.5 px-2.5 py-2 text-left text-[13px] text-muted-foreground/70 hover:text-foreground/80"
50 }
51 onClick={() => void navigate({ to: item.to, replace: true })}
52 >
53 <Icon
54 className={
55 isActive
56 ? "size-4 shrink-0 text-foreground"
57 : "size-4 shrink-0 text-muted-foreground/60"
58 }
59 />
60 <span className="truncate">{item.label}</span>
61 </SidebarMenuButton>
62 </SidebarMenuItem>
63 );
64 })}
65 </SidebarMenu>
66 </SidebarGroup>
67 </SidebarContent>
68
69 <SidebarSeparator />
70 <SidebarFooter className="p-2">
71 <SidebarMenu>
72 <SidebarMenuItem>
73 <SidebarMenuButton
74 size="sm"
75 className="gap-2 px-2 py-2 text-xs text-muted-foreground hover:bg-accent hover:text-foreground"
76 onClick={() => window.history.back()}
77 >
78 <ArrowLeftIcon className="size-4" />
79 <span>Back</span>
80 </SidebarMenuButton>
81 </SidebarMenuItem>
82 </SidebarMenu>
83 </SidebarFooter>
84 </>
85 );
86}