@atlaskit/button 16.1.2

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.
Files changed (113) hide show
  1. package/CHANGELOG.md +1485 -0
  2. package/LICENSE +13 -0
  3. package/README.md +13 -0
  4. package/__perf__/button.tsx +19 -0
  5. package/__perf__/custom.tsx +19 -0
  6. package/__perf__/customised.tsx +11 -0
  7. package/__perf__/default.tsx +5 -0
  8. package/__perf__/loading.tsx +5 -0
  9. package/__perf__/utils/example-runner.tsx +48 -0
  10. package/__perf__/utils/interaction-tasks.tsx +98 -0
  11. package/button-group/package.json +7 -0
  12. package/codemods/15.0.0-lite-mode.ts +49 -0
  13. package/codemods/15.1.1-data-testid.ts +173 -0
  14. package/codemods/__tests__/15.0.0-lite-mode/optimistic.ts +646 -0
  15. package/codemods/__tests__/15.0.0-lite-mode/safe.ts +223 -0
  16. package/codemods/__tests__/15.0.0-lite-mode/shared.ts +257 -0
  17. package/codemods/__tests__/15.1.1-data-testid/rename-data-testid.ts +186 -0
  18. package/codemods/__tests__/_framework.ts +47 -0
  19. package/codemods/helpers/15.0.0-runner.ts +169 -0
  20. package/codemods/helpers/helpers-generic.ts +662 -0
  21. package/codemods/optimistic-15.0.0-lite-mode.ts +279 -0
  22. package/codemods/readme.md +1 -0
  23. package/custom-theme-button/package.json +7 -0
  24. package/dist/cjs/button-group.js +50 -0
  25. package/dist/cjs/button.js +104 -0
  26. package/dist/cjs/custom-theme-button/custom-theme-button-types.js +5 -0
  27. package/dist/cjs/custom-theme-button/custom-theme-button.js +229 -0
  28. package/dist/cjs/custom-theme-button/index.js +23 -0
  29. package/dist/cjs/custom-theme-button/theme.js +108 -0
  30. package/dist/cjs/entry-points/button-group.js +15 -0
  31. package/dist/cjs/entry-points/custom-theme-button.js +25 -0
  32. package/dist/cjs/entry-points/loading-button.js +15 -0
  33. package/dist/cjs/entry-points/standard-button.js +15 -0
  34. package/dist/cjs/entry-points/types.js +5 -0
  35. package/dist/cjs/index.js +51 -0
  36. package/dist/cjs/loading-button.js +34 -0
  37. package/dist/cjs/shared/block-events.js +44 -0
  38. package/dist/cjs/shared/button-base.js +158 -0
  39. package/dist/cjs/shared/colors.js +409 -0
  40. package/dist/cjs/shared/css.js +265 -0
  41. package/dist/cjs/shared/get-is-only-single-icon.js +26 -0
  42. package/dist/cjs/shared/loading-spinner.js +45 -0
  43. package/dist/cjs/types.js +5 -0
  44. package/dist/cjs/version.json +5 -0
  45. package/dist/es2019/button-group.js +36 -0
  46. package/dist/es2019/button.js +69 -0
  47. package/dist/es2019/custom-theme-button/custom-theme-button-types.js +1 -0
  48. package/dist/es2019/custom-theme-button/custom-theme-button.js +164 -0
  49. package/dist/es2019/custom-theme-button/index.js +2 -0
  50. package/dist/es2019/custom-theme-button/theme.js +81 -0
  51. package/dist/es2019/entry-points/button-group.js +1 -0
  52. package/dist/es2019/entry-points/custom-theme-button.js +1 -0
  53. package/dist/es2019/entry-points/loading-button.js +1 -0
  54. package/dist/es2019/entry-points/standard-button.js +1 -0
  55. package/dist/es2019/entry-points/types.js +1 -0
  56. package/dist/es2019/index.js +6 -0
  57. package/dist/es2019/loading-button.js +17 -0
  58. package/dist/es2019/shared/block-events.js +37 -0
  59. package/dist/es2019/shared/button-base.js +127 -0
  60. package/dist/es2019/shared/colors.js +393 -0
  61. package/dist/es2019/shared/css.js +249 -0
  62. package/dist/es2019/shared/get-is-only-single-icon.js +19 -0
  63. package/dist/es2019/shared/loading-spinner.js +33 -0
  64. package/dist/es2019/types.js +1 -0
  65. package/dist/es2019/version.json +5 -0
  66. package/dist/esm/button-group.js +35 -0
  67. package/dist/esm/button.js +79 -0
  68. package/dist/esm/custom-theme-button/custom-theme-button-types.js +1 -0
  69. package/dist/esm/custom-theme-button/custom-theme-button.js +203 -0
  70. package/dist/esm/custom-theme-button/index.js +2 -0
  71. package/dist/esm/custom-theme-button/theme.js +90 -0
  72. package/dist/esm/entry-points/button-group.js +1 -0
  73. package/dist/esm/entry-points/custom-theme-button.js +1 -0
  74. package/dist/esm/entry-points/loading-button.js +1 -0
  75. package/dist/esm/entry-points/standard-button.js +1 -0
  76. package/dist/esm/entry-points/types.js +1 -0
  77. package/dist/esm/index.js +6 -0
  78. package/dist/esm/loading-button.js +19 -0
  79. package/dist/esm/shared/block-events.js +36 -0
  80. package/dist/esm/shared/button-base.js +135 -0
  81. package/dist/esm/shared/colors.js +393 -0
  82. package/dist/esm/shared/css.js +245 -0
  83. package/dist/esm/shared/get-is-only-single-icon.js +19 -0
  84. package/dist/esm/shared/loading-spinner.js +35 -0
  85. package/dist/esm/types.js +1 -0
  86. package/dist/esm/version.json +5 -0
  87. package/dist/types/button-group.d.ts +18 -0
  88. package/dist/types/button.d.ts +8 -0
  89. package/dist/types/custom-theme-button/custom-theme-button-types.d.ts +21 -0
  90. package/dist/types/custom-theme-button/custom-theme-button.d.ts +6 -0
  91. package/dist/types/custom-theme-button/index.d.ts +2 -0
  92. package/dist/types/custom-theme-button/theme.d.ts +21 -0
  93. package/dist/types/entry-points/button-group.d.ts +1 -0
  94. package/dist/types/entry-points/custom-theme-button.d.ts +2 -0
  95. package/dist/types/entry-points/loading-button.d.ts +2 -0
  96. package/dist/types/entry-points/standard-button.d.ts +2 -0
  97. package/dist/types/entry-points/types.d.ts +4 -0
  98. package/dist/types/index.d.ts +8 -0
  99. package/dist/types/loading-button.d.ts +11 -0
  100. package/dist/types/shared/block-events.d.ts +3 -0
  101. package/dist/types/shared/button-base.d.ts +10 -0
  102. package/dist/types/shared/colors.d.ts +31 -0
  103. package/dist/types/shared/css.d.ts +22 -0
  104. package/dist/types/shared/get-is-only-single-icon.d.ts +2 -0
  105. package/dist/types/shared/loading-spinner.d.ts +4 -0
  106. package/dist/types/types.d.ts +51 -0
  107. package/extract-react-types/custom-theme-button-props.tsx +7 -0
  108. package/extract-react-types/loading-button-props.tsx +5 -0
  109. package/extract-react-types/shared-props.tsx +5 -0
  110. package/loading-button/package.json +7 -0
  111. package/package.json +83 -0
  112. package/standard-button/package.json +7 -0
  113. package/types/package.json +7 -0
