Portfolio website written with Next.js
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wychdev-nextjs/components/burgermenu.tsx

72 lines
1.1 KiB

import styled, {css} from "styled-components"
import React, {useState} from "react"
//import Link from "next/link"
2 years ago
const MenuLine = styled.div`
width: 1.8rem;
height: 2px;
border-radius: 2px;
2 years ago
background-color: var(--fg);
&:not(:last-child) {
margin-bottom: .4rem;
}
2 years ago
`
const BurgerContainer = styled.div<{open: boolean}>`
2 years ago
display: none;
width: 1.8rem;
height: 1.8rem;
2 years ago
flex-direction: column;
justify-content: center;
2 years ago
div {
transition: .2s;
}
&:hover {
cursor: pointer;
}
2 years ago
@media screen and (max-width: 960px) {
display: flex;
nav {
2 years ago
display: none !important;
position: absolute;
top: 0;
2 years ago
}
}
${({open}) => open && css`
2 years ago
div {
position: absolute;
height: 4px;
}
div:nth-child(1) {
transform: rotate(45deg) translate(.2rem, .2rem);
}
div:nth-child(2) {
transform: rotate(-45deg) translate(-.18rem, .2rem);
}
div:last-child {
display: none;
}
`}
2 years ago
`
const Menu = () => {
const [open, setOpen] = useState(false);
2 years ago
return (
<BurgerContainer open={open} onClick={() => setOpen(!open)}>
2 years ago
<MenuLine />
<MenuLine />
<MenuLine />
2 years ago
</BurgerContainer>
2 years ago
)
}
export default Menu