import React, { useState, useRef, useEffect } from "react"; import { Link } from "gatsby" import { StaticImage } from "gatsby-plugin-image" import { Link as AnchorLink } from "react-scroll"; import { useLocation } from '@reach/router'; import { disableBodyScroll, enableBodyScroll } from "body-scroll-lock"; const Header = ({ menu }) => { const ref = useRef(null); const location = useLocation(); const [menuH, setMenuH] = useState(0); const [burgerMenu, setBurgerMenu] = useState(0); const menuGeneralClasses = "md:container max-md:w-full max-md:-mx-3 top-0 mx-auto flex items-center md:justify-between justify-center max-md:flex-col max-md:overflow-y-hidden max-md:bg-black max-md:fixed transition-all"; const burgerGeneralClasses = "bg-white w-7 h-[3px] before:w-7 before:h-[3px] before:bg-white before:block before:relative after:w-7 after:h-[3px] after:bg-white after:block after:relative transition-all before:transition-all after:transition-all"; const burgerActivation = () => { window.addEventListener("resize", (e) => { if(window.screen.width > 767) { setBurgerMenu(0); enableBodyScroll(document.body); } }); if(burgerMenu) { setBurgerMenu(0); enableBodyScroll(document.body); } else { setBurgerMenu(1); disableBodyScroll(document.body); } } useEffect(() => { if(location.pathname === '/') { setMenuH(ref.current.scrollHeight); } }, [location.pathname]); return (
8 (920) 074 55-05
burgerActivation()} onKeyDown={e=> this.handleKeyDown}>
) } export default Header