@stackoverflow/stacks 2.7.2 → 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 (85) hide show
  1. package/LICENSE.MD +9 -9
  2. package/README.md +158 -180
  3. package/dist/css/stacks.css +18 -4
  4. package/dist/css/stacks.min.css +1 -1
  5. package/dist/js/stacks.min.js +1 -1
  6. package/lib/atomic/border.less +139 -139
  7. package/lib/atomic/color.less +36 -36
  8. package/lib/atomic/flex.less +426 -426
  9. package/lib/atomic/gap.less +44 -44
  10. package/lib/atomic/grid.less +139 -139
  11. package/lib/atomic/misc.less +374 -374
  12. package/lib/atomic/spacing.less +98 -98
  13. package/lib/atomic/typography.less +266 -264
  14. package/lib/atomic/width-height.less +194 -194
  15. package/lib/base/body.less +44 -44
  16. package/lib/base/configuration-static.less +61 -61
  17. package/lib/base/fieldset.less +5 -5
  18. package/lib/base/icon.less +11 -11
  19. package/lib/base/internal.less +220 -220
  20. package/lib/base/reset-meyer.less +64 -64
  21. package/lib/base/reset-normalize.less +449 -449
  22. package/lib/base/reset.less +20 -20
  23. package/lib/components/activity-indicator/activity-indicator.less +53 -53
  24. package/lib/components/avatar/avatar.less +108 -108
  25. package/lib/components/award-bling/award-bling.less +31 -31
  26. package/lib/components/banner/banner.less +44 -44
  27. package/lib/components/banner/banner.ts +149 -149
  28. package/lib/components/block-link/block-link.less +82 -82
  29. package/lib/components/breadcrumbs/breadcrumbs.less +41 -41
  30. package/lib/components/button-group/button-group.less +82 -82
  31. package/lib/components/card/card.less +37 -37
  32. package/lib/components/check-control/check-control.less +17 -17
  33. package/lib/components/check-group/check-group.less +19 -19
  34. package/lib/components/checkbox_radio/checkbox_radio.less +159 -159
  35. package/lib/components/code-block/code-block.fixtures.ts +88 -88
  36. package/lib/components/code-block/code-block.less +116 -116
  37. package/lib/components/description/description.less +9 -9
  38. package/lib/components/empty-state/empty-state.less +16 -16
  39. package/lib/components/expandable/expandable.less +118 -118
  40. package/lib/components/input-fill/input-fill.less +35 -35
  41. package/lib/components/input-icon/input-icon.less +45 -45
  42. package/lib/components/input-message/input-message.less +49 -49
  43. package/lib/components/label/label.less +110 -110
  44. package/lib/components/link/link.less +7 -1
  45. package/lib/components/link-preview/link-preview.less +148 -148
  46. package/lib/components/menu/menu.less +41 -41
  47. package/lib/components/modal/modal.less +118 -118
  48. package/lib/components/modal/modal.ts +383 -383
  49. package/lib/components/navigation/navigation.less +136 -136
  50. package/lib/components/navigation/navigation.ts +128 -128
  51. package/lib/components/page-title/page-title.less +51 -51
  52. package/lib/components/popover/popover.less +159 -159
  53. package/lib/components/popover/popover.ts +651 -651
  54. package/lib/components/post-summary/post-summary.less +457 -457
  55. package/lib/components/progress-bar/progress-bar.less +291 -291
  56. package/lib/components/prose/prose.less +452 -452
  57. package/lib/components/select/select.less +138 -138
  58. package/lib/components/spinner/spinner.less +103 -103
  59. package/lib/components/table/table.ts +296 -296
  60. package/lib/components/table-container/table-container.less +4 -4
  61. package/lib/components/tag/tag.less +186 -186
  62. package/lib/components/toast/toast.less +35 -35
  63. package/lib/components/toast/toast.ts +357 -357
  64. package/lib/components/toggle-switch/toggle-switch.less +104 -104
  65. package/lib/components/topbar/topbar.less +553 -553
  66. package/lib/components/uploader/uploader.less +205 -205
  67. package/lib/components/user-card/user-card.less +129 -129
  68. package/lib/controllers.ts +33 -33
  69. package/lib/exports/color-mixins.less +283 -283
  70. package/lib/exports/constants-helpers.less +108 -108
  71. package/lib/exports/constants-type.less +155 -155
  72. package/lib/exports/exports.less +15 -15
  73. package/lib/exports/mixins.less +334 -333
  74. package/lib/exports/spacing-mixins.less +67 -67
  75. package/lib/index.ts +32 -32
  76. package/lib/input-utils.less +41 -41
  77. package/lib/stacks-dynamic.less +24 -24
  78. package/lib/stacks-static.less +93 -93
  79. package/lib/stacks.less +13 -13
  80. package/lib/test/assertions.ts +36 -36
  81. package/lib/test/less-test-utils.ts +28 -28
  82. package/lib/test/open-wc-testing-patch.d.ts +26 -26
  83. package/lib/tsconfig.build.json +4 -4
  84. package/lib/tsconfig.json +17 -17
  85. package/package.json +26 -22
