Skip to content

Commit 70f6493

Browse files
authored
feat: New Card for BDP (#46)
* chore(new-components): new componens from branding * feat(card): bdp card addition * chore:initial commit * --amend
1 parent aeaaf29 commit 70f6493

File tree

21 files changed

+342
-8
lines changed

21 files changed

+342
-8
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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react";
2+
import { Pangolins } from "../../icons";
3+
4+
export const ByBDPBadge = () => {
5+
return (
6+
<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]">
7+
<Pangolins />
8+
<span className="font-quicksand font-bold text-[11px] ">By BDP</span>
9+
</div>
10+
);
11+
};

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/Button.stories.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,14 @@ Disabled.args = {
3131
label: "Disabled Button",
3232
disabled: true,
3333
};
34+
export const PillButton = Template.bind({});
35+
PillButton.args = {
36+
label: "Learn",
37+
variant: "navigation",
38+
};
39+
40+
export const Rebrand = Template.bind({});
41+
Rebrand.args = {
42+
label: "Clear Filters",
43+
variant: "rebrand",
44+
};

src/components/button/Button.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import React from "react";
44
export interface ButtonProps {
55
label: string;
66
onClick?: () => void;
7-
variant?: "primary" | "secondary";
7+
variant?: "primary" | "secondary" | "navigation" | "rebrand";
88
size?: "small" | "medium" | "large";
99
disabled?: boolean;
10+
className?: string;
1011
}
1112

1213
export const Button: React.FC<ButtonProps> = ({
@@ -15,11 +16,18 @@ export const Button: React.FC<ButtonProps> = ({
1516
variant = "primary",
1617
size = "medium",
1718
disabled = false,
19+
className: customClass,
1820
}) => {
19-
const baseStyles = "font-bold py-2 px-4 rounded";
21+
const baseStyles = "font-bold";
2022
const variantStyles = {
21-
primary: "bg-blue-500 hover:bg-blue-700 text-white",
22-
secondary: "bg-gray-300 hover:bg-gray-400 text-gray-800",
23+
primary: "bg-blue-500 hover:bg-blue-700 py-2 px-4 text-white",
24+
secondary: "bg-gray-300 hover:bg-gray-400 py-2 px-4 text-gray-800",
25+
navigation: `border-brand-gray-100/60 rounded-lg bg-transparent border py-1 px-2 text-brand-gray-100/60
26+
hover:bg-brand-gray-200/20 active:bg-brand-gray-100/60 active:text-brand-gray-400 active:border-0
27+
`,
28+
rebrand:
29+
"bg-brand-orange-100 text-brand-light-100 px-2 py-2.5 rounded-lg font-bold hover:bg-brand-dark-100 w-full",
30+
custom: `${customClass}`,
2331
};
2432
const sizeStyles = {
2533
small: "text-sm",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// src/components/Button/Button.stories.tsx
2+
3+
import React from "react";
4+
import { StoryFn, Meta } from "@storybook/react";
5+
import { LeavesProps, Leaf } from "./Leaves";
6+
7+
export default {
8+
title: "Components/Leaves",
9+
component: Leaf,
10+
argTypes: {
11+
variant: {
12+
control: { type: "select", options: [1, 2, 3] },
13+
},
14+
selected: {
15+
control: "boolean",
16+
},
17+
onClick: { action: "clicked" },
18+
},
19+
} as Meta;
20+
21+
const Template: StoryFn<LeavesProps> = (args) => <Leaf {...args} />;
22+
23+
export const OneLeaf = Template.bind({});
24+
OneLeaf.args = {
25+
leavesCount: 1,
26+
};
27+
28+
export const TwoLeaf = Template.bind({});
29+
TwoLeaf.args = {
30+
leavesCount: 1,
31+
selected: true,
32+
};

src/components/button/Leaves.tsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// src/components/Button/Leaves.tsx
2+
3+
import LeafIcon from "../../icons/LeafIcon";
4+
import React from "react";
5+
6+
export interface LeavesProps {
7+
leavesCount: number;
8+
onClick?: () => void;
9+
disabled?: boolean;
10+
withBorder?: boolean;
11+
selected?: boolean;
12+
showLeftOvers?: boolean;
13+
}
14+
15+
export const Leaf: React.FC<LeavesProps> = ({
16+
leavesCount = 1,
17+
selected = false,
18+
withBorder,
19+
showLeftOvers,
20+
}) => {
21+
const baseStyles = `rounded-md w-max py-1 px-2 flex gap-1 `;
22+
const allStyles = `
23+
${baseStyles}
24+
${selected ? "bg-brand-green text-white" : " text-brand-green"}
25+
${withBorder ? "border border-brand-green" : "border-0"}
26+
${showLeftOvers ? "bg-none! hover:bg-none" : "hover:bg-brand-green/30 active:bg-brand-green active:text-white"}
27+
`.trim();
28+
29+
const leaves = showLeftOvers
30+
? Array.from({ length: 3 }).map((_, i) => ({
31+
active: i + 1 <= leavesCount,
32+
}))
33+
: [];
34+
return (
35+
<div className={allStyles} role="button" tabIndex={0}>
36+
{!showLeftOvers &&
37+
Array.from({ length: leavesCount }).map((_, i) => <LeafIcon key={i} />)}
38+
39+
{showLeftOvers &&
40+
leaves.map((leave, i) => (
41+
<LeafIcon
42+
key={i}
43+
className={`${leave.active ? "text-brand-green" : "text-[#A9A49B99]"}`}
44+
/>
45+
))}
46+
</div>
47+
);
48+
};

0 commit comments

Comments
 (0)