@@ -0,0 +1,393 @@
1
+ import * as colors from '@atlaskit/theme/colors';
2
+ import { token } from '@atlaskit/tokens';
3
+ // Hard coding the active rgba color value rather than using a helper to convert it
4
+ // With helper it would be: hex2rgba(colors.B75, 0.6)
5
+ const fadedB75 = 'rgba(179, 212, 255, 0.6)';
6
+ const values = {
7
+ // Default appearance
8
+ background: {
9
+ default: {
10
+ default: {
11
+ light: token('color.background.subtleNeutral.resting', colors.N20A),
12
+ dark: token('color.background.subtleNeutral.resting', colors.DN70)
13
+ },
14
+ hover: {
15
+ light: token('color.background.subtleNeutral.hover', colors.N30A),
16
+ dark: token('color.background.subtleNeutral.hover', colors.DN60)
17
+ },
18
+ active: {
19
+ light: token('color.background.subtleNeutral.pressed', fadedB75),
20
+ dark: token('color.background.subtleNeutral.pressed', colors.B75)
21
+ },
22
+ disabled: {
23
+ light: token('color.background.disabled', colors.N20A),
24
+ dark: token('color.background.disabled', colors.DN70)
25
+ },
26
+ selected: {
27
+ light: token('color.background.selected.resting', colors.N700),
28
+ dark: token('color.background.selected.resting', colors.DN0)
29
+ },
30
+ focusSelected: {
31
+ light: token('color.background.selected.resting', colors.N700),
32
+ dark: token('color.background.selected.resting', colors.DN0)
33
+ }
34
+ },
35
+ primary: {
36
+ default: {
37
+ light: token('color.background.boldBrand.resting', colors.B400),
38
+ dark: token('color.background.boldBrand.resting', colors.B100)
39
+ },
40
+ hover: {
41
+ light: token('color.background.boldBrand.hover', colors.B300),
42
+ dark: token('color.background.boldBrand.hover', colors.B75)
43
+ },
44
+ active: {
45
+ light: token('color.background.boldBrand.pressed', colors.B500),
46
+ dark: token('color.background.boldBrand.pressed', colors.B200)
47
+ },
48
+ disabled: {
49
+ light: token('color.background.disabled', colors.N20A),
50
+ dark: token('color.background.disabled', colors.DN70)
51
+ },
52
+ selected: {
53
+ light: token('color.background.selected.resting', colors.N700),
54
+ dark: token('color.background.selected.resting', colors.DN0)
55
+ },
56
+ focusSelected: {
57
+ light: token('color.background.selected.resting', colors.N700),
58
+ dark: token('color.background.selected.resting', colors.DN0)
59
+ }
60
+ },
61
+ warning: {
62
+ default: {
63
+ light: token('color.background.boldWarning.resting', colors.Y300),
64
+ dark: token('color.background.boldWarning.resting', colors.Y300)
65
+ },
66
+ hover: {
67
+ light: token('color.background.boldWarning.hover', colors.Y200),
68
+ dark: token('color.background.boldWarning.hover', colors.Y200)
69
+ },
70
+ active: {
71
+ light: token('color.background.boldWarning.pressed', colors.Y400),
72
+ dark: token('color.background.boldWarning.pressed', colors.Y400)
73
+ },
74
+ disabled: {
75
+ light: token('color.background.disabled', colors.N20A),
76
+ dark: token('color.background.disabled', colors.DN70)
77
+ },
78
+ selected: {
79
+ light: token('color.background.selected.resting', colors.Y400),
80
+ dark: token('color.background.selected.resting', colors.Y400)
81
+ },
82
+ focusSelected: {
83
+ light: token('color.background.selected.resting', colors.Y400),
84
+ dark: token('color.background.selected.resting', colors.Y400)
85
+ }
86
+ },
87
+ danger: {
88
+ default: {
89
+ light: token('color.background.boldDanger.resting', colors.R400),
90
+ dark: token('color.background.boldDanger.resting', colors.R400)
91
+ },
92
+ hover: {
93
+ light: token('color.background.boldDanger.hover', colors.R300),
94
+ dark: token('color.background.boldDanger.hover', colors.R300)
95
+ },
96
+ active: {
97
+ light: token('color.background.boldDanger.pressed', colors.R500),
98
+ dark: token('color.background.boldDanger.pressed', colors.R500)
99
+ },
100
+ disabled: {
101
+ light: token('color.background.disabled', colors.N20A),
102
+ dark: token('color.background.disabled', colors.DN70)
103
+ },
104
+ selected: {
105
+ light: token('color.background.selected.resting', colors.R500),
106
+ dark: token('color.background.selected.resting', colors.R500)
107
+ },
108
+ focusSelected: {
109
+ light: token('color.background.selected.resting', colors.R500),
110
+ dark: token('color.background.selected.resting', colors.R500)
111
+ }
112
+ },
113
+ link: {
114
+ default: {
115
+ light: 'none',
116
+ dark: 'none'
117
+ },
118
+ selected: {
119
+ light: token('color.background.selected.resting', colors.N700),
120
+ dark: token('color.background.selected.resting', colors.N20)
121
+ },
122
+ focusSelected: {
123
+ light: token('color.background.selected.resting', colors.N700),
124
+ dark: token('color.background.selected.resting', colors.N20)
125
+ }
126
+ },
127
+ subtle: {
128
+ default: {
129
+ light: 'none',
130
+ dark: 'none'
131
+ },
132
+ hover: {
133
+ light: token('color.background.transparentNeutral.hover', colors.N30A),
134
+ dark: token('color.background.transparentNeutral.hover', colors.DN60)
135
+ },
136
+ active: {
137
+ light: token('color.background.transparentNeutral.pressed', fadedB75),
138
+ dark: token('color.background.transparentNeutral.pressed', colors.B75)
139
+ },
140
+ disabled: {
141
+ light: 'none',
142
+ dark: 'none'
143
+ },
144
+ selected: {
145
+ light: token('color.background.selected.resting', colors.N700),
146
+ dark: token('color.background.selected.resting', colors.DN0)
147
+ },
148
+ focusSelected: {
149
+ light: token('color.background.selected.resting', colors.N700),
150
+ dark: token('color.background.selected.resting', colors.DN0)
151
+ }
152
+ },
153
+ 'subtle-link': {
154
+ default: {
155
+ light: 'none',
156
+ dark: 'none'
157
+ },
158
+ selected: {
159
+ light: token('color.background.selected.resting', colors.N700),
160
+ dark: token('color.background.selected.resting', colors.N20)
161
+ },
162
+ focusSelected: {
163
+ light: token('color.background.selected.resting', colors.N700),
164
+ dark: token('color.background.selected.resting', colors.N20)
165
+ }
166
+ }
167
+ },
168
+ boxShadowColor: {
169
+ default: {
170
+ focus: {
171
+ light: token('color.border.focus', colors.B100),
172
+ dark: token('color.border.focus', colors.B75)
173
+ },
174
+ focusSelected: {
175
+ light: token('color.border.focus', colors.B100),
176
+ dark: token('color.border.focus', colors.B75)
177
+ }
178
+ },
179
+ primary: {
180
+ focus: {
181
+ light: token('color.border.focus', colors.B100),
182
+ dark: token('color.border.focus', colors.B75)
183
+ },
184
+ focusSelected: {
185
+ light: token('color.border.focus', colors.B100),
186
+ dark: token('color.border.focus', colors.B75)
187
+ }
188
+ },
189
+ warning: {
190
+ focus: {
191
+ light: token('color.border.focus', colors.Y500),
192
+ dark: token('color.border.focus', colors.Y500)
193
+ },
194
+ focusSelected: {
195
+ light: token('color.border.focus', colors.Y500),
196
+ dark: token('color.border.focus', colors.Y500)
197
+ }
198
+ },
199
+ danger: {
200
+ focus: {
201
+ light: token('color.border.focus', colors.R100),
202
+ dark: token('color.border.focus', colors.R100)
203
+ },
204
+ focusSelected: {
205
+ light: token('color.border.focus', colors.R100),
206
+ dark: token('color.border.focus', colors.R100)
207
+ }
208
+ },
209
+ link: {
210
+ focus: {
211
+ light: token('color.border.focus', colors.B100),
212
+ dark: token('color.border.focus', colors.B75)
213
+ },
214
+ focusSelected: {
215
+ light: token('color.border.focus', colors.B100),
216
+ dark: token('color.border.focus', colors.B75)
217
+ }
218
+ },
219
+ subtle: {
220
+ focus: {
221
+ light: token('color.border.focus', colors.B100),
222
+ dark: token('color.border.focus', colors.B75)
223
+ },
224
+ focusSelected: {
225
+ light: token('color.border.focus', colors.B100),
226
+ dark: token('color.border.focus', colors.B75)
227
+ }
228
+ },
229
+ 'subtle-link': {
230
+ focus: {
231
+ light: token('color.border.focus', colors.B100),
232
+ dark: token('color.border.focus', colors.B75)
233
+ },
234
+ focusSelected: {
235
+ light: token('color.border.focus', colors.B100),
236
+ dark: token('color.border.focus', colors.B75)
237
+ }
238
+ }
239
+ },
240
+ color: {
241
+ default: {
242
+ default: {
243
+ light: token('color.text.highEmphasis', colors.N500),
244
+ dark: token('color.text.highEmphasis', colors.DN400)
245
+ },
246
+ active: {
247
+ light: token('color.text.highEmphasis', colors.B400),
248
+ dark: token('color.text.highEmphasis', colors.B400)
249
+ },
250
+ disabled: {
251
+ light: token('color.text.disabled', colors.N70),
252
+ dark: token('color.text.disabled', colors.DN30)
253
+ },
254
+ selected: {
255
+ light: token('color.text.selected', colors.N20),
256
+ dark: token('color.text.selected', colors.DN400)
257
+ },
258
+ focusSelected: {
259
+ light: token('color.text.selected', colors.N20),
260
+ dark: token('color.text.selected', colors.DN400)
261
+ }
262
+ },
263
+ primary: {
264
+ default: {
265
+ light: token('color.text.onBold', colors.N0),
266
+ dark: token('color.text.onBold', colors.DN30)
267
+ },
268
+ disabled: {
269
+ light: token('color.text.disabled', colors.N70),
270
+ dark: token('color.text.disabled', colors.DN30)
271
+ },
272
+ selected: {
273
+ light: token('color.text.selected', colors.N20),
274
+ dark: token('color.text.selected', colors.DN400)
275
+ },
276
+ focusSelected: {
277
+ light: token('color.text.selected', colors.N20),
278
+ dark: token('color.text.selected', colors.DN400)
279
+ }
280
+ },
281
+ warning: {
282
+ default: {
283
+ light: token('color.text.onBoldWarning', colors.N800),
284
+ dark: token('color.text.onBoldWarning', colors.N800)
285
+ },
286
+ disabled: {
287
+ light: token('color.text.disabled', colors.N70),
288
+ dark: token('color.text.disabled', colors.DN30)
289
+ },
290
+ selected: {
291
+ light: token('color.text.selected', colors.N800),
292
+ dark: token('color.text.selected', colors.N800)
293
+ },
294
+ focusSelected: {
295
+ light: token('color.text.selected', colors.N800),
296
+ dark: token('color.text.selected', colors.N800)
297
+ }
298
+ },
299
+ danger: {
300
+ default: {
301
+ light: token('color.text.onBold', colors.N0),
302
+ dark: token('color.text.onBold', colors.N0)
303
+ },
304
+ disabled: {
305
+ light: token('color.text.disabled', colors.N70),
306
+ dark: token('color.text.disabled', colors.DN30)
307
+ },
308
+ selected: {
309
+ light: token('color.text.selected', colors.N0),
310
+ dark: token('color.text.selected', colors.N0)
311
+ },
312
+ focusSelected: {
313
+ light: token('color.text.selected', colors.N0),
314
+ dark: token('color.text.selected', colors.N0)
315
+ }
316
+ },
317
+ link: {
318
+ default: {
319
+ light: token('color.text.link.resting', colors.B400),
320
+ dark: token('color.text.link.resting', colors.B100)
321
+ },
322
+ hover: {
323
+ light: token('color.text.link.resting', colors.B300),
324
+ dark: token('color.text.link.resting', colors.B75)
325
+ },
326
+ active: {
327
+ light: token('color.text.link.pressed', colors.B500),
328
+ dark: token('color.text.link.pressed', colors.B200)
329
+ },
330
+ disabled: {
331
+ light: token('color.text.disabled', colors.N70),
332
+ dark: token('color.text.disabled', colors.DN100)
333
+ },
334
+ selected: {
335
+ light: token('color.text.selected', colors.N20),
336
+ dark: token('color.text.selected', colors.N700)
337
+ },
338
+ focusSelected: {
339
+ light: token('color.text.selected', colors.N20),
340
+ dark: token('color.text.selected', colors.N700)
341
+ }
342
+ },
343
+ subtle: {
344
+ default: {
345
+ light: token('color.text.highEmphasis', colors.N500),
346
+ dark: token('color.text.highEmphasis', colors.DN400)
347
+ },
348
+ active: {
349
+ light: token('color.text.highEmphasis', colors.B400),
350
+ dark: token('color.text.highEmphasis', colors.B400)
351
+ },
352
+ disabled: {
353
+ light: token('color.text.disabled', colors.N70),
354
+ dark: token('color.text.disabled', colors.DN100)
355
+ },
356
+ selected: {
357
+ light: token('color.text.selected', colors.N20),
358
+ dark: token('color.text.selected', colors.DN400)
359
+ },
360
+ focusSelected: {
361
+ light: token('color.text.selected', colors.N20),
362
+ dark: token('color.text.selected', colors.DN400)
363
+ }
364
+ },
365
+ 'subtle-link': {
366
+ default: {
367
+ light: token('color.text.mediumEmphasis', colors.N200),
368
+ dark: token('color.text.mediumEmphasis', colors.DN400)
369
+ },
370
+ hover: {
371
+ light: token('color.text.mediumEmphasis', colors.N90),
372
+ dark: token('color.text.mediumEmphasis', colors.B50)
373
+ },
374
+ active: {
375
+ light: token('color.text.highEmphasis', colors.N400),
376
+ dark: token('color.text.highEmphasis', colors.DN300)
377
+ },
378
+ disabled: {
379
+ light: token('color.text.disabled', colors.N70),
380
+ dark: token('color.text.disabled', colors.DN100)
381
+ },
382
+ selected: {
383
+ light: token('color.text.selected', colors.N20),
384
+ dark: token('color.text.selected', colors.DN400)
385
+ },
386
+ focusSelected: {
387
+ light: token('color.text.selected', colors.N20),
388
+ dark: token('color.text.selected', colors.DN400)
389
+ }
390
+ }
391
+ }
392
+ };
393
+ export default values;
@@ -0,0 +1,249 @@
1
+ import { borderRadius as getBorderRadius, fontSize as getFontSize, gridSize as getGridSize } from '@atlaskit/theme/constants';
2
+ import colors from './colors';
3
+ const borderRadius = getBorderRadius();
4
+ const gridSize = getGridSize();
5
+ const fontSize = getFontSize(); // ## Button layout
6
+ //
7
+ // /------------------------------------------------------------------------------------------------------------------\
8
+ // | → | ← | | → | ← | | → | ← | | → | ← |
9
+ // | 10px → | ← 2px | icon | 2px → | ← 2px | | 2px → | ← 2px | icon | 2px → | ← 10px |
10
+ // | padding | margin | before | margin | margin | content | margin | margin | after | margin | padding |
11
+ // | (12px total) | | (4px total) | | (4px total) | | (12px total) |
12
+ // | → | ← | | → | ← | | → | ← | | → | ← |
13
+ // \------------------------------------------------------------------------------------------------------------------/
14
+ // ↑ ↑
15
+ // Margins don't collapse with inline-flex
16
+ //
17
+
18
+ const heights = {
19
+ default: `${gridSize * 4 / fontSize}em`,
20
+ // 32px
21
+ compact: `${gridSize * 3 / fontSize}em`,
22
+ none: 'auto'
23
+ };
24
+ const lineHeights = {
25
+ default: heights.default,
26
+ compact: heights.compact,
27
+ none: 'inherit'
28
+ };
29
+ const padding = {
30
+ // 10px gutter
31
+ default: `0 ${gridSize + gridSize / 4}px`,
32
+ compact: `0 ${gridSize + gridSize / 4}px`,
33
+ none: '0'
34
+ };
35
+ const singleIconPadding = {
36
+ // 2px gutter
37
+ compact: `0 ${gridSize / 4}px`,
38
+ default: `0 ${gridSize / 4}px`,
39
+ none: '0'
40
+ };
41
+ const verticalAlign = {
42
+ default: 'middle',
43
+ compact: 'middle',
44
+ none: 'baseline'
45
+ };
46
+ const innerMargin = {
47
+ content: `0 ${gridSize / 4}px`,
48
+ icon: `0 ${gridSize / 4}px`
49
+ };
50
+
51
+ function getColor({
52
+ group,
53
+ key,
54
+ mode
55
+ }) {
56
+ const rule = group[key] || group.default;
57
+ return rule[mode];
58
+ }
59
+
60
+ function getColors({
61
+ appearance,
62
+ key,
63
+ mode
64
+ }) {
65
+ return {
66
+ background: getColor({
67
+ group: colors.background[appearance],
68
+ key,
69
+ mode
70
+ }),
71
+ // Needing to add !important to overcome specificity issue caused by deprecated AtlaskitThemeProvider
72
+ color: `${getColor({
73
+ group: colors.color[appearance],
74
+ key,
75
+ mode
76
+ })} !important`
77
+ };
78
+ }
79
+
80
+ export function getCss({
81
+ appearance,
82
+ spacing,
83
+ mode,
84
+ isSelected,
85
+ shouldFitContainer,
86
+ isOnlySingleIcon
87
+ }) {
88
+ const baseColors = getColors({
89
+ appearance,
90
+ key: isSelected ? 'selected' : 'default',
91
+ mode
92
+ });
93
+ return {
94
+ // 0px margin added to css-reset
95
+ alignItems: 'baseline',
96
+ borderWidth: 0,
97
+ borderRadius,
98
+ boxSizing: 'border-box',
99
+ display: 'inline-flex',
100
+ fontSize: 'inherit',
101
+ fontStyle: 'normal',
102
+ // Chrome recently changed button so that they use 'arial' as the font family
103
+ fontFamily: 'inherit',
104
+ fontWeight: 500,
105
+ // margin for button has been applied to css reset
106
+ maxWidth: '100%',
107
+ // Needed to position overlay
108
+ position: 'relative',
109
+ textAlign: 'center',
110
+ textDecoration: 'none',
111
+ transition: 'background 0.1s ease-out, box-shadow 0.15s cubic-bezier(0.47, 0.03, 0.49, 1.38)',
112
+ whiteSpace: 'nowrap',
113
+ // dynamic styles
114
+ ...baseColors,
115
+ cursor: 'pointer',
116
+ height: heights[spacing],
117
+ lineHeight: lineHeights[spacing],
118
+ padding: isOnlySingleIcon ? singleIconPadding[spacing] : padding[spacing],
119
+ verticalAlign: verticalAlign[spacing],
120
+ width: shouldFitContainer ? '100%' : 'auto',
121
+ // justifyContent required for shouldFitContainer buttons with an icon inside
122
+ justifyContent: 'center',
123
+ // Note: we cannot disable pointer events when there is an overlay.
124
+ // That would be easy for styling, but it would start letting events through on disabled buttons
125
+ // Disabling visited styles (just using the base colors)
126
+ '&:visited': { ...baseColors
127
+ },
128
+ '&:hover': { ...getColors({
129
+ appearance,
130
+ key: isSelected ? 'selected' : 'hover',
131
+ mode
132
+ }),
133
+ textDecoration: !isSelected && (appearance === 'link' || appearance === 'subtle-link') ? 'underline' : 'inherit',
134
+ // background, box-shadow
135
+ transitionDuration: '0s, 0.15s'
136
+ },
137
+ '&:focus': { ...getColors({
138
+ appearance,
139
+ key: isSelected ? 'focusSelected' : 'focus',
140
+ mode
141
+ }),
142
+ boxShadow: `0 0 0 2px ${colors.boxShadowColor[appearance].focus[mode]}`,
143
+ // background, box-shadow
144
+ transitionDuration: '0s, 0.2s',
145
+ // disabling browser focus outline
146
+ outline: 'none'
147
+ },
148
+ // giving active styles preference by listing them after focus
149
+ '&:active': { ...getColors({
150
+ appearance,
151
+ key: isSelected ? 'selected' : 'active',
152
+ mode
153
+ }),
154
+ // background, box-shadow
155
+ transitionDuration: '0s, 0s'
156
+ },
157
+ // preventDefault prevents regular active styles from applying in Firefox
158
+ '&[data-firefox-is-active="true"]': { ...getColors({
159
+ appearance,
160
+ key: isSelected ? 'selected' : 'active',
161
+ mode
162
+ }),
163
+ // background, box-shadow
164
+ transitionDuration: '0s, 0s'
165
+ },
166
+ // Giving disabled styles preference over active by listing them after.
167
+ // Not using '&:disabled' because :disabled is not a valid state for all element types
168
+ // so we are targeting the attribute
169
+ // Attributes have the same specificity a pseudo classes so we are overriding :disabled here
170
+ '&[disabled]': { // always using 'disabled' even when selected
171
+ ...getColors({
172
+ appearance,
173
+ key: 'disabled',
174
+ mode
175
+ }),
176
+ cursor: 'not-allowed',
177
+ textDecoration: 'none'
178
+ },
179
+ '&[data-has-overlay="true"]': {
180
+ cursor: 'default',
181
+ textDecoration: 'none'
182
+ },
183
+ // disabling hover and active color changes when there is an overlay, but the button is not disabled
184
+ '&[data-has-overlay="true"]:not([disabled]):hover, &[data-has-overlay="true"]:not([disabled]):active': { ...getColors({
185
+ appearance,
186
+ key: isSelected ? 'selected' : 'default',
187
+ mode
188
+ })
189
+ },
190
+ '&::-moz-focus-inner': {
191
+ border: 0,
192
+ margin: 0,
193
+ padding: 0
194
+ }
195
+ };
196
+ } // inline-flex child
197
+
198
+ export function getIconStyle({
199
+ spacing
200
+ }) {
201
+ return {
202
+ alignSelf: 'center',
203
+ display: 'flex',
204
+ // icon size cannot grow and shrink
205
+ flexGrow: 0,
206
+ flexShrink: 0,
207
+ lineHeight: 0,
208
+ fontSize: 0,
209
+ userSelect: 'none',
210
+ margin: spacing === 'none' ? 0 : innerMargin.icon
211
+ };
212
+ } // inline-flex child
213
+
214
+ export function getContentStyle({
215
+ spacing
216
+ }) {
217
+ return {
218
+ margin: spacing === 'none' ? 0 : innerMargin.content,
219
+ // content can grow and shrink
220
+ flexGrow: 1,
221
+ flexShrink: 1,
222
+ // ellipsis for overflow text
223
+ overflow: 'hidden',
224
+ textOverflow: 'ellipsis',
225
+ whiteSpace: 'nowrap'
226
+ };
227
+ }
228
+ export function getFadingCss({
229
+ hasOverlay
230
+ }) {
231
+ return {
232
+ transition: 'opacity 0.3s',
233
+ opacity: hasOverlay ? 0 : 1
234
+ };
235
+ }
236
+ export const overlayCss = {
237
+ // stretching to full width / height of button
238
+ // this is important as we need it to still block
239
+ // event if clicking in the button's own padding
240
+ position: 'absolute',
241
+ left: 0,
242
+ top: 0,
243
+ right: 0,
244
+ bottom: 0,
245
+ // Putting all children in the center
246
+ display: 'flex',
247
+ justifyContent: 'center',
248
+ alignItems: 'center'
249
+ };