@stackoverflow/stacks 2.5.4 → 2.5.5

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 (101) hide show
  1. package/LICENSE.MD +9 -9
  2. package/README.md +180 -180
  3. package/dist/css/stacks.css +102 -122
  4. package/dist/css/stacks.min.css +1 -1
  5. package/lib/atomic/border.less +139 -139
  6. package/lib/atomic/color.less +36 -36
  7. package/lib/atomic/flex.less +426 -426
  8. package/lib/atomic/gap.less +44 -44
  9. package/lib/atomic/grid.less +139 -139
  10. package/lib/atomic/misc.less +374 -374
  11. package/lib/atomic/spacing.less +98 -98
  12. package/lib/atomic/typography.less +264 -264
  13. package/lib/atomic/width-height.less +194 -194
  14. package/lib/base/body.less +44 -44
  15. package/lib/base/configuration-static.less +61 -61
  16. package/lib/base/fieldset.less +5 -5
  17. package/lib/base/icon.less +11 -11
  18. package/lib/base/internal.less +220 -220
  19. package/lib/base/reset-meyer.less +64 -64
  20. package/lib/base/reset-normalize.less +449 -449
  21. package/lib/base/reset.less +20 -20
  22. package/lib/components/activity-indicator/activity-indicator.less +53 -53
  23. package/lib/components/anchor/anchor.less +78 -68
  24. package/lib/components/avatar/avatar.less +108 -108
  25. package/lib/components/award-bling/award-bling.less +31 -31
  26. package/lib/components/badge/badge.less +258 -258
  27. package/lib/components/banner/banner.less +44 -44
  28. package/lib/components/banner/banner.ts +149 -149
  29. package/lib/components/block-link/block-link.less +82 -82
  30. package/lib/components/breadcrumbs/breadcrumbs.less +41 -41
  31. package/lib/components/button/button.less +473 -473
  32. package/lib/components/button-group/button-group.less +82 -82
  33. package/lib/components/card/card.less +37 -37
  34. package/lib/components/check-control/check-control.less +17 -17
  35. package/lib/components/check-group/check-group.less +19 -19
  36. package/lib/components/checkbox_radio/checkbox_radio.less +159 -159
  37. package/lib/components/code-block/code-block.fixtures.ts +88 -88
  38. package/lib/components/code-block/code-block.less +116 -116
  39. package/lib/components/description/description.less +9 -9
  40. package/lib/components/empty-state/empty-state.less +16 -16
  41. package/lib/components/expandable/expandable.less +118 -118
  42. package/lib/components/expandable/expandable.ts +238 -238
  43. package/lib/components/input-fill/input-fill.less +35 -35
  44. package/lib/components/input-icon/input-icon.less +45 -45
  45. package/lib/components/input-message/input-message.less +49 -49
  46. package/lib/components/input_textarea/input_textarea.less +150 -150
  47. package/lib/components/label/label.less +110 -110
  48. package/lib/components/link/link.less +135 -120
  49. package/lib/components/link-preview/link-preview.less +148 -148
  50. package/lib/components/menu/menu.less +41 -41
  51. package/lib/components/modal/modal.less +118 -118
  52. package/lib/components/modal/modal.ts +383 -383
  53. package/lib/components/navigation/navigation.less +136 -136
  54. package/lib/components/navigation/navigation.ts +128 -128
  55. package/lib/components/notice/notice.less +195 -195
  56. package/lib/components/page-title/page-title.less +51 -51
  57. package/lib/components/pagination/pagination.less +65 -65
  58. package/lib/components/popover/popover.less +159 -159
  59. package/lib/components/popover/popover.ts +651 -651
  60. package/lib/components/popover/tooltip.ts +343 -343
  61. package/lib/components/post-summary/post-summary.less +457 -447
  62. package/lib/components/progress-bar/progress-bar.less +291 -291
  63. package/lib/components/prose/prose.less +452 -452
  64. package/lib/components/select/select.less +138 -138
  65. package/lib/components/sidebar-widget/sidebar-widget.less +257 -257
  66. package/lib/components/spinner/spinner.less +103 -103
  67. package/lib/components/table/table.less +307 -307
  68. package/lib/components/table/table.ts +296 -296
  69. package/lib/components/table-container/table-container.less +4 -4
  70. package/lib/components/tag/tag.less +186 -186
  71. package/lib/components/toast/toast.less +35 -35
  72. package/lib/components/toast/toast.ts +357 -357
  73. package/lib/components/toggle-switch/toggle-switch.less +104 -104
  74. package/lib/components/topbar/topbar.less +553 -553
  75. package/lib/components/uploader/uploader.less +205 -205
  76. package/lib/components/uploader/uploader.ts +207 -207
  77. package/lib/components/user-card/user-card.less +129 -129
  78. package/lib/controllers.ts +33 -33
  79. package/lib/exports/color-mixins.less +283 -283
  80. package/lib/exports/color-sets.less +711 -711
  81. package/lib/exports/color.less +65 -65
  82. package/lib/exports/constants-helpers.less +108 -108
  83. package/lib/exports/constants-type.less +155 -155
  84. package/lib/exports/exports.less +15 -15
  85. package/lib/exports/mixins.less +333 -333
  86. package/lib/exports/spacing-mixins.less +67 -67
  87. package/lib/index.ts +32 -32
  88. package/lib/input-utils.less +41 -41
  89. package/lib/stacks-dynamic.less +24 -24
  90. package/lib/stacks-static.less +93 -93
  91. package/lib/stacks.less +13 -13
  92. package/lib/stacks.ts +113 -113
  93. package/lib/test/a11y-test-utils.ts +94 -94
  94. package/lib/test/assertions.ts +36 -36
  95. package/lib/test/less-test-utils.ts +28 -28
  96. package/lib/test/open-wc-testing-patch.d.ts +26 -26
  97. package/lib/test/test-utils.ts +364 -364
  98. package/lib/test/visual-test-utils.ts +58 -58
  99. package/lib/tsconfig.build.json +4 -4
  100. package/lib/tsconfig.json +17 -17
  101. package/package.json +115 -115
