add site title to left nav, move Modeling to right
Honestly I don't think this is the long-term home for the Modeling link, I think it'll become a homepage-only link as we add more modules there. But I wanted to get it out of the way!
This commit is contained in:
parent
abda9e4687
commit
34112b30df
1 changed files with 38 additions and 51 deletions
|
@ -1,18 +1,8 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {
|
import { Box, Button, HStack, IconButton } from "@chakra-ui/core";
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
HStack,
|
|
||||||
IconButton,
|
|
||||||
Menu,
|
|
||||||
MenuButton,
|
|
||||||
MenuItem,
|
|
||||||
MenuList,
|
|
||||||
useBreakpointValue,
|
|
||||||
} from "@chakra-ui/core";
|
|
||||||
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, HamburgerIcon } from "@chakra-ui/icons";
|
import { ChevronLeftIcon } from "@chakra-ui/icons";
|
||||||
|
|
||||||
import useCurrentUser from "./components/useCurrentUser";
|
import useCurrentUser from "./components/useCurrentUser";
|
||||||
|
|
||||||
|
@ -20,15 +10,20 @@ import HomeLinkIcon from "../images/home-link-icon.png";
|
||||||
import HomeLinkIcon2x from "../images/home-link-icon@2x.png";
|
import HomeLinkIcon2x from "../images/home-link-icon@2x.png";
|
||||||
|
|
||||||
function GlobalNavBar() {
|
function GlobalNavBar() {
|
||||||
const navStyle = useBreakpointValue({ base: "menu", md: "buttons" });
|
const { pathname } = useLocation();
|
||||||
|
const isHomePage = pathname === "/";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box display="flex" alignItems="center" flexWrap="wrap">
|
<Box display="flex" alignItems="center" flexWrap="wrap">
|
||||||
<HStack alignItems="center" spacing="2" marginRight="4">
|
<HomeLink showArrow={!isHomePage} />
|
||||||
<HomeLink />
|
<Box
|
||||||
{navStyle === "menu" && <NavMenu />}
|
display="flex"
|
||||||
{navStyle === "buttons" && <NavButtons />}
|
alignItems="center"
|
||||||
</HStack>
|
opacity={isHomePage ? "0" : "1"}
|
||||||
|
transition="0.2s opacity"
|
||||||
|
>
|
||||||
|
<DressToImpressTitle marginLeft="2" />
|
||||||
|
</Box>
|
||||||
<Box marginLeft="auto">
|
<Box marginLeft="auto">
|
||||||
<UserNavBarSection />
|
<UserNavBarSection />
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -36,10 +31,7 @@ function GlobalNavBar() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function HomeLink() {
|
function HomeLink({ showArrow }) {
|
||||||
const { pathname } = useLocation();
|
|
||||||
const isHomePage = pathname === "/";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
as={Link}
|
as={Link}
|
||||||
|
@ -56,8 +48,8 @@ function HomeLink() {
|
||||||
<Box
|
<Box
|
||||||
position="absolute"
|
position="absolute"
|
||||||
right="100%"
|
right="100%"
|
||||||
opacity={isHomePage ? "0" : "1"}
|
opacity={showArrow ? "1" : "0"}
|
||||||
transform={isHomePage ? "translateX(3px)" : "none"}
|
transform={showArrow ? "none" : "translateX(3px)"}
|
||||||
transition="all 0.2s"
|
transition="all 0.2s"
|
||||||
>
|
>
|
||||||
<ChevronLeftIcon />
|
<ChevronLeftIcon />
|
||||||
|
@ -104,46 +96,41 @@ function UserNavBarSection() {
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
{id && (
|
{id && (
|
||||||
<NavButton
|
<NavButton as={Link} to={`/user/${id}/items`}>
|
||||||
as={Link}
|
|
||||||
to={`/user/${id}/items`}
|
|
||||||
size="sm"
|
|
||||||
variant="outline"
|
|
||||||
>
|
|
||||||
Items
|
Items
|
||||||
</NavButton>
|
</NavButton>
|
||||||
)}
|
)}
|
||||||
|
<NavButton as={Link} to="/modeling">
|
||||||
|
Modeling
|
||||||
|
</NavButton>
|
||||||
<NavButton onClick={() => logout({ returnTo: window.location.origin })}>
|
<NavButton onClick={() => logout({ returnTo: window.location.origin })}>
|
||||||
Log out
|
Log out
|
||||||
</NavButton>
|
</NavButton>
|
||||||
</HStack>
|
</HStack>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return <NavButton onClick={() => loginWithRedirect()}>Log in</NavButton>;
|
return (
|
||||||
|
<HStack align="center" spacing="2">
|
||||||
|
<NavButton as={Link} to="/modeling">
|
||||||
|
Modeling
|
||||||
|
</NavButton>
|
||||||
|
<NavButton onClick={() => loginWithRedirect()}>Log in</NavButton>
|
||||||
|
</HStack>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function NavMenu() {
|
function DressToImpressTitle(props) {
|
||||||
return (
|
return (
|
||||||
<Menu>
|
<Box
|
||||||
<MenuButton as={NavButton} icon={<HamburgerIcon />} />
|
fontFamily="Delicious"
|
||||||
<MenuList fontSize="sm">
|
fontWeight="bold"
|
||||||
<MenuItem as={Link} to="/">
|
fontSize="2xl"
|
||||||
Home
|
display={{ base: "none", sm: "block" }}
|
||||||
</MenuItem>
|
{...props}
|
||||||
<MenuItem as={Link} to="/modeling">
|
>
|
||||||
Modeling
|
Dress to Impress
|
||||||
</MenuItem>
|
</Box>
|
||||||
</MenuList>
|
|
||||||
</Menu>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function NavButtons() {
|
|
||||||
return (
|
|
||||||
<NavButton as={Link} to="/modeling">
|
|
||||||
Modeling
|
|
||||||
</NavButton>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue