@@ -37,7 +37,7 @@ cssInterop(UIButton.Spinner, { className: 'style' });
37
37
cssInterop ( UIButton . Icon , { className : 'style' } ) ;
38
38
39
39
const buttonStyle = tva ( {
40
- base : 'group/button rounded-lg bg-primary-500 flex-row items-center justify-center data-[focus=true]:web:outline-none data-[focus-visible=true]:web:ring-2 ' ,
40
+ base : 'group/button rounded-lg bg-primary-500 flex-row items-center justify-center data-[focus=true]:web:outline-none data-[focus-visible=true]:web:ring-2 data-[disabled=true]:opacity-40 ' ,
41
41
variants : {
42
42
action : {
43
43
primary :
@@ -160,6 +160,62 @@ const buttonTextStyle = tva({
160
160
] ,
161
161
} ) ;
162
162
163
+ const buttonIconStyle = tva ( {
164
+ base : 'text-typography-0' ,
165
+ parentVariants : {
166
+ action : {
167
+ primary :
168
+ 'text-primary-600 group-hover/button:text-primary-600 group-active/button:text-primary-700' ,
169
+ secondary :
170
+ 'text-secondary-600 group-hover/button:text-secondary-600 group-active/button:text-secondary-700' ,
171
+ positive :
172
+ 'text-success-600 group-hover/button:text-success-600 group-active/button:text-success-700' ,
173
+ negative :
174
+ 'text-error-600 group-hover/button:text-error-600 group-active/button:text-error-700' ,
175
+ } ,
176
+ variant : {
177
+ link : 'group-hover/button:underline group-active/button:underline' ,
178
+ outline : '' ,
179
+ solid :
180
+ 'text-typography-0 group-hover/button:text-typography-0 group-active/button:text-typography-0' ,
181
+ } ,
182
+ size : {
183
+ '2xs' : 'h-3 w-3' ,
184
+ 'xs' : 'h-3.5 w-3.5' ,
185
+ 'sm' : 'h-4 w-4' ,
186
+ 'md' : 'h-[18px] w-[18px]' ,
187
+ 'lg' : 'h-5 w-5' ,
188
+ 'xl' : 'h-6 w-6' ,
189
+ } ,
190
+ } ,
191
+ parentCompoundVariants : [
192
+ {
193
+ variant : 'solid' ,
194
+ action : 'primary' ,
195
+ class :
196
+ 'text-typography-0 group-hover/button:text-typography-0 group-active/button:text-typography-0' ,
197
+ } ,
198
+ {
199
+ variant : 'solid' ,
200
+ action : 'secondary' ,
201
+ class :
202
+ 'text-typography-0 group-hover/button:text-typography-0 group-active/button:text-typography-0' ,
203
+ } ,
204
+ {
205
+ variant : 'solid' ,
206
+ action : 'positive' ,
207
+ class :
208
+ 'text-typography-0 group-hover/button:text-typography-0 group-active/button:text-typography-0' ,
209
+ } ,
210
+ {
211
+ variant : 'solid' ,
212
+ action : 'negative' ,
213
+ class :
214
+ 'text-typography-0 group-hover/button:text-typography-0 group-active/button:text-typography-0' ,
215
+ } ,
216
+ ] ,
217
+ } ) ;
218
+
163
219
type IButtonProps = React . ComponentProps < typeof UIButton > &
164
220
VariantProps < typeof buttonStyle > ;
165
221
@@ -234,12 +290,43 @@ const ButtonSpinner = UIButton.Spinner;
234
290
const ButtonIcon = ( {
235
291
className,
236
292
as : AsComp ,
293
+ size,
237
294
...props
238
295
} : IButtonIcon & { className ?: any } ) => {
296
+ const {
297
+ variant : parentVariant ,
298
+ size : parentSize ,
299
+ action : parentAction ,
300
+ } = useStyleContext ( ) ;
301
+
239
302
if ( AsComp ) {
240
- return < AsComp className = { className } { ...props } /> ;
303
+ return (
304
+ < AsComp
305
+ { ...props }
306
+ className = { buttonIconStyle ( {
307
+ parentVariants : {
308
+ size : parentSize ,
309
+ variant : parentVariant ,
310
+ action : parentAction ,
311
+ } ,
312
+ size,
313
+ class : className ,
314
+ } ) }
315
+ />
316
+ ) ;
241
317
}
242
- return < UIButton . Icon className = { className } { ...props } /> ;
318
+ return (
319
+ < UIButton . Icon
320
+ { ...props }
321
+ className = { buttonIconStyle ( {
322
+ parentVariants : {
323
+ size : parentSize ,
324
+ } ,
325
+ size,
326
+ class : className ,
327
+ } ) }
328
+ />
329
+ ) ;
243
330
} ;
244
331
Button . displayName = 'Button' ;
245
332
ButtonText . displayName = 'ButtonText' ;
0 commit comments