-
Notifications
You must be signed in to change notification settings - Fork 1
✨ [Feature] chip 컴포넌트 리팩토링 & 모임 chip 구현 #129
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
The head ref may contain hidden characters: "126-feature-chip-\uCEF4\uD3EC\uB10C\uD2B8-\uB9AC\uD329\uD1A0\uB9C1"
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
wynter24
left a comment
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.
수고하셨습니다!
haegu97
left a comment
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.
수고하셨습니당
| const getChipVariant = () => { | ||
| switch (variant) { | ||
| case 'completed': | ||
| return 'square-filled'; | ||
| case 'scheduled': | ||
| return 'square-filled'; | ||
| case 'pending': | ||
| return 'square-outlined'; | ||
| case 'confirmed': | ||
| return 'square-filled'; | ||
| } | ||
| }; | ||
|
|
||
| const getCustomClassName = () => { | ||
| switch (variant) { | ||
| case 'completed': | ||
| return 'bg-gray-normal-01 text-gray-dark-02'; | ||
| case 'scheduled': | ||
| return 'bg-green-normal-01 text-gray-white'; | ||
| case 'pending': | ||
| return 'border-blue-normal-01 text-blue-normal-01'; | ||
| case 'confirmed': | ||
| return 'bg-blue-normal-01 text-gray-white'; | ||
| } |
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.
큰 차이는 없을 거 같긴한데 통일성 있게 객체화 시키는 방법은 어떤가요??
객체화 시켜서 사용하는 방법과 switch case 문을 같이 사용한 이유가 있으실까요?
const CLUB_CHIP_VARIANTS = {
completed: 'square-filled',
scheduled: 'square-filled',
pending: 'square-outlined',
confirmed: 'square-filled',
} as const;
const CLUB_CHIP_CLASSES = {
completed: 'bg-gray-normal-01 text-gray-dark-02',
scheduled: 'bg-green-normal-01 text-gray-white',
pending: 'border-blue-normal-01 text-blue-normal-01',
confirmed: 'bg-blue-normal-01 text-gray-white',
} as const;| variant={getChipVariant()} | ||
| className={twMerge(getCustomClassName(), className)} |
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.
variant={CHIP_VARIANTS[variant]}
className={twMerge(CHIP_CLASSES[variant], className)}
#️⃣연관된 이슈
📝작업 내용
마이페이지 쪽에서 chip 디자인이 몇 개 새롭게 추가되었는데, 전체 chip 컴포넌트를 이에 맞게 바꿀지 고민하다가 나중에 교환쪽에서도 새로운 chip이 나오게 되면 varint를 수정하고 사용된 chip들을 다 변경하기가 번거로울 것 같아서 chip을 리팩토링 하고 마이 페이지에서 쓰는 chip의 경우 새롭게 chip 폴더 내부에
ClubChip으로 구현했습니다.미리보기, 사용방법 및 결과물
chip 컴포넌트는 4개의 varint로 모양에 따라 기본 틀만 담당해줍니다. (밑에 회색부분은 지난 모임인지 아닌지 여부에 따라 색상 바뀌는 부분)
해당 chip 컴포넌트를 베이스로 모임에서 사용되는 chip들을 따로 만들어 두었습니다.
기본 틀은 chip컴포넌트에서 받아오고 varint (참여 완료 등..)에 따라 모양을 구체화하는 식으로 만들었습니다.
실제 사용 코드 예시
기타 참고사항