Newer
Older
import React from "react";
import "./App.scss";
import TopBar from "./organisms/TopBar";
import BottomBar from "./organisms/BottomBar";
import { Redirect, Switch, Route } from "react-router-dom";
import {
faBookOpen,
faEllipsisH,
faCalendarWeek,
faChalkboardTeacher,
} from "@fortawesome/free-solid-svg-icons";
import LeftBar from "./organisms/LeftBar";
type MyState = {
isToggled: boolean;
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class App extends React.Component<{}, MyState> {
constructor(props: {}) {
super(props);
this.state = {isToggled: false};
}
handleIconClick(e: React.MouseEvent<HTMLImageElement>) {
e.preventDefault();
this.setState(state => ({
isToggled: !state.isToggled
}));
}
render() {
const horizontalBarPages = [
{ name: "Courses", path: "/courses", icon: faChalkboardTeacher },
{ name: "Timetable", path: "/timetable", icon: faCalendarWeek },
{ name: "Exams", path: "/exams", icon: faBookOpen },
{ name: "Other", path: "/other", icon: faEllipsisH },
];
const topBarRoutes = horizontalBarPages.map(({ name, path }) => (
<Route path={path} key={name}>
<ExamplePage name={name} />
</Route>
));
return (
<>
<TopBar pages={horizontalBarPages} onIconClick={e => this.handleIconClick(e)}/>
<div id="wrapper" className={this.state.isToggled ? "toggled" : ""}>
<LeftBar />
<Switch>
<Route exact path="/" render={() => <Redirect to="/courses" />} />
{topBarRoutes}
</Switch>
</div>
<BottomBar pages={horizontalBarPages} />
</>
);
}
}