diff --git a/vinvoor/src/navbar/NavBar.tsx b/vinvoor/src/navbar/NavBar.tsx index fa3cd7b..a970ba6 100644 --- a/vinvoor/src/navbar/NavBar.tsx +++ b/vinvoor/src/navbar/NavBar.tsx @@ -5,7 +5,7 @@ import { CreditCardMultipleOutline, CreditCardScanOutline, } from "mdi-material-ui"; -import { useContext } from "react"; +import { useContext, useState } from "react"; import { DarkModeToggle } from "../components/DarkModeToggle"; import { UserContext } from "../providers/UserProvider"; import { NavBarLogo } from "./NavBarLogo"; @@ -30,12 +30,15 @@ const userMenuPages: PageIcon[] = [ export const NavBar = () => { const { user } = useContext(UserContext); + const [selectedPage, setSelectedPage] = useState(""); const screenSize = { mobile: { xs: "flex", md: "none" }, desktop: { xs: "none", md: "flex" }, }; + const handleSelectedPage = (page: string) => setSelectedPage(page); + return ( @@ -43,7 +46,11 @@ export const NavBar = () => { {/* Display either the ZeSS logo or a sandwich menu */} - + {user && ( { )} @@ -70,7 +79,11 @@ export const NavBar = () => { - + diff --git a/vinvoor/src/navbar/NavBarLogo.tsx b/vinvoor/src/navbar/NavBarLogo.tsx index d2a4990..7b953fe 100644 --- a/vinvoor/src/navbar/NavBarLogo.tsx +++ b/vinvoor/src/navbar/NavBarLogo.tsx @@ -6,6 +6,8 @@ import { ThemeContext } from "../providers/ThemeProvider"; interface NavBarLogoProps { sx?: SxProps; + selectedPage?: string; + handleSelectedPage?: (page: string) => void; } const CLICK_AMOUNT = 10; @@ -14,9 +16,15 @@ const CLICK_TIME_MS = 1000; let pressedAmount = 0; let startTimePress = 0; -export const NavBarLogo: FC = ({ sx }) => { +export const NavBarLogo: FC = ({ + sx, + selectedPage, + handleSelectedPage, +}) => { const { setTheme } = useContext(ThemeContext); const handleClick = () => { + if (handleSelectedPage) handleSelectedPage("home"); + if (pressedAmount < CLICK_AMOUNT) { if (pressedAmount === 0) startTimePress = Date.now(); @@ -40,6 +48,12 @@ export const NavBarLogo: FC = ({ sx }) => { ...sx, textTransform: "none", color: "secondary.contrastText", + borderTop: "2px solid transparent", + borderBottom: "2px solid transparent", + ...(selectedPage === "home" && { + borderBottom: theme => + `2px solid ${theme.palette.secondary.main}`, + }), }} > diff --git a/vinvoor/src/navbar/NavBarPages.tsx b/vinvoor/src/navbar/NavBarPages.tsx index 721c1bf..1d626c1 100644 --- a/vinvoor/src/navbar/NavBarPages.tsx +++ b/vinvoor/src/navbar/NavBarPages.tsx @@ -6,16 +6,31 @@ import { PageIcon } from "./NavBar"; interface NavBarPagesProps { pageIcons: readonly PageIcon[]; sx?: SxProps; + selectedPage: string; + handleSelectedPage: (page: string) => void; } -export const NavBarPages: FC = ({ pageIcons, sx }) => { +export const NavBarPages: FC = ({ + pageIcons, + sx, + selectedPage, + handleSelectedPage, +}) => { return ( {pageIcons.map(({ page, icon }) => (