baseui 15.0.1 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/button/button-internals.d.ts +2 -2
- package/button/button-internals.js +56 -7
- package/button/button.d.ts +2 -2
- package/button/button.js +80 -8
- package/button/constants.d.ts +22 -0
- package/button/constants.js +31 -3
- package/button/default-props.d.ts +5 -3
- package/button/default-props.js +5 -3
- package/button/index.d.ts +1 -1
- package/button/index.js +21 -0
- package/button/styled-components.d.ts +7 -0
- package/button/styled-components.js +476 -66
- package/button/types.d.ts +39 -3
- package/button/utils.d.ts +2 -2
- package/button/utils.js +9 -3
- package/button-group/button-group.d.ts +1 -0
- package/button-group/button-group.js +22 -33
- package/button-group/constants.d.ts +5 -0
- package/button-group/constants.js +6 -1
- package/button-group/index.d.ts +10 -1
- package/button-group/index.js +33 -4
- package/button-group/styled-components.d.ts +5 -2
- package/button-group/styled-components.js +47 -6
- package/button-group/types.d.ts +9 -2
- package/checkbox/styled-components.js +2 -6
- package/modal/modal-button.d.ts +8 -1
- package/package.json +1 -1
- package/tag/constants.d.ts +31 -5
- package/tag/constants.js +18 -11
- package/tag/deprecated-styles.d.ts +119 -0
- package/tag/deprecated-styles.js +179 -0
- package/tag/index.d.ts +1 -1
- package/tag/index.js +15 -1
- package/tag/styled-components.js +199 -230
- package/tag/tag.js +10 -4
- package/tag/types.d.ts +16 -11
- package/tag-group/index.d.ts +5 -0
- package/tag-group/index.js +51 -0
- package/tag-group/styled-components.d.ts +3 -0
- package/tag-group/styled-components.js +46 -0
- package/tag-group/tag-group.d.ts +4 -0
- package/tag-group/tag-group.js +65 -0
- package/tag-group/types.d.ts +18 -0
- package/tag-group/types.js +1 -0
- package/themes/dark-theme/color-component-tokens.js +56 -3
- package/themes/dark-theme/color-semantic-tokens.js +104 -0
- package/themes/light-theme/color-component-tokens.js +55 -2
- package/themes/light-theme/color-semantic-tokens.js +104 -0
- package/themes/shared/animation.js +30 -5
- package/themes/types.d.ts +76 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.StartEnhancer = exports.LoadingSpinnerContainer = exports.LoadingSpinner = exports.EndEnhancer = exports.BaseButton = exports.AnchorBaseButton = void 0;
|
|
6
|
+
exports.getArtworkSize = exports.StartEnhancerButtonContentContainer = exports.StartEnhancer = exports.LoadingSpinnerContainer = exports.LoadingSpinner = exports.EndEnhancer = exports.BaseButton = exports.AnchorBaseButton = void 0;
|
|
7
7
|
var _styles = require("../styles");
|
|
8
8
|
var _constants = require("./constants");
|
|
9
9
|
/*
|
|
@@ -26,7 +26,10 @@ const createStyledBaseButton = (type, styleFn) => (0, _styles.styled)(type, ({
|
|
|
26
26
|
$isSelected,
|
|
27
27
|
$disabled,
|
|
28
28
|
$isFocusVisible,
|
|
29
|
-
$
|
|
29
|
+
$minHitArea,
|
|
30
|
+
$as,
|
|
31
|
+
$backgroundSafe,
|
|
32
|
+
$widthType
|
|
30
33
|
}) => ({
|
|
31
34
|
display: 'inline-flex',
|
|
32
35
|
// need to maintain button width while showing loading spinner
|
|
@@ -42,7 +45,9 @@ const createStyledBaseButton = (type, styleFn) => (0, _styles.styled)(type, ({
|
|
|
42
45
|
borderRightStyle: 'none',
|
|
43
46
|
borderBottomStyle: 'none',
|
|
44
47
|
outline: 'none',
|
|
45
|
-
|
|
48
|
+
boxSizing: 'border-box',
|
|
49
|
+
// <button> is default to border-box for most browsers, but <a> is content-box
|
|
50
|
+
boxShadow: $isFocusVisible && $backgroundSafe ? `inset 0 0 0 2px ${$theme.colors.borderAccent}, ${$theme.lighting.shallowBelow}` : $backgroundSafe ? `${$theme.lighting.shallowBelow}` : $isFocusVisible ? `inset 0 0 0 2px ${$theme.colors.borderAccent}` : 'none',
|
|
46
51
|
textDecoration: 'none',
|
|
47
52
|
WebkitAppearance: 'none',
|
|
48
53
|
transitionProperty: 'background',
|
|
@@ -62,11 +67,16 @@ const createStyledBaseButton = (type, styleFn) => (0, _styles.styled)(type, ({
|
|
|
62
67
|
marginTop: 0,
|
|
63
68
|
marginRight: 0,
|
|
64
69
|
marginBottom: 0,
|
|
70
|
+
...getDimensionStyles({
|
|
71
|
+
$theme,
|
|
72
|
+
$size,
|
|
73
|
+
$widthType
|
|
74
|
+
}),
|
|
65
75
|
...getFontStyles({
|
|
66
76
|
$theme,
|
|
67
77
|
$size
|
|
68
78
|
}),
|
|
69
|
-
...
|
|
79
|
+
...getBorderRadiusStyles({
|
|
70
80
|
$theme,
|
|
71
81
|
$size,
|
|
72
82
|
$shape
|
|
@@ -76,13 +86,22 @@ const createStyledBaseButton = (type, styleFn) => (0, _styles.styled)(type, ({
|
|
|
76
86
|
$size,
|
|
77
87
|
$shape
|
|
78
88
|
}),
|
|
89
|
+
...getDoubleBorderStyles({
|
|
90
|
+
$theme,
|
|
91
|
+
$isLoading,
|
|
92
|
+
$isSelected,
|
|
93
|
+
$kind,
|
|
94
|
+
$disabled,
|
|
95
|
+
$backgroundSafe
|
|
96
|
+
}),
|
|
79
97
|
...getColorStyles({
|
|
80
98
|
$theme,
|
|
81
99
|
$colors,
|
|
82
100
|
$kind,
|
|
83
101
|
$isLoading,
|
|
84
102
|
$isSelected,
|
|
85
|
-
$disabled
|
|
103
|
+
$disabled,
|
|
104
|
+
$backgroundSafe
|
|
86
105
|
}),
|
|
87
106
|
...getAnchorDisabledStyles({
|
|
88
107
|
$as,
|
|
@@ -93,7 +112,12 @@ const createStyledBaseButton = (type, styleFn) => (0, _styles.styled)(type, ({
|
|
|
93
112
|
}),
|
|
94
113
|
...getShapeStyles({
|
|
95
114
|
$shape,
|
|
96
|
-
$size
|
|
115
|
+
$size,
|
|
116
|
+
$theme
|
|
117
|
+
}),
|
|
118
|
+
...getMinHitAreaStyles({
|
|
119
|
+
$minHitArea,
|
|
120
|
+
$theme
|
|
97
121
|
}),
|
|
98
122
|
...styleFn?.({
|
|
99
123
|
$theme,
|
|
@@ -105,6 +129,7 @@ const createStyledBaseButton = (type, styleFn) => (0, _styles.styled)(type, ({
|
|
|
105
129
|
$isSelected,
|
|
106
130
|
$disabled,
|
|
107
131
|
$isFocusVisible,
|
|
132
|
+
$minHitArea,
|
|
108
133
|
$as
|
|
109
134
|
})
|
|
110
135
|
}));
|
|
@@ -145,23 +170,34 @@ const StartEnhancer = exports.StartEnhancer = (0, _styles.styled)('div', ({
|
|
|
145
170
|
});
|
|
146
171
|
StartEnhancer.displayName = "StartEnhancer";
|
|
147
172
|
StartEnhancer.displayName = 'StartEnhancer';
|
|
173
|
+
const StartEnhancerButtonContentContainer = exports.StartEnhancerButtonContentContainer = (0, _styles.styled)('div', ({
|
|
174
|
+
$theme
|
|
175
|
+
}) => {
|
|
176
|
+
return {
|
|
177
|
+
display: 'flex',
|
|
178
|
+
justifyContent: 'center',
|
|
179
|
+
alignItems: 'center',
|
|
180
|
+
flexGrow: 1
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
StartEnhancerButtonContentContainer.displayName = "StartEnhancerButtonContentContainer";
|
|
184
|
+
StartEnhancerButtonContentContainer.displayName = 'StartEnhancerButtonContentContainer';
|
|
148
185
|
const LoadingSpinnerContainer = exports.LoadingSpinnerContainer = (0, _styles.styled)('div', ({
|
|
149
186
|
$theme,
|
|
150
187
|
$size
|
|
151
188
|
}) => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if ($size === _constants.SIZE.mini || $size === _constants.SIZE.
|
|
155
|
-
margins =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
189
|
+
let margins = {};
|
|
190
|
+
// Add a few pixels of margin to match the line-height for non-loading xSmall buttons.
|
|
191
|
+
if ($size === _constants.SIZE.mini || $size === _constants.SIZE.xSmall) {
|
|
192
|
+
margins = {
|
|
193
|
+
marginBottom: $theme.sizing.scale0,
|
|
194
|
+
marginTop: $theme.sizing.scale0
|
|
195
|
+
};
|
|
159
196
|
}
|
|
160
197
|
return {
|
|
161
198
|
lineHeight: 0,
|
|
162
199
|
position: 'static',
|
|
163
|
-
|
|
164
|
-
marginTop: margins
|
|
200
|
+
...margins
|
|
165
201
|
};
|
|
166
202
|
});
|
|
167
203
|
LoadingSpinnerContainer.displayName = "LoadingSpinnerContainer";
|
|
@@ -180,12 +216,24 @@ const LoadingSpinner = exports.LoadingSpinner = (0, _styles.styled)('span', ({
|
|
|
180
216
|
$kind,
|
|
181
217
|
$disabled
|
|
182
218
|
});
|
|
183
|
-
let dimension
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
219
|
+
let dimension;
|
|
220
|
+
switch ($size) {
|
|
221
|
+
case _constants.SIZE.mini:
|
|
222
|
+
case _constants.SIZE.xSmall:
|
|
223
|
+
dimension = $theme.sizing.scale500;
|
|
224
|
+
break;
|
|
225
|
+
case _constants.SIZE.compact:
|
|
226
|
+
case _constants.SIZE.small:
|
|
227
|
+
dimension = $theme.sizing.scale600;
|
|
228
|
+
break;
|
|
229
|
+
case _constants.SIZE.large:
|
|
230
|
+
dimension = $theme.sizing.scale800;
|
|
231
|
+
break;
|
|
232
|
+
case _constants.SIZE.medium:
|
|
233
|
+
case _constants.SIZE.default:
|
|
234
|
+
default:
|
|
235
|
+
dimension = $theme.sizing.scale700;
|
|
236
|
+
break;
|
|
189
237
|
}
|
|
190
238
|
return {
|
|
191
239
|
height: dimension,
|
|
@@ -251,6 +299,34 @@ function getLoadingSpinnerColors({
|
|
|
251
299
|
background: $theme.colors.buttonTertiarySpinnerBackground
|
|
252
300
|
};
|
|
253
301
|
}
|
|
302
|
+
case _constants.KIND.dangerPrimary:
|
|
303
|
+
{
|
|
304
|
+
return {
|
|
305
|
+
foreground: $theme.colors.buttonDangerPrimarySpinnerForeground,
|
|
306
|
+
background: $theme.colors.buttonDangerPrimarySpinnerBackground
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
case _constants.KIND.dangerSecondary:
|
|
310
|
+
{
|
|
311
|
+
return {
|
|
312
|
+
foreground: $theme.colors.buttonDangerSecondarySpinnerForeground,
|
|
313
|
+
background: $theme.colors.buttonDangerSecondarySpinnerBackground
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
case _constants.KIND.dangerTertiary:
|
|
317
|
+
{
|
|
318
|
+
return {
|
|
319
|
+
foreground: $theme.colors.buttonDangerTertiarySpinnerForeground,
|
|
320
|
+
background: $theme.colors.buttonDangerTertiarySpinnerBackground
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
case _constants.BUTTON_GROUP_EXCLUSIVE_KINDS.outline:
|
|
324
|
+
{
|
|
325
|
+
return {
|
|
326
|
+
foreground: $theme.colors.buttonOutlineSpinnerForeground,
|
|
327
|
+
background: $theme.colors.buttonOutlineSpinnerBackground
|
|
328
|
+
};
|
|
329
|
+
}
|
|
254
330
|
case _constants.KIND.primary:
|
|
255
331
|
default:
|
|
256
332
|
{
|
|
@@ -263,24 +339,16 @@ function getLoadingSpinnerColors({
|
|
|
263
339
|
}
|
|
264
340
|
|
|
265
341
|
// @ts-ignore
|
|
266
|
-
function
|
|
342
|
+
function getBorderRadiusStyles({
|
|
267
343
|
$theme,
|
|
268
344
|
$size,
|
|
269
345
|
$shape
|
|
270
346
|
}) {
|
|
271
347
|
let value = $theme.borders.buttonBorderRadius;
|
|
272
|
-
if ($shape === _constants.SHAPE.pill) {
|
|
273
|
-
|
|
274
|
-
value = '30px';
|
|
275
|
-
} else if ($size === _constants.SIZE.large) {
|
|
276
|
-
value = '42px';
|
|
277
|
-
} else {
|
|
278
|
-
value = '38px';
|
|
279
|
-
}
|
|
348
|
+
if ($shape === _constants.SHAPE.pill || $shape === _constants.SHAPE.rounded) {
|
|
349
|
+
value = '999px';
|
|
280
350
|
} else if ($shape === _constants.SHAPE.circle || $shape === _constants.SHAPE.round) {
|
|
281
351
|
value = '50%';
|
|
282
|
-
} else if ($size === _constants.SIZE.mini) {
|
|
283
|
-
value = $theme.borders.buttonBorderRadiusMini;
|
|
284
352
|
}
|
|
285
353
|
return {
|
|
286
354
|
borderTopRightRadius: value,
|
|
@@ -296,14 +364,16 @@ function getFontStyles({
|
|
|
296
364
|
$size
|
|
297
365
|
}) {
|
|
298
366
|
switch ($size) {
|
|
367
|
+
case _constants.SIZE.xSmall:
|
|
299
368
|
case _constants.SIZE.mini:
|
|
300
|
-
return $theme.typography.
|
|
369
|
+
return $theme.typography.LabelXSmall;
|
|
370
|
+
case _constants.SIZE.small:
|
|
301
371
|
case _constants.SIZE.compact:
|
|
302
|
-
return $theme.typography.
|
|
372
|
+
return $theme.typography.LabelSmall;
|
|
303
373
|
case _constants.SIZE.large:
|
|
304
|
-
return $theme.typography.
|
|
374
|
+
return $theme.typography.LabelLarge;
|
|
305
375
|
default:
|
|
306
|
-
return $theme.typography.
|
|
376
|
+
return $theme.typography.LabelMedium;
|
|
307
377
|
}
|
|
308
378
|
}
|
|
309
379
|
function getAnchorDisabledStyles({
|
|
@@ -349,7 +419,7 @@ function getDisabledStyles({
|
|
|
349
419
|
}
|
|
350
420
|
}
|
|
351
421
|
return {
|
|
352
|
-
backgroundColor: $
|
|
422
|
+
backgroundColor: $theme.colors.buttonDisabledFill,
|
|
353
423
|
color: $theme.colors.buttonDisabledText
|
|
354
424
|
};
|
|
355
425
|
}
|
|
@@ -363,6 +433,7 @@ function getPaddingStyles({
|
|
|
363
433
|
const iconShape = $shape === _constants.SHAPE.square || $shape === _constants.SHAPE.circle || $shape === _constants.SHAPE.round;
|
|
364
434
|
switch ($size) {
|
|
365
435
|
case _constants.SIZE.mini:
|
|
436
|
+
case _constants.SIZE.xSmall:
|
|
366
437
|
return {
|
|
367
438
|
paddingTop: $theme.sizing.scale200,
|
|
368
439
|
paddingBottom: $theme.sizing.scale200,
|
|
@@ -370,6 +441,7 @@ function getPaddingStyles({
|
|
|
370
441
|
paddingRight: iconShape ? $theme.sizing.scale200 : $theme.sizing.scale300
|
|
371
442
|
};
|
|
372
443
|
case _constants.SIZE.compact:
|
|
444
|
+
case _constants.SIZE.small:
|
|
373
445
|
return {
|
|
374
446
|
paddingTop: $theme.sizing.scale400,
|
|
375
447
|
paddingBottom: $theme.sizing.scale400,
|
|
@@ -383,6 +455,8 @@ function getPaddingStyles({
|
|
|
383
455
|
paddingLeft: iconShape ? $theme.sizing.scale600 : $theme.sizing.scale700,
|
|
384
456
|
paddingRight: iconShape ? $theme.sizing.scale600 : $theme.sizing.scale700
|
|
385
457
|
};
|
|
458
|
+
case _constants.SIZE.medium:
|
|
459
|
+
case _constants.SIZE.default:
|
|
386
460
|
default:
|
|
387
461
|
return {
|
|
388
462
|
paddingTop: $theme.sizing.scale550,
|
|
@@ -404,39 +478,54 @@ function getColorStyles({
|
|
|
404
478
|
// @ts-ignore
|
|
405
479
|
$kind,
|
|
406
480
|
// @ts-ignore
|
|
407
|
-
$disabled
|
|
481
|
+
$disabled,
|
|
482
|
+
// @ts-ignore
|
|
483
|
+
$backgroundSafe
|
|
408
484
|
}) {
|
|
485
|
+
if ($disabled) {
|
|
486
|
+
return Object.freeze({});
|
|
487
|
+
}
|
|
488
|
+
const backgroundSafeBoxShadow = $backgroundSafe ? `, ${$theme.lighting.shallowBelow}` : '';
|
|
409
489
|
if ($colors) {
|
|
410
490
|
return {
|
|
411
491
|
color: $colors.color,
|
|
412
492
|
backgroundColor: $colors.backgroundColor,
|
|
413
|
-
|
|
414
|
-
|
|
493
|
+
// Applies only on devices that support hovering, like desktop computers.
|
|
494
|
+
'@media (hover: hover)': {
|
|
495
|
+
':hover': {
|
|
496
|
+
boxShadow: `inset 999px 999px 0px rgba(0, 0, 0, 0.04) ${backgroundSafeBoxShadow}`
|
|
497
|
+
}
|
|
415
498
|
},
|
|
416
499
|
':active': {
|
|
417
|
-
boxShadow:
|
|
500
|
+
boxShadow: `inset 999px 999px 0px rgba(0, 0, 0, 0.08) ${backgroundSafeBoxShadow}`
|
|
418
501
|
}
|
|
419
502
|
};
|
|
420
503
|
}
|
|
421
|
-
if ($disabled) {
|
|
422
|
-
return Object.freeze({});
|
|
423
|
-
}
|
|
424
504
|
switch ($kind) {
|
|
425
505
|
case _constants.KIND.primary:
|
|
426
506
|
if ($isSelected) {
|
|
427
507
|
return {
|
|
428
|
-
color: $theme.colors.buttonPrimarySelectedText,
|
|
429
|
-
|
|
508
|
+
color: $theme.colors.buttonPrimarySelectedText || $theme.colors.buttonPrimaryText,
|
|
509
|
+
// provide fallback values in case some projects customized the theme but do not provide the tokens.
|
|
510
|
+
backgroundColor: $theme.colors.buttonPrimarySelectedFill || $theme.colors.buttonPrimaryFill
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
if ($isLoading) {
|
|
514
|
+
return {
|
|
515
|
+
backgroundColor: $theme.colors.buttonPrimaryLoadingFill || $theme.colors.buttonPrimaryFill
|
|
430
516
|
};
|
|
431
517
|
}
|
|
432
518
|
return {
|
|
433
519
|
color: $theme.colors.buttonPrimaryText,
|
|
434
520
|
backgroundColor: $theme.colors.buttonPrimaryFill,
|
|
435
|
-
|
|
436
|
-
|
|
521
|
+
// Applies only on devices that support hovering, like desktop computers.
|
|
522
|
+
'@media (hover: hover)': {
|
|
523
|
+
':hover': {
|
|
524
|
+
boxShadow: `inset 999px 999px 0px ${$theme.colors.buttonPrimaryHoverOverlay} ${backgroundSafeBoxShadow}`
|
|
525
|
+
}
|
|
437
526
|
},
|
|
438
527
|
':active': {
|
|
439
|
-
|
|
528
|
+
boxShadow: `inset 999px 999px 0px ${$theme.colors.buttonPrimaryActiveOverlay} ${backgroundSafeBoxShadow}`
|
|
440
529
|
}
|
|
441
530
|
};
|
|
442
531
|
case _constants.KIND.secondary:
|
|
@@ -446,33 +535,271 @@ function getColorStyles({
|
|
|
446
535
|
backgroundColor: $theme.colors.buttonPrimaryFill
|
|
447
536
|
};
|
|
448
537
|
}
|
|
538
|
+
if ($isLoading) {
|
|
539
|
+
return {
|
|
540
|
+
backgroundColor: $theme.colors.buttonSecondaryLoadingFill || $theme.colors.buttonSecondaryFill
|
|
541
|
+
};
|
|
542
|
+
}
|
|
449
543
|
return {
|
|
450
544
|
color: $theme.colors.buttonSecondaryText,
|
|
451
545
|
backgroundColor: $theme.colors.buttonSecondaryFill,
|
|
452
|
-
|
|
453
|
-
|
|
546
|
+
// Applies only on devices that support hovering, like desktop computers.
|
|
547
|
+
'@media (hover: hover)': {
|
|
548
|
+
':hover': {
|
|
549
|
+
boxShadow: `inset 999px 999px 0px ${$theme.colors.buttonSecondaryHoverOverlay} ${backgroundSafeBoxShadow}`
|
|
550
|
+
}
|
|
454
551
|
},
|
|
455
552
|
':active': {
|
|
456
|
-
|
|
553
|
+
boxShadow: `inset 999px 999px 0px ${$theme.colors.buttonSecondaryActiveOverlay} ${backgroundSafeBoxShadow}`
|
|
457
554
|
}
|
|
458
555
|
};
|
|
459
556
|
case _constants.KIND.tertiary:
|
|
460
557
|
if ($isSelected) {
|
|
461
558
|
return {
|
|
462
|
-
color: $theme.colors.buttonTertiarySelectedText,
|
|
463
|
-
backgroundColor: $theme.colors.buttonTertiarySelectedFill
|
|
559
|
+
color: $theme.colors.buttonTertiarySelectedText || $theme.colors.buttonTertiaryText,
|
|
560
|
+
backgroundColor: $theme.colors.buttonTertiarySelectedFill || $theme.colors.buttonTertiaryFill
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
if ($isLoading) {
|
|
564
|
+
return {
|
|
565
|
+
backgroundColor: $theme.colors.buttonTertiaryLoadingFill || $theme.colors.buttonTertiaryFill
|
|
464
566
|
};
|
|
465
567
|
}
|
|
466
568
|
return {
|
|
467
569
|
color: $theme.colors.buttonTertiaryText,
|
|
468
570
|
backgroundColor: $theme.colors.buttonTertiaryFill,
|
|
469
|
-
|
|
470
|
-
|
|
571
|
+
// Applies only on devices that support hovering, like desktop computers.
|
|
572
|
+
'@media (hover: hover)': {
|
|
573
|
+
':hover': {
|
|
574
|
+
boxShadow: `inset 999px 999px 0px ${$theme.colors.buttonTertiaryHoverOverlay} ${backgroundSafeBoxShadow}`
|
|
575
|
+
}
|
|
471
576
|
},
|
|
472
577
|
':active': {
|
|
473
|
-
|
|
578
|
+
boxShadow: `inset 999px 999px 0px ${$theme.colors.buttonTertiaryActiveOverlay} ${backgroundSafeBoxShadow}`
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
// Below are the danger button styles.(newly added, other customized themes system should provide the tokens)
|
|
582
|
+
case _constants.KIND.dangerPrimary:
|
|
583
|
+
{
|
|
584
|
+
if ($isSelected) {
|
|
585
|
+
return {
|
|
586
|
+
color: $theme.colors.buttonDangerPrimarySelectedText,
|
|
587
|
+
backgroundColor: $theme.colors.buttonDangerPrimarySelectedFill
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
if ($isLoading) {
|
|
591
|
+
return {
|
|
592
|
+
backgroundColor: $theme.colors.buttonDangerPrimaryLoadingFill
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
return {
|
|
596
|
+
color: $theme.colors.buttonDangerPrimaryText,
|
|
597
|
+
backgroundColor: $theme.colors.buttonDangerPrimaryFill,
|
|
598
|
+
// Applies only on devices that support hovering, like desktop computers.
|
|
599
|
+
'@media (hover: hover)': {
|
|
600
|
+
':hover': {
|
|
601
|
+
boxShadow: `inset 999px 999px 0px ${$theme.colors.buttonDangerPrimaryHoverOverlay} ${backgroundSafeBoxShadow}`
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
':active': {
|
|
605
|
+
boxShadow: `inset 999px 999px 0px ${$theme.colors.buttonDangerPrimaryActiveOverlay} ${backgroundSafeBoxShadow}`
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
case _constants.KIND.dangerSecondary:
|
|
610
|
+
{
|
|
611
|
+
if ($isSelected) {
|
|
612
|
+
return {
|
|
613
|
+
color: $theme.colors.buttonDangerSecondarySelectedText,
|
|
614
|
+
backgroundColor: $theme.colors.buttonDangerSecondarySelectedFill
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
if ($isLoading) {
|
|
618
|
+
return {
|
|
619
|
+
backgroundColor: $theme.colors.buttonDangerSecondaryLoadingFill
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
return {
|
|
623
|
+
color: $theme.colors.buttonDangerSecondaryText,
|
|
624
|
+
backgroundColor: $theme.colors.buttonDangerSecondaryFill,
|
|
625
|
+
// Applies only on devices that support hovering, like desktop computers.
|
|
626
|
+
'@media (hover: hover)': {
|
|
627
|
+
':hover': {
|
|
628
|
+
boxShadow: `inset 999px 999px 0px ${$theme.colors.buttonDangerSecondaryHoverOverlay} ${backgroundSafeBoxShadow}`
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
':active': {
|
|
632
|
+
boxShadow: `inset 999px 999px 0px ${$theme.colors.buttonDangerSecondaryActiveOverlay} ${backgroundSafeBoxShadow}`
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
case _constants.KIND.dangerTertiary:
|
|
637
|
+
{
|
|
638
|
+
if ($isSelected) {
|
|
639
|
+
return {
|
|
640
|
+
color: $theme.colors.buttonDangerTertiarySelectedText,
|
|
641
|
+
backgroundColor: $theme.colors.buttonDangerTertiarySelectedFill
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
if ($isLoading) {
|
|
645
|
+
return {
|
|
646
|
+
backgroundColor: $theme.colors.buttonDangerTertiaryLoadingFill
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
return {
|
|
650
|
+
color: $theme.colors.buttonDangerTertiaryText,
|
|
651
|
+
backgroundColor: $theme.colors.buttonDangerTertiaryFill,
|
|
652
|
+
// Applies only on devices that support hovering, like desktop computers.
|
|
653
|
+
'@media (hover: hover)': {
|
|
654
|
+
':hover': {
|
|
655
|
+
boxShadow: `inset 999px 999px 0px ${$theme.colors.buttonDangerTertiaryHoverOverlay} ${backgroundSafeBoxShadow}`
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
':active': {
|
|
659
|
+
boxShadow: `inset 999px 999px 0px ${$theme.colors.buttonDangerTertiaryActiveOverlay} ${backgroundSafeBoxShadow}`
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
case _constants.BUTTON_GROUP_EXCLUSIVE_KINDS.outline:
|
|
664
|
+
{
|
|
665
|
+
if ($isSelected) {
|
|
666
|
+
return {
|
|
667
|
+
color: $theme.colors.buttonOutlineSelectedText,
|
|
668
|
+
backgroundColor: $theme.colors.buttonOutlineSelectedFill
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
if ($isLoading) {
|
|
672
|
+
return {
|
|
673
|
+
backgroundColor: $theme.colors.buttonOutlineLoadingFill
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
return {
|
|
677
|
+
color: $theme.colors.buttonOutlineText,
|
|
678
|
+
backgroundColor: $theme.colors.buttonOutlineFill,
|
|
679
|
+
// adding overlay for hovered and pressed state (we previously used inset box shadow to simulate this, but cannot extend to border)
|
|
680
|
+
// This is ideally moved to root level, but putting here is less risky since it's probably ::after element is used or overridden somewhere.
|
|
681
|
+
position: 'relative',
|
|
682
|
+
'::after': {
|
|
683
|
+
content: '""',
|
|
684
|
+
position: 'absolute',
|
|
685
|
+
top: 0,
|
|
686
|
+
right: 0,
|
|
687
|
+
bottom: 0,
|
|
688
|
+
left: 0,
|
|
689
|
+
borderTopLeftRadius: 'inherit',
|
|
690
|
+
borderTopRightRadius: 'inherit',
|
|
691
|
+
borderBottomRightRadius: 'inherit',
|
|
692
|
+
borderBottomLeftRadius: 'inherit',
|
|
693
|
+
backgroundColor: 'transparent',
|
|
694
|
+
boxShadow: `0 0 0 ${$theme.sizing.scale0} transparent`,
|
|
695
|
+
pointerEvents: 'none'
|
|
696
|
+
},
|
|
697
|
+
// end of overlay
|
|
698
|
+
// Applies only on devices that support hovering, like desktop computers.
|
|
699
|
+
'@media (hover: hover)': {
|
|
700
|
+
':hover::after': {
|
|
701
|
+
backgroundColor: $theme.colors.buttonOutlineHoverOverlay,
|
|
702
|
+
// this box shadow is used to extend the overlay to the border
|
|
703
|
+
boxShadow: `0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonOutlineHoverOverlay} ${backgroundSafeBoxShadow}`
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
':active::after': {
|
|
707
|
+
backgroundColor: $theme.colors.buttonOutlineActiveOverlay,
|
|
708
|
+
// this box shadow is used to extend the overlay to the border
|
|
709
|
+
boxShadow: `0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonOutlineActiveOverlay} ${backgroundSafeBoxShadow}`
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
default:
|
|
714
|
+
return Object.freeze({});
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
function getDoubleBorderStyles({
|
|
718
|
+
// @ts-ignore
|
|
719
|
+
$theme,
|
|
720
|
+
// @ts-ignore
|
|
721
|
+
$isLoading,
|
|
722
|
+
// @ts-ignore
|
|
723
|
+
$isSelected,
|
|
724
|
+
// @ts-ignore
|
|
725
|
+
$kind,
|
|
726
|
+
// @ts-ignore
|
|
727
|
+
$disabled,
|
|
728
|
+
// @ts-ignore
|
|
729
|
+
$backgroundSafe
|
|
730
|
+
}) {
|
|
731
|
+
if ($disabled) {
|
|
732
|
+
return Object.freeze({});
|
|
733
|
+
}
|
|
734
|
+
const backgroundSafeBoxShadow = $backgroundSafe ? `, ${$theme.lighting.shallowBelow}` : '';
|
|
735
|
+
switch ($kind) {
|
|
736
|
+
case _constants.KIND.primary:
|
|
737
|
+
return {
|
|
738
|
+
...($isSelected ? {
|
|
739
|
+
boxShadow: `inset 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonInnerBorder}, 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonOuterBorder} ${backgroundSafeBoxShadow}`
|
|
740
|
+
} : {}),
|
|
741
|
+
':focus-visible': {
|
|
742
|
+
boxShadow: `inset 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonInnerBorder}, 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonFocusOuterBorder} ${backgroundSafeBoxShadow}`
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
case _constants.KIND.secondary:
|
|
746
|
+
return {
|
|
747
|
+
':focus-visible': {
|
|
748
|
+
boxShadow: `inset 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonInnerBorder}, 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonFocusOuterBorder} ${backgroundSafeBoxShadow}`
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
case _constants.KIND.tertiary:
|
|
752
|
+
return {
|
|
753
|
+
...($isSelected ? {
|
|
754
|
+
boxShadow: `inset 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonInnerBorder}, 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonOuterBorder} ${backgroundSafeBoxShadow}`
|
|
755
|
+
} : {}),
|
|
756
|
+
':focus-visible': {
|
|
757
|
+
boxShadow: `inset 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonInnerBorder}, 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonFocusOuterBorder} ${backgroundSafeBoxShadow}`
|
|
474
758
|
}
|
|
475
759
|
};
|
|
760
|
+
case _constants.KIND.dangerPrimary:
|
|
761
|
+
{
|
|
762
|
+
return {
|
|
763
|
+
...($isSelected ? {
|
|
764
|
+
boxShadow: `inset 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonInnerBorder}, 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonOuterBorder} ${backgroundSafeBoxShadow}`
|
|
765
|
+
} : {}),
|
|
766
|
+
':focus-visible': {
|
|
767
|
+
boxShadow: `inset 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonInnerBorder}, 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonFocusOuterBorder} ${backgroundSafeBoxShadow}`
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
case _constants.KIND.dangerSecondary:
|
|
772
|
+
{
|
|
773
|
+
return {
|
|
774
|
+
':focus-visible': {
|
|
775
|
+
boxShadow: `inset 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonInnerBorder}, 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonFocusOuterBorder} ${backgroundSafeBoxShadow}`
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
case _constants.KIND.dangerTertiary:
|
|
780
|
+
{
|
|
781
|
+
return {
|
|
782
|
+
...($isSelected ? {
|
|
783
|
+
boxShadow: `inset 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonTransparentBorder}, 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonDangerTertiaryOuterBorder} ${backgroundSafeBoxShadow}`
|
|
784
|
+
} : {}),
|
|
785
|
+
':focus-visible': {
|
|
786
|
+
boxShadow: `inset 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonTransparentBorder}, 0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonFocusOuterBorder} ${backgroundSafeBoxShadow}`
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
case _constants.BUTTON_GROUP_EXCLUSIVE_KINDS.outline:
|
|
791
|
+
{
|
|
792
|
+
return {
|
|
793
|
+
...($isSelected ? {
|
|
794
|
+
boxShadow: `0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonOuterBorder}`
|
|
795
|
+
} : {
|
|
796
|
+
boxShadow: `0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonOutlineOuterBorder}`
|
|
797
|
+
}),
|
|
798
|
+
':focus-visible': {
|
|
799
|
+
boxShadow: `0 0 0 ${$theme.sizing.scale0} ${$theme.colors.buttonFocusOuterBorder}`
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
}
|
|
476
803
|
default:
|
|
477
804
|
return Object.freeze({});
|
|
478
805
|
}
|
|
@@ -481,27 +808,31 @@ function getColorStyles({
|
|
|
481
808
|
// @ts-ignore
|
|
482
809
|
function getShapeStyles({
|
|
483
810
|
$shape,
|
|
484
|
-
$size
|
|
811
|
+
$size,
|
|
812
|
+
$theme
|
|
485
813
|
}) {
|
|
486
814
|
if ($shape === _constants.SHAPE.circle || $shape === _constants.SHAPE.square) {
|
|
487
815
|
let height, width;
|
|
488
816
|
switch ($size) {
|
|
489
817
|
case _constants.SIZE.mini:
|
|
490
|
-
|
|
491
|
-
|
|
818
|
+
case _constants.SIZE.xSmall:
|
|
819
|
+
height = $theme.sizing.scale850;
|
|
820
|
+
width = $theme.sizing.scale850;
|
|
492
821
|
break;
|
|
493
822
|
case _constants.SIZE.compact:
|
|
494
|
-
|
|
495
|
-
|
|
823
|
+
case _constants.SIZE.small:
|
|
824
|
+
height = $theme.sizing.scale950;
|
|
825
|
+
width = $theme.sizing.scale950;
|
|
496
826
|
break;
|
|
497
827
|
case _constants.SIZE.large:
|
|
498
|
-
height =
|
|
499
|
-
width =
|
|
828
|
+
height = $theme.sizing.scale1400;
|
|
829
|
+
width = $theme.sizing.scale1400;
|
|
500
830
|
break;
|
|
501
831
|
case _constants.SIZE.default:
|
|
832
|
+
case _constants.SIZE.medium:
|
|
502
833
|
default:
|
|
503
|
-
height =
|
|
504
|
-
width =
|
|
834
|
+
height = $theme.sizing.scale1200;
|
|
835
|
+
width = $theme.sizing.scale1200;
|
|
505
836
|
break;
|
|
506
837
|
}
|
|
507
838
|
return {
|
|
@@ -515,4 +846,83 @@ function getShapeStyles({
|
|
|
515
846
|
} else {
|
|
516
847
|
return {};
|
|
517
848
|
}
|
|
849
|
+
}
|
|
850
|
+
const getArtworkSize = ({
|
|
851
|
+
$theme,
|
|
852
|
+
$size
|
|
853
|
+
}) => {
|
|
854
|
+
switch ($size) {
|
|
855
|
+
case _constants.SIZE.mini:
|
|
856
|
+
case _constants.SIZE.xSmall:
|
|
857
|
+
return $theme.sizing.scale500;
|
|
858
|
+
case _constants.SIZE.compact:
|
|
859
|
+
case _constants.SIZE.small:
|
|
860
|
+
return $theme.sizing.scale600;
|
|
861
|
+
case _constants.SIZE.large:
|
|
862
|
+
return $theme.sizing.scale800;
|
|
863
|
+
case _constants.SIZE.default:
|
|
864
|
+
case _constants.SIZE.medium:
|
|
865
|
+
default:
|
|
866
|
+
return $theme.sizing.scale700;
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
// @ts-ignore
|
|
871
|
+
exports.getArtworkSize = getArtworkSize;
|
|
872
|
+
function getMinHitAreaStyles({
|
|
873
|
+
$minHitArea,
|
|
874
|
+
$theme
|
|
875
|
+
}) {
|
|
876
|
+
if (!$minHitArea || $minHitArea !== _constants.MIN_HIT_AREA.tap) {
|
|
877
|
+
return {};
|
|
878
|
+
}
|
|
879
|
+
return {
|
|
880
|
+
'::before': {
|
|
881
|
+
content: '""',
|
|
882
|
+
position: 'absolute',
|
|
883
|
+
top: '50%',
|
|
884
|
+
left: 0,
|
|
885
|
+
right: 0,
|
|
886
|
+
height: $theme.sizing.scale1200,
|
|
887
|
+
minHeight: $theme.sizing.scale1200,
|
|
888
|
+
transform: 'translateY(-50%)'
|
|
889
|
+
},
|
|
890
|
+
position: 'relative'
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
function getDimensionStyles({
|
|
894
|
+
$theme,
|
|
895
|
+
$size,
|
|
896
|
+
$widthType
|
|
897
|
+
}) {
|
|
898
|
+
let minWidth, minHeight;
|
|
899
|
+
switch ($size) {
|
|
900
|
+
case _constants.SIZE.mini:
|
|
901
|
+
case _constants.SIZE.xSmall:
|
|
902
|
+
minHeight = $theme.sizing.scale850;
|
|
903
|
+
minWidth = '52px'; //
|
|
904
|
+
break;
|
|
905
|
+
case _constants.SIZE.compact:
|
|
906
|
+
case _constants.SIZE.small:
|
|
907
|
+
minHeight = $theme.sizing.scale950;
|
|
908
|
+
minWidth = '60px'; // min-width = min-height + 24px
|
|
909
|
+
break;
|
|
910
|
+
case _constants.SIZE.large:
|
|
911
|
+
minHeight = $theme.sizing.scale1400;
|
|
912
|
+
minWidth = '80px'; // min-width = min-height + 24px
|
|
913
|
+
break;
|
|
914
|
+
case _constants.SIZE.default:
|
|
915
|
+
case _constants.SIZE.medium:
|
|
916
|
+
default:
|
|
917
|
+
minHeight = $theme.sizing.scale1200;
|
|
918
|
+
minWidth = '72px'; // min-width = min-height + 24px
|
|
919
|
+
break;
|
|
920
|
+
}
|
|
921
|
+
return {
|
|
922
|
+
...($widthType === _constants.WIDTH_TYPE.fill ? {
|
|
923
|
+
minWidth,
|
|
924
|
+
minHeight,
|
|
925
|
+
width: '100%'
|
|
926
|
+
} : {}) // min-width and min-height only apply to "fill" width type
|
|
927
|
+
};
|
|
518
928
|
}
|