|
1 | 1 | // src/components/card/BDPCard.tsx |
2 | 2 |
|
3 | 3 | import React from "react"; |
| 4 | +import { ByBDPBadge } from "../badge"; |
| 5 | +import { Leaf } from "../button"; |
| 6 | +import { Tag, TagType } from "../tag"; |
4 | 7 | export interface CardProps { |
5 | | - difficulty?: "easy" | "medium" | "hard"; |
| 8 | + title: string; |
| 9 | + description: string; |
| 10 | + bannerColor: string; |
| 11 | + onClick: () => void; |
| 12 | + logo: string; |
| 13 | + link: string; |
| 14 | + difficulty: Difficulty; |
| 15 | + tagList: TagType[]; |
6 | 16 | byBDP?: boolean; |
7 | | - onClick: ()=> void; |
8 | | - link:string; |
| 17 | +} |
| 18 | +export type Difficulty = "easy" | "medium" | "hard"; |
| 19 | +enum DIFFICULTY { |
| 20 | + EASY = "easy", |
| 21 | + MEDIUM = "medium", |
| 22 | + HARD = "hard", |
9 | 23 | } |
10 | 24 |
|
11 | 25 | export const BDPCard: React.FC<CardProps> = ({ |
12 | | - difficulty="easy", |
| 26 | + difficulty = "easy", |
| 27 | + logo, |
13 | 28 | onClick, |
14 | | - link |
| 29 | + title, |
| 30 | + description, |
| 31 | + bannerColor, |
| 32 | + link, |
| 33 | + tagList, |
| 34 | + byBDP, |
15 | 35 | }) => { |
16 | | - const baseStyles = "min-h"; |
| 36 | + const baseStyles = `border border-brand-stroke-on-base p-2 |
| 37 | + flex min-h-[290px] w-[374px] rounded-2xl bg-brand-card-bg`; |
17 | 38 |
|
18 | 39 | const className = ` |
19 | 40 | ${baseStyles} |
20 | 41 | `.trim(); |
21 | 42 |
|
| 43 | + const convertToLeavesCount = (level: string) => { |
| 44 | + switch (level) { |
| 45 | + case DIFFICULTY.EASY: |
| 46 | + return 1; |
| 47 | + case DIFFICULTY.MEDIUM: |
| 48 | + return 2; |
| 49 | + case DIFFICULTY.HARD: |
| 50 | + return 3; |
| 51 | + default: |
| 52 | + return 0; |
| 53 | + } |
| 54 | + }; |
22 | 55 | return ( |
23 | 56 | <a href={link} className={className} onClick={onClick}> |
24 | | - |
| 57 | + <div className="flex flex-col rounded-xl border border-brand-stroke-on-base w-full min-h-full bg-brand-card-bg"> |
| 58 | + <div |
| 59 | + className={`h-[126px] flex border border-l-0 border-r-0 border-t-0 |
| 60 | + border-brand-stroke-on-base rounded-lg relative flex-col items-center justify-center`} |
| 61 | + style={{ backgroundColor: bannerColor }} |
| 62 | + > |
| 63 | + <div> |
| 64 | + <img className="w-full h-fit" src={logo} /> |
| 65 | + </div> |
| 66 | + |
| 67 | + {byBDP && <div className="absolute bottom-3 left-3"> |
| 68 | + <ByBDPBadge /> |
| 69 | + </div> } |
| 70 | + </div> |
| 71 | + {/* Footer */} |
| 72 | + <div className="flex flex-col w-full p-3 gap-2"> |
| 73 | + <div className="w-full flex items-center justify-between"> |
| 74 | + <h6 className="font-montserrat text-lg font-semibold">{title}</h6> |
| 75 | + <Leaf showLeftOvers leavesCount={convertToLeavesCount(difficulty)} /> |
| 76 | + </div> |
| 77 | + <p className="font-light font-quicksand">{description}</p> |
| 78 | + |
| 79 | + <div className="flex gap-[9px] flex-wrap"> |
| 80 | + {tagList && |
| 81 | + tagList.map((tag) => ( |
| 82 | + <Tag className="capitalize" key={tag} type={tag}> |
| 83 | + {tag} |
| 84 | + </Tag> |
| 85 | + ))} |
| 86 | + </div> |
| 87 | + </div> |
| 88 | + </div> |
25 | 89 | </a> |
26 | 90 | ); |
27 | 91 | }; |
0 commit comments