diff --git a/src/components/Course/Chapter.tsx b/src/components/Course/Chapter.tsx index 0a1decb40..756283d86 100644 --- a/src/components/Course/Chapter.tsx +++ b/src/components/Course/Chapter.tsx @@ -11,10 +11,19 @@ type ChapterProps = ChapterFileType & { index: number; isActive?: boolean; isCompleted?: boolean; + + onChapterClick?: () => void; }; export function Chapter(props: ChapterProps) { - const { index, frontmatter, lessons, exercises, isActive = false } = props; + const { + index, + frontmatter, + lessons, + exercises, + isActive = false, + onChapterClick, + } = props; const { title } = frontmatter; return ( @@ -24,6 +33,7 @@ export function Chapter(props: ChapterProps) { 'flex w-full items-center gap-2 border-b border-zinc-800 p-2 text-sm', isActive && 'bg-zinc-300 text-zinc-900', )} + onClick={onChapterClick} >
{index} diff --git a/src/components/Course/CourseSidebar.tsx b/src/components/Course/CourseSidebar.tsx index a1b00e0ce..b13a4cb3f 100644 --- a/src/components/Course/CourseSidebar.tsx +++ b/src/components/Course/CourseSidebar.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import type { ChapterFileType } from '../../lib/course'; import { Chapter } from './Chapter'; @@ -11,6 +12,8 @@ export type CourseSidebarProps = { export function CourseSidebar(props: CourseSidebarProps) { const { title, chapters, completedPercentage } = props; + const [activeChapterId, setActiveChapterId] = useState(''); + return (