From b4d856d32f1bbc6eb3c33438da28ff849fb60acc Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Mon, 28 Aug 2023 16:25:01 +0100 Subject: [PATCH] Improved a bit more of the responsiveness and solved a bug --- src/components/BottomBar.tsx | 63 ++++++++++++++++++++++++++++++++++ src/components/High/Layout.tsx | 20 +++++++++-- src/components/Navbar.tsx | 32 ++++++++++++----- src/components/Sidebar.tsx | 5 +-- src/pages/exam.tsx | 7 ++-- src/pages/exercises.tsx | 6 ++-- 6 files changed, 113 insertions(+), 20 deletions(-) create mode 100644 src/components/BottomBar.tsx diff --git a/src/components/BottomBar.tsx b/src/components/BottomBar.tsx new file mode 100644 index 00000000..49968ef3 --- /dev/null +++ b/src/components/BottomBar.tsx @@ -0,0 +1,63 @@ +import clsx from "clsx"; +import {IconType} from "react-icons"; +import {MdSpaceDashboard} from "react-icons/md"; +import {BsFileEarmarkText, BsClockHistory, BsPencil, BsGraphUp} from "react-icons/bs"; +import {RiLogoutBoxFill} from "react-icons/ri"; +import {SlPencil} from "react-icons/sl"; +import {FaAward} from "react-icons/fa"; +import Link from "next/link"; +import {useRouter} from "next/router"; +import axios from "axios"; +import FocusLayer from "@/components/FocusLayer"; +import {preventNavigation} from "@/utils/navigation.disabled"; +interface Props { + path: string; + navDisabled?: boolean; + focusMode?: boolean; + onFocusLayerMouseEnter?: () => void; + className?: string; +} + +interface NavProps { + Icon: IconType; + label: string; + path: string; + keyPath: string; + disabled?: boolean; +} + +const Nav = ({Icon, label, path, keyPath, disabled = false}: NavProps) => ( + + + +); + +export default function BottomBar({path, navDisabled = false, focusMode = false, onFocusLayerMouseEnter, className}: Props) { + const router = useRouter(); + + const logout = async () => { + axios.post("/api/logout").finally(() => { + setTimeout(() => router.reload(), 500); + }); + }; + + const disableNavigation = preventNavigation(navDisabled, focusMode); + + return ( +
+
+
+ {focusMode && } +
+ ); +} diff --git a/src/components/High/Layout.tsx b/src/components/High/Layout.tsx index cd2d5214..b5f86908 100644 --- a/src/components/High/Layout.tsx +++ b/src/components/High/Layout.tsx @@ -1,6 +1,7 @@ import {User} from "@/interfaces/user"; import clsx from "clsx"; import {useRouter} from "next/router"; +import BottomBar from "../BottomBar"; import Navbar from "../Navbar"; import Sidebar from "../Sidebar"; @@ -17,13 +18,26 @@ export default function Layout({user, children, className, navDisabled = false, const router = useRouter(); return ( -
+
+
- +
{children} diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 694b9c26..3c0abe06 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -3,6 +3,10 @@ import Link from "next/link"; import {Avatar} from "primereact/avatar"; import FocusLayer from "@/components/FocusLayer"; import {preventNavigation} from "@/utils/navigation.disabled"; +import {useRouter} from "next/router"; +import axios from "axios"; +import {RiLogoutBoxFill} from "react-icons/ri"; +import {BsPower} from "react-icons/bs"; interface Props { user: User; @@ -14,18 +18,30 @@ interface Props { /* eslint-disable @next/next/no-img-element */ export default function Navbar({user, navDisabled = false, focusMode = false, onFocusLayerMouseEnter}: Props) { const disableNavigation = preventNavigation(navDisabled, focusMode); + const router = useRouter(); + + const logout = async () => { + axios.post("/api/logout").finally(() => { + setTimeout(() => router.reload(), 500); + }); + }; return ( -
-
+
+ EnCoach's Logo -

EnCoach

-
-
- - +

EnCoach

+ +
+ + {user.name} - {user.name} + {user.name} +
{focusMode && } diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index acb60652..e8c296d4 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -15,6 +15,7 @@ interface Props { navDisabled?: boolean; focusMode?: boolean; onFocusLayerMouseEnter?: () => void; + className?: string; } interface NavProps { @@ -37,7 +38,7 @@ const Nav = ({Icon, label, path, keyPath, disabled = false}: NavProps) => ( ); -export default function Sidebar({path, navDisabled = false, focusMode = false, onFocusLayerMouseEnter}: Props) { +export default function Sidebar({path, navDisabled = false, focusMode = false, onFocusLayerMouseEnter, className}: Props) { const router = useRouter(); const logout = async () => { @@ -49,7 +50,7 @@ export default function Sidebar({path, navDisabled = false, focusMode = false, o const disableNavigation = preventNavigation(navDisabled, focusMode); return ( -
+