|
|
|
@ -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 ( |
|
|
|
|
<aside className="border-r border-zinc-800"> |
|
|
|
|
<div className="border-b border-zinc-800 p-4"> |
|
|
|
@ -24,14 +27,25 @@ export function CourseSidebar(props: CourseSidebarProps) { |
|
|
|
|
|
|
|
|
|
<div className="relative h-full"> |
|
|
|
|
<div className="absolute inset-0 overflow-y-auto [scrollbar-color:#3f3f46_#27272a;]"> |
|
|
|
|
{chapters.map((chapter, index) => ( |
|
|
|
|
{chapters.map((chapter, index) => { |
|
|
|
|
const isActive = activeChapterId === chapter.id; |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<Chapter |
|
|
|
|
key={chapter.id} |
|
|
|
|
isActive={index === 0} |
|
|
|
|
isActive={isActive} |
|
|
|
|
onChapterClick={() => { |
|
|
|
|
if (isActive) { |
|
|
|
|
setActiveChapterId(''); |
|
|
|
|
} else { |
|
|
|
|
setActiveChapterId(chapter.id); |
|
|
|
|
} |
|
|
|
|
}} |
|
|
|
|
index={index + 1} |
|
|
|
|
{...chapter} |
|
|
|
|
/> |
|
|
|
|
))} |
|
|
|
|
); |
|
|
|
|
})} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</aside> |
|
|
|
|