diff --git a/src/app/Header.tsx b/src/app/Header.tsx index 50f490c..7d4ff70 100644 --- a/src/app/Header.tsx +++ b/src/app/Header.tsx @@ -1,16 +1,14 @@ import { AppBar, Box, IconButton, Theme, Toolbar } from "@mui/material"; import { Menu } from "@mui/icons-material"; -// import classNames from "classnames"; import { makeStyles } from "@mui/styles"; import { getDarkLogo, getLightLogo, getSignatureAccentColour, hasTransparentLogoBG, hideLogo } from "../services/whiteLabel"; -// import { Link } from "react-router-dom"; import { useThemeType } from "../hooks/useThemeType"; import UserMenu from "../user/UserMenu"; import { useMobile } from "hooks"; import HeaderButtons from "./HeaderButtons"; import { useGlobalState } from "providers"; import SideNavigator from "navigation/SideNavigator"; -import React, { useState } from "react"; +import { useState } from "react"; import BottomNavigator from "navigation/BottomNavigator"; const useStyles = makeStyles((theme: Theme) => ({ @@ -87,53 +85,54 @@ interface Props { export default function Header(props: Props) { - // const { sideIsOpen, openSide, toggleTheme } = props; - const { toggleTheme } = props; - const themeType = useThemeType(); - const classes = useStyles() - const isMobile = useMobile(); + // const { sideIsOpen, openSide, toggleTheme } = props; + const { toggleTheme } = props; + const themeType = useThemeType(); + const classes = useStyles() + const isMobile = useMobile(); - const [{ user, team }] = useGlobalState(); - const hasTeams = user.hasFeature ? user.hasFeature("teams") : false; + const [{ user, team }] = useGlobalState(); + const hasTeams = user.hasFeature ? user.hasFeature("teams") : false; - const [navOpen, setNavOpen] = useState(false) + const [navOpen, setNavOpen] = useState(false) - return ( - - - - - {!isMobile && ( - {setNavOpen(true)}} - style={{ color: getSignatureAccentColour() }} - className={classes.button}> - - - )} - - - {!hideLogo() && ( -
- {import.meta.env.REACT_APP_WEBSITE_TITLE} -
- )} -
- - - - - + return ( + <> + + + + {!isMobile && ( + {setNavOpen(true)}} + style={{ color: getSignatureAccentColour() }} + className={classes.button} + > + + + )} + + + {!hideLogo() && ( +
+ {import.meta.env.REACT_APP_WEBSITE_TITLE} +
+ )} +
+ + + + + - - {setNavOpen(true)}} onClose={() => {setNavOpen(false)}} /> - {isMobile && {setNavOpen(true)}} sideIsOpen={navOpen} />} - - ) + + {setNavOpen(true)}} onClose={() => {setNavOpen(false)}} /> + {isMobile && {setNavOpen(true)}} sideIsOpen={navOpen} />} + + ) } \ No newline at end of file diff --git a/src/navigation/BottomNavigator.tsx b/src/navigation/BottomNavigator.tsx index edf3072..928090a 100644 --- a/src/navigation/BottomNavigator.tsx +++ b/src/navigation/BottomNavigator.tsx @@ -25,12 +25,12 @@ import { useAuth0 } from "@auth0/auth0-react"; interface Props { sideIsOpen: boolean; - openSide: () => void; + setNavOpen: (value: React.SetStateAction) => void } export default function BottomNavigator(props: Props) { const theme = useTheme(); - const { sideIsOpen, openSide } = props; + const { sideIsOpen, setNavOpen } = props; const navigate = useNavigate(); const location = useLocation(); const prevLocation = usePrevious(location); @@ -90,10 +90,11 @@ export default function BottomNavigator(props: Props) { const handleRouteChange = (newRoute: string) => { if (newRoute === "more") { - openSide(); + setNavOpen(true); } else { navigate(`/${newRoute}`); setRoute(newRoute); + setNavOpen(false) } }; diff --git a/src/navigation/SideNavigator.tsx b/src/navigation/SideNavigator.tsx index e83655a..130a476 100644 --- a/src/navigation/SideNavigator.tsx +++ b/src/navigation/SideNavigator.tsx @@ -20,7 +20,7 @@ import classNames from "classnames"; import { useWidth } from "../hooks/useWidth"; import { makeStyles } from "@mui/styles"; import BindaptIcon from "../products/Bindapt/BindaptIcon"; -import { Link, useLocation } from "react-router-dom"; +import { useLocation, useNavigate } from "react-router-dom"; import BinsIcon from "products/Bindapt/BinsIcon"; import { useGlobalState } from "providers"; import { @@ -109,6 +109,8 @@ export default function SideNavigator(props: Props) { const location = useLocation(); const [{ user }] = useGlobalState() + const navigate = useNavigate(); + const getClasses = (page: string) => { if (page === "/device") { if (location.pathname.startsWith("/device") || @@ -128,6 +130,11 @@ export default function SideNavigator(props: Props) { }) } + const goTo = (url: string) => { + onClose(); + navigate(url) + } + const authenticatedSideMenu = () => { const isMiVent = IsMiVent(); return ( @@ -135,9 +142,7 @@ export default function SideNavigator(props: Props) { goTo("/bins")} classes={getClasses("/bin")} > @@ -149,9 +154,7 @@ export default function SideNavigator(props: Props) { goTo("/devices")} classes={getClasses("/device")} > @@ -164,9 +167,7 @@ export default function SideNavigator(props: Props) { goTo("/mines")} classes={getClasses("/mine")} > @@ -179,10 +180,8 @@ export default function SideNavigator(props: Props) { goTo("/teams")} + classes={getClasses("/team")} > @@ -193,9 +192,7 @@ export default function SideNavigator(props: Props) { goTo("/users")} classes={getClasses("/user")} > @@ -221,9 +218,7 @@ export default function SideNavigator(props: Props) { open={open} onOpen={onOpen} onClose={onClose} - // disableBackdropTransition={!iOS} - // disableDiscovery={iOS}> - > + > diff --git a/src/theme/theme.ts b/src/theme/theme.ts index 0545e21..360bf3d 100644 --- a/src/theme/theme.ts +++ b/src/theme/theme.ts @@ -30,6 +30,7 @@ function options(themeType: "light" | "dark"): ThemeOptions { const highlight = themeType === "light" ? "black" : "white"; const bg = generateBackgroundShades(themeType) return { + cssVariables: true, zIndex: { modal: 1300, popover: 1350