summaryrefslogtreecommitdiffstats
path: root/src/components/MainNav/MainNav.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-01-07 17:46:34 +0100
committerArmand Philippot <git@armandphilippot.com>2022-01-07 19:04:20 +0100
commit06d0b7bb010f5ac1b3a0c8117b274a700f7266fe (patch)
treef572f73068b92bbfffa3b2a9dde3f4fe668cd09e /src/components/MainNav/MainNav.tsx
parenta385d89dfd6312f2255d1343cea3f63375ce5b39 (diff)
chore: add main nav link states
Diffstat (limited to 'src/components/MainNav/MainNav.tsx')
-rw-r--r--src/components/MainNav/MainNav.tsx9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/components/MainNav/MainNav.tsx b/src/components/MainNav/MainNav.tsx
index 0f5147b..0339a35 100644
--- a/src/components/MainNav/MainNav.tsx
+++ b/src/components/MainNav/MainNav.tsx
@@ -10,6 +10,7 @@ import {
} from '@components/Icons';
import { mainNav } from '@config/nav';
import styles from './MainNav.module.scss';
+import { useRouter } from 'next/router';
const MainNav = ({
isOpened,
@@ -18,6 +19,8 @@ const MainNav = ({
isOpened: boolean;
setIsOpened: (value: SetStateAction<boolean>) => void;
}) => {
+ const router = useRouter();
+
const getIcon = (id: string) => {
switch (id) {
case 'home':
@@ -34,10 +37,12 @@ const MainNav = ({
};
const navItems = mainNav.map((item) => {
+ const currentClass = router.asPath === item.slug ? styles.current : '';
+
return (
- <li key={item.id} className={styles.item}>
+ <li key={item.id}>
<Link href={item.slug}>
- <a className={styles.link}>
+ <a className={`${styles.link} ${currentClass}`}>
{getIcon(item.id)}
<span>{item.name}</span>
</a>