From 822f1a053590e0743c7aa7118b5103b5c28282e2 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sun, 23 Feb 2020 05:10:01 +0300 Subject: [PATCH] MenuIterm selected but clicable mode added --- src/components/Menu/MenuItem.tsx | 5 ++++- src/lib/url.js | 25 ------------------------- src/lib/url.ts | 3 +++ 3 files changed, 7 insertions(+), 26 deletions(-) delete mode 100644 src/lib/url.js create mode 100644 src/lib/url.ts diff --git a/src/components/Menu/MenuItem.tsx b/src/components/Menu/MenuItem.tsx index 774c7aab..b9e1b6b1 100644 --- a/src/components/Menu/MenuItem.tsx +++ b/src/components/Menu/MenuItem.tsx @@ -1,6 +1,7 @@ import cx from 'classnames' import { useRouter } from 'next/router' import { ActiveLink } from './ActiveLink' +import { isPartOfPath } from 'src/lib/url' export type MenuItemProps = { href: string @@ -8,14 +9,16 @@ export type MenuItemProps = { } export const MenuItem: React.FC = props => { + const ignore = ['/'] const router = useRouter() const current = router.asPath === props.href + const selected = current || (!ignore.includes(props.href) && isPartOfPath(props.href, router.asPath)) const href = current ? null : props.href return (