-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] #26 NavBar 구현
- Loading branch information
Showing
5 changed files
with
58 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 6 additions & 18 deletions
24
weatherfit_refactoring/src/Components/Molecules/NavBar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,14 @@ | ||
import IconStore, { IconStyle } from '../Atoms/Icon/IconStore' | ||
import NavBarBox from './NavBarBox' | ||
|
||
export default function NavBar() { | ||
return ( | ||
<div | ||
className="flex w-[370px] justify-around items-center bg-white border border-black rounded-[30px] z-10 py-[5px]" | ||
className="fixed bottom-[45px] mx-[5px] flex justify-around items-center bg-white w-[360px] border border-black rounded-[30px] z-10 py-[5px]" | ||
style={{ boxShadow: '7px 7px 1px' }}> | ||
<div className="flex flex-col items-center"> | ||
<IconStore iconStyle={IconStyle.HOME} size={22} /> | ||
<p className="font-Cafe24SsurroundAir text-[12px]">홈</p> | ||
</div> | ||
<div className="flex flex-col items-center"> | ||
<IconStore iconStyle={IconStyle.SEARCH} size={22} /> | ||
<p className="font-Cafe24SsurroundAir text-[12px]">구경</p> | ||
</div> | ||
<div className="flex flex-col items-center"> | ||
<IconStore iconStyle={IconStyle.UPLOAD} size={22} /> | ||
<p className="font-Cafe24SsurroundAir text-[12px]">업로드</p> | ||
</div> | ||
<div className="flex flex-col items-center"> | ||
<IconStore iconStyle={IconStyle.MY_PROFILE} size={22} /> | ||
<p className="font-Cafe24SsurroundAir text-[12px]">마이페이지</p> | ||
</div> | ||
<NavBarBox iconStyle="HOME" title="홈" url="/" /> | ||
<NavBarBox iconStyle="SEARCH" title="구경" url="/feed" /> | ||
<NavBarBox iconStyle="UPLOAD" title="업로드" url="/upload" /> | ||
<NavBarBox iconStyle="MY_PROFILE" title="마이페이지" url="/mypage" /> | ||
</div> | ||
) | ||
} |
37 changes: 37 additions & 0 deletions
37
weatherfit_refactoring/src/Components/Molecules/NavBarBox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use client' | ||
import { usePathname, useRouter } from 'next/navigation' | ||
import IconStore, { IconStyle } from '../Atoms/Icon/IconStore' | ||
import { useEffect, useState } from 'react' | ||
import Link from 'next/link' | ||
|
||
interface Props { | ||
iconStyle: keyof typeof IconStyle | ||
title: string | ||
url: string | ||
} | ||
|
||
export default function NavBarBox({ iconStyle, title, url }: Props) { | ||
const router = useRouter() | ||
const pathname = usePathname() | ||
const [isActive, setIsActive] = useState<boolean>(false) | ||
|
||
useEffect(() => { | ||
console.log('pathname: ', pathname) | ||
setIsActive(pathname === url) | ||
}, [pathname]) | ||
console.log('isActive: ', isActive) | ||
|
||
const activeIconStyle = isActive | ||
? IconStyle[`${iconStyle}_FILL` as keyof typeof IconStyle] | ||
: IconStyle[iconStyle] | ||
const activeTextStyle = isActive | ||
? 'font-Cafe24SsurroundAir text-[11px] font-bold' | ||
: 'font-Cafe24SsurroundAir text-[11px]' | ||
|
||
return ( | ||
<Link href={url} className="flex flex-col items-center cursor-pointer"> | ||
<IconStore iconStyle={activeIconStyle} size={22} /> | ||
<p className={activeTextStyle}>{title}</p> | ||
</Link> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters