aboutsummaryrefslogtreecommitdiff
path: root/components/navbar.tsx
blob: 9286120daf580dc2d1832319ebbf66d8685e11bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { ReactNode } from 'react';

import HomeRoundedIcon from '@material-ui/icons/HomeRounded';
import SearchRoundedIcon from '@material-ui/icons/SearchRounded';

export function NavbarItem(props: {
	icon?: ReactNode;
	title: string;
	href?: string;
	active?: boolean;
	chapterIndent?: number;
	children?: ReactNode;
}) {
	return <a href={props.href} className={
		"navbarItem"
		+ (props.active ? " active" : "")
		+ (typeof props.chapterIndent !== "undefined" ? " chapter" : "")
		+ " indentLevel" + (props.chapterIndent || 0)
	}>
		<div className="inner" style={{
			marginLeft: 12 * props.chapterIndent || 0
		}}>
			{props.icon}
			<span>{props.title}</span>
		</div>
		{props.children}
	</a>
}

export default function Navbar(props: {
	page?: string;
}) {
	return <div style={{ marginBottom: 24 }}>
		<NavbarItem active={props.page == "home"} icon={<HomeRoundedIcon/>} title="Home" href="/"/>
		<NavbarItem active={props.page == "search"} icon={<SearchRoundedIcon/>} title="Search for posts" href="/search"/>
	</div>
}