1
+ import type { Meta , StoryObj } from "@storybook/react" ;
2
+
3
+ import { Meter as MeterComponent } from "./index.jsx" ;
4
+
5
+ const meta = {
6
+ component : MeterComponent ,
7
+ argTypes : {
8
+ value : {
9
+ control : { type : "range" , min : 0 , max : 100 , step : 1 } ,
10
+ description : "The current value" ,
11
+ table : {
12
+ category : "Value" ,
13
+ } ,
14
+ } ,
15
+ minValue : {
16
+ control : "number" ,
17
+ description : "The minimum value" ,
18
+ table : {
19
+ category : "Value" ,
20
+ } ,
21
+ } ,
22
+ maxValue : {
23
+ control : "number" ,
24
+ description : "The maximum value" ,
25
+ table : {
26
+ category : "Value" ,
27
+ } ,
28
+ } ,
29
+ label : {
30
+ control : "text" ,
31
+ description : "Aria label for accessibility" ,
32
+ table : {
33
+ category : "Accessibility" ,
34
+ } ,
35
+ } ,
36
+ startLabel : {
37
+ control : "text" ,
38
+ description : "Label shown at the start of the meter" ,
39
+ table : {
40
+ category : "Labels" ,
41
+ } ,
42
+ } ,
43
+ endLabel : {
44
+ control : "text" ,
45
+ description : "Label shown at the end of the meter" ,
46
+ table : {
47
+ category : "Labels" ,
48
+ } ,
49
+ } ,
50
+ variant : {
51
+ control : "radio" ,
52
+ options : [ "default" , "error" ] ,
53
+ description : "Visual variant of the meter" ,
54
+ table : {
55
+ category : "Appearance" ,
56
+ } ,
57
+ } ,
58
+ labelClassName : {
59
+ control : "text" ,
60
+ description : "Class name for the label" ,
61
+ table : {
62
+ category : "Labels" ,
63
+ } ,
64
+ } ,
65
+ } ,
66
+ tags : [ "autodocs" ] ,
67
+ } satisfies Meta < typeof MeterComponent > ;
68
+ export default meta ;
69
+
70
+ type Story = StoryObj < typeof MeterComponent > ;
71
+
72
+ export const Default : Story = {
73
+ args : {
74
+ label : "Progress" ,
75
+ value : 50 ,
76
+ minValue : 0 ,
77
+ maxValue : 100 ,
78
+ } ,
79
+ } ;
80
+
81
+ export const WithLabels : Story = {
82
+ args : {
83
+ label : "Storage usage" ,
84
+ value : 75 ,
85
+ minValue : 0 ,
86
+ maxValue : 100 ,
87
+ startLabel : "0 GB" ,
88
+ endLabel : "100 GB" ,
89
+ } ,
90
+ } ;
91
+
92
+ export const ErrorVariant : Story = {
93
+ args : {
94
+ label : "Critical usage" ,
95
+ value : 95 ,
96
+ minValue : 0 ,
97
+ maxValue : 100 ,
98
+ startLabel : "0%" ,
99
+ endLabel : "100%" ,
100
+ variant : "error" ,
101
+ } ,
102
+ } ;
103
+
104
+ export const Empty : Story = {
105
+ args : {
106
+ label : "No progress" ,
107
+ value : 0 ,
108
+ minValue : 0 ,
109
+ maxValue : 100 ,
110
+ startLabel : "Start" ,
111
+ endLabel : "End" ,
112
+ } ,
113
+ } ;
114
+
115
+ export const Full : Story = {
116
+ args : {
117
+ label : "Complete" ,
118
+ value : 100 ,
119
+ minValue : 0 ,
120
+ maxValue : 100 ,
121
+ startLabel : "0%" ,
122
+ endLabel : "100%" ,
123
+ } ,
124
+ } ;
125
+
126
+ export const CustomRange : Story = {
127
+ args : {
128
+ label : "Temperature" ,
129
+ value : 72 ,
130
+ minValue : 32 ,
131
+ maxValue : 100 ,
132
+ startLabel : "32°F" ,
133
+ endLabel : "100°F" ,
134
+ } ,
135
+ } ;
136
+
137
+ export const LoadingProgress : Story = {
138
+ args : {
139
+ label : "Loading" ,
140
+ value : 33 ,
141
+ minValue : 0 ,
142
+ maxValue : 100 ,
143
+ startLabel : "0 MB" ,
144
+ endLabel : "150 MB" ,
145
+ } ,
146
+ } ;
147
+
148
+ export const BatteryLevel : Story = {
149
+ args : {
150
+ label : "Battery" ,
151
+ value : 20 ,
152
+ minValue : 0 ,
153
+ maxValue : 100 ,
154
+ startLabel : "Empty" ,
155
+ endLabel : "Full" ,
156
+ variant : "error" ,
157
+ } ,
158
+ } ;
159
+
160
+ export const PerformanceScore : Story = {
161
+ render : ( ) => (
162
+ < div style = { { display : "flex" , flexDirection : "column" , gap : "24px" } } >
163
+ < div >
164
+ < h3 style = { { marginBottom : "8px" } } > CPU Usage</ h3 >
165
+ < MeterComponent
166
+ label = "CPU usage"
167
+ value = { 45 }
168
+ minValue = { 0 }
169
+ maxValue = { 100 }
170
+ startLabel = "0%"
171
+ endLabel = "100%"
172
+ />
173
+ </ div >
174
+ < div >
175
+ < h3 style = { { marginBottom : "8px" } } > Memory Usage</ h3 >
176
+ < MeterComponent
177
+ label = "Memory usage"
178
+ value = { 78 }
179
+ minValue = { 0 }
180
+ maxValue = { 100 }
181
+ startLabel = "0%"
182
+ endLabel = "100%"
183
+ variant = "error"
184
+ />
185
+ </ div >
186
+ < div >
187
+ < h3 style = { { marginBottom : "8px" } } > Disk Usage</ h3 >
188
+ < MeterComponent
189
+ label = "Disk usage"
190
+ value = { 30 }
191
+ minValue = { 0 }
192
+ maxValue = { 100 }
193
+ startLabel = "0%"
194
+ endLabel = "100%"
195
+ />
196
+ </ div >
197
+ </ div >
198
+ ) ,
199
+ } ;
0 commit comments