|
| 1 | +import type { CombinationName, CombinationStatus } from '@/constants/combination'; |
| 2 | +import { |
| 3 | + COMBINATION_NAME_STYLE_MAP, |
| 4 | + COMBINATION_STATUS_STYLE_MAP, |
| 5 | +} from '@/constants/combination'; |
| 6 | +import type { Grade } from '@/constants/evaluation/grade'; |
| 7 | + |
| 8 | +interface CombinationEvaluationCardProps { |
| 9 | + category: CombinationName; |
| 10 | + grade: Grade; |
| 11 | + description: string; |
| 12 | + tags: string[]; |
| 13 | +} |
| 14 | + |
| 15 | +// 등급 텍스트 색상 클래스 추출 (COMBINATION_STATUS_STYLE_MAP에서 색상만 추출) |
| 16 | +const getGradeTextColorClass = (grade: Grade): string => { |
| 17 | + const statusStyle = COMBINATION_STATUS_STYLE_MAP[grade as CombinationStatus]; |
| 18 | + // 'font-caption-sm text-optimal' 형태에서 색상 부분만 추출 |
| 19 | + return statusStyle.split(' ').find((cls) => cls.startsWith('text-')) ?? 'text-optimal'; |
| 20 | +}; |
| 21 | + |
| 22 | +const CombinationEvaluationCard = ({ |
| 23 | + category, |
| 24 | + grade, |
| 25 | + description, |
| 26 | + tags, |
| 27 | +}: CombinationEvaluationCardProps) => { |
| 28 | + const gradeTextColorClass = getGradeTextColorClass(grade); |
| 29 | + const tagStyleClass = COMBINATION_NAME_STYLE_MAP[category]; |
| 30 | + |
| 31 | + return ( |
| 32 | + <div className="bg-white rounded-card px-42 py-30 flex flex-col gap-30"> |
| 33 | + <div className="flex items-center gap-16"> |
| 34 | + <p className="font-heading-4 text-black">{category}:</p> |
| 35 | + <p className={`font-heading-4 ${gradeTextColorClass}`}>{grade}</p> |
| 36 | + </div> |
| 37 | + <p className="font-body-3-r text-black leading-28">{description}</p> |
| 38 | + <div className="flex gap-8 -ml-4"> |
| 39 | + {tags.map((tag) => ( |
| 40 | + <span |
| 41 | + key={tag} |
| 42 | + className={`${tagStyleClass} font-body-2-sm px-12 py-8 rounded-full`} |
| 43 | + > |
| 44 | + {tag} |
| 45 | + </span> |
| 46 | + ))} |
| 47 | + </div> |
| 48 | + </div> |
| 49 | + ); |
| 50 | +}; |
| 51 | + |
| 52 | +export default CombinationEvaluationCard; |
0 commit comments