diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-03-26 22:40:52 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-03-26 22:40:52 +0100 |
commit | edba91f524455dcbb108da56d893290013816087 (patch) | |
tree | fc75bf00c3b17f8eb45df16664930f496b184580 /components/chapters.tsx | |
parent | 6682690a1c8a05bcffc24bcef3c89a14c1762d85 (diff) |
chapter hierarchy thingy working
Diffstat (limited to 'components/chapters.tsx')
-rw-r--r-- | components/chapters.tsx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/components/chapters.tsx b/components/chapters.tsx new file mode 100644 index 0000000..73c1630 --- /dev/null +++ b/components/chapters.tsx @@ -0,0 +1,33 @@ +import { NavbarItem } from '../components/navbar'; + +import RemoveRoundedIcon from '@material-ui/icons/RemoveRounded'; +import KeyboardArrowRightRoundedIcon from '@material-ui/icons/KeyboardArrowRightRounded'; +import KeyboardArrowDownRoundedIcon from '@material-ui/icons/KeyboardArrowDownRounded'; + +interface chapter { + name: string; + sectionLink?: string; + children?: Array<chapter>; +} + +class Chapter { + constructor(public chapters: Array<chapter>, public level: number) {} + render() { + console.log(this) + return <div> + { + this.chapters?.map(chapter => { + return <NavbarItem icon={<RemoveRoundedIcon/>} chapterIndent={this.level} title={chapter.name}> + { new Chapter(chapter.children, this.level + 1).render() } + </NavbarItem> + }) + } + </div> + } +} + +export default function Chapters(props: { + chapters: Array<chapter>; +}) { + return new Chapter(props.chapters, 0).render(); +} |