From 78af36bb92694f36966ee65faaa29bb9091c543a Mon Sep 17 00:00:00 2001 From: Wille Marcel Date: Mon, 2 Sep 2024 17:10:56 -0300 Subject: [PATCH] DIsmiss mobile Nav after clicking on menu item --- src/components/header.js | 21 +++++++++------------ src/components/layout/layout.js | 7 +------ src/components/nav.js | 17 ++++++++++------- src/components/sticky-banner.js | 18 ++++++++++-------- 4 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/components/header.js b/src/components/header.js index ac3b18d4..65645948 100644 --- a/src/components/header.js +++ b/src/components/header.js @@ -5,10 +5,11 @@ import { Link } from "gatsby" import { colors, layout, breakpoints } from "../theme" import { CaseiLogoIcon, CloseIcon, HamburgerIcon } from "../icons" -import { NEGATIVE } from "../utils/constants" +import { NEGATIVE, POSITIVE } from "../utils/constants" import StickyBanner from "./sticky-banner" import Button from "./button" import NasaLogoIcon from "../icons/nasa-logo" +import NavList from "./nav" const reveal = keyframes` 0% { @@ -173,18 +174,11 @@ const PageNavGlobalStyle = createGlobalStyle` } ` -const Header = ({ shortname, children, mode }) => { - const offsetCalculator = (scrollDirection, _, currentScroll) => { - if (scrollDirection === "scroll-down" && currentScroll > 250) { - return `-${document.getElementById("main-header").clientHeight}px` - } else { - return 0 - } - } - +const Header = ({ shortname, mode }) => { const [navRevealed, setNavRevealed] = useState(false) + return ( - + @@ -225,7 +219,10 @@ const Header = ({ shortname, children, mode }) => { role="navigation" revealed={navRevealed} > - {children} + setNavRevealed(false)} + /> diff --git a/src/components/layout/layout.js b/src/components/layout/layout.js index 08b57f1d..b50f8ee6 100644 --- a/src/components/layout/layout.js +++ b/src/components/layout/layout.js @@ -17,7 +17,6 @@ import "@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css" import "../global.css" import Header from "../header" -import Nav from "../nav" import Footer from "../footer" import { POSITIVE } from "../../utils/constants" @@ -45,12 +44,8 @@ const Layout = ({ children }) => { return ( -
-
- +
{children}
-