1
+ import { ButtonVariantValues } from '@components/components/Button/types' ;
2
+ import { MATERIAL_UI_ICONS , PHOSPHOR_ICONS } from '@components/components/Icon/constants' ;
3
+ import { SizeValues } from '@components/theme/config' ;
1
4
import React from 'react' ;
2
5
3
6
import type { Meta , StoryObj } from '@storybook/react' ;
@@ -33,7 +36,7 @@ const meta = {
33
36
} ,
34
37
variant : {
35
38
description : 'The variant of the Button.' ,
36
- options : [ 'filled' , 'outline' , 'text' ] ,
39
+ options : Object . values ( ButtonVariantValues ) ,
37
40
table : {
38
41
defaultValue : { summary : buttonDefaults . variant } ,
39
42
} ,
@@ -43,7 +46,7 @@ const meta = {
43
46
} ,
44
47
color : {
45
48
description : 'The color of the Button.' ,
46
- options : [ 'violet' , 'green' , 'red' , 'blue' , ' gray'] ,
49
+ options : [ 'violet' , 'green' , 'red' , 'gray' ] ,
47
50
table : {
48
51
defaultValue : { summary : buttonDefaults . color } ,
49
52
} ,
@@ -53,31 +56,22 @@ const meta = {
53
56
} ,
54
57
size : {
55
58
description : 'The size of the Button.' ,
56
- options : [ 'sm' , 'md' , 'lg' , 'xl' ] ,
59
+ options : Object . values ( SizeValues ) ,
57
60
table : {
58
61
defaultValue : { summary : buttonDefaults . size } ,
59
62
} ,
60
63
control : {
61
64
type : 'select' ,
62
65
} ,
63
66
} ,
64
- iconSize : {
65
- description : 'The optional size of the Icon.' ,
66
- options : [ 'xs' , 'sm' , 'md' , 'lg' , 'xl' , '2xl' , '3xl' , '4xl' ] ,
67
- table : {
68
- defaultValue : {
69
- summary : 'undefined' ,
70
- detail : 'The size of the Button will be used as the size of the Icon' ,
71
- } ,
72
- } ,
73
- control : {
74
- type : 'select' ,
75
- } ,
76
- } ,
77
67
icon : {
78
68
description : 'The icon to display in the Button.' ,
79
69
type : 'string' ,
80
70
options : AVAILABLE_ICONS ,
71
+ mapping : Object . fromEntries ( [
72
+ ...MATERIAL_UI_ICONS . map ( ( icon ) => [ icon , { icon, source : 'material' , size : '2xl' } ] ) ,
73
+ ...PHOSPHOR_ICONS . map ( ( icon ) => [ icon , { icon, source : 'phosphor' , size : '2xl' } ] ) ,
74
+ ] ) ,
81
75
table : {
82
76
defaultValue : { summary : 'undefined' } ,
83
77
} ,
@@ -143,7 +137,7 @@ const meta = {
143
137
144
138
// Define defaults
145
139
args : {
146
- children : 'Button Content ' ,
140
+ children : 'Button' ,
147
141
variant : buttonDefaults . variant ,
148
142
color : buttonDefaults . color ,
149
143
size : buttonDefaults . size ,
@@ -167,7 +161,7 @@ type Story = StoryObj<typeof meta>;
167
161
// Pass props to this so that it can be customized via the UI props panel
168
162
export const sandbox : Story = {
169
163
tags : [ 'dev' ] ,
170
- render : ( props ) => < Button { ...props } > Button </ Button > ,
164
+ render : ( props ) => < Button { ...props } / >,
171
165
} ;
172
166
173
167
export const states = ( ) => (
@@ -191,26 +185,27 @@ export const colors = () => (
191
185
192
186
export const sizes = ( ) => (
193
187
< GridList >
194
- < Button size = "sm" > Small Button</ Button >
195
- < Button size = "md" > Regular Button</ Button >
196
- < Button size = "lg" > Large Button</ Button >
197
- < Button size = "xl" > XLarge Button</ Button >
188
+ < Button size = "xs" > XSmall</ Button >
189
+ < Button size = "sm" > Small</ Button >
190
+ < Button size = "md" > Regular</ Button >
191
+ < Button size = "lg" > Large</ Button >
192
+ < Button size = "xl" > XLarge</ Button >
198
193
</ GridList >
199
194
) ;
200
195
201
196
export const withIcon = ( ) => (
202
197
< GridList >
203
- < Button icon = " Add" > Icon Left</ Button >
204
- < Button icon = " Add" iconPosition = "right" >
198
+ < Button icon = { { icon : ' Add' , source : 'material' } } > Icon Left</ Button >
199
+ < Button icon = { { icon : ' Add' , source : 'material' } } iconPosition = "right" >
205
200
Icon Right
206
201
</ Button >
207
202
</ GridList >
208
203
) ;
209
204
210
205
export const circleShape = ( ) => (
211
206
< GridList >
212
- < Button icon = " Add" size = "sm" isCircle />
213
- < Button icon = " Add" isCircle />
214
- < Button icon = " Add" size = "lg" isCircle />
207
+ < Button icon = { { icon : ' Add' , source : 'material' } } size = "sm" isCircle />
208
+ < Button icon = { { icon : ' Add' , source : 'material' } } isCircle />
209
+ < Button icon = { { icon : ' Add' , source : 'material' } } size = "lg" isCircle />
215
210
</ GridList >
216
211
) ;
0 commit comments