Created
December 27, 2019 19:56
-
-
Save emmabostian/bf9151bbc0aaad042e7c6fe7bf7799a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react" | |
import PropTypes from "prop-types" | |
import { useSpring } from "react-spring" | |
import Header from "./header" | |
import Nav from "./nav" | |
import "./layout.css" | |
const Layout = ({ children }) => { | |
const [navOpen, toggleNavOpen] = useState(false) | |
const navAnimation = useSpring({ | |
opacity: navOpen ? 1 : 0, | |
transform: navOpen ? `translateY(0)` : `translateY(-100%)`, | |
}) | |
return ( | |
<> | |
<Header navOpen={navOpen} toggleNavOpen={() => toggleNavOpen(!navOpen)} /> | |
<Nav style={navAnimation} /> | |
<main>{children}</main> | |
</> | |
) | |
} | |
Layout.propTypes = { | |
children: PropTypes.node.isRequired, | |
} | |
export default Layout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment