I'm not sure how to add a click event to trigger the active class in my styled component. I'm using react hooks and functional component for this code.
Here is the code I'm trying to replicate with styled components
<ul className={click ? 'nav-menu active' : 'nav-menu'}>
Right now it automatically shows the active class, but I only need it to show active if I click, but I don't know where I'd write that code to show if click is true or false?
const NavMenu = styled.ul`
display: flex;
align-items: center;
list-style: none;
text-align: center;
@media screen and (max-width: 960px) {
display: flex;
flex-direction: column;
width: 100%;
height: 90vh;
position: absolute;
top: 80px;
left: -100%;
opacity: 1;
transition: all 0.5s ease;
${({ active }) =>
active &&
css`
background: #1c2237;
left: 0;
opacity: 1;
transition: all 0.6s ease;
z-index: 1;
`}
}
`;
Then in my NavMenu I have the active added
<NavMenu active></NavMenu>