- Updated the icons;

- Extracted the Layout into its own component;
This commit is contained in:
Tiago Ribeiro
2023-06-15 09:12:13 +01:00
parent ec3157870e
commit 60217e9a66
5 changed files with 281 additions and 278 deletions

View File

@@ -0,0 +1,20 @@
import {User} from "@/interfaces/user";
import Navbar from "../Navbar";
import Sidebar from "../Sidebar";
interface Props {
user: User;
children: React.ReactNode;
}
export default function Layout({user, children}: Props) {
return (
<main className="w-full h-[100vh] flex flex-col bg-mti-gray-smoke">
<Navbar user={user} />
<div className="h-full w-full flex py-4 pb-8 gap-2">
<Sidebar path={window.location.pathname} />
<div className="w-5/6 h-full mr-8 bg-white shadow-md rounded-2xl p-12 flex flex-col gap-12">{children}</div>
</div>
</main>
);
}

View File

@@ -1,7 +1,7 @@
import clsx from "clsx"; import clsx from "clsx";
import {IconType} from "react-icons"; import {IconType} from "react-icons";
import {MdSpaceDashboard} from "react-icons/md"; import {MdSpaceDashboard} from "react-icons/md";
import {BsFileEarmarkText, BsClockHistory} from "react-icons/bs"; import {BsFileEarmarkText, BsClockHistory, BsPencil, BsGraphUp} from "react-icons/bs";
import {RiLogoutBoxFill} from "react-icons/ri"; import {RiLogoutBoxFill} from "react-icons/ri";
import {SlPencil} from "react-icons/sl"; import {SlPencil} from "react-icons/sl";
import {FaAward} from "react-icons/fa"; import {FaAward} from "react-icons/fa";
@@ -46,8 +46,8 @@ export default function Sidebar({path}: Props) {
<div className="flex flex-col gap-3"> <div className="flex flex-col gap-3">
<Nav Icon={MdSpaceDashboard} label="Dashboard" path={path} keyPath="/" /> <Nav Icon={MdSpaceDashboard} label="Dashboard" path={path} keyPath="/" />
<Nav Icon={BsFileEarmarkText} label="Exams" path={path} keyPath="/exam" /> <Nav Icon={BsFileEarmarkText} label="Exams" path={path} keyPath="/exam" />
<Nav Icon={SlPencil} label="Exercises" path={path} keyPath="/exercise" /> <Nav Icon={BsPencil} label="Exercises" path={path} keyPath="/exercise" />
<Nav Icon={FaAward} label="Score" path={path} keyPath="/score" /> <Nav Icon={BsGraphUp} label="Stats" path={path} keyPath="/stats" />
<Nav Icon={BsClockHistory} label="Record" path={path} keyPath="/record" /> <Nav Icon={BsClockHistory} label="Record" path={path} keyPath="/record" />
</div> </div>

View File

@@ -20,6 +20,7 @@ import {v4 as uuidv4} from "uuid";
import useUser from "@/hooks/useUser"; import useUser from "@/hooks/useUser";
import useExamStore from "@/stores/examStore"; import useExamStore from "@/stores/examStore";
import Sidebar from "@/components/Sidebar"; import Sidebar from "@/components/Sidebar";
import Layout from "@/components/High/Layout";
export const getServerSideProps = withIronSessionSsr(({req, res}) => { export const getServerSideProps = withIronSessionSsr(({req, res}) => {
const user = req.session.user; const user = req.session.user;
@@ -208,15 +209,7 @@ export default function Page() {
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
</Head> </Head>
<ToastContainer /> <ToastContainer />
{user && ( {user && <Layout user={user}>{renderScreen()}</Layout>}
<main className="w-full h-[100vh] flex flex-col bg-mti-gray-smoke">
<Navbar user={user} />
<div className="h-full w-full flex py-4 pb-8 gap-2">
<Sidebar path="/exam" />
<div className="w-5/6 h-full mr-8 bg-white shadow-md rounded-2xl p-12 flex flex-col gap-12">{renderScreen()}</div>
</div>
</main>
)}
</> </>
); );
} }

View File

@@ -14,6 +14,7 @@ import {ToastContainer} from "react-toastify";
import {capitalize} from "lodash"; import {capitalize} from "lodash";
import {Module} from "@/interfaces"; import {Module} from "@/interfaces";
import ProgressBar from "@/components/Low/ProgressBar"; import ProgressBar from "@/components/Low/ProgressBar";
import Layout from "@/components/High/Layout";
export const getServerSideProps = withIronSessionSsr(({req, res}) => { export const getServerSideProps = withIronSessionSsr(({req, res}) => {
const user = req.session.user; const user = req.session.user;
@@ -79,11 +80,7 @@ export default function Home() {
</Head> </Head>
<ToastContainer /> <ToastContainer />
{user && ( {user && (
<main className="w-full h-[100vh] flex flex-col bg-mti-gray-smoke"> <Layout user={user}>
<Navbar user={user} />
<div className="h-full w-full flex py-4 pb-8 gap-2">
<Sidebar path="/" />
<div className="w-5/6 h-full mr-8 bg-white shadow-md rounded-2xl p-12 flex flex-col gap-12">
<section className="w-full flex gap-8"> <section className="w-full flex gap-8">
<img src={user.profilePicture} alt={user.name} className="aspect-square h-64 rounded-3xl drop-shadow-xl" /> <img src={user.profilePicture} alt={user.name} className="aspect-square h-64 rounded-3xl drop-shadow-xl" />
<div className="flex flex-col gap-4 py-4 w-full"> <div className="flex flex-col gap-4 py-4 w-full">
@@ -134,11 +131,11 @@ export default function Home() {
<section className="flex flex-col gap-3"> <section className="flex flex-col gap-3">
<span className="font-bold text-lg">Bio</span> <span className="font-bold text-lg">Bio</span>
<span className="text-mti-gray-taupe"> <span className="text-mti-gray-taupe">
Patricia Smith is a dedicated and enthusiastic student. Her passion for knowledge drives her to constantly seek Patricia Smith is a dedicated and enthusiastic student. Her passion for knowledge drives her to constantly seek new
new academic challenges. She is recognized for her exemplary work ethic, active participation in the classroom, academic challenges. She is recognized for her exemplary work ethic, active participation in the classroom, and commitment
and commitment to helping her peers. Her insatiable curiosity has led her to explore a wide range of areas of to helping her peers. Her insatiable curiosity has led her to explore a wide range of areas of study, making her a
study, making her a versatile and adaptable learner. Patricia is a true academic leader, inspiring other students versatile and adaptable learner. Patricia is a true academic leader, inspiring other students to pursue their own
to pursue their own educational goals. educational goals.
</span> </span>
</section> </section>
<section className="flex flex-col gap-3"> <section className="flex flex-col gap-3">
@@ -230,9 +227,7 @@ export default function Home() {
</div> </div>
</div> </div>
</section> </section>
</div> </Layout>
</div>
</main>
)} )}
</> </>
); );

View File

@@ -10,6 +10,7 @@ import Sidebar from "@/components/Sidebar";
import dynamic from "next/dynamic"; import dynamic from "next/dynamic";
import {BsCheckCircleFill, BsMicFill, BsPauseCircle, BsPauseFill, BsPlayCircle, BsPlayFill, BsTrashFill} from "react-icons/bs"; import {BsCheckCircleFill, BsMicFill, BsPauseCircle, BsPauseFill, BsPlayCircle, BsPlayFill, BsTrashFill} from "react-icons/bs";
import {useEffect, useState} from "react"; import {useEffect, useState} from "react";
import Layout from "@/components/High/Layout";
const Waveform = dynamic(() => import("../components/Waveform"), {ssr: false}); const Waveform = dynamic(() => import("../components/Waveform"), {ssr: false});
const ReactMediaRecorder = dynamic(() => import("react-media-recorder").then((mod) => mod.ReactMediaRecorder), { const ReactMediaRecorder = dynamic(() => import("react-media-recorder").then((mod) => mod.ReactMediaRecorder), {
@@ -67,11 +68,7 @@ export default function Page() {
</Head> </Head>
<ToastContainer /> <ToastContainer />
{user && ( {user && (
<main className="w-full h-[100vh] flex flex-col bg-mti-gray-smoke"> <Layout user={user}>
<Navbar user={user} />
<div className="h-full w-full flex py-4 pb-8 gap-2">
<Sidebar path="/exam" />
<div className="w-5/6 h-full mr-8 bg-white shadow-md rounded-2xl p-12 flex flex-col gap-12">
<ReactMediaRecorder <ReactMediaRecorder
audio audio
onStop={(blob) => setMediaBlob(blob)} onStop={(blob) => setMediaBlob(blob)}
@@ -186,9 +183,7 @@ export default function Page() {
</div> </div>
)} )}
/> />
</div> </Layout>
</div>
</main>
)} )}
</> </>
); );