Skip to content

Commit ab63132

Browse files
committed
feat(card): bdp card addition
1 parent c29d589 commit ab63132

File tree

14 files changed

+173
-11
lines changed

14 files changed

+173
-11
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
assets/images

.storybook/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { StorybookConfig } from "@storybook/react-webpack5";
22

33
const config: StorybookConfig = {
4+
staticDirs: ['../src/assets/images'],
45
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
56
addons: [
67
"@storybook/addon-webpack5-compiler-swc",
8.13 KB
Loading

src/assets/images/whitepaper.png

7.23 KB
Loading

src/components/badge/ByBdp.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react'
2+
import { Pangolins } from '../../icons'
3+
4+
interface IByBDPBadge {
5+
className?:string
6+
}
7+
export const ByBDPBadge = () => {
8+
return (
9+
<div className='shadow-by-bdp text-brand-dark-100 border border-[#A9A49B] w-fit flex gap-1 p-1 rounded-md items-center bg-[#F6F0E6]'>
10+
<Pangolins />
11+
<span className='font-quicksand font-bold text-[11px] '>By BDP</span>
12+
</div>
13+
)
14+
}

src/components/badge/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./ByBdp"

src/components/button/Leaves.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,33 @@ import LeafIcon from "../../icons/LeafIcon";
44
import React from "react";
55

66
export interface LeavesProps {
7+
leavesCount: number;
78
onClick?: () => void;
89
disabled?: boolean;
910
withBorder?: boolean;
10-
leavesCount: number;
1111
selected?: boolean;
12+
showLeftOvers?: boolean
1213
}
1314

14-
export const Leaf: React.FC<LeavesProps> = ({ leavesCount = 1, selected=false }) => {
15-
const baseStyles = `rounded-md border border-brand-green w-max py-1 px-2 flex gap-1 hover:bg-brand-green/30 active:bg-brand-green active:text-white`
15+
export const Leaf: React.FC<LeavesProps> = ({ leavesCount = 1, selected=false, withBorder, showLeftOvers }) => {
16+
const baseStyles = `rounded-md w-max py-1 px-2 flex gap-1 `
1617
const allStyles = `
1718
${baseStyles}
1819
${selected ? "bg-brand-green text-white": " text-brand-green"}
20+
${withBorder ? "border border-brand-green" : "border-0"}
21+
${showLeftOvers? "bg-none! hover:bg-none" : "hover:bg-brand-green/30 active:bg-brand-green active:text-white"}
1922
`.trim();
2023

24+
const leaves = showLeftOvers ? Array.from({length:3}).map((_,i) => ({
25+
active: (i+1) <= leavesCount
26+
})) : []
2127
return <div className={allStyles} role="button" tabIndex={0}>
22-
{Array.from({length:leavesCount}).map((_,i)=>
28+
{ !showLeftOvers && Array.from({length:leavesCount}).map((_,i)=>
2329
<LeafIcon key={i} />
2430
)}
31+
32+
{showLeftOvers && leaves.map( (leave, i) =>
33+
<LeafIcon key={i} className={`${leave.active ? "text-brand-green" : "text-[#A9A49B99]"}`} /> )}
2534
</div>;
2635
};
2736

src/components/card/BDPCard.tsx

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,91 @@
11
// src/components/card/BDPCard.tsx
22

33
import React from "react";
4+
import { ByBDPBadge } from "../badge";
5+
import { Leaf } from "../button";
6+
import { Tag, TagType } from "../tag";
47
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[];
616
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",
923
}
1024

1125
export const BDPCard: React.FC<CardProps> = ({
12-
difficulty="easy",
26+
difficulty = "easy",
27+
logo,
1328
onClick,
14-
link
29+
title,
30+
description,
31+
bannerColor,
32+
link,
33+
tagList,
34+
byBDP,
1535
}) => {
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`;
1738

1839
const className = `
1940
${baseStyles}
2041
`.trim();
2142

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+
};
2255
return (
2356
<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>
2589
</a>
2690
);
2791
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// src/components/Card/BDPCard.tsx
2+
3+
import React from "react";
4+
import { StoryFn, Meta } from "@storybook/react";
5+
import { BDPCard, CardProps } from "./BDPCard";
6+
7+
8+
export default {
9+
title: "Components/Card",
10+
component: BDPCard,
11+
tags: ["autodocs"],
12+
} as Meta;
13+
14+
const Template: StoryFn<CardProps> = (args) => <BDPCard {...args} />;
15+
16+
export const Default = Template.bind({});
17+
Default.args = {
18+
bannerColor:"#D5BBA4",
19+
logo:"whitepaper.png",
20+
difficulty:"easy",
21+
title:"Bitcoin TLDR",
22+
description:"The foundational document that introduced Bitcoin, explaining its decentralized, P2P, electronic cash system.",
23+
tagList:["guide","interactive"]
24+
25+
}
26+
export const MediumDifficulty = Template.bind({});
27+
28+
MediumDifficulty.args = {
29+
bannerColor:"#0E9158",
30+
logo:"good-first-issues.png",
31+
difficulty:"medium",
32+
title:"Good first issues",
33+
byBDP:true,
34+
description:"Discover beginner-friendly issues from BOSS projects to start contributing today.",
35+
tagList:["tool"]
36+
37+
}
38+

src/components/card/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./BDPCard"

0 commit comments

Comments
 (0)