changed navigation logic of side navigator to make sur ebackground goes away
This commit is contained in:
parent
85bfcce921
commit
9ac8958ff4
4 changed files with 67 additions and 71 deletions
|
|
@ -1,16 +1,14 @@
|
||||||
import { AppBar, Box, IconButton, Theme, Toolbar } from "@mui/material";
|
import { AppBar, Box, IconButton, Theme, Toolbar } from "@mui/material";
|
||||||
import { Menu } from "@mui/icons-material";
|
import { Menu } from "@mui/icons-material";
|
||||||
// import classNames from "classnames";
|
|
||||||
import { makeStyles } from "@mui/styles";
|
import { makeStyles } from "@mui/styles";
|
||||||
import { getDarkLogo, getLightLogo, getSignatureAccentColour, hasTransparentLogoBG, hideLogo } from "../services/whiteLabel";
|
import { getDarkLogo, getLightLogo, getSignatureAccentColour, hasTransparentLogoBG, hideLogo } from "../services/whiteLabel";
|
||||||
// import { Link } from "react-router-dom";
|
|
||||||
import { useThemeType } from "../hooks/useThemeType";
|
import { useThemeType } from "../hooks/useThemeType";
|
||||||
import UserMenu from "../user/UserMenu";
|
import UserMenu from "../user/UserMenu";
|
||||||
import { useMobile } from "hooks";
|
import { useMobile } from "hooks";
|
||||||
import HeaderButtons from "./HeaderButtons";
|
import HeaderButtons from "./HeaderButtons";
|
||||||
import { useGlobalState } from "providers";
|
import { useGlobalState } from "providers";
|
||||||
import SideNavigator from "navigation/SideNavigator";
|
import SideNavigator from "navigation/SideNavigator";
|
||||||
import React, { useState } from "react";
|
import { useState } from "react";
|
||||||
import BottomNavigator from "navigation/BottomNavigator";
|
import BottomNavigator from "navigation/BottomNavigator";
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) => ({
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
|
|
@ -87,53 +85,54 @@ interface Props {
|
||||||
|
|
||||||
export default function Header(props: Props) {
|
export default function Header(props: Props) {
|
||||||
|
|
||||||
// const { sideIsOpen, openSide, toggleTheme } = props;
|
// const { sideIsOpen, openSide, toggleTheme } = props;
|
||||||
const { toggleTheme } = props;
|
const { toggleTheme } = props;
|
||||||
const themeType = useThemeType();
|
const themeType = useThemeType();
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const isMobile = useMobile();
|
const isMobile = useMobile();
|
||||||
|
|
||||||
const [{ user, team }] = useGlobalState();
|
const [{ user, team }] = useGlobalState();
|
||||||
const hasTeams = user.hasFeature ? user.hasFeature("teams") : false;
|
const hasTeams = user.hasFeature ? user.hasFeature("teams") : false;
|
||||||
|
|
||||||
const [navOpen, setNavOpen] = useState(false)
|
const [navOpen, setNavOpen] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<>
|
||||||
<AppBar position="fixed" className={classes.appBar}>
|
<AppBar position="fixed" className={classes.appBar}>
|
||||||
<Toolbar disableGutters className={classes.toolbar}>
|
<Toolbar disableGutters className={classes.toolbar}>
|
||||||
<Box className={classes.buttonContainer}>
|
<Box className={classes.buttonContainer}>
|
||||||
{!isMobile && (
|
{!isMobile && (
|
||||||
<IconButton
|
<IconButton
|
||||||
color="inherit"
|
color="inherit"
|
||||||
aria-label="Open side menu"
|
aria-label="Open side menu"
|
||||||
onClick={() => {setNavOpen(true)}}
|
onClick={() => {setNavOpen(true)}}
|
||||||
style={{ color: getSignatureAccentColour() }}
|
style={{ color: getSignatureAccentColour() }}
|
||||||
className={classes.button}>
|
className={classes.button}
|
||||||
<Menu />
|
>
|
||||||
</IconButton>
|
<Menu />
|
||||||
)}
|
</IconButton>
|
||||||
</Box>
|
)}
|
||||||
<Box flexGrow={1} marginLeft={0.5}>
|
</Box>
|
||||||
{!hideLogo() && (
|
<Box flexGrow={1} marginLeft={0.5}>
|
||||||
<div className={classes.logoContainer}>
|
{!hideLogo() && (
|
||||||
<img
|
<div className={classes.logoContainer}>
|
||||||
className={classes.HeaderLogo}
|
<img
|
||||||
src={themeType === "light" ? getDarkLogo() : getLightLogo()}
|
className={classes.HeaderLogo}
|
||||||
alt={import.meta.env.REACT_APP_WEBSITE_TITLE}
|
src={themeType === "light" ? getDarkLogo() : getLightLogo()}
|
||||||
/>
|
alt={import.meta.env.REACT_APP_WEBSITE_TITLE}
|
||||||
</div>
|
/>
|
||||||
)}
|
</div>
|
||||||
</Box>
|
)}
|
||||||
<Box className={classes.appBarRight}>
|
</Box>
|
||||||
<UserMenu toggleTheme={toggleTheme} />
|
<Box className={classes.appBarRight}>
|
||||||
<HeaderButtons hasTeams={hasTeams} team={team} user={user} />
|
<UserMenu toggleTheme={toggleTheme} />
|
||||||
</Box>
|
<HeaderButtons hasTeams={hasTeams} team={team} user={user} />
|
||||||
</Toolbar>
|
</Box>
|
||||||
|
</Toolbar>
|
||||||
|
|
||||||
</AppBar>
|
</AppBar>
|
||||||
<SideNavigator open={navOpen} onOpen={() => {setNavOpen(true)}} onClose={() => {setNavOpen(false)}} />
|
<SideNavigator open={navOpen} onOpen={() => {setNavOpen(true)}} onClose={() => {setNavOpen(false)}} />
|
||||||
{isMobile && <BottomNavigator openSide={() => {setNavOpen(true)}} sideIsOpen={navOpen} />}
|
{isMobile && <BottomNavigator setNavOpen={() => {setNavOpen(true)}} sideIsOpen={navOpen} />}
|
||||||
</React.Fragment>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -25,12 +25,12 @@ import { useAuth0 } from "@auth0/auth0-react";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
sideIsOpen: boolean;
|
sideIsOpen: boolean;
|
||||||
openSide: () => void;
|
setNavOpen: (value: React.SetStateAction<boolean>) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function BottomNavigator(props: Props) {
|
export default function BottomNavigator(props: Props) {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { sideIsOpen, openSide } = props;
|
const { sideIsOpen, setNavOpen } = props;
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const prevLocation = usePrevious(location);
|
const prevLocation = usePrevious(location);
|
||||||
|
|
@ -90,10 +90,11 @@ export default function BottomNavigator(props: Props) {
|
||||||
|
|
||||||
const handleRouteChange = (newRoute: string) => {
|
const handleRouteChange = (newRoute: string) => {
|
||||||
if (newRoute === "more") {
|
if (newRoute === "more") {
|
||||||
openSide();
|
setNavOpen(true);
|
||||||
} else {
|
} else {
|
||||||
navigate(`/${newRoute}`);
|
navigate(`/${newRoute}`);
|
||||||
setRoute(newRoute);
|
setRoute(newRoute);
|
||||||
|
setNavOpen(false)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import classNames from "classnames";
|
||||||
import { useWidth } from "../hooks/useWidth";
|
import { useWidth } from "../hooks/useWidth";
|
||||||
import { makeStyles } from "@mui/styles";
|
import { makeStyles } from "@mui/styles";
|
||||||
import BindaptIcon from "../products/Bindapt/BindaptIcon";
|
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 BinsIcon from "products/Bindapt/BinsIcon";
|
||||||
import { useGlobalState } from "providers";
|
import { useGlobalState } from "providers";
|
||||||
import {
|
import {
|
||||||
|
|
@ -109,6 +109,8 @@ export default function SideNavigator(props: Props) {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const [{ user }] = useGlobalState()
|
const [{ user }] = useGlobalState()
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const getClasses = (page: string) => {
|
const getClasses = (page: string) => {
|
||||||
if (page === "/device") {
|
if (page === "/device") {
|
||||||
if (location.pathname.startsWith("/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 authenticatedSideMenu = () => {
|
||||||
const isMiVent = IsMiVent();
|
const isMiVent = IsMiVent();
|
||||||
return (
|
return (
|
||||||
|
|
@ -135,9 +142,7 @@ export default function SideNavigator(props: Props) {
|
||||||
<Tooltip title="Bins" placement="right">
|
<Tooltip title="Bins" placement="right">
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
id="tour-dashboard"
|
id="tour-dashboard"
|
||||||
component={Link}
|
onClick={() => goTo("/bins")}
|
||||||
to="/bins"
|
|
||||||
onClick={onClose}
|
|
||||||
classes={getClasses("/bin")}
|
classes={getClasses("/bin")}
|
||||||
>
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
|
|
@ -149,9 +154,7 @@ export default function SideNavigator(props: Props) {
|
||||||
<Tooltip title="Devices" placement="right">
|
<Tooltip title="Devices" placement="right">
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
id="tour-dashboard"
|
id="tour-dashboard"
|
||||||
component={Link}
|
onClick={() => goTo("/devices")}
|
||||||
to="/devices"
|
|
||||||
onClick={onClose}
|
|
||||||
classes={getClasses("/device")}
|
classes={getClasses("/device")}
|
||||||
>
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
|
|
@ -164,9 +167,7 @@ export default function SideNavigator(props: Props) {
|
||||||
<Tooltip title="Mines" placement="right">
|
<Tooltip title="Mines" placement="right">
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
id="tour-dashboard"
|
id="tour-dashboard"
|
||||||
component={Link}
|
onClick={() => goTo("/mines")}
|
||||||
to="/mines"
|
|
||||||
onClick={onClose}
|
|
||||||
classes={getClasses("/mine")}
|
classes={getClasses("/mine")}
|
||||||
>
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
|
|
@ -179,10 +180,8 @@ export default function SideNavigator(props: Props) {
|
||||||
<Tooltip title="Teams" placement="right">
|
<Tooltip title="Teams" placement="right">
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
id="tour-dashboard"
|
id="tour-dashboard"
|
||||||
component={Link}
|
onClick={() => goTo("/teams")}
|
||||||
to="/teams"
|
classes={getClasses("/team")}
|
||||||
onClick={onClose}
|
|
||||||
classes={getClasses("/team")}
|
|
||||||
>
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<People />
|
<People />
|
||||||
|
|
@ -193,9 +192,7 @@ export default function SideNavigator(props: Props) {
|
||||||
<Tooltip title="Users" placement="right">
|
<Tooltip title="Users" placement="right">
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
id="tour-dashboard"
|
id="tour-dashboard"
|
||||||
component={Link}
|
onClick={() => goTo("/users")}
|
||||||
to="/users"
|
|
||||||
onClick={onClose}
|
|
||||||
classes={getClasses("/user")}
|
classes={getClasses("/user")}
|
||||||
>
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
|
|
@ -221,9 +218,7 @@ export default function SideNavigator(props: Props) {
|
||||||
open={open}
|
open={open}
|
||||||
onOpen={onOpen}
|
onOpen={onOpen}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
// disableBackdropTransition={!iOS}
|
>
|
||||||
// disableDiscovery={iOS}>
|
|
||||||
>
|
|
||||||
<Toolbar >
|
<Toolbar >
|
||||||
<Grid container direction="row" justifyContent={"flex-end"}>
|
<Grid container direction="row" justifyContent={"flex-end"}>
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ function options(themeType: "light" | "dark"): ThemeOptions {
|
||||||
const highlight = themeType === "light" ? "black" : "white";
|
const highlight = themeType === "light" ? "black" : "white";
|
||||||
const bg = generateBackgroundShades(themeType)
|
const bg = generateBackgroundShades(themeType)
|
||||||
return {
|
return {
|
||||||
|
cssVariables: true,
|
||||||
zIndex: {
|
zIndex: {
|
||||||
modal: 1300,
|
modal: 1300,
|
||||||
popover: 1350
|
popover: 1350
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue