Skip to content

Commit 49f8366

Browse files
committed
docs: add stories for Badge types
1 parent fa74d53 commit 49f8366

File tree

1 file changed

+129
-1
lines changed

1 file changed

+129
-1
lines changed

packages/component-library/src/Badge/index.stories.tsx

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Meta, StoryObj } from "@storybook/react";
22

3-
import { Badge as BadgeComponent, VARIANTS, SIZES, STYLES } from "./index.jsx";
3+
import { Badge as BadgeComponent, SIZES, STYLES, VARIANTS } from "./index.jsx";
44

55
const meta = {
66
component: BadgeComponent,
@@ -33,6 +33,7 @@ const meta = {
3333
},
3434
},
3535
},
36+
tags: ["autodocs"],
3637
} satisfies Meta<typeof BadgeComponent>;
3738
export default meta;
3839

@@ -44,3 +45,130 @@ export const Badge = {
4445
size: "md",
4546
},
4647
} satisfies StoryObj<typeof BadgeComponent>;
48+
49+
type Story = StoryObj<typeof BadgeComponent>;
50+
51+
const renderAllVariants = (style: typeof STYLES[number], size: typeof SIZES[number], children: React.ReactNode) => (
52+
<div style={{ display: "flex", gap: "8px", flexWrap: "wrap", alignItems: "center" }}>
53+
{VARIANTS.map((variant) => (
54+
<BadgeComponent key={variant} variant={variant} style={style} size={size}>
55+
{children}
56+
</BadgeComponent>
57+
))}
58+
</div>
59+
);
60+
61+
export const FilledXS: Story = {
62+
args: {
63+
children: "Badge",
64+
},
65+
render: ({ children }) => renderAllVariants("filled", "xs", children),
66+
argTypes: {
67+
variant: { table: { disable: true } },
68+
style: { table: { disable: true } },
69+
size: { table: { disable: true } },
70+
},
71+
parameters: {
72+
docs: {
73+
description: {
74+
story: "Extra small filled badges in all variants",
75+
},
76+
},
77+
},
78+
};
79+
80+
export const FilledMD: Story = {
81+
args: {
82+
children: "Badge",
83+
},
84+
render: ({ children }) => renderAllVariants("filled", "md", children),
85+
argTypes: {
86+
variant: { table: { disable: true } },
87+
style: { table: { disable: true } },
88+
size: { table: { disable: true } },
89+
},
90+
parameters: {
91+
docs: {
92+
description: {
93+
story: "Medium filled badges in all variants",
94+
},
95+
},
96+
},
97+
};
98+
99+
export const FilledLG: Story = {
100+
args: {
101+
children: "Badge",
102+
},
103+
render: ({ children }) => renderAllVariants("filled", "lg", children),
104+
argTypes: {
105+
variant: { table: { disable: true } },
106+
style: { table: { disable: true } },
107+
size: { table: { disable: true } },
108+
},
109+
parameters: {
110+
docs: {
111+
description: {
112+
story: "Large filled badges in all variants",
113+
},
114+
},
115+
},
116+
};
117+
118+
export const OutlineXS: Story = {
119+
args: {
120+
children: "Badge",
121+
},
122+
render: ({ children }) => renderAllVariants("outline", "xs", children),
123+
argTypes: {
124+
variant: { table: { disable: true } },
125+
style: { table: { disable: true } },
126+
size: { table: { disable: true } },
127+
},
128+
parameters: {
129+
docs: {
130+
description: {
131+
story: "Extra small outline badges in all variants",
132+
},
133+
},
134+
},
135+
};
136+
137+
138+
export const OutlineMD: Story = {
139+
args: {
140+
children: "Badge",
141+
},
142+
render: ({ children }) => renderAllVariants("outline", "md", children),
143+
argTypes: {
144+
variant: { table: { disable: true } },
145+
style: { table: { disable: true } },
146+
size: { table: { disable: true } },
147+
},
148+
parameters: {
149+
docs: {
150+
description: {
151+
story: "Medium outline badges in all variants",
152+
},
153+
},
154+
},
155+
};
156+
157+
export const OutlineLG: Story = {
158+
args: {
159+
children: "Badge",
160+
},
161+
render: ({ children }) => renderAllVariants("outline", "lg", children),
162+
argTypes: {
163+
variant: { table: { disable: true } },
164+
style: { table: { disable: true } },
165+
size: { table: { disable: true } },
166+
},
167+
parameters: {
168+
docs: {
169+
description: {
170+
story: "Large outline badges in all variants",
171+
},
172+
},
173+
},
174+
};

0 commit comments

Comments
 (0)