Skip to content

Instantly share code, notes, and snippets.

@emmabostian
Created December 27, 2019 19:56
Show Gist options
  • Save emmabostian/bf9151bbc0aaad042e7c6fe7bf7799a5 to your computer and use it in GitHub Desktop.
Save emmabostian/bf9151bbc0aaad042e7c6fe7bf7799a5 to your computer and use it in GitHub Desktop.
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