@stackoverflow/stacks 2.7.3 → 2.7.4

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 (83) hide show
  1. package/LICENSE.MD +9 -9
  2. package/README.md +158 -180
  3. package/dist/css/stacks.css +6 -0
  4. package/dist/js/stacks.min.js +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 +266 -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/avatar/avatar.less +108 -108
  24. package/lib/components/award-bling/award-bling.less +31 -31
  25. package/lib/components/banner/banner.less +44 -44
  26. package/lib/components/banner/banner.ts +149 -149
  27. package/lib/components/block-link/block-link.less +82 -82
  28. package/lib/components/breadcrumbs/breadcrumbs.less +41 -41
  29. package/lib/components/button-group/button-group.less +82 -82
  30. package/lib/components/card/card.less +37 -37
  31. package/lib/components/check-control/check-control.less +17 -17
  32. package/lib/components/check-group/check-group.less +19 -19
  33. package/lib/components/checkbox_radio/checkbox_radio.less +159 -159
  34. package/lib/components/code-block/code-block.fixtures.ts +88 -88
  35. package/lib/components/code-block/code-block.less +116 -116
  36. package/lib/components/description/description.less +9 -9
  37. package/lib/components/empty-state/empty-state.less +16 -16
  38. package/lib/components/expandable/expandable.less +118 -118
  39. package/lib/components/input-fill/input-fill.less +35 -35
  40. package/lib/components/input-icon/input-icon.less +45 -45
  41. package/lib/components/input-message/input-message.less +49 -49
  42. package/lib/components/label/label.less +110 -110
  43. package/lib/components/link-preview/link-preview.less +148 -148
  44. package/lib/components/menu/menu.less +41 -41
  45. package/lib/components/modal/modal.less +118 -118
  46. package/lib/components/modal/modal.ts +383 -383
  47. package/lib/components/navigation/navigation.less +136 -136
  48. package/lib/components/navigation/navigation.ts +128 -128
  49. package/lib/components/page-title/page-title.less +51 -51
  50. package/lib/components/popover/popover.less +159 -159
  51. package/lib/components/popover/popover.ts +651 -651
  52. package/lib/components/post-summary/post-summary.less +457 -457
  53. package/lib/components/progress-bar/progress-bar.less +291 -291
  54. package/lib/components/prose/prose.less +452 -452
  55. package/lib/components/select/select.less +138 -138
  56. package/lib/components/spinner/spinner.less +103 -103
  57. package/lib/components/table/table.ts +296 -296
  58. package/lib/components/table-container/table-container.less +4 -4
  59. package/lib/components/tag/tag.less +186 -186
  60. package/lib/components/toast/toast.less +35 -35
  61. package/lib/components/toast/toast.ts +357 -357
  62. package/lib/components/toggle-switch/toggle-switch.less +104 -104
  63. package/lib/components/topbar/topbar.less +553 -553
  64. package/lib/components/uploader/uploader.less +205 -205
  65. package/lib/components/user-card/user-card.less +129 -129
  66. package/lib/controllers.ts +33 -33
  67. package/lib/exports/color-mixins.less +283 -283
  68. package/lib/exports/constants-helpers.less +108 -108
  69. package/lib/exports/constants-type.less +155 -155
  70. package/lib/exports/exports.less +15 -15
  71. package/lib/exports/mixins.less +334 -333
  72. package/lib/exports/spacing-mixins.less +67 -67
  73. package/lib/index.ts +32 -32
  74. package/lib/input-utils.less +41 -41
  75. package/lib/stacks-dynamic.less +24 -24
  76. package/lib/stacks-static.less +93 -93
  77. package/lib/stacks.less +13 -13
  78. package/lib/test/assertions.ts +36 -36
  79. package/lib/test/less-test-utils.ts +28 -28
  80. package/lib/test/open-wc-testing-patch.d.ts +26 -26
  81. package/lib/tsconfig.build.json +4 -4
  82. package/lib/tsconfig.json +17 -17
  83. package/package.json +26 -22
