Open History to see the last commit
1import { ExternalLinkIcon } from "lucide-react";
2import {
3 SidebarGroup,
4 SidebarGroupContent,
5 SidebarGroupLabel,
6 SidebarMenu,
7 SidebarMenuItem,
8 SidebarMenuSub,
9 SidebarMenuSubButton,
10 SidebarMenuSubItem,
11} from "@/components/ui/sidebar";
12import { deepDiveArticles, tutorialArticles } from "@/data/tutorial";
13
14type TutorialTableOfContentsProps = {
15 activeStep: string | null;
16 onStepChange: (stepTitle: string) => void;
17};
18
19const sections = [
20 {
21 sectionTitle: "Tutorial",
22 articles: tutorialArticles,
23 },
24 {
25 sectionTitle: "Deep Dive Articles",
26 articles: deepDiveArticles,
27 },
28];
29
30export function TutorialTableOfContents({
31 activeStep,
32 onStepChange,
33}: TutorialTableOfContentsProps) {
34 return (
35 <div className="w-48 shrink-0">
36 <div className="px-2 py-2 mb-2">
37 <a
38 href="https://tanstack.com/db/latest"
39 target="_blank"
40 rel="noreferrer"
41 className="text-foreground font-bold flex items-center text-sm hover:text-primary transition-colors"
42 >
43 Official docs <ExternalLinkIcon className="h-4 ml-1" />
44 </a>
45 </div>
46
47 {sections.map(({ sectionTitle, articles }) => (
48 <SidebarGroup key={sectionTitle} className="px-0 py-1">
49 <SidebarGroupLabel className="text-foreground font-bold text-sm px-2">
50 {sectionTitle}
51 </SidebarGroupLabel>
52 <SidebarGroupContent>
53 <SidebarMenu>
54 <SidebarMenuItem>
55 <SidebarMenuSub className="border-l-muted-foreground/30">
56 {articles.map((step) => (
57 <SidebarMenuSubItem key={step.title}>
58 <SidebarMenuSubButton
59 isActive={activeStep === step.title}
60 onClick={() => onStepChange(step.title)}
61 className="cursor-pointer text-muted-foreground hover:text-foreground data-[active=true]:bg-secondary data-[active=true]:text-primary-foreground h-fit"
62 >
63 {step.title}
64 </SidebarMenuSubButton>
65 </SidebarMenuSubItem>
66 ))}
67 </SidebarMenuSub>
68 </SidebarMenuItem>
69 </SidebarMenu>
70 </SidebarGroupContent>
71 </SidebarGroup>
72 ))}
73 </div>
74 );
75}