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: 공통 컴포넌트 Chips, Tab, Badge, Filters, Tag 추가 #25

Merged
merged 7 commits into from
Sep 6, 2024

Conversation

yunchaeney
Copy link
Contributor

@yunchaeney yunchaeney commented Sep 6, 2024

✏️ 작업 내용

공통 컴포넌트 총 10개 파일 추가하였으며, 내역은 아래와 같습니다.

  • Badge

  • Tag

  • Tab

    • Tab
    • TopTab
  • Filter

    • FilterList
    • FilterSort
  • Chip

    • Chip
    • InfoChip
    • StateChip
    • TimeChip
  • tailwind config 에 fontSize 추가

📷 스크린샷

image

(동영상) 기본 Chip, Filter 컴포넌트의 경우 모바일 뷰포트일 때 사이즈 변경이 있습니다
movie-size

(동영상) Tab 컴포넌트의 경우 state 변경에 따른 애니메이션이 있습니다 (아래 사용법 참고)
movie-tab

tailwind.config.ts
image

추가! TopTab
image

✍️ 사용법

<Badge>1</Badge> 

<Tag>오늘 21 마감</Tag>                          //default size : large
<Tag size='small'>오늘 21 마감</Tag>

<Tab type='workation'            // or 'dalaemfit'
  isActive={firstActive}
  onClick={() => setFirstActive((prev) => !prev)}
 />

<Chip state='default'>전체</Chip>
<Chip state='active'>전체</Chip>

<TimeChip state='default'>13:00</TimeChip>
<TimeChip state='active'>13:00</TimeChip>
<TimeChip state='disabled'>13:00</TimeChip>

<StateChip state='scheduled' />
<StateChip state='done' />
<StateChip state='confirmed' />
<StateChip state='pending' />

<InfoChip type='date'>1월 7일</InfoChip>
<InfoChip type='time'>13:00</InfoChip>

<FilterList state='default'>전체</FilterList>
<FilterList state='active'>전체</FilterList>

<FilterSort state='default'>마감임박</FilterSort>
<FilterSort state='active'>마감임박</FilterSort>

<TopTab isActive={true}>모임 찾기</TopTab>
<TopTab>
  찜한 모임
  <Badge>10</Badge>
</TopTab>
<div className='text-12'> 12px </div>
<div className='text-16'> 16px </div>

🎸 기타

  • ic_check 컴포넌트의 경우, 피그마 상 2가지 color state 를 가지고 있지만
    사용처가 Card 컴포넌트에만, 오렌지컬러만 "개설확정" 이라는 라벨과 사용되고 있었습니다.
    이에 너무 마이크로하게 컴포넌트를 분리하는 것 같아 추가하지 않았습니다.
    의견 주시면 감사하겠습니다!

  • Filter 컴포넌트가 하나의 컴포넌트로 되어 있었으나, dropdown 형태와 sort 형태가 뷰포트 사이즈에 따른 스타일 변화가 커서 List, Sort 두 개의 컴포넌트로 분리하였습니다.

  • Top Tab 컴포넌트 빼먹었습니다... 얼른 작업하고 수정하겠습니다. 추가 완료.

close #17

@yunchaeney yunchaeney added ✨ Feat 기능 추가 and removed ✨ Feat 기능 추가 labels Sep 6, 2024
@yunchaeney yunchaeney self-assigned this Sep 6, 2024
Copy link
Contributor

@BeMatthewsong BeMatthewsong left a comment

Choose a reason for hiding this comment

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

PR 마스터 좋습니다 LGTM 👍

Comment on lines 7 to 11
<>
<div className='rounded-full bg-var-gray-900 px-8 text-12 font-semibold text-white'>
{children}
</div>
</>
Copy link
Contributor

Choose a reason for hiding this comment

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

P4) 빈 프래그먼트 안 감싸도 충분할 것 같은데 빼시는 건 어떠신가요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

수정하겠습니다!

Comment on lines +7 to +12
const stateClasses = {
scheduled: 'bg-var-orange-100 text-var-orange-600',
done: 'bg-var-gray-200 text-var-gray-500',
confirmed: 'bg-white text-var-orange-500 border border-var-orange-100',
pending: 'bg-white text-var-gray-500 border border-var-gray-200',
};
Copy link
Contributor

Choose a reason for hiding this comment

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

이거 볼 때마다 아이디어 좋네요 👏