@@ -1,333 +1,334 @@
1
- /* stylelint-disable indentation */
2
- //
3
- // STACK OVERFLOW
4
- // MIXINS
5
- //
6
- // This CSS comes from Stacks, our CSS & Pattern library for rapidly building
7
- // Stack Overflow. For documentation of all these classes and how to contribute,
8
- // visit https://stackoverflow.design/
9
- //
10
- // ============================================================================
11
- // $ Clearfix
12
- // -----------------------------------------------------------------------------
13
- .clearfix() {
14
- &:before,
15
- &:after {
16
- content: "";
17
- display: table;
18
- }
19
- &:after { clear: both; }
20
- }
21
-
22
- // ============================================================================
23
- // -- LIGHTMODE
24
- // .light-mode-forced ensures light color scheme is used in .theme-light__forced
25
- //
26
- // .light-mode-forced({ color: var(--black-600) });
27
- //
28
- // ---------------------------------------------------------------------------
29
-
30
- .light-mode-forced(@rules) {
31
- .theme-light__forced &,
32
- body.theme-system .theme-light__forced &,
33
- body.theme-dark .theme-light__forced & {
34
- @rules();
35
- }
36
- }
37
-
38
- // ===========================================================================
39
- // -- DARKMODE
40
- // .darkmode renders a dark mode override behind the
41
- // prefers-color-scheme: dark media query and .theme-system. It also
42
- // renders the same rules outside of the media query with .theme-dark
43
- //
44
- // Usage example:
45
- //
46
- // .dark-mode({ background-color: var(--black-100); });
47
- //
48
- // ---------------------------------------------------------------------------
49
-
50
- .dark-mode(@rules) {
51
- body.theme-system & {
52
- @media (prefers-color-scheme: dark) {
53
- @rules();
54
- }
55
- }
56
-
57
- body.theme-dark &,
58
- .theme-dark__forced &,
59
- body.theme-system .theme-dark__forced & {
60
- @rules();
61
- }
62
- }
63
-
64
- // ===========================================================================
65
- // -- HIGHCONTRAST
66
- // .highcontrast-mode renders a high contrast mode override for .theme-highcontrast
67
- //
68
- // Usage example:
69
- //
70
- // .highcontrast-mode({ background-color: var(--black-100); });
71
- //
72
- // ---------------------------------------------------------------------------
73
-
74
- .highcontrast-mode(@rules) {
75
- body.theme-highcontrast & {
76
- @rules();
77
- }
78
- }
79
-
80
- .highcontrast-dark-mode(@rules) {
81
- body.theme-highcontrast.theme-system & {
82
- @media (prefers-color-scheme: dark) {
83
- @rules();
84
- }
85
- }
86
- body.theme-highcontrast.theme-dark & {
87
- @rules();
88
- }
89
- }
90
-
91
- // ===========================================================================
92
- // -- FONT FACE
93
- // Used to load hosted, custom webfonts. You must provide the font's
94
- // full file path in the mixin. All modern browsers the WOFF file format.
95
- // Will automatically add various local()s to try using already-installed
96
- // fonts before downloading.
97
- // ---------------------------------------------------------------------------
98
- .font-face(@family, @path, @weight, @style) {
99
- @font-face {
100
- font-family: "@{family}";
101
- font-style: @style;
102
- font-weight: @weight;
103
- & when (@style=italic) {
104
- #stacks-internals #font-face-src(@family, @path, @weight, " Italic");
105
- }
106
- & when not (@style=italic) {
107
- #stacks-internals #font-face-src(@family, @path, @weight, "");
108
- }
109
- }
110
- }
111
-
112
-
113
- /**
114
- * Focus styles for the given context.
115
- *
116
- * Usage example:
117
- * .focus-styles(true, true);
118
- *
119
- * @inset: boolean - whether the focus style be placed inside the element.
120
- * @border: boolean - whether the element's border color change to match the focus style.
121
- */
122
- .focus-styles(@inset: false, @border: false) {
123
- & when not (@inset) and not (@border) {
124
- box-shadow: 0 0 0 var(--su-static2) var(--focus-neutral), 0 0 0 var(--su-static4) var(--focus-theme);
125
- }
126
-
127
- & when not (@inset) and (@border) {
128
- border-color: var(--focus-neutral) !important;
129
- box-shadow: 0 0 0 var(--su-static1) var(--focus-neutral), 0 0 0 calc(var(--su-static4) - var(--su-static1)) var(--focus-theme);
130
- }
131
-
132
- & when (@inset) and not (@border) {
133
- box-shadow: inset 0 0 0 var(--su-static2) var(--focus-theme), inset 0 0 0 var(--su-static4) var(--focus-neutral);
134
- }
135
-
136
- & when (@inset) and (@border) {
137
- border-color: var(--focus-theme) !important;
138
- box-shadow: inset 0 0 0 var(--su-static1) var(--focus-theme), inset 0 0 0 calc(var(--su-static4) - var(--su-static1)) var(--focus-neutral);
139
- }
140
-
141
- // We include a 2px transparent outline to ensure Windows High Contrast Forced Color Mode
142
- // includes outlines as expected See https://blogs.windows.com/msedgedev/2020/09/17/styling-for-windows-high-contrast-with-new-standards-for-forced-colors/
143
- outline: var(--su-static2) solid transparent !important;
144
- }
145
-
146
- // =============================================================================
147
- // -- COLORS
148
- // The following mixins let us do color math on the browser. They take a
149
- // color prefix, and they expect the different values to be stored in
150
- // --{prefix}-h, --{prefix}-s and --{prefix}-l
151
- // -----------------------------------------------------------------------------
152
-
153
- .load-color-variables(@amount) {
154
- @amountDecimal: (@amount / 100);
155
- @amountPercentage: @amount * 1%;
156
- @complementDecimal: 1 - @amountDecimal;
157
- @additionDecimal: 1 + @amountDecimal;
158
- }
159
-
160
- .assemble-color(@color-prefix) {
161
- @result: hsl(var(~"--@{color-prefix}-h"),
162
- var(~"--@{color-prefix}-s"),
163
- var(~"--@{color-prefix}-l"));
164
- }
165
-
166
- // Increase the lightness of a color in the HSL color space by an absolute amount.
167
- .native-lighten(@color-prefix, @amount) {
168
- .load-color-variables(@amount);
169
- @result: hsl(var(~"--@{color-prefix}-h"),
170
- var(~"--@{color-prefix}-s"),
171
- calc(var(~"--@{color-prefix}-l") + @amountPercentage));
172
- }
173
-
174
- // Decrease the lightness and saturation of a color in the HSL color space by absolute amounts.
175
- .native-darken-desaturate(@color-prefix, @darken-amount, @desaturate-amount) {
176
- @darkenAmountPercentage: .load-color-variables(@darken-amount)[@amountPercentage];
177
- @desaturateAmountPercentage: .load-color-variables(@desaturate-amount)[@amountPercentage];
178
- @result: hsl(var(~"--@{color-prefix}-h"),
179
- calc(var(~"--@{color-prefix}-s") - @desaturateAmountPercentage),
180
- calc(var(~"--@{color-prefix}-l") - @darkenAmountPercentage));
181
- }
182
-
183
-
184
- // Decrease the lightness of a color in the HSL color space by an absolute amount.
185
- .native-darken(@color-prefix, @amount) {
186
- .load-color-variables(@amount);
187
- @result: hsl(var(~"--@{color-prefix}-h"),
188
- var(~"--@{color-prefix}-s"),
189
- calc(var(~"--@{color-prefix}-l") - @amountPercentage));
190
- }
191
-
192
- // Mix color with white in variable proportion
193
- .native-tint(@color-prefix, @amount) {
194
- .load-color-variables(@amount);
195
- @ramount: 255 * @amountDecimal;
196
- @gamount: 255 * @amountDecimal;
197
- @bamount: 255 * @amountDecimal;
198
- @result: rgb(calc(@ramount + var(~"--@{color-prefix}-r") * @complementDecimal),
199
- calc(@gamount + var(~"--@{color-prefix}-g") * @complementDecimal),
200
- calc(@bamount + var(~"--@{color-prefix}-b") * @complementDecimal));
201
- }
202
-
203
- // Mix color with black in variable proportion
204
- .native-shade(@color-prefix, @amount) {
205
- .load-color-variables(@amount);
206
- @result: rgb(calc(var(~"--@{color-prefix}-r") * @complementDecimal),
207
- calc(var(~"--@{color-prefix}-g") * @complementDecimal),
208
- calc(var(~"--@{color-prefix}-b") * @complementDecimal));
209
- }
210
-
211
- // Set the absolute opacity of a color.
212
- .native-fade(@color-prefix, @amount) {
213
- .load-color-variables(@amount);
214
- @result: hsla(var(~"--@{color-prefix}-h"),
215
- var(~"--@{color-prefix}-s"),
216
- var(~"--@{color-prefix}-l"),
217
- @amountDecimal);
218
- }
219
-
220
- // =============================================================================
221
- // -- SIZE STYLES
222
- // The following mixins let us generate pseudo-private custom properties
223
- // for common sizes. They expect a size (@size), a prefix for the custom
224
- // property (@prefix), and an array of comma-separates abbreviated styles
225
- // (@styles).
226
- // -----------------------------------------------------------------------------
227
-
228
- .size-styles(@size, @prefix, @styles, @index: length(@styles)) {
229
- & when (@index > 0) {
230
- @style: extract(@styles, @index);
231
-
232
- // xs
233
- & when (@size = xs) and (@style = fs) {
234
- --_@{prefix}-fs: var(--fs-fine);
235
- }
236
-
237
- // sm
238
- & when (@size = sm) and (@style = fs) {
239
- --_@{prefix}-fs: var(--fs-caption);
240
- }
241
-
242
- // md
243
- & when (@size = md) and (@style = br) {
244
- --_@{prefix}-br: calc(var(--br-sm) + var(--su-static1));
245
- }
246
- & when (@size = md) and (@style = fs) {
247
- --_@{prefix}-fs: var(--fs-body3);
248
- }
249
-
250
- // lg
251
- & when (@size = lg) and (@style = br) {
252
- --_@{prefix}-br: calc(var(--br-sm) + var(--su-static1));
253
- }
254
- & when (@size = lg) and (@style = fs) {
255
- --_@{prefix}-fs: var(--fs-title);
256
- }
257
-
258
- // xl
259
- & when (@size = xl) and (@style = br) {
260
- --_@{prefix}-br: var(--br-md);
261
- }
262
- & when (@size = xl) and (@style = fs) {
263
- --_@{prefix}-fs: var(--fs-headline1);
264
- }
265
-
266
- .size-styles(@size, @prefix, @styles, @index: @index - 1);
267
- }
268
- }
269
-
270
- // =============================================================================
271
- // -- WEBKIT AUTOFILL
272
- // -----------------------------------------------------------------------------
273
- .webkit-autofill() {
274
- &:-webkit-autofill {
275
- &:focus {
276
- border-color: var(--blue-400);
277
- // Since the box shadow is overwritten to show a background, we have to re-add the focus outline
278
- -webkit-box-shadow: 0 0 0 1000px var(--blue-200) inset, 0 0 0 var(--su-static4) var(--focus-ring);
279
- }
280
-
281
- -webkit-box-shadow: 0 0 0 1000px var(--theme-secondary-200) inset; // This acts as a background color by stretching an inset box shadow across the input
282
- -webkit-text-fill-color: var(--black);
283
- border-color: var(--blue-400);
284
- transition: background-color 0s 50000s; // A hack to infinitely delay background styles that come from the browser.
285
- }
286
-
287
- &::-webkit-contacts-auto-fill-button {
288
- background-color: var(--black); // In Safari, make the autocomplete button darkmode-aware
289
- }
290
-
291
- }
292
-
293
- // ===========================================================================
294
- // Internals only beyond this point -- helpers for .font-face()
295
- // ---------------------------------------------------------------------------
296
-
297
-
298
- #stacks-internals() {
299
-
300
- // Generate all common variants for local names that this font face may have.
301
- // The CSS spec (Font Module Level 3, Section 4.3) says to use "only the Postscript
302
- // name or the full font name".
303
- // For example, given the family "Comic Sans MS", weight 800, italic, we're
304
- // trying these local names:
305
- //
306
- // - Comic Sans MS Extra Bold Italic
307
- // - ComicSansMS-ExtraBoldItalic
308
- // - Comic Sans MS 800 Italic
309
- // - ComicSansMS-800Italic
310
- //
311
- // For the weight 400 we also include the un-weight-postfixed name ("Comic Sans MS Italic").
312
-
313
- #font-face-src(@family, @path, @weight, @style-postfix) {
314
- @index: round(@weight/100);
315
- @weight-names: "Thin", "Extra Light", "Light", "Regular", "Medium", "Semi Bold", "Bold", "Extra Bold", "Black";
316
- @weight-name: extract(@weight-names, @index);
317
- #stacks-internals #font-face-src-postfix(@family, @path, "@{weight-name}", @weight, @style-postfix);
318
- }
319
-
320
- #font-face-src-postfix(@family, @path, @postfix-name, @postfix-number, @style-postfix) {
321
- @family-nospace: replace(@family, " ", "");
322
- @postfix-name-nospace: replace("@{postfix-name}@{style-postfix}", " ", "");
323
- @postfix-number-nospace: replace("@{postfix-number}@{style-postfix}", " ", "");
324
-
325
- & when (@postfix-name="Regular") {
326
- src: local("@{family} @{postfix-name}@{style-postfix}"), local("@{family-nospace}-@{postfix-name-nospace}"), local("@{family} @{postfix-number}@{style-postfix}"), local("@{family-nospace}-@{postfix-number-nospace}"), local("@{family}@{style-postfix}"), @path format("woff");
327
- }
328
-
329
- & when not (@postfix-name="Regular") {
330
- src: local("@{family} @{postfix-name}@{style-postfix}"), local("@{family-nospace}-@{postfix-name-nospace}"), local("@{family} @{postfix-number}@{style-postfix}"), local("@{family-nospace}-@{postfix-number-nospace}"), @path format("woff");
331
- }
332
- }
333
- }
1
+ /* stylelint-disable indentation */
2
+ //
3
+ // STACK OVERFLOW
4
+ // MIXINS
5
+ //
6
+ // This CSS comes from Stacks, our CSS & Pattern library for rapidly building
7
+ // Stack Overflow. For documentation of all these classes and how to contribute,
8
+ // visit https://stackoverflow.design/
9
+ //
10
+ // ============================================================================
11
+ // $ Clearfix
12
+ // -----------------------------------------------------------------------------
13
+ .clearfix() {
14
+ &:before,
15
+ &:after {
16
+ content: "";
17
+ display: table;
18
+ }
19
+ &:after { clear: both; }
20
+ }
21
+
22
+ // ============================================================================
23
+ // -- LIGHTMODE
24
+ // .light-mode-forced ensures light color scheme is used in .theme-light__forced
25
+ //
26
+ // .light-mode-forced({ color: var(--black-600) });
27
+ //
28
+ // ---------------------------------------------------------------------------
29
+
30
+ .light-mode-forced(@rules) {
31
+ .theme-light__forced &,
32
+ body.theme-system .theme-light__forced &,
33
+ body.theme-dark .theme-light__forced & {
34
+ @rules();
35
+ }
36
+ }
37
+
38
+ // ===========================================================================
39
+ // -- DARKMODE
40
+ // .darkmode renders a dark mode override behind the
41
+ // prefers-color-scheme: dark media query and .theme-system. It also
42
+ // renders the same rules outside of the media query with .theme-dark
43
+ //
44
+ // Usage example:
45
+ //
46
+ // .dark-mode({ background-color: var(--black-100); });
47
+ //
48
+ // ---------------------------------------------------------------------------
49
+
50
+ .dark-mode(@rules) {
51
+ body.theme-system & {
52
+ @media (prefers-color-scheme: dark) {
53
+ @rules();
54
+ }
55
+ }
56
+
57
+ body.theme-dark &,
58
+ .theme-dark__forced &,
59
+ body.theme-system .theme-dark__forced & {
60
+ @rules();
61
+ }
62
+ }
63
+
64
+ // ===========================================================================
65
+ // -- HIGHCONTRAST
66
+ // .highcontrast-mode renders a high contrast mode override for .theme-highcontrast
67
+ //
68
+ // Usage example:
69
+ //
70
+ // .highcontrast-mode({ background-color: var(--black-100); });
71
+ //
72
+ // ---------------------------------------------------------------------------
73
+
74
+ .highcontrast-mode(@rules) {
75
+ body.theme-highcontrast & {
76
+ @rules();
77
+ }
78
+ }
79
+
80
+ .highcontrast-dark-mode(@rules) {
81
+ body.theme-highcontrast.theme-system & {
82
+ @media (prefers-color-scheme: dark) {
83
+ @rules();
84
+ }
85
+ }
86
+ body.theme-highcontrast.theme-dark & {
87
+ @rules();
88
+ }
89
+ }
90
+
91
+ // ===========================================================================
92
+ // -- FONT FACE
93
+ // Used to load hosted, custom webfonts. You must provide the font's
94
+ // full file path in the mixin. All modern browsers the WOFF file format.
95
+ // Will automatically add various local()s to try using already-installed
96
+ // fonts before downloading.
97
+ // ---------------------------------------------------------------------------
98
+ /* stylelint-disable at-rule-descriptor-value-no-unknown */
99
+ .font-face(@family, @path, @weight, @style) {
100
+ @font-face {
101
+ font-family: "@{family}";
102
+ font-style: @style;
103
+ font-weight: @weight;
104
+ & when (@style=italic) {
105
+ #stacks-internals #font-face-src(@family, @path, @weight, " Italic");
106
+ }
107
+ & when not (@style=italic) {
108
+ #stacks-internals #font-face-src(@family, @path, @weight, "");
109
+ }
110
+ }
111
+ }
112
+ /* stylelint-enable at-rule-descriptor-value-no-unknown */
113
+
114
+ /**
115
+ * Focus styles for the given context.
116
+ *
117
+ * Usage example:
118
+ * .focus-styles(true, true);
119
+ *
120
+ * @inset: boolean - whether the focus style be placed inside the element.
121
+ * @border: boolean - whether the element's border color change to match the focus style.
122
+ */
123
+ .focus-styles(@inset: false, @border: false) {
124
+ & when not (@inset) and not (@border) {
125
+ box-shadow: 0 0 0 var(--su-static2) var(--focus-neutral), 0 0 0 var(--su-static4) var(--focus-theme);
126
+ }
127
+
128
+ & when not (@inset) and (@border) {
129
+ border-color: var(--focus-neutral) !important;
130
+ box-shadow: 0 0 0 var(--su-static1) var(--focus-neutral), 0 0 0 calc(var(--su-static4) - var(--su-static1)) var(--focus-theme);
131
+ }
132
+
133
+ & when (@inset) and not (@border) {
134
+ box-shadow: inset 0 0 0 var(--su-static2) var(--focus-theme), inset 0 0 0 var(--su-static4) var(--focus-neutral);
135
+ }
136
+
137
+ & when (@inset) and (@border) {
138
+ border-color: var(--focus-theme) !important;
139
+ box-shadow: inset 0 0 0 var(--su-static1) var(--focus-theme), inset 0 0 0 calc(var(--su-static4) - var(--su-static1)) var(--focus-neutral);
140
+ }
141
+
142
+ // We include a 2px transparent outline to ensure Windows High Contrast Forced Color Mode
143
+ // includes outlines as expected See https://blogs.windows.com/msedgedev/2020/09/17/styling-for-windows-high-contrast-with-new-standards-for-forced-colors/
144
+ outline: var(--su-static2) solid transparent !important;
145
+ }
146
+
147
+ // =============================================================================
148
+ // -- COLORS
149
+ // The following mixins let us do color math on the browser. They take a
150
+ // color prefix, and they expect the different values to be stored in
151
+ // --{prefix}-h, --{prefix}-s and --{prefix}-l
152
+ // -----------------------------------------------------------------------------
153
+
154
+ .load-color-variables(@amount) {
155
+ @amountDecimal: (@amount / 100);
156
+ @amountPercentage: @amount * 1%;
157
+ @complementDecimal: 1 - @amountDecimal;
158
+ @additionDecimal: 1 + @amountDecimal;
159
+ }
160
+
161
+ .assemble-color(@color-prefix) {
162
+ @result: hsl(var(~"--@{color-prefix}-h"),
163
+ var(~"--@{color-prefix}-s"),
164
+ var(~"--@{color-prefix}-l"));
165
+ }
166
+
167
+ // Increase the lightness of a color in the HSL color space by an absolute amount.
168
+ .native-lighten(@color-prefix, @amount) {
169
+ .load-color-variables(@amount);
170
+ @result: hsl(var(~"--@{color-prefix}-h"),
171
+ var(~"--@{color-prefix}-s"),
172
+ calc(var(~"--@{color-prefix}-l") + @amountPercentage));
173
+ }
174
+
175
+ // Decrease the lightness and saturation of a color in the HSL color space by absolute amounts.
176
+ .native-darken-desaturate(@color-prefix, @darken-amount, @desaturate-amount) {
177
+ @darkenAmountPercentage: .load-color-variables(@darken-amount)[@amountPercentage];
178
+ @desaturateAmountPercentage: .load-color-variables(@desaturate-amount)[@amountPercentage];
179
+ @result: hsl(var(~"--@{color-prefix}-h"),
180
+ calc(var(~"--@{color-prefix}-s") - @desaturateAmountPercentage),
181
+ calc(var(~"--@{color-prefix}-l") - @darkenAmountPercentage));
182
+ }
183
+
184
+
185
+ // Decrease the lightness of a color in the HSL color space by an absolute amount.
186
+ .native-darken(@color-prefix, @amount) {
187
+ .load-color-variables(@amount);
188
+ @result: hsl(var(~"--@{color-prefix}-h"),
189
+ var(~"--@{color-prefix}-s"),
190
+ calc(var(~"--@{color-prefix}-l") - @amountPercentage));
191
+ }
192
+
193
+ // Mix color with white in variable proportion
194
+ .native-tint(@color-prefix, @amount) {
195
+ .load-color-variables(@amount);
196
+ @ramount: 255 * @amountDecimal;
197
+ @gamount: 255 * @amountDecimal;
198
+ @bamount: 255 * @amountDecimal;
199
+ @result: rgb(calc(@ramount + var(~"--@{color-prefix}-r") * @complementDecimal),
200
+ calc(@gamount + var(~"--@{color-prefix}-g") * @complementDecimal),
201
+ calc(@bamount + var(~"--@{color-prefix}-b") * @complementDecimal));
202
+ }
203
+
204
+ // Mix color with black in variable proportion
205
+ .native-shade(@color-prefix, @amount) {
206
+ .load-color-variables(@amount);
207
+ @result: rgb(calc(var(~"--@{color-prefix}-r") * @complementDecimal),
208
+ calc(var(~"--@{color-prefix}-g") * @complementDecimal),
209
+ calc(var(~"--@{color-prefix}-b") * @complementDecimal));
210
+ }
211
+
212
+ // Set the absolute opacity of a color.
213
+ .native-fade(@color-prefix, @amount) {
214
+ .load-color-variables(@amount);
215
+ @result: hsla(var(~"--@{color-prefix}-h"),
216
+ var(~"--@{color-prefix}-s"),
217
+ var(~"--@{color-prefix}-l"),
218
+ @amountDecimal);
219
+ }
220
+
221
+ // =============================================================================
222
+ // -- SIZE STYLES
223
+ // The following mixins let us generate pseudo-private custom properties
224
+ // for common sizes. They expect a size (@size), a prefix for the custom
225
+ // property (@prefix), and an array of comma-separates abbreviated styles
226
+ // (@styles).
227
+ // -----------------------------------------------------------------------------
228
+
229
+ .size-styles(@size, @prefix, @styles, @index: length(@styles)) {
230
+ & when (@index > 0) {
231
+ @style: extract(@styles, @index);
232
+
233
+ // xs
234
+ & when (@size = xs) and (@style = fs) {
235
+ --_@{prefix}-fs: var(--fs-fine);
236
+ }
237
+
238
+ // sm
239
+ & when (@size = sm) and (@style = fs) {
240
+ --_@{prefix}-fs: var(--fs-caption);
241
+ }
242
+
243
+ // md
244
+ & when (@size = md) and (@style = br) {
245
+ --_@{prefix}-br: calc(var(--br-sm) + var(--su-static1));
246
+ }
247
+ & when (@size = md) and (@style = fs) {
248
+ --_@{prefix}-fs: var(--fs-body3);
249
+ }
250
+
251
+ // lg
252
+ & when (@size = lg) and (@style = br) {
253
+ --_@{prefix}-br: calc(var(--br-sm) + var(--su-static1));
254
+ }
255
+ & when (@size = lg) and (@style = fs) {
256
+ --_@{prefix}-fs: var(--fs-title);
257
+ }
258
+
259
+ // xl
260
+ & when (@size = xl) and (@style = br) {
261
+ --_@{prefix}-br: var(--br-md);
262
+ }
263
+ & when (@size = xl) and (@style = fs) {
264
+ --_@{prefix}-fs: var(--fs-headline1);
265
+ }
266
+
267
+ .size-styles(@size, @prefix, @styles, @index: @index - 1);
268
+ }
269
+ }
270
+
271
+ // =============================================================================
272
+ // -- WEBKIT AUTOFILL
273
+ // -----------------------------------------------------------------------------
274
+ .webkit-autofill() {
275
+ &:-webkit-autofill {
276
+ &:focus {
277
+ border-color: var(--blue-400);
278
+ // Since the box shadow is overwritten to show a background, we have to re-add the focus outline
279
+ -webkit-box-shadow: 0 0 0 1000px var(--blue-200) inset, 0 0 0 var(--su-static4) var(--focus-ring);
280
+ }
281
+
282
+ -webkit-box-shadow: 0 0 0 1000px var(--theme-secondary-200) inset; // This acts as a background color by stretching an inset box shadow across the input
283
+ -webkit-text-fill-color: var(--black);
284
+ border-color: var(--blue-400);
285
+ transition: background-color 0s 50000s; // A hack to infinitely delay background styles that come from the browser.
286
+ }
287
+
288
+ &::-webkit-contacts-auto-fill-button {
289
+ background-color: var(--black); // In Safari, make the autocomplete button darkmode-aware
290
+ }
291
+
292
+ }
293
+
294
+ // ===========================================================================
295
+ // Internals only beyond this point -- helpers for .font-face()
296
+ // ---------------------------------------------------------------------------
297
+
298
+
299
+ #stacks-internals() {
300
+
301
+ // Generate all common variants for local names that this font face may have.
302
+ // The CSS spec (Font Module Level 3, Section 4.3) says to use "only the Postscript
303
+ // name or the full font name".
304
+ // For example, given the family "Comic Sans MS", weight 800, italic, we're
305
+ // trying these local names:
306
+ //
307
+ // - Comic Sans MS Extra Bold Italic
308
+ // - ComicSansMS-ExtraBoldItalic
309
+ // - Comic Sans MS 800 Italic
310
+ // - ComicSansMS-800Italic
311
+ //
312
+ // For the weight 400 we also include the un-weight-postfixed name ("Comic Sans MS Italic").
313
+
314
+ #font-face-src(@family, @path, @weight, @style-postfix) {
315
+ @index: round(@weight/100);
316
+ @weight-names: "Thin", "Extra Light", "Light", "Regular", "Medium", "Semi Bold", "Bold", "Extra Bold", "Black";
317
+ @weight-name: extract(@weight-names, @index);
318
+ #stacks-internals #font-face-src-postfix(@family, @path, "@{weight-name}", @weight, @style-postfix);
319
+ }
320
+
321
+ #font-face-src-postfix(@family, @path, @postfix-name, @postfix-number, @style-postfix) {
322
+ @family-nospace: replace(@family, " ", "");
323
+ @postfix-name-nospace: replace("@{postfix-name}@{style-postfix}", " ", "");
324
+ @postfix-number-nospace: replace("@{postfix-number}@{style-postfix}", " ", "");
325
+
326
+ & when (@postfix-name="Regular") {
327
+ src: local("@{family} @{postfix-name}@{style-postfix}"), local("@{family-nospace}-@{postfix-name-nospace}"), local("@{family} @{postfix-number}@{style-postfix}"), local("@{family-nospace}-@{postfix-number-nospace}"), local("@{family}@{style-postfix}"), @path format("woff");
328
+ }
329
+
330
+ & when not (@postfix-name="Regular") {
331
+ src: local("@{family} @{postfix-name}@{style-postfix}"), local("@{family-nospace}-@{postfix-name-nospace}"), local("@{family} @{postfix-number}@{style-postfix}"), local("@{family-nospace}-@{postfix-number-nospace}"), @path format("woff");
332
+ }
333
+ }
334
+ }