@@ -1,33 +1,33 @@
1
- // export all controllers *with helpers* so they can be bulk re-exported by the package entry point
2
- export {
3
- BannerController,
4
- hideBanner,
5
- showBanner,
6
- } from "./components/banner/banner";
7
- export { ExpandableController } from "./components/expandable/expandable";
8
- export {
9
- ModalController,
10
- hideModal,
11
- showModal,
12
- } from "./components/modal/modal";
13
- export { TabListController } from "./components/navigation/navigation";
14
- export {
15
- attachPopover,
16
- detachPopover,
17
- hidePopover,
18
- BasePopoverController,
19
- PopoverController,
20
- showPopover,
21
- } from "./components/popover/popover";
22
- export { TableController } from "./components/table/table";
23
- export {
24
- ToastController,
25
- hideToast,
26
- showToast,
27
- } from "./components/toast/toast";
28
- export {
29
- setTooltipHtml,
30
- setTooltipText,
31
- TooltipController,
32
- } from "./components/popover/tooltip";
33
- export { UploaderController } from "./components/uploader/uploader";
1
+ // export all controllers *with helpers* so they can be bulk re-exported by the package entry point
2
+ export {
3
+ BannerController,
4
+ hideBanner,
5
+ showBanner,
6
+ } from "./components/banner/banner";
7
+ export { ExpandableController } from "./components/expandable/expandable";
8
+ export {
9
+ ModalController,
10
+ hideModal,
11
+ showModal,
12
+ } from "./components/modal/modal";
13
+ export { TabListController } from "./components/navigation/navigation";
14
+ export {
15
+ attachPopover,
16
+ detachPopover,
17
+ hidePopover,
18
+ BasePopoverController,
19
+ PopoverController,
20
+ showPopover,
21
+ } from "./components/popover/popover";
22
+ export { TableController } from "./components/table/table";
23
+ export {
24
+ ToastController,
25
+ hideToast,
26
+ showToast,
27
+ } from "./components/toast/toast";
28
+ export {
29
+ setTooltipHtml,
30
+ setTooltipText,
31
+ TooltipController,
32
+ } from "./components/popover/tooltip";
33
+ export { UploaderController } from "./components/uploader/uploader";
@@ -1,283 +1,283 @@
1
- @import (reference) "./mixins.less";
2
- @import (reference) "./color-sets.less";
3
-
4
- // Type definitions
5
- //
6
- // @mode: light | dark | light-highcontrast | dark-highcontrast;
7
- // @modeCustom: base | dark; // legacy we're supporting for theming in Core
8
- // @modeSimple: light | dark; // TODO consider different name?
9
- // @property: all | background-color | border-color | color;
10
- // @set: { [key: stop]: color }[];
11
- // @sets: set[] | { [key: string]: set }[];
12
- // @stop: default | 050 | 100 | 150 | 200 | 225 | 300 | 350 | 400 | 500 | 600;
13
- // @tier: primary | secondary;
14
- // @type: classes | variables;
15
-
16
- /**
17
- * Primary function to generate colors variables for a given mode.
18
- *
19
- * Usage example:
20
- * .generate-colors(dark);
21
- *
22
- * @mode - Determines what to generate and which mode set to use.
23
- */
24
- //
25
- .generate-colors(@mode: light) {
26
- @set: .sets-mode()[$@mode];
27
- @setUtility: .sets-utility-mode()[$@mode];
28
- @modeCustom: if(@mode = dark, dark, base);
29
-
30
- & when (@mode = light), (@mode = dark) {
31
- &,
32
- &.themed,
33
- & .themed {
34
- .create-colors(@set);
35
- .create-colors(@setUtility);
36
- .create-theme-variables(@mode);
37
- .create-custom-theme-variables(primary, @modeCustom);
38
- .create-custom-theme-variables(secondary, @modeCustom);
39
- color: var(--theme-body-font-color, var(--black-600));
40
- }
41
- }
42
-
43
- & when (@mode = light-highcontrast), (@mode = dark-highcontrast) {
44
- .create-colors(@set);
45
- .create-colors(@setUtility);
46
- .create-theme-variables(@mode);
47
- --_o-disabled: 0.8;
48
- }
49
- }
50
-
51
- /**
52
- * Creates color variables or atomic classes based on the given sets of colors.
53
- *
54
- * Usage example:
55
- * .create-colors(.sets-mode()[dark], classes);
56
- *
57
- * @sets - (required) A collection of name/set pairs.
58
- * @type - The type of output.
59
- * @modeSimple - The mode to use for generating classes.
60
- * @property - The property to use for generating classes.
61
- */
62
- .create-colors(@sets, @type: variables, @modeSimple: light, @property: all) {
63
- each(@sets, .(@set, @setName, @iSet) {
64
- each(@set, .(@value, @stop, @iColorValue) {
65
- @suffix: if((@stop = default), "", ~"-@{stop}");
66
- @name: ~"@{setName}@{suffix}";
67
- @variable: ~"--@{name}";
68
-
69
- // Create custom property assignment
70
- & when (@type = variables) {
71
- @{variable}: @value;
72
- }
73
-
74
- // Create bg atomic class assignments
75
- & when (@type = classes) {
76
- @customValue: ~"var(@{variable}) !important";
77
- .create-color-classes(@name, @customValue, @modeSimple, @property);
78
- }
79
- });
80
- });
81
- }
82
-
83
- /**
84
- * Creates atomic color classes for background and text color with the given color name and property value.
85
- *
86
- * Usage example:
87
- * .create-color-classes(red-500, var(--red-500));
88
- *
89
- * @name - (required) Used as a suffix to each class.
90
- * @value - (required) The value assigned to the generated class' property.
91
- * @modeSimple - Generate either all standard or dark conditional classes.
92
- * @property - Determines which type(s) of atomic class to generate.
93
- */
94
- .create-color-classes(@name, @value, @modeSimple: light, @property: all) {
95
- & when (@modeSimple = light) {
96
- // Create bg atomic class assignments
97
- & when (@property = all), (@property = background-color) {
98
- .bg-@{name},
99
- .h\:bg-@{name}:hover,
100
- .f\:bg-@{name}:focus,
101
- .f\:bg-@{name}:focus-within {
102
- background-color: @value;
103
- }
104
- }
105
-
106
- // Create bc atomic class assignments
107
- & when (@property = all), (@property = border-color) {
108
- .bc-@{name},
109
- .h\:bc-@{name}:hover,
110
- .f\:bc-@{name}:focus,
111
- .f\:bc-@{name}:focus-within {
112
- border-color: @value;
113
- }
114
- }
115
-
116
- // Create fc atomic class assignments
117
- & when (@property = all), (@property = color) {
118
- .fc-@{name},
119
- .h\:fc-@{name}:hover,
120
- .f\:fc-@{name}:focus,
121
- .f\:fc-@{name}:focus-within {
122
- color: @value;
123
- }
124
- }
125
- }
126
-
127
- // Create dark mode atomic class assignments
128
- & when (@modeSimple = dark) {
129
- // Note: we currently do not generate conditional border-color classes
130
- // & when (@property = all), (@property = border-color) {
131
- // .d\:bc-@{name} {
132
- // border-color: @value;
133
- // }
134
- // }
135
-
136
- // Create bg atomic class assignments
137
- & when (@property = all), (@property = background-color) {
138
- .d\:bg-@{name} {
139
- background-color: @value;
140
- }
141
- }
142
-
143
- // Create fc atomic class assignments
144
- & when (@property = all), (@property = color) {
145
- .d\:fc-@{name} {
146
- color: @value;
147
- }
148
- }
149
- }
150
- }
151
-
152
- /**
153
- * Creates aliased color classes or variables.
154
- *
155
- * Usage example:
156
- * .create-aliased-utility-colors(classes)
157
- *
158
- * @modeSimple - Generate either all standard or dark conditional classes.
159
- */
160
- .create-aliased-utility-classes(@modeSimple: light) {
161
- // TODO add font color aliases
162
- each(.set-fc(), .(@value, @stop, @iColorValue) {
163
- @customValue: ~"var(--fc-@{stop}) !important";
164
- .create-color-classes(@stop, @customValue, @modeSimple, color);
165
- });
166
- each(.set-utility-alias(), .(@value, @stop, @iColorValue) {
167
- @customValue: ~"var(--bg-@{stop}) !important";
168
- .create-color-classes(@stop, @customValue, @modeSimple, background-color);
169
- });
170
- each(.set-utility-alias(), .(@value, @stop, @iColorValue) {
171
- @suffix: if((@stop = default), "", ~"@{stop}");
172
- @customValue: ~"var(--bc-@{stop}) !important";
173
- .create-color-classes(@stop, @customValue, @modeSimple, border-color);
174
- });
175
- }
176
-
177
- // THEMING -- PUBLIC API
178
- /**
179
- * Creates theme h/s/l and r/g/b variables based on the given color for a specified theme.
180
- *
181
- * Usage example:
182
- * .create-custom-theme-hsl-variables("#ff1100", secondary, dark);
183
- *
184
- * @color - (required) The color to be used to generate h/s/g and /r/g/b values.
185
- * @tier - The tier name to be used to generate the variable name.
186
- * @modeCustom - A custom label to be used to generate the variable name.
187
- */
188
- .create-custom-theme-hsl-variables(@color, @tier: primary, @modeCustom: base) {
189
- @varBase: ~"--theme-@{modeCustom}-@{tier}-color";
190
-
191
- @{varBase}-h: hue(@color);
192
- @{varBase}-s: saturation(@color);
193
- @{varBase}-l: lightness(@color);
194
-
195
- .create-custom-theme-variables(@tier, @modeCustom);
196
- }
197
-
198
- // THEMING -- PSEUDO-PRIVATE API
199
- /**
200
- * Defines custom theme varaibles from assembled h/s/l variables
201
- *
202
- * Usage example:
203
- * .create-custom-theme-variables(base);
204
- *
205
- * @tier - The tier name to be used to generate the variable name.
206
- * @modeCustom - A custom label to be used to generate the variable name.
207
- */
208
- .create-custom-theme-variables(@tier: primary, @modeCustom: base) {
209
- @valueVar: ~"theme-@{modeCustom}-@{tier}-color";
210
- @focusRingHSLVars: ~"var(--@{valueVar}-h), var(--@{valueVar}-s), var(--@{valueVar}-l)";
211
- @h: var(~"--@{valueVar}-h");
212
- @s: var(~"--@{valueVar}-s");
213
- @l: var(~"--@{valueVar}-l");
214
-
215
- // TODO verify color stops with design
216
- & when (@modeCustom = base) {
217
- @varBase: ~"--theme-@{tier}-custom";
218
-
219
- @{varBase}-100: ~"hsl(@{h}, @{s}, calc(@{l} + ((100% - @{l}) * .9)))";
220
- @{varBase}-200: ~"hsl(@{h}, @{s}, calc(@{l} + ((100% - @{l}) * .75)))";
221
- @{varBase}-300: ~"hsl(@{h}, @{s}, calc(@{l} + ((100% - @{l}) * .5)))";
222
- @{varBase}-400: ~"hsl(@{h}, @{s}, @{l})";
223
- @{varBase}-500: ~"hsl(@{h}, @{s}, calc(@{l} + (@{l} * -.3)))";
224
- @{varBase}-600: ~"hsl(@{h}, @{s}, calc(@{l} + (@{l} * -.6)))";
225
- @{varBase}: ~"var(@{varBase}-400)";
226
-
227
- & when (@tier = secondary) {
228
- @{varBase}-focus-ring: ~"hsla(@{focusRingHSLVars}, 0.15)";
229
- @{varBase}-translucent: ~"hsla(@{focusRingHSLVars}, 0.15)";
230
- }
231
- }
232
-
233
- & when (@modeCustom = dark) {
234
- @varBaseDark: ~"--theme-@{modeCustom}-@{tier}-custom";
235
-
236
- @{varBaseDark}-100: ~"hsl(@{h}, calc(@{s} + (@{s} * -.6)), calc(@{l} + (@{l} * -.7)))";
237
- @{varBaseDark}-200: ~"hsl(@{h}, calc(@{s} + (@{s} * -.4)), calc(@{l} + (@{l} * -.5)))";
238
- @{varBaseDark}-300: ~"hsl(@{h}, calc(@{s} + (@{s} * -.3)), calc(@{l} + (@{l} * -.2)))";
239
- @{varBaseDark}-400: ~"hsl(@{h}, @{s}, @{l})";
240
- @{varBaseDark}-500: ~"hsl(@{h}, @{s}, calc(@{l} + ((100% - @{l}) * .5)))";
241
- @{varBaseDark}-600: ~"hsl(@{h}, @{s}, calc(@{l} + ((100% - @{l}) * .8)))";
242
- @{varBaseDark}: ~"var(@{varBaseDark}-400)";
243
-
244
- & when (@tier = secondary) {
245
- @{varBaseDark}-focus-ring: ~"hsla(@{focusRingHSLVars}, 0.25)";
246
- @{varBaseDark}-translucent: ~"hsla(@{focusRingHSLVars}, 0.25)";
247
- }
248
- }
249
- }
250
-
251
- /**
252
- * Generates theme variables with values mapped to custom hsl values
253
- *
254
- * Usage example:
255
- * .create-theme-variables();
256
- *
257
- * @mode - determines which variable naming convention to use.
258
- */
259
- .create-theme-variables(@mode: light) {
260
- @tiers: primary, secondary;
261
-
262
- each(@tiers, .(@tier, @k, @i) {
263
- @stops: 100, 200, 300, 400, 500, 600;
264
- @fallbackColor: if(@tier = primary, orange, blue);
265
- @baseThemeVar: ~"--theme-@{tier}";
266
- @customThemeVar: if(@mode = light, ~"@{baseThemeVar}-custom", ~"--theme-dark-@{tier}-custom");
267
-
268
- & when (@mode = light), (@mode = dark) {
269
- @{baseThemeVar}: ~"var(@{customThemeVar}, var(--@{fallbackColor}-400))";
270
- each(@stops, .(@stop, @kStop, @iStop) {
271
- @{baseThemeVar}-@{stop}: ~"var(@{customThemeVar}-@{stop}, var(--@{fallbackColor}-@{stop}))";
272
- });
273
- }
274
-
275
- & when (@mode = light-highcontrast), (@mode = dark-highcontrast) {
276
- @{baseThemeVar}: ~"var(--@{fallbackColor}-400)";
277
-
278
- each(@stops, .(@stop, @kStop, @iStop) {
279
- @{baseThemeVar}-@{stop}: ~"var(--@{fallbackColor}-@{stop})";
280
- });
281
- }
282
- });
283
- }
1
+ @import (reference) "./mixins.less";
2
+ @import (reference) "./color-sets.less";
3
+
4
+ // Type definitions
5
+ //
6
+ // @mode: light | dark | light-highcontrast | dark-highcontrast;
7
+ // @modeCustom: base | dark; // legacy we're supporting for theming in Core
8
+ // @modeSimple: light | dark; // TODO consider different name?
9
+ // @property: all | background-color | border-color | color;
10
+ // @set: { [key: stop]: color }[];
11
+ // @sets: set[] | { [key: string]: set }[];
12
+ // @stop: default | 050 | 100 | 150 | 200 | 225 | 300 | 350 | 400 | 500 | 600;
13
+ // @tier: primary | secondary;
14
+ // @type: classes | variables;
15
+
16
+ /**
17
+ * Primary function to generate colors variables for a given mode.
18
+ *
19
+ * Usage example:
20
+ * .generate-colors(dark);
21
+ *
22
+ * @mode - Determines what to generate and which mode set to use.
23
+ */
24
+ //
25
+ .generate-colors(@mode: light) {
26
+ @set: .sets-mode()[$@mode];
27
+ @setUtility: .sets-utility-mode()[$@mode];
28
+ @modeCustom: if(@mode = dark, dark, base);
29
+
30
+ & when (@mode = light), (@mode = dark) {
31
+ &,
32
+ &.themed,
33
+ & .themed {
34
+ .create-colors(@set);
35
+ .create-colors(@setUtility);
36
+ .create-theme-variables(@mode);
37
+ .create-custom-theme-variables(primary, @modeCustom);
38
+ .create-custom-theme-variables(secondary, @modeCustom);
39
+ color: var(--theme-body-font-color, var(--black-600));
40
+ }
41
+ }
42
+
43
+ & when (@mode = light-highcontrast), (@mode = dark-highcontrast) {
44
+ .create-colors(@set);
45
+ .create-colors(@setUtility);
46
+ .create-theme-variables(@mode);
47
+ --_o-disabled: 0.8;
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Creates color variables or atomic classes based on the given sets of colors.
53
+ *
54
+ * Usage example:
55
+ * .create-colors(.sets-mode()[dark], classes);
56
+ *
57
+ * @sets - (required) A collection of name/set pairs.
58
+ * @type - The type of output.
59
+ * @modeSimple - The mode to use for generating classes.
60
+ * @property - The property to use for generating classes.
61
+ */
62
+ .create-colors(@sets, @type: variables, @modeSimple: light, @property: all) {
63
+ each(@sets, .(@set, @setName, @iSet) {
64
+ each(@set, .(@value, @stop, @iColorValue) {
65
+ @suffix: if((@stop = default), "", ~"-@{stop}");
66
+ @name: ~"@{setName}@{suffix}";
67
+ @variable: ~"--@{name}";
68
+
69
+ // Create custom property assignment
70
+ & when (@type = variables) {
71
+ @{variable}: @value;
72
+ }
73
+
74
+ // Create bg atomic class assignments
75
+ & when (@type = classes) {
76
+ @customValue: ~"var(@{variable}) !important";
77
+ .create-color-classes(@name, @customValue, @modeSimple, @property);
78
+ }
79
+ });
80
+ });
81
+ }
82
+
83
+ /**
84
+ * Creates atomic color classes for background and text color with the given color name and property value.
85
+ *
86
+ * Usage example:
87
+ * .create-color-classes(red-500, var(--red-500));
88
+ *
89
+ * @name - (required) Used as a suffix to each class.
90
+ * @value - (required) The value assigned to the generated class' property.
91
+ * @modeSimple - Generate either all standard or dark conditional classes.
92
+ * @property - Determines which type(s) of atomic class to generate.
93
+ */
94
+ .create-color-classes(@name, @value, @modeSimple: light, @property: all) {
95
+ & when (@modeSimple = light) {
96
+ // Create bg atomic class assignments
97
+ & when (@property = all), (@property = background-color) {
98
+ .bg-@{name},
99
+ .h\:bg-@{name}:hover,
100
+ .f\:bg-@{name}:focus,
101
+ .f\:bg-@{name}:focus-within {
102
+ background-color: @value;
103
+ }
104
+ }
105
+
106
+ // Create bc atomic class assignments
107
+ & when (@property = all), (@property = border-color) {
108
+ .bc-@{name},
109
+ .h\:bc-@{name}:hover,
110
+ .f\:bc-@{name}:focus,
111
+ .f\:bc-@{name}:focus-within {
112
+ border-color: @value;
113
+ }
114
+ }
115
+
116
+ // Create fc atomic class assignments
117
+ & when (@property = all), (@property = color) {
118
+ .fc-@{name},
119
+ .h\:fc-@{name}:hover,
120
+ .f\:fc-@{name}:focus,
121
+ .f\:fc-@{name}:focus-within {
122
+ color: @value;
123
+ }
124
+ }
125
+ }
126
+
127
+ // Create dark mode atomic class assignments
128
+ & when (@modeSimple = dark) {
129
+ // Note: we currently do not generate conditional border-color classes
130
+ // & when (@property = all), (@property = border-color) {
131
+ // .d\:bc-@{name} {
132
+ // border-color: @value;
133
+ // }
134
+ // }
135
+
136
+ // Create bg atomic class assignments
137
+ & when (@property = all), (@property = background-color) {
138
+ .d\:bg-@{name} {
139
+ background-color: @value;
140
+ }
141
+ }
142
+
143
+ // Create fc atomic class assignments
144
+ & when (@property = all), (@property = color) {
145
+ .d\:fc-@{name} {
146
+ color: @value;
147
+ }
148
+ }
149
+ }
150
+ }
151
+
152
+ /**
153
+ * Creates aliased color classes or variables.
154
+ *
155
+ * Usage example:
156
+ * .create-aliased-utility-colors(classes)
157
+ *
158
+ * @modeSimple - Generate either all standard or dark conditional classes.
159
+ */
160
+ .create-aliased-utility-classes(@modeSimple: light) {
161
+ // TODO add font color aliases
162
+ each(.set-fc(), .(@value, @stop, @iColorValue) {
163
+ @customValue: ~"var(--fc-@{stop}) !important";
164
+ .create-color-classes(@stop, @customValue, @modeSimple, color);
165
+ });
166
+ each(.set-utility-alias(), .(@value, @stop, @iColorValue) {
167
+ @customValue: ~"var(--bg-@{stop}) !important";
168
+ .create-color-classes(@stop, @customValue, @modeSimple, background-color);
169
+ });
170
+ each(.set-utility-alias(), .(@value, @stop, @iColorValue) {
171
+ @suffix: if((@stop = default), "", ~"@{stop}");
172
+ @customValue: ~"var(--bc-@{stop}) !important";
173
+ .create-color-classes(@stop, @customValue, @modeSimple, border-color);
174
+ });
175
+ }
176
+
177
+ // THEMING -- PUBLIC API
178
+ /**
179
+ * Creates theme h/s/l and r/g/b variables based on the given color for a specified theme.
180
+ *
181
+ * Usage example:
182
+ * .create-custom-theme-hsl-variables("#ff1100", secondary, dark);
183
+ *
184
+ * @color - (required) The color to be used to generate h/s/g and /r/g/b values.
185
+ * @tier - The tier name to be used to generate the variable name.
186
+ * @modeCustom - A custom label to be used to generate the variable name.
187
+ */
188
+ .create-custom-theme-hsl-variables(@color, @tier: primary, @modeCustom: base) {
189
+ @varBase: ~"--theme-@{modeCustom}-@{tier}-color";
190
+
191
+ @{varBase}-h: hue(@color);
192
+ @{varBase}-s: saturation(@color);
193
+ @{varBase}-l: lightness(@color);
194
+
195
+ .create-custom-theme-variables(@tier, @modeCustom);
196
+ }
197
+
198
+ // THEMING -- PSEUDO-PRIVATE API
199
+ /**
200
+ * Defines custom theme varaibles from assembled h/s/l variables
201
+ *
202
+ * Usage example:
203
+ * .create-custom-theme-variables(base);
204
+ *
205
+ * @tier - The tier name to be used to generate the variable name.
206
+ * @modeCustom - A custom label to be used to generate the variable name.
207
+ */
208
+ .create-custom-theme-variables(@tier: primary, @modeCustom: base) {
209
+ @valueVar: ~"theme-@{modeCustom}-@{tier}-color";
210
+ @focusRingHSLVars: ~"var(--@{valueVar}-h), var(--@{valueVar}-s), var(--@{valueVar}-l)";
211
+ @h: var(~"--@{valueVar}-h");
212
+ @s: var(~"--@{valueVar}-s");
213
+ @l: var(~"--@{valueVar}-l");
214
+
215
+ // TODO verify color stops with design
216
+ & when (@modeCustom = base) {
217
+ @varBase: ~"--theme-@{tier}-custom";
218
+
219
+ @{varBase}-100: ~"hsl(@{h}, @{s}, calc(@{l} + ((100% - @{l}) * .9)))";
220
+ @{varBase}-200: ~"hsl(@{h}, @{s}, calc(@{l} + ((100% - @{l}) * .75)))";
221
+ @{varBase}-300: ~"hsl(@{h}, @{s}, calc(@{l} + ((100% - @{l}) * .5)))";
222
+ @{varBase}-400: ~"hsl(@{h}, @{s}, @{l})";
223
+ @{varBase}-500: ~"hsl(@{h}, @{s}, calc(@{l} + (@{l} * -.3)))";
224
+ @{varBase}-600: ~"hsl(@{h}, @{s}, calc(@{l} + (@{l} * -.6)))";
225
+ @{varBase}: ~"var(@{varBase}-400)";
226
+
227
+ & when (@tier = secondary) {
228
+ @{varBase}-focus-ring: ~"hsla(@{focusRingHSLVars}, 0.15)";
229
+ @{varBase}-translucent: ~"hsla(@{focusRingHSLVars}, 0.15)";
230
+ }
231
+ }
232
+
233
+ & when (@modeCustom = dark) {
234
+ @varBaseDark: ~"--theme-@{modeCustom}-@{tier}-custom";
235
+
236
+ @{varBaseDark}-100: ~"hsl(@{h}, calc(@{s} + (@{s} * -.6)), calc(@{l} + (@{l} * -.7)))";
237
+ @{varBaseDark}-200: ~"hsl(@{h}, calc(@{s} + (@{s} * -.4)), calc(@{l} + (@{l} * -.5)))";
238
+ @{varBaseDark}-300: ~"hsl(@{h}, calc(@{s} + (@{s} * -.3)), calc(@{l} + (@{l} * -.2)))";
239
+ @{varBaseDark}-400: ~"hsl(@{h}, @{s}, @{l})";
240
+ @{varBaseDark}-500: ~"hsl(@{h}, @{s}, calc(@{l} + ((100% - @{l}) * .5)))";
241
+ @{varBaseDark}-600: ~"hsl(@{h}, @{s}, calc(@{l} + ((100% - @{l}) * .8)))";
242
+ @{varBaseDark}: ~"var(@{varBaseDark}-400)";
243
+
244
+ & when (@tier = secondary) {
245
+ @{varBaseDark}-focus-ring: ~"hsla(@{focusRingHSLVars}, 0.25)";
246
+ @{varBaseDark}-translucent: ~"hsla(@{focusRingHSLVars}, 0.25)";
247
+ }
248
+ }
249
+ }
250
+
251
+ /**
252
+ * Generates theme variables with values mapped to custom hsl values
253
+ *
254
+ * Usage example:
255
+ * .create-theme-variables();
256
+ *
257
+ * @mode - determines which variable naming convention to use.
258
+ */
259
+ .create-theme-variables(@mode: light) {
260
+ @tiers: primary, secondary;
261
+
262
+ each(@tiers, .(@tier, @k, @i) {
263
+ @stops: 100, 200, 300, 400, 500, 600;
264
+ @fallbackColor: if(@tier = primary, orange, blue);
265
+ @baseThemeVar: ~"--theme-@{tier}";
266
+ @customThemeVar: if(@mode = light, ~"@{baseThemeVar}-custom", ~"--theme-dark-@{tier}-custom");
267
+
268
+ & when (@mode = light), (@mode = dark) {
269
+ @{baseThemeVar}: ~"var(@{customThemeVar}, var(--@{fallbackColor}-400))";
270
+ each(@stops, .(@stop, @kStop, @iStop) {
271
+ @{baseThemeVar}-@{stop}: ~"var(@{customThemeVar}-@{stop}, var(--@{fallbackColor}-@{stop}))";
272
+ });
273
+ }
274
+
275
+ & when (@mode = light-highcontrast), (@mode = dark-highcontrast) {
276
+ @{baseThemeVar}: ~"var(--@{fallbackColor}-400)";
277
+
278
+ each(@stops, .(@stop, @kStop, @iStop) {
279
+ @{baseThemeVar}-@{stop}: ~"var(--@{fallbackColor}-@{stop})";
280
+ });
281
+ }
282
+ });
283
+ }