Comment on lines +9 to +12
const Tab = ({ type, isActive, onClick }: TabProps) => {
const styles = isActive
? 'text-var-gray-900 first-of-type:before:right-0 last-of-type:before:left-0'
: 'text-var-gray-400 first-of-type:before:-right-full last-of-type:before:-left-full';
Copy link
Contributor

Choose a reason for hiding this comment

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

P3) 진짜궁금
first-of-type:before:right-0 last-of-type:before:left-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.

Tab에서 클릭 시 active 상태가 바뀜에 따라 밑줄의 움직임 애니메이션을 하기 위함입니다!
before 상태로 border-bottom을 추가해 놓고,
isActive = false 시 첫번째 아이템은 -right-full -left-full 로, 마지막 아이템은 -left-full 로 밑줄이 안 보이게 되어 있습니다.
isActive가 true로 바뀌면 각각 왼쪽/오른쪽에서부터 0으로 밑줄이 이동합니다.

이에 애니메이션 상에서는 두개 tab을 번갈아 클릭 시 밑줄이 두 아이템 사이를 오가는 것처럼 보입니다.

설명을 잘 못하겠어요 😥

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.

여기 쉽지 않네요

@@ -0,0 +1,16 @@
interface TopTabProps {
isActive?: boolean;
children: React.ReactNode;
Copy link
Contributor

Choose a reason for hiding this comment

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

P2) ReactNode 만 따로 임포트해서 쓰시는 거 어떠신가요?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

수정하겠습니다!

Copy link
Contributor

@HMRyu HMRyu left a comment

Choose a reason for hiding this comment

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

전반적으로 코드가 깔끔한 것 같습니다!

작업량이 많으셨을 텐데 고생 많으셨습니다...!

Comment on lines 7 to 11
<>
<div className='rounded-full bg-var-gray-900 px-8 text-12 font-semibold text-white'>
{children}
</div>
</>
Copy link
Contributor

Choose a reason for hiding this comment

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

P4) fragment 가 불필요하다면 삭제해도 될 것 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

수정하겠습니다!

Comment on lines +3 to +19
interface StateChipProps {
state: 'scheduled' | 'done' | 'confirmed' | 'pending'; // 이용 예정 | 이용 완료 | 개설 확정 | 개설 대기
}

const stateClasses = {
scheduled: 'bg-var-orange-100 text-var-orange-600',
done: 'bg-var-gray-200 text-var-gray-500',
confirmed: 'bg-white text-var-orange-500 border border-var-orange-100',
pending: 'bg-white text-var-gray-500 border border-var-gray-200',
};

const stateContents = {
scheduled: '이용 예정',
done: '이용 완료',
confirmed: '개설 확정',
pending: '개설 대기',
};
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Comment on lines +10 to +12
const styles = isActive
? 'text-var-gray-900 first-of-type:before:right-0 last-of-type:before:left-0'
: 'text-var-gray-400 first-of-type:before:-right-full last-of-type:before:-left-full';
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Comment on lines 15 to 22
<>
<div
className={`absolute right-0 top-0 flex items-center gap-4 rounded-bl-[12px] bg-orange-600 py-4 pl-8 text-12 font-medium text-white ${sizeClasses[size]}`}
>
<IconAlarm width='24' height='24' />
<span className='shrink-0'>{children}</span>
</div>
</>
Copy link
Contributor

Choose a reason for hiding this comment

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

P4) 여기도 fragment 가 불필요하다면 삭제해도 될 것 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

수정하겠습니다!

@yunchaeney
Copy link
Contributor Author

리뷰 주신 부분 반영하였습니다.

  • TopTab 컴포넌트의 ReactNode import 하여 사용
  • Badge, Tag 컴포넌트의 불필요한 fragment 삭제

fragment 의 경우 습관이었어서, 지적 감사합니다. 고쳐보겠습니다. 😊

done: '이용 완료',
confirmed: '개설 확정',
pending: '개설 대기',
};
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.

이게 원래 사용할 top tap이었군요..! 제가 isActive만 props로 내려주도록 수정하면 사용할 수 있을 것 같습니다!

20: ['2.0rem', '2.8rem'],
24: ['2.4rem', '3.2rem'],
30: ['3rem', '3.6rem'],
},
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@yunchaeney yunchaeney merged commit bf66cbb into develop Sep 6, 2024
4 checks passed
@yunchaeney yunchaeney deleted the feat/chaeney/KAN-3-chip-tab branch September 8, 2024 06:32
children: string;
}

const Badge = ({ children }: BadgeProps) => {

Choose a reason for hiding this comment

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

PropWithChilren type을 사용해볼까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feat 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: 공통 컴포넌트 - chip, tab
5 participants