1
+ import type { Meta , StoryObj } from "@storybook/react" ;
2
+
3
+ import { Badge } from "../Badge/index.jsx" ;
4
+ import { EntityList as EntityListComponent } from "./index.jsx" ;
5
+
6
+ const meta = {
7
+ component : EntityListComponent ,
8
+ argTypes : {
9
+ label : {
10
+ control : "text" ,
11
+ description : "Aria label for the list" ,
12
+ table : {
13
+ category : "Accessibility" ,
14
+ } ,
15
+ } ,
16
+ isLoading : {
17
+ control : "boolean" ,
18
+ description : "Show loading state" ,
19
+ table : {
20
+ category : "State" ,
21
+ } ,
22
+ } ,
23
+ onSelectionChange : {
24
+ action : "selectionChanged" ,
25
+ table : {
26
+ category : "Events" ,
27
+ } ,
28
+ } ,
29
+ } ,
30
+ tags : [ "autodocs" ] ,
31
+ } satisfies Meta < typeof EntityListComponent > ;
32
+ export default meta ;
33
+
34
+ type Story = StoryObj < typeof EntityListComponent > ;
35
+
36
+ const defaultFields = [
37
+ { id : "name" as const , name : "Name" } ,
38
+ { id : "status" as const , name : "Status" } ,
39
+ { id : "price" as const , name : "Price" } ,
40
+ { id : "change" as const , name : "24h Change" } ,
41
+ ] ;
42
+
43
+ const sampleRows = [
44
+ {
45
+ id : "1" ,
46
+ textValue : "Bitcoin" ,
47
+ data : {
48
+ name : "Bitcoin" ,
49
+ status : < Badge variant = "success" > Active</ Badge > ,
50
+ price : "$45,234.56" ,
51
+ change : "+2.34%" ,
52
+ } ,
53
+ } ,
54
+ {
55
+ id : "2" ,
56
+ textValue : "Ethereum" ,
57
+ data : {
58
+ name : "Ethereum" ,
59
+ status : < Badge variant = "success" > Active</ Badge > ,
60
+ price : "$3,234.56" ,
61
+ change : "-1.23%" ,
62
+ } ,
63
+ } ,
64
+ {
65
+ id : "3" ,
66
+ textValue : "Solana" ,
67
+ data : {
68
+ name : "Solana" ,
69
+ status : < Badge variant = "success" > Active</ Badge > ,
70
+ price : "$123.45" ,
71
+ change : "+5.67%" ,
72
+ } ,
73
+ } ,
74
+ ] ;
75
+
76
+ export const Default : Story = {
77
+ args : {
78
+ label : "Cryptocurrency list" ,
79
+ fields : defaultFields ,
80
+ rows : sampleRows ,
81
+ isLoading : false ,
82
+ } ,
83
+ } ;
84
+
85
+ export const Loading : Story = {
86
+ args : {
87
+ label : "Cryptocurrency list" ,
88
+ fields : [
89
+ { id : "name" as const , name : "Name" , loadingSkeletonWidth : 80 } ,
90
+ { id : "status" as const , name : "Status" , loadingSkeletonWidth : 60 } ,
91
+ { id : "price" as const , name : "Price" , loadingSkeletonWidth : 100 } ,
92
+ { id : "change" as const , name : "24h Change" , loadingSkeletonWidth : 70 } ,
93
+ ] ,
94
+ isLoading : true ,
95
+ } ,
96
+ } ;
97
+
98
+ export const WithHeaders : Story = {
99
+ args : {
100
+ label : "Price feeds" ,
101
+ fields : [
102
+ { id : "symbol" as const , name : "Symbol" } ,
103
+ { id : "confidence" as const , name : "Confidence" } ,
104
+ { id : "price" as const , name : "Price" } ,
105
+ ] ,
106
+ rows : [
107
+ {
108
+ id : "btc-usd" ,
109
+ textValue : "BTC/USD" ,
110
+ header : < h3 > BTC/USD</ h3 > ,
111
+ data : {
112
+ symbol : "BTC/USD" ,
113
+ confidence : "±$12.34" ,
114
+ price : "$45,234.56" ,
115
+ } ,
116
+ } ,
117
+ {
118
+ id : "eth-usd" ,
119
+ textValue : "ETH/USD" ,
120
+ header : < h3 > ETH/USD</ h3 > ,
121
+ data : {
122
+ symbol : "ETH/USD" ,
123
+ confidence : "±$2.34" ,
124
+ price : "$3,234.56" ,
125
+ } ,
126
+ } ,
127
+ ] ,
128
+ } ,
129
+ } ;
130
+
131
+ export const WithLinks : Story = {
132
+ args : {
133
+ label : "Blockchain networks" ,
134
+ fields : [
135
+ { id : "network" as const , name : "Network" } ,
136
+ { id : "chainId" as const , name : "Chain ID" } ,
137
+ { id : "rpc" as const , name : "RPC" } ,
138
+ ] ,
139
+ rows : [
140
+ {
141
+ id : "ethereum" ,
142
+ textValue : "Ethereum" ,
143
+ href : "#ethereum" ,
144
+ data : {
145
+ network : "Ethereum" ,
146
+ chainId : "1" ,
147
+ rpc : "https://eth.example.com" ,
148
+ } ,
149
+ } ,
150
+ {
151
+ id : "polygon" ,
152
+ textValue : "Polygon" ,
153
+ href : "#polygon" ,
154
+ data : {
155
+ network : "Polygon" ,
156
+ chainId : "137" ,
157
+ rpc : "https://polygon.example.com" ,
158
+ } ,
159
+ } ,
160
+ ] ,
161
+ } ,
162
+ } ;
163
+
164
+ export const SingleRow : Story = {
165
+ args : {
166
+ label : "Single item list" ,
167
+ fields : [
168
+ { id : "key" as const , name : "Key" } ,
169
+ { id : "value" as const , name : "Value" } ,
170
+ ] ,
171
+ rows : [
172
+ {
173
+ id : "single" ,
174
+ textValue : "Configuration" ,
175
+ data : {
176
+ key : "API_ENDPOINT" ,
177
+ value : "https://api.example.com" ,
178
+ } ,
179
+ } ,
180
+ ] ,
181
+ } ,
182
+ } ;
183
+
184
+ export const ComplexContent : Story = {
185
+ args : {
186
+ label : "Complex content list" ,
187
+ fields : [
188
+ { id : "project" as const , name : "Project" } ,
189
+ { id : "metrics" as const , name : "Metrics" } ,
190
+ { id : "actions" as const , name : "Actions" } ,
191
+ ] ,
192
+ rows : [
193
+ {
194
+ id : "project-1" ,
195
+ textValue : "Project Alpha" ,
196
+ data : {
197
+ project : < strong > Project Alpha</ strong > ,
198
+ metrics : (
199
+ < div style = { { display : "flex" , gap : "8px" } } >
200
+ < Badge variant = "neutral" > 10 feeds</ Badge >
201
+ < Badge variant = "success" > 98% uptime</ Badge >
202
+ </ div >
203
+ ) ,
204
+ actions : (
205
+ < div style = { { display : "flex" , gap : "8px" } } >
206
+ < button > Edit</ button >
207
+ < button > Delete</ button >
208
+ </ div >
209
+ ) ,
210
+ } ,
211
+ } ,
212
+ {
213
+ id : "project-2" ,
214
+ textValue : "Project Beta" ,
215
+ data : {
216
+ project : < strong > Project Beta</ strong > ,
217
+ metrics : (
218
+ < div style = { { display : "flex" , gap : "8px" } } >
219
+ < Badge variant = "neutral" > 5 feeds</ Badge >
220
+ < Badge variant = "warning" > 92% uptime</ Badge >
221
+ </ div >
222
+ ) ,
223
+ actions : (
224
+ < div style = { { display : "flex" , gap : "8px" } } >
225
+ < button > Edit</ button >
226
+ < button > Delete</ button >
227
+ </ div >
228
+ ) ,
229
+ } ,
230
+ } ,
231
+ ] ,
232
+ } ,
233
+ } ;
0 commit comments