Newer
Older
import React from "react";
import "./App.scss";
import TopBar from "./organisms/TopBar";
import BottomBar from "./organisms/BottomBar";
import StandardView from "./pages/StandardView";
import { Switch, Route } from "react-router-dom";
import SignIn from "./pages/SignIn";
import SettingsModal from "./pages/SettingsModal";
showSettings: boolean;
fileView: string;
this.state = {
toggledLeft: false,
toggledRight: false,
fileView: localStorage.getItem("fileView") || "card",
}
componentDidMount() {
document.documentElement.style.fontSize = `${
localStorage.getItem("interfaceSize") || "90"
}%`;
const currentTheme = localStorage.getItem("theme");
if (currentTheme === "light" || currentTheme === "dark") {
document.documentElement.setAttribute("data-theme", currentTheme);
} else {
let mq = window.matchMedia("(prefers-color-scheme: dark)");
mq.addListener((mq) => this.setDarkTheme(mq.matches));
this.setDarkTheme(mq.matches);
window.addEventListener("resize", () => {
if (window.innerWidth !== this.width) {
this.width = window.innerWidth;
this.showOrHideSideBars();
}
});
setDarkTheme(toSet: boolean) {
document.documentElement.setAttribute(
"data-theme",
toSet ? "dark" : "light"
);
}
if (window.innerWidth <= 1024) {
this.setState((state) => ({
toggledLeft: !state.toggledLeft,
if (window.innerWidth <= 1024) {
this.setState((state) => ({
toggledRight: !state.toggledRight,
if (window.innerWidth <= 1024 || this.isTimelineView) {
});
} else {
this.setState({
toggledLeft: true,
}
setFileView(view: string) {
this.setState({ fileView: view });
localStorage.setItem("fileView", view);
}
render() {
const horizontalBarPages = [
{ name: "Dashboard", path: "/dashboard", icon: faHome },
{ name: "Modules", path: "/modules", icon: faChalkboardTeacher },
{ name: "Timeline", path: "/timeline", icon: faCalendarWeek },
{ name: "Exams", path: "/exams", icon: faBookOpen },
<SettingsModal
show={this.state.showSettings}
onHide={() => this.setState({ showSettings: false })}
fileView={this.state.fileView}
onCardViewClick={() => this.setFileView("card")}
onListViewClick={() => this.setFileView("list")}
setDarkTheme={(b) => this.setDarkTheme(b)}
<Switch>
<Route path="/signin">
<SignIn />
</Route>
<Route path="/">
<TopBar
pages={horizontalBarPages}
e.preventDefault();
this.toggleLeftBar();
}}
e.preventDefault();
this.toggleRightBar();
}}
/>
onSettingsClick={() => this.setState({ showSettings: true })}
toggledLeft={this.state.toggledLeft}
toggledRight={this.state.toggledRight}
initTimelineSideBar={() => {
this.isTimelineView = true;
this.showOrHideSideBars();
}}
revertTimelineSideBar={() => {
this.showOrHideSideBars();
}}
this.setState({
toggledLeft: false,
toggledRight: false,
});
fileView={this.state.fileView}
<BottomBar pages={horizontalBarPages} />
</Route>
</Switch>