Skip to content

Commit 1e1d2cd

Browse files
authored
Merge pull request #312 from WeGo-Together/somang-fix/layout
fix: GNB 하이라이팅을 현재 path의 subPath까지 적용
2 parents c4c4533 + 4099eb7 commit 1e1d2cd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/components/layout/gnb/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@ import { Icon } from '@/components/icon';
88
export const GNB = () => {
99
const pathname = usePathname();
1010

11+
const highLightPath = (path: string) => {
12+
if (path === '/') {
13+
return pathname === '/';
14+
}
15+
return pathname.startsWith(path);
16+
};
17+
1118
return (
1219
<nav className='sticky bottom-0 z-100 h-14 border-t-1 border-gray-200 bg-white py-2'>
1320
<ul className='flex w-full justify-evenly gap-4'>
1421
{NAV_MENU.map(({ path, svgId }) => (
1522
<li key={path}>
1623
<Link href={path} className='flex-center h-10 w-10'>
17-
<Icon id={svgId} className={pathname === path ? 'text-mint-500' : 'text-gray-500'} />
24+
<Icon
25+
id={svgId}
26+
className={highLightPath(path) ? 'text-mint-500' : 'text-gray-500'}
27+
/>
1828
</Link>
1929
</li>
2030
))}

0 commit comments

Comments
 (0)