@@ -16,6 +16,7 @@ export type ButtonProps = {
16
16
title ?: string ;
17
17
fullWidth ?: boolean ;
18
18
variant ?: ButtonVariant ;
19
+ inverted ?: boolean ;
19
20
size ?: ButtonSize ;
20
21
position ?: ButtonPosition ;
21
22
accent ?: ButtonAccent ;
@@ -36,6 +37,7 @@ const StyledButton = styled('button', {
36
37
ButtonProps ,
37
38
| 'fullWidth'
38
39
| 'variant'
40
+ | 'inverted'
39
41
| 'size'
40
42
| 'position'
41
43
| 'accent'
@@ -46,83 +48,112 @@ const StyledButton = styled('button', {
46
48
>
47
49
> `
48
50
align-items: center;
49
- ${ ( { theme, variant, accent, disabled, focus } ) => {
51
+ ${ ( { theme, variant, inverted , accent, disabled, focus } ) => {
50
52
switch ( variant ) {
51
53
case 'primary' :
52
54
switch ( accent ) {
53
55
case 'default' :
54
56
return css `
55
- background : ${ theme . background . secondary } ;
56
- border-color : ${ ! disabled
57
+ background : ${ ! inverted
58
+ ? theme . background . secondary
59
+ : theme . background . primary } ;
60
+ border-color : ${ ! inverted
57
61
? focus
58
62
? theme . color . blue
59
63
: theme . background . transparent . light
60
- : 'transparent' } ;
61
- border-width : ${ ! disabled && focus ? '1px 1px !important' : 0 } ;
64
+ : theme . background . transparent . light } ;
65
+ border-width : 1px 1px 1px 1px !important ;
66
+ opacity : ${ disabled ? 0.24 : 1 } ;
62
67
box-shadow : ${ ! disabled && focus
63
- ? `0 0 0 3px ${ theme . accent . tertiary } `
68
+ ? `0 0 0 3px ${
69
+ ! inverted
70
+ ? theme . accent . tertiary
71
+ : theme . background . transparent . medium
72
+ } `
64
73
: 'none' } ;
65
- color : ${ ! disabled
66
- ? theme . font . color . secondary
67
- : theme . font . color . extraLight } ;
74
+ color : ${ ! inverted
75
+ ? ! disabled
76
+ ? theme . font . color . secondary
77
+ : theme . font . color . extraLight
78
+ : theme . font . color . secondary } ;
68
79
& : hover {
69
- background : ${ ! disabled
80
+ background : ${ ! inverted
70
81
? theme . background . tertiary
71
82
: theme . background . secondary } ;
72
83
}
73
84
& : active {
74
- background : ${ ! disabled
85
+ background : ${ ! inverted
75
86
? theme . background . quaternary
76
- : theme . background . secondary } ;
87
+ : theme . background . tertiary } ;
77
88
}
78
89
` ;
79
90
case 'blue' :
80
91
return css `
81
- background : ${ theme . color . blue } ;
82
- border-color : ${ ! disabled
92
+ background : ${ ! inverted
93
+ ? theme . color . blue
94
+ : theme . background . primary } ;
95
+ border-color : ${ ! inverted
83
96
? focus
84
97
? theme . color . blue
85
98
: theme . background . transparent . light
86
- : ' transparent' } ;
87
- border-width : ${ ! disabled && focus ? ' 1px 1px !important' : 0 } ;
99
+ : theme . background . transparent . light } ;
100
+ border-width : 1 px 1 px 1px 1px !important ;
88
101
box-shadow : ${ ! disabled && focus
89
- ? `0 0 0 3px ${ theme . accent . tertiary } `
102
+ ? `0 0 0 3px ${
103
+ ! inverted
104
+ ? theme . accent . tertiary
105
+ : theme . background . transparent . medium
106
+ } `
90
107
: 'none' } ;
91
- color : ${ theme . grayScale . gray0 } ;
108
+ color : ${ ! inverted ? theme . grayScale . gray0 : theme . color . blue } ;
92
109
opacity : ${ disabled ? 0.24 : 1 } ;
93
-
94
110
${ disabled
95
111
? ''
96
112
: css `
97
113
& : hover {
98
- background : ${ theme . color . blue50 } ;
114
+ background : ${ ! inverted
115
+ ? theme . color . blue50
116
+ : theme . background . secondary } ;
99
117
}
100
118
& : active {
101
- background : ${ theme . color . blue60 } ;
119
+ background : ${ ! inverted
120
+ ? theme . color . blue60
121
+ : theme . background . tertiary } ;
102
122
}
103
123
` }
104
124
` ;
105
125
case 'danger' :
106
126
return css `
107
- background : ${ theme . color . red } ;
108
- border-color : ${ ! disabled
127
+ background : ${ ! inverted
128
+ ? theme . color . red
129
+ : theme . background . primary } ;
130
+ border-color : ${ ! inverted
109
131
? focus
110
132
? theme . color . red
111
133
: theme . background . transparent . light
112
- : ' transparent' } ;
113
- border-width : ${ ! disabled && focus ? ' 1px 1px !important' : 0 } ;
134
+ : theme . background . transparent . light } ;
135
+ border-width : 1px 1px !important ;
114
136
box-shadow : ${ ! disabled && focus
115
- ? `0 0 0 3px ${ theme . color . red10 } `
137
+ ? `0 0 0 3px ${
138
+ ! inverted
139
+ ? theme . color . red10
140
+ : theme . background . transparent . medium
141
+ } `
116
142
: 'none' } ;
117
- color : ${ theme . grayScale . gray0 } ;
143
+ color : ${ ! inverted ? theme . background . primary : theme . color . red } ;
118
144
opacity : ${ disabled ? 0.24 : 1 } ;
119
-
120
145
${ disabled
121
146
? ''
122
147
: css `
123
- & : hover ,
148
+ & : hover {
149
+ background : ${ ! inverted
150
+ ? theme . color . red40
151
+ : theme . background . secondary } ;
152
+ }
124
153
& : active {
125
- background : ${ theme . color . red50 } ;
154
+ background : ${ ! inverted
155
+ ? theme . color . red50
156
+ : theme . background . tertiary } ;
126
157
}
127
158
` }
128
159
` ;
@@ -133,88 +164,143 @@ const StyledButton = styled('button', {
133
164
switch ( accent ) {
134
165
case 'default' :
135
166
return css `
136
- background : ${ focus
137
- ? theme . background . transparent . primary
138
- : 'transparent' } ;
139
- border-color : ${ variant === 'secondary'
140
- ? ! disabled && focus
141
- ? theme . color . blue
142
- : theme . background . transparent . medium
143
- : focus
144
- ? theme . color . blue
145
- : 'transparent' } ;
146
- border-width : ${ ! disabled && focus ? '1px 1px !important' : 0 } ;
167
+ background : transparent;
168
+ border-color : ${ ! inverted
169
+ ? variant === 'secondary'
170
+ ? ! disabled && focus
171
+ ? theme . color . blue
172
+ : theme . background . transparent . medium
173
+ : focus
174
+ ? theme . color . blue
175
+ : 'transparent'
176
+ : variant === 'secondary'
177
+ ? focus || disabled
178
+ ? theme . grayScale . gray0
179
+ : theme . background . transparent . primary
180
+ : focus
181
+ ? theme . grayScale . gray0
182
+ : 'transparent' } ;
183
+ border-width : 1px 1px 1px 1px !important ;
147
184
box-shadow : ${ ! disabled && focus
148
- ? `0 0 0 3px ${ theme . accent . tertiary } `
185
+ ? `0 0 0 3px ${
186
+ ! inverted
187
+ ? theme . accent . tertiary
188
+ : theme . background . transparent . medium
189
+ } `
149
190
: 'none' } ;
150
- color : ${ ! disabled
151
- ? theme . font . color . secondary
152
- : theme . font . color . extraLight } ;
191
+ opacity : ${ disabled ? 0.24 : 1 } ;
192
+ color : ${ ! inverted
193
+ ? ! disabled
194
+ ? theme . font . color . secondary
195
+ : theme . font . color . extraLight
196
+ : theme . font . color . inverted } ;
153
197
& : hover {
154
- background : ${ ! disabled
155
- ? theme . background . transparent . light
156
- : 'transparent' } ;
198
+ background : ${ ! inverted
199
+ ? ! disabled
200
+ ? theme . background . transparent . light
201
+ : 'transparent'
202
+ : theme . background . transparent . light } ;
157
203
}
158
204
& : active {
159
- background : ${ ! disabled
160
- ? theme . background . transparent . light
161
- : 'transparent' } ;
205
+ background : ${ ! inverted
206
+ ? ! disabled
207
+ ? theme . background . transparent . light
208
+ : 'transparent'
209
+ : theme . background . transparent . medium } ;
162
210
}
163
211
` ;
164
212
case 'blue' :
165
213
return css `
166
- background : ${ focus
167
- ? theme . background . transparent . primary
168
- : 'transparent' } ;
169
- border-color : ${ variant === 'secondary'
170
- ? focus
171
- ? theme . color . blue
172
- : theme . accent . primary
173
- : focus
174
- ? theme . color . blue
175
- : 'transparent' } ;
176
- border-width : ${ ! disabled && focus ? '1px 1px !important' : 0 } ;
214
+ background : transparent;
215
+ border-color : ${ ! inverted
216
+ ? variant === 'secondary'
217
+ ? focus
218
+ ? theme . color . blue
219
+ : theme . accent . primary
220
+ : focus
221
+ ? theme . color . blue
222
+ : 'transparent'
223
+ : variant === 'secondary'
224
+ ? focus || disabled
225
+ ? theme . grayScale . gray0
226
+ : theme . background . transparent . primary
227
+ : focus
228
+ ? theme . grayScale . gray0
229
+ : 'transparent' } ;
230
+ border-width : 1px 1px 1px 1px !important ;
177
231
box-shadow : ${ ! disabled && focus
178
- ? `0 0 0 3px ${ theme . accent . tertiary } `
232
+ ? `0 0 0 3px ${
233
+ ! inverted
234
+ ? theme . accent . tertiary
235
+ : theme . background . transparent . medium
236
+ } `
179
237
: 'none' } ;
180
- color : ${ ! disabled ? theme . color . blue : theme . accent . accent4060 } ;
238
+ opacity : ${ disabled ? 0.24 : 1 } ;
239
+ color : ${ ! inverted
240
+ ? ! disabled
241
+ ? theme . color . blue
242
+ : theme . accent . accent4060
243
+ : theme . font . color . inverted } ;
181
244
& : hover {
182
- background : ${ ! disabled
183
- ? theme . accent . tertiary
184
- : 'transparent' } ;
245
+ background : ${ ! inverted
246
+ ? ! disabled
247
+ ? theme . accent . tertiary
248
+ : 'transparent'
249
+ : theme . background . transparent . light } ;
185
250
}
186
251
& : active {
187
- background : ${ ! disabled
188
- ? theme . accent . secondary
189
- : 'transparent' } ;
252
+ background : ${ ! inverted
253
+ ? ! disabled
254
+ ? theme . accent . secondary
255
+ : 'transparent'
256
+ : theme . background . transparent . medium } ;
190
257
}
191
258
` ;
192
259
case 'danger' :
193
260
return css `
194
261
background : transparent;
195
- border-color : ${ variant === 'secondary'
196
- ? focus
197
- ? theme . color . red
198
- : theme . border . color . danger
199
- : focus
200
- ? theme . color . red
201
- : 'transparent' } ;
202
- border-width : ${ ! disabled && focus ? '1px 1px !important' : 0 } ;
262
+ border-color : ${ ! inverted
263
+ ? variant === 'secondary'
264
+ ? focus
265
+ ? theme . color . red
266
+ : theme . border . color . danger
267
+ : focus
268
+ ? theme . color . red
269
+ : 'transparent'
270
+ : variant === 'secondary'
271
+ ? focus || disabled
272
+ ? theme . grayScale . gray0
273
+ : theme . background . transparent . primary
274
+ : focus
275
+ ? theme . grayScale . gray0
276
+ : 'transparent' } ;
277
+ border-width : 1px 1px 1px 1px !important ;
203
278
box-shadow : ${ ! disabled && focus
204
- ? `0 0 0 3px ${ theme . color . red10 } `
279
+ ? `0 0 0 3px ${
280
+ ! inverted
281
+ ? theme . color . red10
282
+ : theme . background . transparent . medium
283
+ } `
205
284
: 'none' } ;
206
- color : ${ ! disabled
207
- ? theme . font . color . danger
208
- : theme . border . color . danger } ;
285
+ opacity : ${ disabled ? 0.24 : 1 } ;
286
+ color : ${ ! inverted
287
+ ? ! disabled
288
+ ? theme . font . color . danger
289
+ : theme . color . red20
290
+ : theme . font . color . inverted } ;
209
291
& : hover {
210
- background : ${ ! disabled
211
- ? theme . background . danger
212
- : 'transparent' } ;
292
+ background : ${ ! inverted
293
+ ? ! disabled
294
+ ? theme . background . danger
295
+ : 'transparent'
296
+ : theme . background . transparent . light } ;
213
297
}
214
298
& : active {
215
- background : ${ ! disabled
216
- ? theme . background . danger
217
- : 'transparent' } ;
299
+ background : ${ ! inverted
300
+ ? ! disabled
301
+ ? theme . background . danger
302
+ : 'transparent'
303
+ : theme . background . transparent . medium } ;
218
304
}
219
305
` ;
220
306
}
@@ -277,6 +363,7 @@ export const Button = ({
277
363
title,
278
364
fullWidth = false ,
279
365
variant = 'primary' ,
366
+ inverted = false ,
280
367
size = 'medium' ,
281
368
accent = 'default' ,
282
369
position = 'standalone' ,
@@ -294,6 +381,7 @@ export const Button = ({
294
381
< StyledButton
295
382
fullWidth = { fullWidth }
296
383
variant = { variant }
384
+ inverted = { inverted }
297
385
size = { size }
298
386
position = { position }
299
387
disabled = { soon || disabled }
0 commit comments