re-add nav menu, to prevent bad wrapping on iphone
noticed that the left-title and right-nav were running into each other on a standard iphone layout... menu fixes this!
This commit is contained in:
parent
a81060d5b8
commit
64d09f040a
1 changed files with 49 additions and 9 deletions
|
@ -1,5 +1,16 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Box, Button, HStack, IconButton } from "@chakra-ui/core";
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
HStack,
|
||||||
|
IconButton,
|
||||||
|
Menu,
|
||||||
|
MenuButton,
|
||||||
|
MenuList,
|
||||||
|
MenuItem,
|
||||||
|
useBreakpointValue,
|
||||||
|
} from "@chakra-ui/core";
|
||||||
|
import { HamburgerIcon } from "@chakra-ui/icons";
|
||||||
import { Link, useLocation } from "react-router-dom";
|
import { Link, useLocation } from "react-router-dom";
|
||||||
import { useAuth0 } from "@auth0/auth0-react";
|
import { useAuth0 } from "@auth0/auth0-react";
|
||||||
import { ChevronLeftIcon } from "@chakra-ui/icons";
|
import { ChevronLeftIcon } from "@chakra-ui/icons";
|
||||||
|
@ -107,14 +118,16 @@ function UserNavBarSection() {
|
||||||
Hi, {username}!
|
Hi, {username}!
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
<NavLinksList>
|
||||||
{id && (
|
{id && (
|
||||||
<NavButton as={Link} to={`/user/${id}/items`}>
|
<NavLinkItem as={Link} to={`/user/${id}/items`}>
|
||||||
Items
|
Items
|
||||||
</NavButton>
|
</NavLinkItem>
|
||||||
)}
|
)}
|
||||||
<NavButton as={Link} to="/modeling">
|
<NavLinkItem as={Link} to="/modeling">
|
||||||
Modeling
|
Modeling
|
||||||
</NavButton>
|
</NavLinkItem>
|
||||||
|
</NavLinksList>
|
||||||
<NavButton onClick={() => logout({ returnTo: window.location.origin })}>
|
<NavButton onClick={() => logout({ returnTo: window.location.origin })}>
|
||||||
Log out
|
Log out
|
||||||
</NavButton>
|
</NavButton>
|
||||||
|
@ -132,6 +145,33 @@ function UserNavBarSection() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function NavLinksList({ children }) {
|
||||||
|
const navStyle = useBreakpointValue({ base: "menu", md: "buttons" });
|
||||||
|
|
||||||
|
if (navStyle === "menu") {
|
||||||
|
return (
|
||||||
|
<Menu>
|
||||||
|
<MenuButton>
|
||||||
|
<NavButton icon={<HamburgerIcon />} />
|
||||||
|
</MenuButton>
|
||||||
|
<MenuList>{children}</MenuList>
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function NavLinkItem(props) {
|
||||||
|
const navStyle = useBreakpointValue({ base: "menu", md: "buttons" });
|
||||||
|
|
||||||
|
if (navStyle === "menu") {
|
||||||
|
return <MenuItem {...props} />;
|
||||||
|
} else {
|
||||||
|
return <NavButton {...props} />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const NavButton = React.forwardRef(({ icon, ...props }, ref) => {
|
const NavButton = React.forwardRef(({ icon, ...props }, ref) => {
|
||||||
const Component = icon ? IconButton : Button;
|
const Component = icon ? IconButton : Button;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue