Skip to content
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

Merged
merged 27 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3fe1182
[KAN-10] style: gnb UI 추가
hakyoung12 Sep 6, 2024
16b0c09
[KAN-10] style: 주소에 pathname이 포함되어있다면 해당 메뉴 텍스트 색상이 black으로 변경
hakyoung12 Sep 6, 2024
f5f306c
[KAN-10] style: 프로필 UI 추가
hakyoung12 Sep 6, 2024
8dc165c
[KAN-10] style: gnb 반응형 디자인 설정
hakyoung12 Sep 6, 2024
c1edb78
[KAN-10] style: 반응형 사이즈 수정
hakyoung12 Sep 6, 2024
5147919
[KAN-10] style: profile 커서포인터 추가
hakyoung12 Sep 6, 2024
4342508
[KAN-10] style: gnb style 수정
hakyoung12 Sep 6, 2024
f613ce1
[KAN-10] style: gnb 반응형 폰트 사이즈 추가
hakyoung12 Sep 6, 2024
1f695be
[KAN-11] feat: BoxSelect 컴포넌트 (데스크톱 버전) 추가
BeMatthewsong Sep 6, 2024
4d0a8a5
[KAN-11] chore: tailwind 미디어쿼리 설정 추가
BeMatthewsong Sep 6, 2024
2f8013e
[KAN-11] style: BoxSelect 컴포넌트 (모바일 버전) 추가 및 trasition 추가
BeMatthewsong Sep 6, 2024
9aecc82
[KAN-11] fix: 상위 태그를 label 태그로 교체
BeMatthewsong Sep 6, 2024
336e845
[KAN-11] style: 스크린 사이즈에 따른 전체 높이 조절
BeMatthewsong Sep 6, 2024
798c302
[KAN-11] chore: 불필요한 코드 삭제
BeMatthewsong Sep 6, 2024
b98120c
[KAN-11] chore: ChangeEvent Import
BeMatthewsong Sep 6, 2024
5bcdcf2
[KAN-11] chore: 불필요한 코드 삭제
BeMatthewsong Sep 6, 2024
4be38c8
[KAN-11] fix: 변수명 변경 및 테일윈드 수정
BeMatthewsong Sep 6, 2024
e5c1124
[KAN-3] chore : tailwind 설정 font-size 추가
yunchaeney Sep 6, 2024
dea6550
[KAN-3] feat: 컴포넌트 Tab 추가 및 svg icon 코드 변경
yunchaeney Sep 6, 2024
fe7b6b1
[KAN-3] feat: 컴포넌트 Chips 추가 (chip, info, state, time)
yunchaeney Sep 6, 2024
641109c
[KAN-3] feat: 컴포넌트 Badge, Tag 추가
yunchaeney Sep 6, 2024
bac2058
[KAN-3] feat: 컴포넌트 Filter 추가 (list, sort)
yunchaeney Sep 6, 2024
6420887
[KAN-3] feat: 컴포넌트 Top Tab 추가
yunchaeney Sep 6, 2024
4ca1ebf
[KAN-3] refactor: PR 리뷰 반영 (fragment 삭제, ReactNode import)
yunchaeney Sep 6, 2024
5afe17a
[KAN-10] rename: Input 폴더 변경
hakyoung12 Sep 9, 2024
66a7390
[KAN-10] feat: TopTab 컴포넌트적용
hakyoung12 Sep 9, 2024
e1515f0
[KAN-10] feat: 찜한 모임 뱃지 추가
hakyoung12 Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/app/components/Gnb/Gnb.tsx
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 정해질 시 추가 예정
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

P4) 정말 사소한 건데 'use client' 쓰고 한 줄 띄워주셔도 좋을 것 같습니다!

const navList = [
{
name: '모임 찾기',
link: '#',
},
{
name: '찜한 모임',
link: '#',
Comment on lines +20 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

찜한 모임 옆에 갯수 Badge 달리는 경우는 어떻게 되나요 ?_?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그부분은 제가 깜빡했습니다ㅠ 추가하겠습니다!

},
{
name: '모든 리뷰',
link: '#',
},
];

const Gnb = () => {
const pathname = usePathname();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 URL 경로를 가져오는 코드입니다.

Copy link
Contributor

Choose a reason for hiding this comment

The 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'>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

시멘틱 태그 👍

P4) 혹시 gap-0 은 사용되고 있는 스타일일까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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'}`}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 URL경로를 받아와서 link가 포함되어있다면 글자색상이 검정색으로 출력됩니다.

href={nav.link}
>
{nav.name}
</Link>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

componenets/Tab/TopTab.tsx 파일에 해당 부분이 컴포넌트로 작성되어 있습니다만, 굳이 컴포넌트로 갈아끼울 필요가 있을까? 싶습니다.
현재 방식도 복잡해 보이진 않아서 유지하고, 위 언급한 컴포넌트는 아예 삭제해도 될 것 같아요.

p1) 모바일 사이즈에서 font 크기 조정이 필요합니다.
p2) text-[16px]text-16 으로 수정해 주시면, 제 PR 머지 시 반영됩니다.
--> 괜찮으시면 위 언급한 컴포넌트에서 class name 만 참고해 주세요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text 사이즈는 수정완료했습니다!
제가 봤을 때에는 네이게이션바를 다른 컴포넌트로 분리하고 채현님께서 만든 컴포넌트를 사용하는 방식도 좋아보입니다!
사실 제 방식은 찜한 모임 뱃지 넣기 애매할거같더라구요...

</li>
))}
</ul>
</nav>
<UserStatus />
</div>
</header>
);
};

export default Gnb;
65 changes: 65 additions & 0 deletions src/app/components/Gnb/UserStatus.tsx
Copy link
Contributor

Choose a reason for hiding this comment

The 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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이러한 로직들도 하나의 공통 훅으로 마련해서 처리를 해보면 좋을 것 같네요

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3) !dropDownRef.current.contains(event.target as Node) 에 대해 설명 부탁드려도 되나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;
Loading