From edba91f524455dcbb108da56d893290013816087 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 26 Mar 2021 22:40:52 +0100 Subject: chapter hierarchy thingy working --- components/chapters.tsx | 33 +++++++++++++++++++++++++++++++++ components/navbar.tsx | 22 ++++++++++++++++------ 2 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 components/chapters.tsx (limited to 'components') 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; +} + +class Chapter { + constructor(public chapters: Array, public level: number) {} + render() { + console.log(this) + return
+ { + this.chapters?.map(chapter => { + return } chapterIndent={this.level} title={chapter.name}> + { new Chapter(chapter.children, this.level + 1).render() } + + }) + } +
+ } +} + +export default function Chapters(props: { + chapters: Array; +}) { + return new Chapter(props.chapters, 0).render(); +} diff --git a/components/navbar.tsx b/components/navbar.tsx index bdadfbc..9286120 100644 --- a/components/navbar.tsx +++ b/components/navbar.tsx @@ -3,24 +3,34 @@ import { ReactNode } from 'react'; import HomeRoundedIcon from '@material-ui/icons/HomeRounded'; import SearchRoundedIcon from '@material-ui/icons/SearchRounded'; -function NavbarItem(props: { +export function NavbarItem(props: { icon?: ReactNode; title: string; - href: string; - active: boolean; + href?: string; + active?: boolean; + chapterIndent?: number; + children?: ReactNode; }) { - return -
+ return +
{props.icon} {props.title}
+ {props.children}
} export default function Navbar(props: { page?: string; }) { - return
+ return
} title="Home" href="/"/> } title="Search for posts" href="/search"/>
-- cgit v1.2.3