-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 공통 컴포넌트 gnb 컴포넌트 UI 작성 #26
Changes from 6 commits
3fe1182
16b0c09
f5f306c
8dc165c
c1edb78
5147919
4342508
f613ce1
1f695be
4d0a8a5
2f8013e
9aecc82
336e845
798c302
b98120c
5bcdcf2
4be38c8
e5c1124
dea6550
fe7b6b1
641109c
bac2058
6420887
4ca1ebf
5afe17a
66a7390
e1515f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use client'; | ||
import { Logo } from '@/public/images'; | ||
import Link from 'next/link'; | ||
import { usePathname } from 'next/navigation'; | ||
import UserStatus from './UserStatus'; | ||
|
||
//@todo pathname 정해질 시 추가 예정 | ||
const navList = [ | ||
{ | ||
name: '모임 찾기', | ||
link: '#', | ||
}, | ||
{ | ||
name: '찜한 모임', | ||
link: '#', | ||
Comment on lines
+20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 찜한 모임 옆에 갯수 Badge 달리는 경우는 어떻게 되나요 ?_? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그부분은 제가 깜빡했습니다ㅠ 추가하겠습니다! |
||
}, | ||
{ | ||
name: '모든 리뷰', | ||
link: '#', | ||
}, | ||
]; | ||
|
||
const Gnb = () => { | ||
const pathname = usePathname(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 URL 경로를 가져오는 코드입니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
return ( | ||
<header className='gap-0 bg-var-orange-600 py-16'> | ||
<div className='mx-16 flex max-w-[1200px] items-center justify-between md:mx-24 lg:mx-auto'> | ||
<nav className='flex items-center'> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 시멘틱 태그 👍 P4) 혹시 gap-0 은 사용되고 있는 스타일일까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 잘못 들어간 스타일인데 현재는 수정했습니다! |
||
<Link href='/'> | ||
<Logo className='mr-20 h-40 w-72' /> | ||
</Link> | ||
<ul className='flex gap-24'> | ||
{navList.map((nav, index) => ( | ||
<li key={index}> | ||
<Link | ||
className={`text-[16px] font-semibold ${pathname.includes(nav.link) ? 'text-black' : 'text-white'}`} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 URL경로를 받아와서 link가 포함되어있다면 글자색상이 검정색으로 출력됩니다. |
||
href={nav.link} | ||
> | ||
{nav.name} | ||
</Link> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. componenets/Tab/TopTab.tsx 파일에 해당 부분이 컴포넌트로 작성되어 있습니다만, 굳이 컴포넌트로 갈아끼울 필요가 있을까? 싶습니다. p1) 모바일 사이즈에서 font 크기 조정이 필요합니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. text 사이즈는 수정완료했습니다! |
||
</li> | ||
))} | ||
</ul> | ||
</nav> | ||
<UserStatus /> | ||
</div> | ||
</header> | ||
); | ||
}; | ||
|
||
export default Gnb; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 객체 야무지게 잘 쓰셨네요 👍 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
'use client'; | ||
|
||
import { Profile } from '@/public/images'; | ||
import Link from 'next/link'; | ||
import { useState, useRef, useEffect } from 'react'; | ||
|
||
/* user을 null로 설정하면 로그아웃된 상황을 볼 수 있습니다. */ | ||
const user = { | ||
name: 'test name', | ||
}; | ||
|
||
const options = [{ name: '마이페이지' }, { name: '로그아웃' }]; | ||
|
||
const UserStatus = () => { | ||
const [isOpen, setIsOpen] = useState<boolean>(false); | ||
const dropDownRef = useRef<HTMLDivElement>(null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이러한 로직들도 하나의 공통 훅으로 마련해서 처리를 해보면 좋을 것 같네요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cont { ref, clickOutSide } = useClickoutSide(); |
||
|
||
useEffect(() => { | ||
const handleClickOutside = (event: MouseEvent) => { | ||
if ( | ||
dropDownRef.current && | ||
!dropDownRef.current.contains(event.target as Node) | ||
) { | ||
setIsOpen(false); | ||
} | ||
Comment on lines
+20
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. event.target, 즉 현재 클릭이벤트가 일어난 곳이 dropDownRef.current가 참조하는 DOM 요소의 내부에 있는지 아닌지 판단하고 만약 false가 나올 시에 setIsOpen(false);를 실행하여 드롭다운을 닫습니다. |
||
}; | ||
|
||
document.addEventListener('mousedown', handleClickOutside); | ||
return () => { | ||
document.removeEventListener('mousedown', handleClickOutside); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<> | ||
{user ? ( | ||
<div className='relative' ref={dropDownRef}> | ||
<Profile | ||
className='size-40 cursor-pointer' | ||
onClick={() => setIsOpen((prev) => !prev)} | ||
/> | ||
{isOpen && ( | ||
<ul className='absolute right-0 mt-8 max-h-240 w-120 overflow-y-auto rounded-xl bg-var-gray-50 lg:left-0'> | ||
{options.map((option, index) => ( | ||
<li | ||
key={index} | ||
className='cursor-pointer px-16 py-12 text-[12px] font-medium text-var-black hover:bg-var-orange-100 md:px-16' | ||
> | ||
{option.name} | ||
</li> | ||
))} | ||
</ul> | ||
)} | ||
</div> | ||
) : ( | ||
<Link href='/signin'> | ||
{/* @todo 임시 경로입니다. */} | ||
<div className='text-[16px] font-semibold text-white'>로그인</div> | ||
</Link> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default UserStatus; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
P4) 정말 사소한 건데 'use client' 쓰고 한 줄 띄워주셔도 좋을 것 같습니다!