@@ -1,474 +1,474 @@
1
- .s-btn {
2
- // BASE COMPONENT-SPECIFIC CUSTOM PROPERTIES
3
- --_bu-baw: var(--su-static1);
4
- --_bu-bc: transparent;
5
- // --_bu-bg: inherit; // [1]
6
- --_bu-br: var(--br-md);
7
- --_bu-fc: var(--theme-button-color, var(--theme-secondary-400));
8
- --_bu-fs: var(--fs-body1);
9
- --_bu-p: 0.8em;
10
-
11
- // Active
12
- --_bu-bc-active: var(--_bu-bc);
13
- --_bu-bg-active: var(--theme-button-active-background-color, var(--theme-secondary-300));
14
- --_bu-fc-active: var(--theme-button-hover-color, var(--theme-secondary-500)); // Note: hover color used on purpose
15
-
16
- // Hover
17
- --_bu-bc-hover: var(--_bu-bc);
18
- --_bu-bg-hover: var(--theme-button-hover-background-color, var(--theme-secondary-200));
19
- --_bu-fc-hover: var(--theme-button-hover-color, var(--theme-secondary-500));
20
-
21
- // BASE SELECTED MODIFIER
22
- --_bu-bg-selected: var(--theme-button-selected-background-color, var(--theme-secondary-300));
23
- --_bu-fc-selected: var(--theme-button-selected-color, var(--theme-secondary-600));
24
-
25
- // FILLED VARIANT
26
- --_bu-filled-bc: transparent;
27
- --_bu-filled-bg: var(--theme-button-primary-background-color, var(--theme-secondary-400));
28
- --_bu-filled-fc: var(--theme-button-primary-color, var(--white));
29
- // Filled + Selected
30
- --_bu-filled-bc-selected: transparent;
31
- --_bu-filled-bg-selected: var(--theme-button-primary-selected-background-color, var(--theme-secondary-500));
32
- --_bu-filled-fc-selected: var(--theme-button-primary-selected-color, var(--white));
33
- // Filled + Active
34
- --_bu-filled-bc-active: var(--_bu-filled-bc);
35
- --_bu-filled-bg-active: var(--theme-button-primary-active-background-color, var(--theme-secondary-600));
36
- --_bu-filled-fc-active: var(--theme-button-primary-hover-color, var(--white));
37
- // Filled + Hover
38
- --_bu-filled-bc-hover: var(--_bu-filled-bc);
39
- --_bu-filled-bg-hover: var(--theme-button-primary-hover-background-color, var(--theme-secondary-500));
40
- --_bu-filled-fc-hover: var(--theme-button-primary-hover-color, var(--white));
41
-
42
- // OUTLINED VARIANT
43
- --_bu-outlined-bc: var(--theme-button-outlined-border-color, var(--theme-secondary-400));
44
- --_bu-outlined-bg: var(--theme-button-outlined-background-color);
45
- --_bg-outlined-fc: var(--theme-button-outlined-color, var(--theme-secondary-400));
46
- // Outlined + Selected
47
- --_bu-outlined-bc-selected: var(--theme-button-outlined-selected-border-color, var(--theme-secondary-400));
48
- --_bu-outlined-bg-selected: var(--theme-button-selected-background-color, var(--theme-secondary-300));
49
- --_bu-outlined-fc-selected: var(--theme-button-selected-color, var(--theme-secondary-600));
50
-
51
- // CHILD COMPONENT CUSTOM PROPERTIES
52
- --_bu-badge-o: 0.5;
53
- --_bu-dropdown-bw: var(--su-static4);
54
- --_bu-number-fc: var(--white);
55
- --_bu-number-fc-filled: var(--theme-button-primary-number-color, var(--theme-secondary-600));
56
- --_bu-number-fc-selected: var(--white);
57
-
58
- // CONTEXTUAL STYLES
59
- .highcontrast-mode({
60
- --_bu-bc: currentColor;
61
- --_bu-outlined-bc: var(--_bu-bc);
62
- --_bu-bc-selected: var(--_bu-bc);
63
- --_bu-fc-selected: var(--white);
64
- --_bu-outlined-fc-selected: var(--white);
65
- --_bu-badge-o: 0.8;
66
- --_bu-number-fc-selected: var(--theme-button-primary-number-color, var(--theme-secondary-600));
67
- });
68
-
69
- // STATES
70
- fieldset[disabled] &,
71
- &[disabled],
72
- &[aria-disabled="true"] {
73
- opacity: var(--_o-disabled-static);
74
- pointer-events: none;
75
- text-decoration: none;
76
- }
77
-
78
- button &,
79
- button[type="submit"] &,
80
- button[type="reset"] & {
81
- -webkit-appearance: button; // [2]
82
- }
83
-
84
- &.grid {
85
- display: flex; // Override &&__danger buttons having inline-block by default
86
- }
87
-
88
- &.is-loading {
89
- .svg-icon:first-child {
90
- margin-left: calc((var(--su-static24) - var(--su-static1)) * -1); // -23px
91
- opacity: 0; // [3]
92
- }
93
-
94
- padding-left: 2.2em;
95
- }
96
-
97
- &.is-selected,
98
- &--radio:checked + & {
99
- background-color: var(--_bu-bg-selected);
100
- border-color: var(--_bu-bc-selected, transparent);
101
- color: var(--_bu-fc-selected);
102
-
103
- .s-btn--number {
104
- color: var(--_bu-number-fc-selected);
105
- }
106
-
107
- &.s-btn__filled { // this needs to live here to adapt to radio button-group
108
- border-color: var(--_bu-filled-bc-selected);
109
- background-color: var(--_bu-filled-bg-selected);
110
- color: var(--_bu-filled-fc-selected);
111
- }
112
- &.s-btn__outlined { // this needs to live here to adapt to radio button-group
113
- border-color: var(--_bu-outlined-bc-selected);
114
- background-color: var(--_bu-outlined-bg-selected);
115
- color: var(--_bu-outlined-fc-selected);
116
-
117
- &.s-btn__muted {
118
- .highcontrast-mode({
119
- --_bu-outlined-bc-selected: var(--_bu-filled-bc-selected);
120
- --_bu-outlined-bg-selected: var(--_bu-filled-bg-selected);
121
- --_bu-outlined-fc-selected: var(--_bu-filled-fc-selected);
122
- --_bu-number-fc-selected: var(--_bu-filled-bg-selected);
123
- });
124
- }
125
- }
126
- }
127
-
128
- // MODIFIERS
129
- &&__filled {
130
- .s-btn--number {
131
- color: var(--_bu-number-fc-filled);
132
- }
133
-
134
- border-color: var(--_bu-filled-bc);
135
- background-color: var(--_bu-filled-bg);
136
- color: var(--_bu-filled-fc);
137
- }
138
-
139
- &&__outlined {
140
- border-color: var(--_bu-outlined-bc);
141
- background-color: var(--_bu-outlined-bg, inherit);
142
- }
143
-
144
- // Resets
145
- &&__link,
146
- &&__unset {
147
- --_bu-baw: 0;
148
- --_bu-br: 0;
149
- --_bu-p: 0;
150
-
151
- &:focus,
152
- &:focus-visible {
153
- outline-style: auto;
154
- }
155
- }
156
-
157
- &&__link {
158
- &,
159
- &:hover,
160
- &:active,
161
- &:focus,
162
- &[disabled],
163
- &[aria-disabled="true"] {
164
- --_bu-bg: none;
165
- }
166
-
167
- &.s-btn__dropdown {
168
- padding-right: 0.9em;
169
- }
170
-
171
- .s-link();
172
- display: inline;
173
- font: inherit;
174
- outline: revert;
175
- text-align: inherit;
176
- }
177
-
178
- &&__unset {
179
- &,
180
- &:hover,
181
- &:active,
182
- &:focus {
183
- --_bu-bg: none;
184
- --_bu-fc: unset;
185
-
186
- cursor: default;
187
- font: unset;
188
- user-select: auto;
189
- }
190
-
191
- outline: initial;
192
- }
193
-
194
- // Pseudo-elements and child-based modifiers
195
- &&__dropdown {
196
- &:after {
197
- border-color: currentColor transparent;
198
- border-style: solid;
199
- border-width: var(--_bu-dropdown-bw);
200
- border-bottom-width: 0;
201
- content: "";
202
- pointer-events: none;
203
- position: absolute;
204
- right: var(--_bu-px, var(--_bu-p));
205
- top: calc(50% - var(--su-static2));
206
- z-index: var(--zi-active);
207
- }
208
-
209
- padding-right: calc(var(--_bu-px, var(--_bu-p)) * 2.5);
210
- }
211
-
212
- &&__icon {
213
- .svg-icon {
214
- vertical-align: baseline;
215
- margin-top: -0.3em; // [4]
216
- margin-bottom: -0.3em; // [4]
217
- transition: opacity 200ms var(--te-smooth); // Animate the transition to .is-loading
218
- }
219
- }
220
-
221
- // Size
222
- &&__xs {
223
- .size-styles(xs; bu; @styles: fs);
224
- --_bu-dropdown-bw: calc(var(--su-static4) - var(--su-static1));
225
- --_bu-p: 0.6em;
226
- }
227
-
228
- &&__sm {
229
- .size-styles(sm; bu; @styles: fs);
230
- }
231
-
232
- &&__md {
233
- .size-styles(md; bu; @styles: br, fs);
234
- --_bu-p: 0.7em;
235
- }
236
-
237
- // VARIANTS
238
- &&__danger,
239
- &&__muted {
240
- .highcontrast-mode({
241
- --_bu-filled-bc: transparent;
242
- });
243
- }
244
-
245
- &&__danger {
246
- --_bu-bg-active: var(--red-300);
247
- --_bu-bg-hover: var(--red-200);
248
- --_bu-bg-selected: var(--red-300);
249
- --_bu-fc: var(--red-500);
250
- --_bu-fc-active: var(--_bu-fc);
251
- --_bu-fc-hover: var(--red-500);
252
- --_bu-fc-selected: var(--red-600);
253
- --_bu-filled-bc: transparent;
254
- --_bu-filled-bc-selected: var(--_bu-filled-bc);
255
- --_bu-filled-bg: var(--red-400);
256
- --_bu-filled-bg-active: var(--red-500);
257
- --_bu-filled-bg-hover: var(--red-500);
258
- --_bu-filled-bg-selected: var(--red-600);
259
- --_bu-filled-fc: var(--white);
260
- --_bu-filled-fc-active: var(--_bu-filled-fc);
261
- --_bu-filled-fc-hover: var(--_bu-filled-fc);
262
- --_bu-filled-fc-selected: var(--_bu-filled-fc);
263
- --_bu-outlined-bc: var(--red-400);
264
- --_bu-outlined-bc-selected: var(--red-500);
265
- --_bu-outlined-bg-selected: var(--_bu-bg-selected);
266
- --_bu-outlined-fc-selected: var(--_bu-fc-selected);
267
- --_bu-number-fc: var(--white);
268
- --_bu-number-fc-filled: var(--black);
269
- }
270
-
271
- &&__muted {
272
- --_bu-bc-hover: var(--black-300);
273
- --_bu-bg-active: var(--black-150);
274
- --_bu-bg-hover: var(--black-100);
275
- --_bu-bg-selected: var(--black-200);
276
- --_bu-fc: var(--black-500);
277
- --_bu-fc-active: var(--_bu-fc);
278
- --_bu-fc-hover: var(--black-500);
279
- --_bu-fc-selected: var(--black-500);
280
- // The filled modifier on the muted button is deprecated and is to be
281
- // removed in Stacks Classic v2
282
- --_bu-filled-bc: transparent;
283
- --_bu-filled-bc-selected: var(--_bu-filled-bc);
284
- --_bu-filled-bg: var(--black-225);
285
- --_bu-filled-bg-active: var(--black-300);
286
- --_bu-filled-bg-hover: var(--black-250);
287
- --_bu-filled-bg-selected: var(--black-350);
288
- --_bu-filled-fc: var(--black-500);
289
- --_bu-filled-fc-active: var(--_bu-filled-fc);
290
- --_bu-filled-fc-hover: var(--_bu-filled-fc);
291
- --_bu-filled-fc-selected: var(--black-600);
292
- --_bu-outlined-bc: var(--black-300);
293
- --_bu-outlined-bc-selected: var(--black-300);
294
- --_bu-outlined-bg-selected: var(--_bu-bg-selected);
295
- --_bu-outlined-fc-selected: var(--_bu-fc-selected);
296
- --_bu-number-fc-filled: var(--white);
297
- --_bu-number-fc-selected: var(--white);
298
- --_bu-bg-focus: var(--black-400);
299
- --_bu-fc-focus: var(--white);
300
- --_bu-number-fc-focus: var(--black-500);
301
-
302
- .highcontrast-mode({
303
- --_bu-bg-hover: var(--black-225);
304
- // // The filled modifier on the muted button is deprecated and is to be
305
- // // removed in Stacks Classic v2
306
- --_bu-filled-bg: var(--black-400);
307
- --_bu-filled-bg-active: var(--black-500);
308
- --_bu-filled-bg-hover: var(--black-400);
309
- --_bu-filled-bg-selected: var(--black-500);
310
- --_bu-filled-fc: var(--white);
311
- --_bu-filled-fc-selected: var(--_bu-filled-fc);
312
- --_bu-fc-selected: var(--black);
313
- --_bu-number-fc: var(--white);
314
- --_bu-number-fc-filled: var(--black);
315
- --_bu-number-fc-selected: var(--white);
316
- });
317
- }
318
-
319
- // Social
320
- &&__facebook,
321
- &&__github {
322
- .highcontrast-mode({
323
- --_bu-bc: transparent;
324
- });
325
- }
326
-
327
- &&__facebook {
328
- @_fb-brand: #385499;
329
- --_bu-bc: transparent;
330
- --_bu-bg: @_fb-brand;
331
- --_bu-bg-active: darken(@_fb-brand, 10%);
332
- --_bu-bg-hover: darken(@_fb-brand, 5%);
333
- --_bu-fc: #fff;
334
- --_bu-fc-active: var(--_bu-fc);
335
- --_bu-fc-hover: var(--_bu-fc);
336
- --_bu-hc-bc: transparent;
337
- }
338
-
339
- &&__google {
340
- --_bu-bc: var(--bc-medium);
341
- --_bu-bg: var(--white);
342
- --_bu-bg-active: var(--black-150);
343
- --_bu-bg-hover: var(--black-100);
344
- --_bu-fc: var(--fc-medium);
345
- --_bu-fc-active: var(--fc-dark);
346
- --_bu-fc-hover: var(--black-600);
347
- }
348
-
349
- &&__github {
350
- --_bu-bg: var(--black-600);
351
- --_bu-bg-active: var(--black);
352
- --_bu-bg-hover: var(--black-600);
353
- --_bu-fc: var(--white);
354
- --_bu-fc-active: var(--white);
355
- --_bu-fc-hover: var(--white);
356
- --_bu-hc-bc: transparent;
357
- }
358
-
359
- // CHILD ELEMENTS
360
- & &--badge {
361
- opacity: var(--_bu-badge-o);
362
- display: inline-block;
363
- border-radius: var(--br-sm);
364
- padding: var(--su2) calc(var(--su4) - var(--su1));
365
- font-size: var(--fs-caption);
366
- line-height: var(--lh-xs);
367
- background-color: currentColor;
368
- }
369
-
370
- & &--number {
371
- color: var(--_bu-number-fc);
372
- }
373
-
374
- &--radio { // This lives alongside a .s-btn element. These styles are the equivelent of `.v-visible-sr`
375
- border: 0;
376
- clip-path: inset(50%);
377
- clip: rect(var(--su-static1), var(--su-static1), var(--su-static1), var(--su-static1)); // rect(1px, 1px, 1px, 1px)
378
- height: var(--su-static1);
379
- margin: calc(var(--su-static1) * -1); // -1px
380
- overflow-wrap: normal;
381
- overflow: hidden;
382
- padding: 0;
383
- position: absolute;
384
- width: var(--su-static1);
385
- }
386
-
387
- // INTERACTION
388
- &:not(&__link):not(&__unset):focus-visible,
389
- &--radio:focus-visible + & {
390
- .focus-styles(true, true);
391
- }
392
-
393
- &:not(&--radio:checked + label):not(&__link):not(&__unset):not(&__facebook):not(&__github):not(&__google):not(.is-selected) {
394
- &:focus-visible,
395
- &.focus-inset-bordered {
396
- &:not(:hover) .s-btn--number {
397
- color: var(--_bu-number-fc-focus, var(--_bu-number-fc-filled));
398
- }
399
-
400
- background-color: var(--_bu-bg-focus, var(--_bu-filled-bg));
401
- color: var(--_bu-fc-focus, var(--_bu-filled-fc));
402
- }
403
-
404
- &:hover {
405
- &.s-btn__filled {
406
- background-color: var(--_bu-filled-bg-hover);
407
- border-color: var(--_bu-filled-bc-hover);
408
- color: var(--_bu-filled-fc-hover);
409
- }
410
-
411
- &:not(.s-btn__outlined) {
412
- border-color: var(--_bu-bc-hover);
413
- }
414
-
415
- &:visited:not(:hover):not(:focus) {
416
- &.s-btn__filled {
417
- background-color: var(--_bu-filled-bg);
418
- border-color: var(--_bu-filled-bc);
419
- color: var(--_bu-filled-fc);
420
- }
421
-
422
- background-color: var(--_bu-bg);
423
- border-color: var(--_bu-bc);
424
- color: var(--_bu-fc);
425
- }
426
-
427
- background-color: var(--_bu-bg-hover);
428
- color: var(--_bu-fc-hover);
429
- }
430
-
431
- &:active {
432
- &.s-btn__filled {
433
- background-color: var(--_bu-filled-bg-active);
434
- border-color: var(--_bu-filled-bc-active);
435
- color: var(--_bu-filled-fc-active);
436
- }
437
-
438
- background-color: var(--_bu-bg-active);
439
- border-color: var(--_bu-bc-active);
440
- color: var(--_bu-fc-active);
441
- }
442
- }
443
-
444
- background-color: var(--_bu-bg, inherit); // [1]
445
- border: var(--_bu-baw) solid var(--_bu-bc);
446
- border-radius: var(--_bu-br);
447
- box-shadow: none;
448
- color: var(--_bu-fc);
449
- font-size: var(--_bu-fs);
450
- padding: var(--_bu-py, var(--_bu-p)) var(--_bu-px, var(--_bu-p));
451
-
452
- cursor: pointer;
453
- display: inline-block;
454
- font-family: inherit;
455
- font-weight: normal;
456
- line-height: var(--lh-sm);
457
- position: relative;
458
- outline: none;
459
- text-align: center;
460
- text-decoration: none;
461
- user-select: none;
462
- }
463
-
464
- // [1] Passing `inherit` as a custom property value has no effect, instead we
465
- // provide it as a fallback value for when --_bu-bg is not defined
466
- // For more info, see https://stackoverflow.com/a/53239881/652353
467
- // [2] Guard against the difference in configurable resets
468
- // Eric Meyer's reset does not include this, while normalize.css does
469
- // Correct the inability to style buttons in iOS and Safari.
470
- // [3] If the first thing in the button is an icon, let's hide it on loading
471
- // We only want to modify the visibility, since we still want it to have shape and keep the same layout.
472
- // [4] Most svg icons are 18px tall, but the button's line-height is 1 (13px).
473
- // This means we need to off set the margin y-axis so we don't add
1
+ .s-btn {
2
+ // BASE COMPONENT-SPECIFIC CUSTOM PROPERTIES
3
+ --_bu-baw: var(--su-static1);
4
+ --_bu-bc: transparent;
5
+ // --_bu-bg: inherit; // [1]
6
+ --_bu-br: var(--br-md);
7
+ --_bu-fc: var(--theme-button-color, var(--theme-secondary-400));
8
+ --_bu-fs: var(--fs-body1);
9
+ --_bu-p: 0.8em;
10
+
11
+ // Active
12
+ --_bu-bc-active: var(--_bu-bc);
13
+ --_bu-bg-active: var(--theme-button-active-background-color, var(--theme-secondary-300));
14
+ --_bu-fc-active: var(--theme-button-hover-color, var(--theme-secondary-500)); // Note: hover color used on purpose
15
+
16
+ // Hover
17
+ --_bu-bc-hover: var(--_bu-bc);
18
+ --_bu-bg-hover: var(--theme-button-hover-background-color, var(--theme-secondary-200));
19
+ --_bu-fc-hover: var(--theme-button-hover-color, var(--theme-secondary-500));
20
+
21
+ // BASE SELECTED MODIFIER
22
+ --_bu-bg-selected: var(--theme-button-selected-background-color, var(--theme-secondary-300));
23
+ --_bu-fc-selected: var(--theme-button-selected-color, var(--theme-secondary-600));
24
+
25
+ // FILLED VARIANT
26
+ --_bu-filled-bc: transparent;
27
+ --_bu-filled-bg: var(--theme-button-primary-background-color, var(--theme-secondary-400));
28
+ --_bu-filled-fc: var(--theme-button-primary-color, var(--white));
29
+ // Filled + Selected
30
+ --_bu-filled-bc-selected: transparent;
31
+ --_bu-filled-bg-selected: var(--theme-button-primary-selected-background-color, var(--theme-secondary-500));
32
+ --_bu-filled-fc-selected: var(--theme-button-primary-selected-color, var(--white));
33
+ // Filled + Active
34
+ --_bu-filled-bc-active: var(--_bu-filled-bc);
35
+ --_bu-filled-bg-active: var(--theme-button-primary-active-background-color, var(--theme-secondary-600));
36
+ --_bu-filled-fc-active: var(--theme-button-primary-hover-color, var(--white));
37
+ // Filled + Hover
38
+ --_bu-filled-bc-hover: var(--_bu-filled-bc);
39
+ --_bu-filled-bg-hover: var(--theme-button-primary-hover-background-color, var(--theme-secondary-500));
40
+ --_bu-filled-fc-hover: var(--theme-button-primary-hover-color, var(--white));
41
+
42
+ // OUTLINED VARIANT
43
+ --_bu-outlined-bc: var(--theme-button-outlined-border-color, var(--theme-secondary-400));
44
+ --_bu-outlined-bg: var(--theme-button-outlined-background-color);
45
+ --_bg-outlined-fc: var(--theme-button-outlined-color, var(--theme-secondary-400));
46
+ // Outlined + Selected
47
+ --_bu-outlined-bc-selected: var(--theme-button-outlined-selected-border-color, var(--theme-secondary-400));
48
+ --_bu-outlined-bg-selected: var(--theme-button-selected-background-color, var(--theme-secondary-300));
49
+ --_bu-outlined-fc-selected: var(--theme-button-selected-color, var(--theme-secondary-600));
50
+
51
+ // CHILD COMPONENT CUSTOM PROPERTIES
52
+ --_bu-badge-o: 0.5;
53
+ --_bu-dropdown-bw: var(--su-static4);
54
+ --_bu-number-fc: var(--white);
55
+ --_bu-number-fc-filled: var(--theme-button-primary-number-color, var(--theme-secondary-600));
56
+ --_bu-number-fc-selected: var(--white);
57
+
58
+ // CONTEXTUAL STYLES
59
+ .highcontrast-mode({
60
+ --_bu-bc: currentColor;
61
+ --_bu-outlined-bc: var(--_bu-bc);
62
+ --_bu-bc-selected: var(--_bu-bc);
63
+ --_bu-fc-selected: var(--white);
64
+ --_bu-outlined-fc-selected: var(--white);
65
+ --_bu-badge-o: 0.8;
66
+ --_bu-number-fc-selected: var(--theme-button-primary-number-color, var(--theme-secondary-600));
67
+ });
68
+
69
+ // STATES
70
+ fieldset[disabled] &,
71
+ &[disabled],
72
+ &[aria-disabled="true"] {
73
+ opacity: var(--_o-disabled-static);
74
+ pointer-events: none;
75
+ text-decoration: none;
76
+ }
77
+
78
+ button &,
79
+ button[type="submit"] &,
80
+ button[type="reset"] & {
81
+ -webkit-appearance: button; // [2]
82
+ }
83
+
84
+ &.grid {
85
+ display: flex; // Override &&__danger buttons having inline-block by default
86
+ }
87
+
88
+ &.is-loading {
89
+ .svg-icon:first-child {
90
+ margin-left: calc((var(--su-static24) - var(--su-static1)) * -1); // -23px
91
+ opacity: 0; // [3]
92
+ }
93
+
94
+ padding-left: 2.2em;
95
+ }
96
+
97
+ &.is-selected,
98
+ &--radio:checked + & {
99
+ background-color: var(--_bu-bg-selected);
100
+ border-color: var(--_bu-bc-selected, transparent);
101
+ color: var(--_bu-fc-selected);
102
+
103
+ .s-btn--number {
104
+ color: var(--_bu-number-fc-selected);
105
+ }
106
+
107
+ &.s-btn__filled { // this needs to live here to adapt to radio button-group
108
+ border-color: var(--_bu-filled-bc-selected);
109
+ background-color: var(--_bu-filled-bg-selected);
110
+ color: var(--_bu-filled-fc-selected);
111
+ }
112
+ &.s-btn__outlined { // this needs to live here to adapt to radio button-group
113
+ border-color: var(--_bu-outlined-bc-selected);
114
+ background-color: var(--_bu-outlined-bg-selected);
115
+ color: var(--_bu-outlined-fc-selected);
116
+
117
+ &.s-btn__muted {
118
+ .highcontrast-mode({
119
+ --_bu-outlined-bc-selected: var(--_bu-filled-bc-selected);
120
+ --_bu-outlined-bg-selected: var(--_bu-filled-bg-selected);
121
+ --_bu-outlined-fc-selected: var(--_bu-filled-fc-selected);
122
+ --_bu-number-fc-selected: var(--_bu-filled-bg-selected);
123
+ });
124
+ }
125
+ }
126
+ }
127
+
128
+ // MODIFIERS
129
+ &&__filled {
130
+ .s-btn--number {
131
+ color: var(--_bu-number-fc-filled);
132
+ }
133
+
134
+ border-color: var(--_bu-filled-bc);
135
+ background-color: var(--_bu-filled-bg);
136
+ color: var(--_bu-filled-fc);
137
+ }
138
+
139
+ &&__outlined {
140
+ border-color: var(--_bu-outlined-bc);
141
+ background-color: var(--_bu-outlined-bg, inherit);
142
+ }
143
+
144
+ // Resets
145
+ &&__link,
146
+ &&__unset {
147
+ --_bu-baw: 0;
148
+ --_bu-br: 0;
149
+ --_bu-p: 0;
150
+
151
+ &:focus,
152
+ &:focus-visible {
153
+ outline-style: auto;
154
+ }
155
+ }
156
+
157
+ &&__link {
158
+ &,
159
+ &:hover,
160
+ &:active,
161
+ &:focus,
162
+ &[disabled],
163
+ &[aria-disabled="true"] {
164
+ --_bu-bg: none;
165
+ }
166
+
167
+ &.s-btn__dropdown {
168
+ padding-right: 0.9em;
169
+ }
170
+
171
+ .s-link();
172
+ display: inline;
173
+ font: inherit;
174
+ outline: revert;
175
+ text-align: inherit;
176
+ }
177
+
178
+ &&__unset {
179
+ &,
180
+ &:hover,
181
+ &:active,
182
+ &:focus {
183
+ --_bu-bg: none;
184
+ --_bu-fc: unset;
185
+
186
+ cursor: default;
187
+ font: unset;
188
+ user-select: auto;
189
+ }
190
+
191
+ outline: initial;
192
+ }
193
+
194
+ // Pseudo-elements and child-based modifiers
195
+ &&__dropdown {
196
+ &:after {
197
+ border-color: currentColor transparent;
198
+ border-style: solid;
199
+ border-width: var(--_bu-dropdown-bw);
200
+ border-bottom-width: 0;
201
+ content: "";
202
+ pointer-events: none;
203
+ position: absolute;
204
+ right: var(--_bu-px, var(--_bu-p));
205
+ top: calc(50% - var(--su-static2));
206
+ z-index: var(--zi-active);
207
+ }
208
+
209
+ padding-right: calc(var(--_bu-px, var(--_bu-p)) * 2.5);
210
+ }
211
+
212
+ &&__icon {
213
+ .svg-icon {
214
+ vertical-align: baseline;
215
+ margin-top: -0.3em; // [4]
216
+ margin-bottom: -0.3em; // [4]
217
+ transition: opacity 200ms var(--te-smooth); // Animate the transition to .is-loading
218
+ }
219
+ }
220
+
221
+ // Size
222
+ &&__xs {
223
+ .size-styles(xs; bu; @styles: fs);
224
+ --_bu-dropdown-bw: calc(var(--su-static4) - var(--su-static1));
225
+ --_bu-p: 0.6em;
226
+ }
227
+
228
+ &&__sm {
229
+ .size-styles(sm; bu; @styles: fs);
230
+ }
231
+
232
+ &&__md {
233
+ .size-styles(md; bu; @styles: br, fs);
234
+ --_bu-p: 0.7em;
235
+ }
236
+
237
+ // VARIANTS
238
+ &&__danger,
239
+ &&__muted {
240
+ .highcontrast-mode({
241
+ --_bu-filled-bc: transparent;
242
+ });
243
+ }
244
+
245
+ &&__danger {
246
+ --_bu-bg-active: var(--red-300);
247
+ --_bu-bg-hover: var(--red-200);
248
+ --_bu-bg-selected: var(--red-300);
249
+ --_bu-fc: var(--red-500);
250
+ --_bu-fc-active: var(--_bu-fc);
251
+ --_bu-fc-hover: var(--red-500);
252
+ --_bu-fc-selected: var(--red-600);
253
+ --_bu-filled-bc: transparent;
254
+ --_bu-filled-bc-selected: var(--_bu-filled-bc);
255
+ --_bu-filled-bg: var(--red-400);
256
+ --_bu-filled-bg-active: var(--red-500);
257
+ --_bu-filled-bg-hover: var(--red-500);
258
+ --_bu-filled-bg-selected: var(--red-600);
259
+ --_bu-filled-fc: var(--white);
260
+ --_bu-filled-fc-active: var(--_bu-filled-fc);
261
+ --_bu-filled-fc-hover: var(--_bu-filled-fc);
262
+ --_bu-filled-fc-selected: var(--_bu-filled-fc);
263
+ --_bu-outlined-bc: var(--red-400);
264
+ --_bu-outlined-bc-selected: var(--red-500);
265
+ --_bu-outlined-bg-selected: var(--_bu-bg-selected);
266
+ --_bu-outlined-fc-selected: var(--_bu-fc-selected);
267
+ --_bu-number-fc: var(--white);
268
+ --_bu-number-fc-filled: var(--black);
269
+ }
270
+
271
+ &&__muted {
272
+ --_bu-bc-hover: var(--black-300);
273
+ --_bu-bg-active: var(--black-150);
274
+ --_bu-bg-hover: var(--black-100);
275
+ --_bu-bg-selected: var(--black-200);
276
+ --_bu-fc: var(--black-500);
277
+ --_bu-fc-active: var(--_bu-fc);
278
+ --_bu-fc-hover: var(--black-500);
279
+ --_bu-fc-selected: var(--black-500);
280
+ // The filled modifier on the muted button is deprecated and is to be
281
+ // removed in Stacks Classic v2
282
+ --_bu-filled-bc: transparent;
283
+ --_bu-filled-bc-selected: var(--_bu-filled-bc);
284
+ --_bu-filled-bg: var(--black-225);
285
+ --_bu-filled-bg-active: var(--black-300);
286
+ --_bu-filled-bg-hover: var(--black-250);
287
+ --_bu-filled-bg-selected: var(--black-350);
288
+ --_bu-filled-fc: var(--black-500);
289
+ --_bu-filled-fc-active: var(--_bu-filled-fc);
290
+ --_bu-filled-fc-hover: var(--_bu-filled-fc);
291
+ --_bu-filled-fc-selected: var(--black-600);
292
+ --_bu-outlined-bc: var(--black-300);
293
+ --_bu-outlined-bc-selected: var(--black-300);
294
+ --_bu-outlined-bg-selected: var(--_bu-bg-selected);
295
+ --_bu-outlined-fc-selected: var(--_bu-fc-selected);
296
+ --_bu-number-fc-filled: var(--white);
297
+ --_bu-number-fc-selected: var(--white);
298
+ --_bu-bg-focus: var(--black-400);
299
+ --_bu-fc-focus: var(--white);
300
+ --_bu-number-fc-focus: var(--black-500);
301
+
302
+ .highcontrast-mode({
303
+ --_bu-bg-hover: var(--black-225);
304
+ // // The filled modifier on the muted button is deprecated and is to be
305
+ // // removed in Stacks Classic v2
306
+ --_bu-filled-bg: var(--black-400);
307
+ --_bu-filled-bg-active: var(--black-500);
308
+ --_bu-filled-bg-hover: var(--black-400);
309
+ --_bu-filled-bg-selected: var(--black-500);
310
+ --_bu-filled-fc: var(--white);
311
+ --_bu-filled-fc-selected: var(--_bu-filled-fc);
312
+ --_bu-fc-selected: var(--black);
313
+ --_bu-number-fc: var(--white);
314
+ --_bu-number-fc-filled: var(--black);
315
+ --_bu-number-fc-selected: var(--white);
316
+ });
317
+ }
318
+
319
+ // Social
320
+ &&__facebook,
321
+ &&__github {
322
+ .highcontrast-mode({
323
+ --_bu-bc: transparent;
324
+ });
325
+ }
326
+
327
+ &&__facebook {
328
+ @_fb-brand: #385499;
329
+ --_bu-bc: transparent;
330
+ --_bu-bg: @_fb-brand;
331
+ --_bu-bg-active: darken(@_fb-brand, 10%);
332
+ --_bu-bg-hover: darken(@_fb-brand, 5%);
333
+ --_bu-fc: #fff;
334
+ --_bu-fc-active: var(--_bu-fc);
335
+ --_bu-fc-hover: var(--_bu-fc);
336
+ --_bu-hc-bc: transparent;
337
+ }
338
+
339
+ &&__google {
340
+ --_bu-bc: var(--bc-medium);
341
+ --_bu-bg: var(--white);
342
+ --_bu-bg-active: var(--black-150);
343
+ --_bu-bg-hover: var(--black-100);
344
+ --_bu-fc: var(--fc-medium);
345
+ --_bu-fc-active: var(--fc-dark);
346
+ --_bu-fc-hover: var(--black-600);
347
+ }
348
+
349
+ &&__github {
350
+ --_bu-bg: var(--black-600);
351
+ --_bu-bg-active: var(--black);
352
+ --_bu-bg-hover: var(--black-600);
353
+ --_bu-fc: var(--white);
354
+ --_bu-fc-active: var(--white);
355
+ --_bu-fc-hover: var(--white);
356
+ --_bu-hc-bc: transparent;
357
+ }
358
+
359
+ // CHILD ELEMENTS
360
+ & &--badge {
361
+ opacity: var(--_bu-badge-o);
362
+ display: inline-block;
363
+ border-radius: var(--br-sm);
364
+ padding: var(--su2) calc(var(--su4) - var(--su1));
365
+ font-size: var(--fs-caption);
366
+ line-height: var(--lh-xs);
367
+ background-color: currentColor;
368
+ }
369
+
370
+ & &--number {
371
+ color: var(--_bu-number-fc);
372
+ }
373
+
374
+ &--radio { // This lives alongside a .s-btn element. These styles are the equivelent of `.v-visible-sr`
375
+ border: 0;
376
+ clip-path: inset(50%);
377
+ clip: rect(var(--su-static1), var(--su-static1), var(--su-static1), var(--su-static1)); // rect(1px, 1px, 1px, 1px)
378
+ height: var(--su-static1);
379
+ margin: calc(var(--su-static1) * -1); // -1px
380
+ overflow-wrap: normal;
381
+ overflow: hidden;
382
+ padding: 0;
383
+ position: absolute;
384
+ width: var(--su-static1);
385
+ }
386
+
387
+ // INTERACTION
388
+ &:not(&__link):not(&__unset):focus-visible,
389
+ &--radio:focus-visible + & {
390
+ .focus-styles(true, true);
391
+ }
392
+
393
+ &:not(&--radio:checked + label):not(&__link):not(&__unset):not(&__facebook):not(&__github):not(&__google):not(.is-selected) {
394
+ &:focus-visible,
395
+ &.focus-inset-bordered {
396
+ &:not(:hover) .s-btn--number {
397
+ color: var(--_bu-number-fc-focus, var(--_bu-number-fc-filled));
398
+ }
399
+
400
+ background-color: var(--_bu-bg-focus, var(--_bu-filled-bg));
401
+ color: var(--_bu-fc-focus, var(--_bu-filled-fc));
402
+ }
403
+
404
+ &:hover {
405
+ &.s-btn__filled {
406
+ background-color: var(--_bu-filled-bg-hover);
407
+ border-color: var(--_bu-filled-bc-hover);
408
+ color: var(--_bu-filled-fc-hover);
409
+ }
410
+
411
+ &:not(.s-btn__outlined) {
412
+ border-color: var(--_bu-bc-hover);
413
+ }
414
+
415
+ &:visited:not(:active):not(:focus) {
416
+ &.s-btn__filled {
417
+ background-color: var(--_bu-filled-bg);
418
+ border-color: var(--_bu-filled-bc);
419
+ color: var(--_bu-filled-fc);
420
+ }
421
+
422
+ background-color: var(--_bu-bg);
423
+ border-color: var(--_bu-bc);
424
+ color: var(--_bu-fc);
425
+ }
426
+
427
+ background-color: var(--_bu-bg-hover);
428
+ color: var(--_bu-fc-hover);
429
+ }
430
+
431
+ &:active {
432
+ &.s-btn__filled {
433
+ background-color: var(--_bu-filled-bg-active);
434
+ border-color: var(--_bu-filled-bc-active);
435
+ color: var(--_bu-filled-fc-active);
436
+ }
437
+
438
+ background-color: var(--_bu-bg-active);
439
+ border-color: var(--_bu-bc-active);
440
+ color: var(--_bu-fc-active);
441
+ }
442
+ }
443
+
444
+ background-color: var(--_bu-bg, inherit); // [1]
445
+ border: var(--_bu-baw) solid var(--_bu-bc);
446
+ border-radius: var(--_bu-br);
447
+ box-shadow: none;
448
+ color: var(--_bu-fc);
449
+ font-size: var(--_bu-fs);
450
+ padding: var(--_bu-py, var(--_bu-p)) var(--_bu-px, var(--_bu-p));
451
+
452
+ cursor: pointer;
453
+ display: inline-block;
454
+ font-family: inherit;
455
+ font-weight: normal;
456
+ line-height: var(--lh-sm);
457
+ position: relative;
458
+ outline: none;
459
+ text-align: center;
460
+ text-decoration: none;
461
+ user-select: none;
462
+ }
463
+
464
+ // [1] Passing `inherit` as a custom property value has no effect, instead we
465
+ // provide it as a fallback value for when --_bu-bg is not defined
466
+ // For more info, see https://stackoverflow.com/a/53239881/652353
467
+ // [2] Guard against the difference in configurable resets
468
+ // Eric Meyer's reset does not include this, while normalize.css does
469
+ // Correct the inability to style buttons in iOS and Safari.
470
+ // [3] If the first thing in the button is an icon, let's hide it on loading
471
+ // We only want to modify the visibility, since we still want it to have shape and keep the same layout.
472
+ // [4] Most svg icons are 18px tall, but the button's line-height is 1 (13px).
473
+ // This means we need to off set the margin y-axis so we don't add
474
474
  // additional height to the button.