import React, { useState } from 'react' import styled, { css } from 'styled-components' const togglerOpened = css` path:nth-child(1) { stroke-dasharray: 90 207; stroke-dashoffset: -134; stroke-width: 6; } path:nth-child(2) { stroke-dasharray: 1 60; stroke-dashoffset: -30; stroke-width: 6; } path:nth-child(3) { stroke-dasharray: 90 207; stroke-dashoffset: -134; stroke-width: 6; } ` const togglerClosed = css` path:nth-child(1) { stroke-dasharray: 60 207; stroke-width: 6; } path:nth-child(2) { stroke-dasharray: 60 60; stroke-width: 6; } path:nth-child(3) { stroke-dasharray: 60 207; stroke-width: 6; } ` const Toggler = styled.button<{ opened: boolean }>` @media (min-width: 768px) { display: none !important; } background-color: transparent !important; border: none !important; cursor: pointer; svg { width: 40px; height: 40px; } outline: none !important; padding: 0 !important; border-radius: 0.25rem; font-size: 1.25rem; line-height: 1; path { fill: none; stroke: black; stroke-width: 6; transition: stroke-dasharray 600ms cubic-bezier(0.4, 0, 0.2, 1), stroke-dashoffset 600ms cubic-bezier(0.4, 0, 0.2, 1); } ${(props) => (props.opened ? togglerOpened : togglerClosed)} ` const DefaultNavToggler = () => { const [menuOpened, setMenuOpened] = useState(false) return ( { setMenuOpened(!menuOpened) }} > ) } export default DefaultNavToggler