-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(toks-main, quiz): 퀴즈 카드 리팩토링 (#406)
* refactor: 메인카드 리스트 리팩토링 * refactor: 캐러셀 카드 수정 및 적용 * fix: badge 위치 수정 * fix: mobile break point를 통한 캐러셀 깨짐방지 * fix: quiztypo * fix: card 최소너비 수정 및 정책정하기 * fix: 캐러셀 사이즈 재구성 및 구현 * 퀴즈 카드 OX썸네일 대응 * feat: 퀴즈 상세 카테고리 색상 변경 --------- Co-authored-by: minsgy <[email protected]> Co-authored-by: dengoyoon <[email protected]>
- Loading branch information
1 parent
5b70297
commit f126825
Showing
6 changed files
with
162 additions
and
128 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
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
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,13 @@ | ||
import React from 'react'; | ||
|
||
import { Text } from '../Text'; | ||
|
||
export const Badge = ({ label }: { label: string }) => { | ||
return ( | ||
<div className="inline-flex items-center justify-center rounded-[4px] bg-gray-110 px-[4px] pb-[2px] pt-[3px]"> | ||
<Text typo="captionBold" color="white"> | ||
{label} | ||
</Text> | ||
</div> | ||
); | ||
}; |
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,88 @@ | ||
import clsx from 'clsx'; | ||
import Image from 'next/image'; | ||
import React from 'react'; | ||
|
||
import { ICON_URL } from '@/common/constants'; | ||
|
||
import { Badge } from './Badge'; | ||
import { QuizCardProps } from './QuizCard/types'; | ||
import { Text } from './Text'; | ||
|
||
export const CarouselCard = ({ | ||
categoryTitle, | ||
quizDescription, | ||
images, | ||
quizType = 'default', | ||
handleCardClick, | ||
}: Omit<QuizCardProps, 'sizeType' | 'commentCount' | 'likeCount'>) => { | ||
const isOX = quizType === 'ox'; | ||
const OxQuizThumbnail = () => { | ||
return ( | ||
<div className="flex h-full w-full rounded-8px"> | ||
<div | ||
className="flex flex-1 items-center justify-center" | ||
style={{ | ||
backgroundColor: '#3E97FF', | ||
}} | ||
> | ||
<Image src={ICON_URL.O} alt="OX 퀴즈 O" width={26} height={26} /> | ||
</div> | ||
<div | ||
className="flex flex-1 items-center justify-center" | ||
style={{ | ||
backgroundColor: '#FF5B65', | ||
}} | ||
> | ||
<Image src={ICON_URL.X} alt="OX 퀴즈 X" width={22} height={22} /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
return ( | ||
<div | ||
role="button" | ||
onClick={handleCardClick} | ||
className={clsx( | ||
'flex min-w-246px max-w-320px justify-between gap-16px rounded-12px bg-gray-90 p-20px' | ||
)} | ||
> | ||
<div className="flex w-full flex-1 flex-col"> | ||
<div className="flex items-center gap-[4px]"> | ||
<Badge label={quizType === 'default' ? 'AB' : 'OX'} /> | ||
<Text typo="captionBold" color="gray60"> | ||
{categoryTitle} | ||
</Text> | ||
</div> | ||
<div className="inline-flex flex-1 -translate-y-0.5 items-center pt-8px"> | ||
<Text className="line-clamp-3" typo="subheadingBold" color="gray10"> | ||
{quizDescription} | ||
</Text> | ||
</div> | ||
</div> | ||
<div className="flex h-100px w-100px flex-col justify-between overflow-hidden rounded-8px"> | ||
{isOX && images?.length === 0 ? ( | ||
<OxQuizThumbnail /> | ||
) : ( | ||
images?.map((src, index) => ( | ||
<div | ||
className={images.length > 1 ? 'h-1/2' : 'h-full'} | ||
key={`${src}-${index}`} | ||
> | ||
<img | ||
className="h-full w-full" | ||
src={src} | ||
alt={src} | ||
loading="lazy" | ||
style={{ | ||
objectFit: 'cover', | ||
objectPosition: 'center', | ||
}} | ||
/> | ||
</div> | ||
)) | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; |
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