menu refactoring

This commit is contained in:
tmshv committed 2020-02-22 04:22:19 +03:00
1 parent 8a41a895fb
commit b07def3eee
2 files changed
+41 -18

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
import cx from 'classnames'
import { useRouter } from 'next/router'
import { ActiveLink } from './ActiveLink'
export type MenuItemProps = {
href: string
layout: 'desktop' | 'mobile'
}
export const MenuItem: React.FC<MenuItemProps> = props => {
const router = useRouter()
const current = router.asPath === props.href
const href = current ? null : props.href
return (
<li
className={cx('menuItem', props.layout, {
selected: current,
})}
>
<ActiveLink
href={href}
activeStyle={{
fontWeight: 'bold'
}}
>
{props.children}
</ActiveLink>
</li>
)
}