1
+ import * as icons from "@phosphor-icons/react/dist/ssr" ;
1
2
import type { Meta , StoryObj } from "@storybook/react" ;
2
3
3
- import { Card as CardComponent , VARIANTS } from "./index.jsx" ;
4
+ import { Badge } from "../Badge/index.jsx" ;
5
+ import { Button } from "../Button/index.jsx" ;
4
6
import { iconControl } from "../icon-control.jsx" ;
7
+ import { Card as CardComponent , VARIANTS } from "./index.jsx" ;
8
+ import styles from "./index.stories.module.scss" ;
5
9
6
10
const meta = {
7
11
component : CardComponent ,
@@ -62,6 +66,7 @@ const meta = {
62
66
} ,
63
67
} ,
64
68
} ,
69
+ tags : [ "autodocs" ] ,
65
70
} satisfies Meta < typeof CardComponent > ;
66
71
export default meta ;
67
72
@@ -74,3 +79,165 @@ export const Card = {
74
79
footer : "" ,
75
80
} ,
76
81
} satisfies StoryObj < typeof CardComponent > ;
82
+
83
+ type Story = StoryObj < typeof CardComponent > ;
84
+
85
+ export const BasicCard : Story = {
86
+ args : {
87
+ children : (
88
+ < p >
89
+ This is a basic card with just content. It can contain any React elements
90
+ and will display them with appropriate styling.
91
+ </ p >
92
+ ) ,
93
+ variant : "secondary" ,
94
+ } ,
95
+ } ;
96
+
97
+ export const WithTitleAndIcon : Story = {
98
+ args : {
99
+ icon : < icons . Package /> ,
100
+ title : "Product Details" ,
101
+ children : (
102
+ < div >
103
+ < p > This card has a title and an icon in the header.</ p >
104
+ < p > Icons help users quickly identify the card's purpose.</ p >
105
+ </ div >
106
+ ) ,
107
+ variant : "secondary" ,
108
+ } ,
109
+ } ;
110
+
111
+ export const WithToolbar : Story = {
112
+ args : {
113
+ title : "User Statistics" ,
114
+ toolbar : (
115
+ < >
116
+ < Button size = "sm" variant = "outline" >
117
+ < icons . DownloadSimple />
118
+ Export
119
+ </ Button >
120
+ < Button size = "sm" variant = "outline" >
121
+ < icons . ArrowsClockwise />
122
+ </ Button >
123
+ </ >
124
+ ) ,
125
+ children : (
126
+ < div >
127
+ < p > Total Users: 1,234</ p >
128
+ < p > Active Today: 567</ p >
129
+ < p > New This Week: 89</ p >
130
+ </ div >
131
+ ) ,
132
+ variant : "secondary" ,
133
+ } ,
134
+ } ;
135
+
136
+ export const WithFooter : Story = {
137
+ args : {
138
+ title : "Latest Activity" ,
139
+ children : (
140
+ < ul className = { styles . activityList } >
141
+ < li > User login at 10:30 AM</ li >
142
+ < li > Data sync completed at 10:15 AM</ li >
143
+ < li > Backup finished at 9:45 AM</ li >
144
+ </ ul >
145
+ ) ,
146
+ footer : (
147
+ < div className = { styles . footerContent } >
148
+ < span className = { styles . footerText } >
149
+ Last updated 5 minutes ago
150
+ </ span >
151
+ < Button size = "sm" variant = "link" >
152
+ View All
153
+ </ Button >
154
+ </ div >
155
+ ) ,
156
+ variant : "secondary" ,
157
+ } ,
158
+ } ;
159
+
160
+ export const AsLink : Story = {
161
+ args : {
162
+ href : "#" ,
163
+ icon : < icons . Link /> ,
164
+ title : "Clickable Card" ,
165
+ children : (
166
+ < p >
167
+ This entire card is clickable and will navigate to the specified URL.
168
+ Hover over it to see the interactive state.
169
+ </ p >
170
+ ) ,
171
+ variant : "secondary" ,
172
+ } ,
173
+ } ;
174
+
175
+ export const AsButton : Story = {
176
+ args : {
177
+ onPress : ( ) => alert ( "Card clicked!" ) ,
178
+ icon : < icons . CursorClick /> ,
179
+ title : "Interactive Card" ,
180
+ children : (
181
+ < p >
182
+ This card acts as a button. Click anywhere on it to trigger an action.
183
+ </ p >
184
+ ) ,
185
+ variant : "secondary" ,
186
+ } ,
187
+ } ;
188
+
189
+ export const CompleteExample : Story = {
190
+ args : {
191
+ icon : < icons . ChartBar /> ,
192
+ title : "Revenue Dashboard" ,
193
+ toolbar : (
194
+ < >
195
+ < Badge variant = "success" > Live</ Badge >
196
+ < Button size = "sm" variant = "ghost" >
197
+ < icons . DotsThree />
198
+ </ Button >
199
+ </ >
200
+ ) ,
201
+ children : (
202
+ < div >
203
+ < div className = { styles . revenueContent } >
204
+ < h3 className = { styles . revenueHeading } > $45,234</ h3 >
205
+ < p className = { styles . revenueSubtext } > Total Revenue This Month</ p >
206
+ </ div >
207
+ < div className = { styles . statsGrid } >
208
+ < div >
209
+ < p className = { styles . statLabel } > Orders</ p >
210
+ < p className = { styles . statValue } > 152</ p >
211
+ </ div >
212
+ < div >
213
+ < p className = { styles . statLabel } > Avg. Value</ p >
214
+ < p className = { styles . statValue } > $297.59</ p >
215
+ </ div >
216
+ </ div >
217
+ </ div >
218
+ ) ,
219
+ footer : (
220
+ < Button variant = "primary" fullWidth >
221
+ View Detailed Report
222
+ </ Button >
223
+ ) ,
224
+ variant : "primary" ,
225
+ } ,
226
+ } ;
227
+
228
+ export const AllVariants : Story = {
229
+ render : ( ) => (
230
+ < div className = { styles . variantsContainer } >
231
+ { VARIANTS . map ( ( variant ) => (
232
+ < CardComponent
233
+ key = { variant }
234
+ variant = { variant }
235
+ title = { `${ variant . charAt ( 0 ) . toUpperCase ( ) + variant . slice ( 1 ) } Card` }
236
+ icon = { < icons . Info /> }
237
+ >
238
+ < p > This is a { variant } variant card.</ p >
239
+ </ CardComponent >
240
+ ) ) }
241
+ </ div >
242
+ ) ,
243
+ } ;
0 commit comments