From bebb8e2d1197306b32040b6d8f9ddffba349692b Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 7 Sep 2020 19:46:11 -0700 Subject: [PATCH] add Modeling link, permanent home link, subtleness --- src/app/PageLayout.js | 74 ++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/src/app/PageLayout.js b/src/app/PageLayout.js index a3a1a01..49d5a1e 100644 --- a/src/app/PageLayout.js +++ b/src/app/PageLayout.js @@ -1,6 +1,6 @@ import React from "react"; import { Box, Button, HStack, IconButton, useColorMode } from "@chakra-ui/core"; -import { Link } from "react-router-dom"; +import { Link, useLocation } from "react-router-dom"; import { useAuth0 } from "@auth0/auth0-react"; import { ChevronLeftIcon, MoonIcon, SunIcon } from "@chakra-ui/icons"; @@ -9,7 +9,7 @@ import useCurrentUser from "./components/useCurrentUser"; import HomeLinkIcon from "../images/home-link-icon.png"; import HomeLinkIcon2x from "../images/home-link-icon@2x.png"; -function PageLayout({ children, hideHomeLink }) { +function PageLayout({ children }) { return ( - {!hideHomeLink && } - + + + + Modeling + + + + + {children} @@ -30,6 +37,9 @@ function PageLayout({ children, hideHomeLink }) { } function HomeLink() { + const { pathname } = useLocation(); + const isHomePage = pathname === "/"; + return ( - + ); } -function UserLoginLogout(props) { +function UserNavBarSection() { const { isLoading, isAuthenticated, loginWithRedirect, logout } = useAuth0(); const { id, username } = useCurrentUser(); @@ -81,7 +97,7 @@ function UserLoginLogout(props) { if (isAuthenticated) { return ( - + {username && ( Hi, {username}! @@ -89,31 +105,25 @@ function UserLoginLogout(props) { )} {id && ( - + )} - + ); } else { return ( - + - + loginWithRedirect()}>Log in ); } @@ -123,16 +133,28 @@ function ColorModeToggleButton() { const { colorMode, toggleColorMode } = useColorMode(); return ( - : } onClick={toggleColorMode} - variant="outline" - size="sm" /> ); } +function NavButton({ kind = "Button", ...props }) { + const Component = kind === "IconButton" ? IconButton : Button; + return ( + // Opacity is in a separate Box, to avoid overriding the built-in Button + // hover/focus states. + + + + ); +} + export default PageLayout;