mirror of
https://github.com/vercel/commerce.git
synced 2025-07-05 04:31:22 +00:00
Working menu button with open and closed state.
This commit is contained in:
parent
f5cb30e4ff
commit
dc365b9232
@ -23,3 +23,11 @@
|
|||||||
.menuButton::before {
|
.menuButton::before {
|
||||||
transform: translateY(-5px);
|
transform: translateY(-5px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.menuButton.isOpen::before {
|
||||||
|
transform: rotate(45deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuButton.isOpen::after {
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
}
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import s from './MenuButton.module.css'
|
import s from './MenuButton.module.css'
|
||||||
|
import cn from 'classnames'
|
||||||
|
|
||||||
interface MenuButtonProps {
|
interface MenuButtonProps {
|
||||||
isOpen: boolean
|
isOpen: boolean
|
||||||
onClick: any
|
onClick: any
|
||||||
}
|
}
|
||||||
|
|
||||||
const MenuButton: FC<MenuButtonProps> = ({ isOpen, onClick }) => {
|
const MenuButton: FC<MenuButtonProps> = ({ isOpen, onClick }) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className={s.menuButton}
|
className={cn(s.menuButton, { [s.isOpen]: isOpen })}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { FC } from 'react'
|
import { FC, useState } from 'react'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import s from './Navbar.module.css'
|
import s from './Navbar.module.css'
|
||||||
import NavbarRoot from './NavbarRoot'
|
import NavbarRoot from './NavbarRoot'
|
||||||
@ -14,43 +14,49 @@ interface NavbarProps {
|
|||||||
links?: Link[]
|
links?: Link[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const Navbar: FC<NavbarProps> = ({ links }) => (
|
const Navbar: FC<NavbarProps> = ({ links }) => {
|
||||||
<NavbarRoot>
|
const [isMenuOpen, setIsMenuOpen] = useState(false)
|
||||||
<div className={s.navContainer}>
|
return (
|
||||||
<Container>
|
<NavbarRoot>
|
||||||
<div className={s.nav}>
|
<div className={s.navContainer}>
|
||||||
<div className="flex items-center flex-1">
|
|
||||||
<Link href="/">
|
|
||||||
<a className={s.logo} aria-label="Logo">
|
|
||||||
<Logo />
|
|
||||||
</a>
|
|
||||||
</Link>
|
|
||||||
<nav className={s.navMenu}>
|
|
||||||
<Link href="/search">
|
|
||||||
<a className={s.link}>All</a>
|
|
||||||
</Link>
|
|
||||||
{links?.map((l) => (
|
|
||||||
<Link href={l.href} key={l.href}>
|
|
||||||
<a className={s.link}>{l.label}</a>
|
|
||||||
</Link>
|
|
||||||
))}
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
<MenuButton isOpen onClick={() => {}} />
|
|
||||||
<div className="flex items-center justify-end flex-1 space-x-8">
|
|
||||||
<UserNav />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Container>
|
|
||||||
</div>
|
|
||||||
{process.env.COMMERCE_SEARCH_ENABLED && (
|
|
||||||
<div className={s.searchContainer}>
|
|
||||||
<Container>
|
<Container>
|
||||||
<Searchbar />
|
<div className={s.nav}>
|
||||||
|
<div className="flex items-center flex-1">
|
||||||
|
<Link href="/">
|
||||||
|
<a className={s.logo} aria-label="Logo">
|
||||||
|
<Logo />
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
|
<nav className={s.navMenu}>
|
||||||
|
<Link href="/search">
|
||||||
|
<a className={s.link}>All</a>
|
||||||
|
</Link>
|
||||||
|
{links?.map((l) => (
|
||||||
|
<Link href={l.href} key={l.href}>
|
||||||
|
<a className={s.link}>{l.label}</a>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
<MenuButton
|
||||||
|
isOpen={isMenuOpen}
|
||||||
|
onClick={() => setIsMenuOpen(!isMenuOpen)}
|
||||||
|
/>
|
||||||
|
<div className="flex items-center justify-end flex-1 space-x-8">
|
||||||
|
<UserNav />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</Container>
|
</Container>
|
||||||
</div>
|
</div>
|
||||||
)}
|
{process.env.COMMERCE_SEARCH_ENABLED && (
|
||||||
</NavbarRoot>
|
<div className={s.searchContainer}>
|
||||||
)
|
<Container>
|
||||||
|
<Searchbar />
|
||||||
|
</Container>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</NavbarRoot>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default Navbar
|
export default Navbar
|
||||||
|
Loading…
x
Reference in New Issue
Block a user