13
13
import { baseColor , focusRing , fontRelative , style } from '../style' with { type : 'macro' } ;
14
14
import { ButtonRenderProps , ContextValue , Link , LinkProps , OverlayTriggerStateContext , Provider , Button as RACButton , ButtonProps as RACButtonProps } from 'react-aria-components' ;
15
15
import { centerBaseline } from './CenterBaseline' ;
16
- import { centerPadding , getAllowedOverrides , StyleProps } from './style-utils' with { type : 'macro' } ;
16
+ import { centerPadding , getAllowedOverrides , staticColor , StyleProps } from './style-utils' with { type : 'macro' } ;
17
17
import { createContext , forwardRef , ReactNode , useContext , useEffect , useState } from 'react' ;
18
18
import { FocusableRef , FocusableRefValue } from '@react-types/shared' ;
19
19
import { IconContext } from './Icon' ;
@@ -48,7 +48,7 @@ interface ButtonStyleProps {
48
48
*/
49
49
size ?: 'S' | 'M' | 'L' | 'XL' ,
50
50
/** The static color style to apply. Useful when the Button appears over a color background. */
51
- staticColor ?: 'white' | 'black'
51
+ staticColor ?: 'white' | 'black' | 'auto'
52
52
}
53
53
54
54
export interface ButtonProps extends Omit < RACButtonProps , 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange' > , StyleProps , ButtonStyleProps {
@@ -65,8 +65,9 @@ export const ButtonContext = createContext<ContextValue<ButtonProps, FocusableRe
65
65
export const LinkButtonContext = createContext < ContextValue < ButtonProps , FocusableRefValue < HTMLAnchorElement > > > ( null ) ;
66
66
67
67
const iconOnly = ':has([slot=icon]):not(:has([data-rsp-slot=text]))' ;
68
- const button = style < ButtonRenderProps & ButtonStyleProps > ( {
68
+ const button = style < ButtonRenderProps & ButtonStyleProps & { isStaticColor : boolean } > ( {
69
69
...focusRing ( ) ,
70
+ ...staticColor ( ) ,
70
71
position : 'relative' ,
71
72
display : 'flex' ,
72
73
alignItems : {
@@ -120,21 +121,12 @@ const button = style<ButtonRenderProps & ButtonStyleProps>({
120
121
secondary : baseColor ( 'gray-300' )
121
122
} ,
122
123
isDisabled : 'disabled' ,
123
- staticColor : {
124
- white : {
125
- variant : {
126
- primary : baseColor ( 'transparent-white-800' ) ,
127
- secondary : baseColor ( 'transparent-white-300' )
128
- } ,
129
- isDisabled : 'transparent-white-300'
124
+ isStaticColor : {
125
+ variant : {
126
+ primary : baseColor ( 'transparent-overlay-800' ) ,
127
+ secondary : baseColor ( 'transparent-overlay-300' )
130
128
} ,
131
- black : {
132
- variant : {
133
- primary : baseColor ( 'transparent-black-800' ) ,
134
- secondary : baseColor ( 'transparent-black-300' )
135
- } ,
136
- isDisabled : 'transparent-black-300'
137
- }
129
+ isDisabled : 'transparent-overlay-300'
138
130
} ,
139
131
forcedColors : {
140
132
default : 'ButtonBorder' ,
@@ -161,41 +153,21 @@ const button = style<ButtonRenderProps & ButtonStyleProps>({
161
153
isDisabled : 'transparent'
162
154
}
163
155
} ,
164
- staticColor : {
165
- white : {
166
- fillStyle : {
167
- fill : {
168
- variant : {
169
- primary : baseColor ( 'transparent-white-800' ) ,
170
- secondary : baseColor ( 'transparent-white-100' )
171
- } ,
172
- isDisabled : 'transparent-white-100'
173
- } ,
174
- outline : {
175
- default : 'transparent' ,
176
- isHovered : 'transparent-white-100' ,
177
- isPressed : 'transparent-white-100' ,
178
- isFocusVisible : 'transparent-white-100' ,
179
- isDisabled : 'transparent'
180
- }
181
- }
182
- } ,
183
- black : {
184
- fillStyle : {
185
- fill : {
186
- variant : {
187
- primary : baseColor ( 'transparent-black-800' ) ,
188
- secondary : baseColor ( 'transparent-black-100' )
189
- } ,
190
- isDisabled : 'transparent-black-100'
156
+ isStaticColor : {
157
+ fillStyle : {
158
+ fill : {
159
+ variant : {
160
+ primary : baseColor ( 'transparent-overlay-800' ) ,
161
+ secondary : baseColor ( 'transparent-overlay-100' )
191
162
} ,
192
- outline : {
193
- default : 'transparent' ,
194
- isHovered : 'transparent-black-100' ,
195
- isPressed : 'transparent-black-100' ,
196
- isFocusVisible : 'transparent-black-100' ,
197
- isDisabled : 'transparent'
198
- }
163
+ isDisabled : 'transparent-overlay-100'
164
+ } ,
165
+ outline : {
166
+ default : 'transparent' ,
167
+ isHovered : 'transparent-overlay-100' ,
168
+ isPressed : 'transparent-overlay-100' ,
169
+ isFocusVisible : 'transparent-overlay-100' ,
170
+ isDisabled : 'transparent'
199
171
}
200
172
}
201
173
} ,
@@ -226,31 +198,17 @@ const button = style<ButtonRenderProps & ButtonStyleProps>({
226
198
isDisabled : 'disabled'
227
199
}
228
200
} ,
229
- staticColor : {
230
- white : {
231
- fillStyle : {
232
- fill : {
233
- variant : {
234
- primary : 'black' ,
235
- secondary : baseColor ( 'transparent-white-800' )
236
- }
237
- } ,
238
- outline : baseColor ( 'transparent-white-800' )
201
+ isStaticColor : {
202
+ fillStyle : {
203
+ fill : {
204
+ variant : {
205
+ primary : 'auto' ,
206
+ secondary : baseColor ( 'transparent-overlay-800' )
207
+ }
239
208
} ,
240
- isDisabled : 'transparent-white-400'
209
+ outline : baseColor ( 'transparent-overlay-800' )
241
210
} ,
242
- black : {
243
- fillStyle : {
244
- fill : {
245
- variant : {
246
- primary : 'white' ,
247
- secondary : baseColor ( 'transparent-black-800' )
248
- }
249
- } ,
250
- outline : baseColor ( 'transparent-black-800' )
251
- } ,
252
- isDisabled : 'transparent-black-400'
253
- }
211
+ isDisabled : 'transparent-overlay-400'
254
212
} ,
255
213
forcedColors : {
256
214
fillStyle : {
@@ -271,10 +229,7 @@ const button = style<ButtonRenderProps & ButtonStyleProps>({
271
229
} ,
272
230
outlineColor : {
273
231
default : 'focus-ring' ,
274
- staticColor : {
275
- white : 'white' ,
276
- black : 'black'
277
- } ,
232
+ isStaticColor : 'transparent-overlay-1000' ,
278
233
forcedColors : 'Highlight'
279
234
} ,
280
235
forcedColorAdjust : 'none' ,
@@ -332,7 +287,8 @@ export const Button = forwardRef(function Button(props: ButtonProps, ref: Focusa
332
287
variant,
333
288
fillStyle,
334
289
size,
335
- staticColor
290
+ staticColor,
291
+ isStaticColor : ! ! staticColor
336
292
} , props . styles ) } >
337
293
< Provider
338
294
values = { [
@@ -419,6 +375,7 @@ export const LinkButton = forwardRef(function LinkButton(props: LinkButtonProps,
419
375
fillStyle : props . fillStyle || 'fill' ,
420
376
size : props . size || 'M' ,
421
377
staticColor : props . staticColor ,
378
+ isStaticColor : ! ! props . staticColor ,
422
379
isPending : false
423
380
} , props . styles ) } >
424
381
< Provider
0 commit comments