@stackoverflow/stacks 2.7.3 → 2.7.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 (85) hide show
  1. package/LICENSE.MD +9 -9
  2. package/README.md +158 -180
  3. package/dist/css/stacks.css +20 -13
  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/input_textarea/input_textarea.less +2 -7
  44. package/lib/components/label/label.less +116 -110
  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 +27 -23
@@ -1,426 +1,426 @@
1
- //
2
- // STACK OVERFLOW
3
- // FLEXBOX HELPERS
4
- //
5
- // This CSS comes from Stacks, our CSS & Pattern library for rapidly building
6
- // Stack Overflow. For documentation of all these classes and how to contribute,
7
- // visit https://stackoverflow.design/
8
- //
9
- // TABLE OF CONTENTS
10
- // • VARIABLES
11
- // • MIXINS
12
- // • FLEX ELEMENTS
13
- // • FLEX SPACING
14
- // • MODIFICATIONS
15
- // • ATOMIC
16
- // • DEPRECATED
17
- //
18
- // ============================================================================
19
- // -- STACKS FLEX LAYOUT MIXINS
20
- // ============================================================================
21
- // -- FIXED COLUMN WIDTHS
22
- // ----------------------------------------------------------------------------
23
-
24
- #stacks-internals() {
25
- #flex-builder-settings() {
26
- @flex-cols: 12; // Desired flex columns
27
- }
28
- #flex-builder-helpers() {
29
- #stacks-internals #flex-builder-settings();
30
-
31
- .create-fixed-items(@num, @count: 1) when (@count =< @num) {
32
- .flex--item@{count} {
33
- flex-basis: ((@count * 100%) / @num);
34
- }
35
-
36
- #stacks-internals #flex-builder-helpers .create-fixed-items(@num, (@count + 1));
37
- }
38
-
39
- // -- AUTO FIXED WIDTH ITEMS
40
- // Automatic adjusting width items are great. And being able to specify an
41
- // item's width is equally amazing. But sometimes you want to be able to
42
- // have all items within a box container to be the same width. Instead
43
- // stating a fixed item width, apply a modifying to the box container and
44
- // all child elements will automatically be sized.
45
- // ----------------------------------------------------------------------------
46
- .create-flex-count-cols(@num, @count: 1) when (@count =< @num) {
47
- .flex__allitems@{count} {
48
- > .d-flex,
49
- > .flex--item {
50
- flex-basis: ((@count * 100%) / @num);
51
- }
52
- }
53
-
54
- #stacks-internals #flex-builder-helpers .create-flex-count-cols(@num, (@count + 1));
55
- }
56
-
57
- // DEPRECATED - START
58
- //
59
- // -- FLEX GUTTERS
60
- // ============================================================================
61
- // We need two mixins to properly generate flex gutters:
62
- //
63
- // [1] Adjusts the fixed column max-width / flex-basis if gutters are present.
64
- // [2] Generate the desired gutters.
65
- //
66
- // ----------------------------------------------------------------------------
67
- // [1] Adjust width / flex-basis numbers
68
- //
69
- // HOW IT WORKS:
70
- // A quick primer on how this mixin works. The TL;DR is we're using a mixin
71
- // guard to start a loop that'll create all the desired `> .flex--item@{count}`
72
- // classes.
73
- //
74
- // The three mixin parameters are:
75
- // - @spacing: the desired distance our gutters should be
76
- // - @num: the number at which we should stop our loop
77
- // - @count: the current column number
78
- //
79
- // The other bit is the mixin guard portion:
80
- //
81
- // when (@count =< @num)
82
- //
83
- // This checks if we should run the mixin. Using a comparison operator,
84
- // it's checking to see if the current @count is equal to (=) or less
85
- // than (<) the desired @num total. If it is, run the mixin.
86
- //
87
- // Next the mixin runs as normal. Using the @item-width variable, we
88
- // calculate the item's width. We do this here because we need to use the
89
- // CSS calc function and this makes the code a little prettier. Using the
90
- // variable, we then update the fixed item's flex-basis and width.
91
- //
92
- // Finally we call for the mixin again within itself, assigning a new
93
- // @count value: the current value + 1. This then fires off the mixin
94
- // again, creating a loop until we've generated updated widths for all
95
- // of our desired @num.
96
- //
97
- // There are two mixins here:
98
- // • "flex-fixed-item-row" -- This is the baseline mixin.
99
- // • "flex-fixed-item-column" -- When the ".d-flex" is a column, change
100
- // the margins, setting a top and bottom margin instead of left
101
- // and right.
102
- //
103
- // ----------------------------------------------------------------------------
104
- .flex-fixed-item-spacing(@spacing, @num, @count: 1) when (@count =< @num) {
105
- @itemWidth: (@count * 100% / @num);
106
-
107
- > .flex--item@{count} {
108
- margin: calc(~"@{spacing}" / 2);
109
- }
110
-
111
- // ------------------------------------------------------------------------
112
- // [1] FIXED WIDTH ITEMS
113
- // This makes the fixed width items to account for gutters.
114
- //
115
- // [2] UNIFORM CHILD FLEX ITEMS
116
- // This class allows you to uniformly state the width of `.flex--item`
117
- // divs within a `.d-flex` element. In particular we adjust the flex-basis
118
- // and max-width here to account for gutters.
119
- // ------------------------------------------------------------------------
120
- > .flex--item@{count}, // [1]
121
- &.flex__allitems@{count} > .d-flex, // [2]
122
- &.flex__allitems@{count} > .flex--item { // [2]
123
- flex-basis: calc(~"@{itemWidth} - @{spacing}");
124
- }
125
-
126
- #stacks-internals #flex-builder-helpers .flex-fixed-item-spacing(@spacing, @num, (@count + 1));
127
- }
128
-
129
-
130
- // ----------------------------------------------------------------------------
131
- // 2. Generate the desired gutters
132
- // We halve the spacing value because the spacing value should be the
133
- // total space between items--not the total applied to each item,
134
- // which would effectively double the desired total.
135
- //
136
- // The "when" statements here refer to when we declare it's for a
137
- // row (default) or a column. When a column we need to reset the
138
- // left and right margins and add in top and bottom margins.
139
- // ----------------------------------------------------------------------------
140
- .gutter-spacing(@spacing) {
141
- #stacks-internals #flex-builder-settings();
142
-
143
- margin: calc(~"@{spacing}" / 2 * -1);
144
-
145
- // -- FLUID ITEMS
146
- > .d-flex,
147
- > .flex--item {
148
- margin: calc(~"@{spacing}" / 2);
149
- }
150
-
151
- // -- FIXED WIDTH ITEMS
152
- // Now we call for the above mixin [1] to make sure we adjust the default
153
- // widths for the new gutters.
154
- #stacks-internals #flex-builder-helpers .flex-fixed-item-spacing(@spacing, @flex-cols);
155
- }
156
- //
157
- // DEPRECATED - END
158
-
159
- // -- FLEX GAP
160
- // ------------------------------------------------------------------------
161
- // [1] FIXED WIDTH ITEMS
162
- // This makes the fixed width items to account for gaps.
163
- //
164
- // [2] UNIFORM CHILD FLEX ITEMS
165
- // This class allows you to uniformly state the width of `.flex--item`
166
- // divs within a `.d-flex` element. In particular we adjust the flex-basis
167
- // and max-width here to account for gaps.
168
- // ------------------------------------------------------------------------
169
- .flex-fixed-item-spacing-gap(@spacing, @num, @count: 1) when (@count =< @num) {
170
- @itemWidth: (@count * 100% / @num);
171
- @gapRatio: ((@num - @count) / @num);
172
-
173
- > .flex--item@{count}, // [1]
174
- &.flex__allitems@{count} > .d-flex, // [2]
175
- &.flex__allitems@{count} > .flex--item { // [2]
176
- flex-basis: calc(~"@{itemWidth} - (@{spacing} * @{gapRatio})");
177
- }
178
-
179
- #stacks-internals #flex-builder-helpers .flex-fixed-item-spacing-gap(@spacing, @num, (@count + 1));
180
- }
181
-
182
-
183
- .gap-spacing(@spacing) {
184
- #stacks-internals #flex-builder-settings();
185
-
186
- #stacks-internals #flex-builder-helpers .flex-fixed-item-spacing-gap(@spacing, @flex-cols);
187
- }
188
- }
189
- }
190
-
191
- // -- UNIVERSAL FLEX WIDTHS
192
- // This applies a flex value it to all of a flex's direct children.
193
- // --------------------------------------------------------------------------
194
- .flex__fl-shrink0 {
195
- &,
196
- > .d-flex,
197
- > .flex--item {
198
- flex: 0 auto;
199
- }
200
- }
201
-
202
- .flex__fl-equal {
203
- &,
204
- > .d-flex,
205
- > .flex--item {
206
- flex: 1 1 0%;
207
- }
208
- }
209
-
210
- .flex__fl-grow1 {
211
- &,
212
- > .d-flex,
213
- > .flex--item {
214
- flex: 1 auto;
215
- }
216
- }
217
-
218
- & {
219
- #stacks-internals #flex-builder-settings(); // load @flex-cols
220
-
221
- // $$ FIXED WIDTH ITEMS
222
- // ----------------------------------------------------------------------------
223
- #stacks-internals #flex-builder-helpers .create-fixed-items(@flex-cols);
224
-
225
- // $$ AUTO FIXED WIDTH ITEMS
226
- // ----------------------------------------------------------------------------
227
- #stacks-internals #flex-builder-helpers .create-flex-count-cols(@flex-cols);
228
- }
229
- // ============================================================================
230
- // $ FLEX SPACING
231
- // Insert spaces or gaps in between flex items
232
- // ----------------------------------------------------------------------------
233
- .g0, .gx0, .gy0 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su0)); }
234
- .g1, .gx1, .gy1 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su1)); }
235
- .g2, .gx2, .gy2 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su2)); }
236
- .g4, .gx4, .gy4 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su4)); }
237
- .g6, .gx6, .gy6 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su6)); }
238
- .g8, .gx8, .gy8 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su8)); }
239
- .g12, .gx12, .gy12 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su12)); }
240
- .g16, .gx16, .gy16 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su16)); }
241
- .g24, .gx24, .gy24 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su24)); }
242
- .g32, .gx32, .gy32 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su32)); }
243
- .g48, .gx48, .gy48 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su48)); }
244
- .g64, .gx64, .gy64 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su64)); }
245
-
246
-
247
- // DEPRECATED - START
248
- //
249
- .gs2 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su2)); }
250
- .gs4 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su4)); }
251
- .gs6 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su6)); }
252
- .gs8 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su8)); }
253
- .gs12 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su12)); }
254
- .gs16 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su16)); }
255
- .gs24 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su24)); }
256
- .gs32 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su32)); }
257
- .gs48 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su48)); }
258
- .gs64 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su64)); }
259
-
260
- // On rows, remove top and bottom margins
261
- .gsx {
262
- &,
263
- > .d-flex,
264
- > [class*="flex--item"] {
265
- margin-top: 0;
266
- margin-bottom: 0;
267
- }
268
- }
269
-
270
- // On columns, remove left and right margins
271
- .gsy {
272
- &,
273
- > .d-flex,
274
- > [class*="flex--item"] {
275
- margin-right: 0;
276
- margin-left: 0;
277
- }
278
- }
279
- //
280
- // DEPRECATED - END
281
-
282
-
283
- // ============================================================================
284
- // $ ATOMIC CLASSES
285
- // ----------------------------------------------------------------------------
286
- // -- FLEX DIRECTION
287
- // This determines the direction content flows within a parent container.
288
- // The default values are row.
289
- // ----------------------------------------------------------------------------
290
- #stacks-internals #responsify('.fd-row', { flex-direction: row !important; });
291
- #stacks-internals #responsify('.fd-row-reverse', { flex-direction: row-reverse !important; });
292
- #stacks-internals #responsify('.fd-column', { flex-direction: column !important; });
293
- #stacks-internals #responsify('.fd-column-reverse', { flex-direction: column-reverse !important; });
294
-
295
- // -- FLEX WRAP
296
- // This determines if a parent's child items will wrap or not.
297
- // ----------------------------------------------------------------------------
298
- #stacks-internals #responsify('.fw-wrap', { flex-wrap: wrap !important; });
299
- #stacks-internals #responsify('.fw-reverse', { flex-wrap: wrap-reverse !important; });
300
- #stacks-internals #responsify('.fw-nowrap', { flex-wrap: nowrap !important; });
301
-
302
- // -- JUSTIFY CONTENT
303
- // Defines the child alignment along the parent's main axis
304
- // ----------------------------------------------------------------------------
305
- #stacks-internals #responsify('.jc-center', { justify-content: center !important; });
306
- #stacks-internals #responsify('.jc-end', { justify-content: flex-end !important; });
307
- #stacks-internals #responsify('.jc-space-around', { justify-content: space-around !important; });
308
- #stacks-internals #responsify('.jc-space-between', { justify-content: space-between !important; });
309
- #stacks-internals #responsify('.jc-space-evenly', { justify-content: space-evenly !important; });
310
- #stacks-internals #responsify('.jc-start', { justify-content: flex-start !important; });
311
-
312
- // -- ALIGN CONTENT
313
- // Aligns the container's lines when there is extra space in the
314
- // cross-axis. Note that this only works when a parent container
315
- // has more than one line.
316
- // ----------------------------------------------------------------------------
317
- .ac-center { align-content: center !important; }
318
- .ac-end { align-content: flex-end !important; }
319
- .ac-space-around { align-content: space-around !important; }
320
- .ac-space-between { align-content: space-between !important; }
321
- .ac-start { align-content: flex-start !important; }
322
- .ac-stretch { align-content: stretch !important; }
323
-
324
- // -- ALIGN ITEMS
325
- // Defines the default behavior for how child items align along
326
- // the parent's cross axis. Think of it the cross-axis for
327
- // justify-content.
328
- // ----------------------------------------------------------------------------
329
- #stacks-internals #build-classes(
330
- responsive,
331
- '.ai',
332
- {
333
- .template(@value) when (@value=start), (@value=end) { align-items: ~"flex-@{value}" !important; }
334
- .template(@value) when (default()) { align-items: @value !important; };
335
- },
336
- baseline center end start stretch
337
- );
338
-
339
- // -- CENTER ITEMS
340
- // A common combination of classes is .jc-center and .ai-center.
341
- // Use this class when you want both.
342
- // ----------------------------------------------------------------------------
343
- .flex__center {
344
- .jc-center;
345
- .ai-center;
346
- }
347
-
348
- // -- ALIGN SELF
349
- // Allows child containers to re-align themselves regardless
350
- // of the parent's main axis direction.
351
- // ----------------------------------------------------------------------------
352
- #stacks-internals #build-classes(
353
- responsive,
354
- '.as',
355
- {
356
- .template(@value) when (@value=start), (@value=end) { align-self: ~"flex-@{value}" !important; }
357
- .template(@value) when (default()) { align-self: @value !important; };
358
- },
359
- auto baseline center end start stretch
360
- );
361
-
362
- // -- FLEX
363
- // Graduating scale of flex-grow and flex-shrink values
364
- // ----------------------------------------------------------------------------
365
- #stacks-internals #responsify('.fl-grow1', { flex-grow: 1 !important; });
366
- #stacks-internals #responsify('.fl-grow0', { flex-grow: 0 !important; });
367
- #stacks-internals #responsify('.fl-shrink1', { flex-shrink: 1 !important; });
368
- #stacks-internals #responsify('.fl-shrink0', { flex-shrink: 0 !important; });
369
- #stacks-internals #responsify('.fl-none', { flex: none !important; });
370
- #stacks-internals #responsify('.fl-initial', { flex: 0 1 auto !important; });
371
- #stacks-internals #responsify('.fl-auto', { flex: 1 1 auto !important; });
372
- #stacks-internals #responsify('.fl-equal', { flex: 1 1 0% !important; });
373
-
374
- // -- Ordering
375
- // Designate a child container's position.
376
- // ----------------------------------------------------------------------------
377
- #stacks-internals #responsify('.order-first', { order: -1 !important; });
378
- #stacks-internals #responsify('.order-last', { order: 1 !important; });
379
-
380
-
381
- // ============================================================================
382
- // $ DEPRECATED CLASSES
383
- // ----------------------------------------------------------------------------
384
-
385
- // -- FLEX FLOW
386
- // This is another shorthand property for flex-direction and flex-wrap.
387
- // Default value is "row nowrap".
388
- // ----------------------------------------------------------------------------
389
- .ff-row-wrap { flex-flow: row wrap !important; }
390
- .ff-row-nowrap { flex-flow: row nowrap !important; }
391
- .ff-row-reverse-wrap { flex-flow: row-reverse wrap !important; }
392
- .ff-row-reverse-nowrap { flex-flow: row-reverse nowrap !important; }
393
- .ff-column-wrap { flex-flow: column wrap !important; }
394
- .ff-column-nowrap { flex-flow: column nowrap !important; }
395
- .ff-column-reverse-wrap { flex-flow: column-reverse wrap !important; }
396
- .ff-column-reverse-nowrap { flex-flow: column-reverse nowrap !important; }
397
-
398
- // -- FLEX
399
- // Graduating scale of flex-grow and flex-shrink values
400
- // ----------------------------------------------------------------------------
401
- #stacks-internals #responsify('.fl0', { flex: 0 auto !important; });
402
- #stacks-internals #responsify('.fl1', { flex: 1 auto !important; });
403
- .fl2 { flex: 2 auto !important; }
404
- .fl3 { flex: 3 auto !important; }
405
- .fl4 { flex: 4 auto !important; }
406
- .fl5 { flex: 5 auto !important; }
407
-
408
- // -- FLEX SHRINK
409
- // Specifies the flex-shrink factor, which states how much an item will
410
- // shrink relative to other flex items in the container when there isn't
411
- // enough space in the row. Default value is 1.
412
- // ----------------------------------------------------------------------------
413
- .fl-shrink2 { flex-shrink: 2; }
414
- .fl-shrink3 { flex-shrink: 3; }
415
- .fl-shrink4 { flex-shrink: 4; }
416
- .fl-shrink5 { flex-shrink: 5; }
417
-
418
- // -- FLEX GROW
419
- // Specifies the flex-shrink grow, which states how much an item will
420
- // grow relative to other flex items in the container when there isn't
421
- // enough space in the row. Default value is 1.
422
- // ----------------------------------------------------------------------------
423
- .fl-grow2 { flex-grow: 2; }
424
- .fl-grow3 { flex-grow: 3; }
425
- .fl-grow4 { flex-grow: 4; }
426
- .fl-grow5 { flex-grow: 5; }
1
+ //
2
+ // STACK OVERFLOW
3
+ // FLEXBOX HELPERS
4
+ //
5
+ // This CSS comes from Stacks, our CSS & Pattern library for rapidly building
6
+ // Stack Overflow. For documentation of all these classes and how to contribute,
7
+ // visit https://stackoverflow.design/
8
+ //
9
+ // TABLE OF CONTENTS
10
+ // • VARIABLES
11
+ // • MIXINS
12
+ // • FLEX ELEMENTS
13
+ // • FLEX SPACING
14
+ // • MODIFICATIONS
15
+ // • ATOMIC
16
+ // • DEPRECATED
17
+ //
18
+ // ============================================================================
19
+ // -- STACKS FLEX LAYOUT MIXINS
20
+ // ============================================================================
21
+ // -- FIXED COLUMN WIDTHS
22
+ // ----------------------------------------------------------------------------
23
+
24
+ #stacks-internals() {
25
+ #flex-builder-settings() {
26
+ @flex-cols: 12; // Desired flex columns
27
+ }
28
+ #flex-builder-helpers() {
29
+ #stacks-internals #flex-builder-settings();
30
+
31
+ .create-fixed-items(@num, @count: 1) when (@count =< @num) {
32
+ .flex--item@{count} {
33
+ flex-basis: ((@count * 100%) / @num);
34
+ }
35
+
36
+ #stacks-internals #flex-builder-helpers .create-fixed-items(@num, (@count + 1));
37
+ }
38
+
39
+ // -- AUTO FIXED WIDTH ITEMS
40
+ // Automatic adjusting width items are great. And being able to specify an
41
+ // item's width is equally amazing. But sometimes you want to be able to
42
+ // have all items within a box container to be the same width. Instead
43
+ // stating a fixed item width, apply a modifying to the box container and
44
+ // all child elements will automatically be sized.
45
+ // ----------------------------------------------------------------------------
46
+ .create-flex-count-cols(@num, @count: 1) when (@count =< @num) {
47
+ .flex__allitems@{count} {
48
+ > .d-flex,
49
+ > .flex--item {
50
+ flex-basis: ((@count * 100%) / @num);
51
+ }
52
+ }
53
+
54
+ #stacks-internals #flex-builder-helpers .create-flex-count-cols(@num, (@count + 1));
55
+ }
56
+
57
+ // DEPRECATED - START
58
+ //
59
+ // -- FLEX GUTTERS
60
+ // ============================================================================
61
+ // We need two mixins to properly generate flex gutters:
62
+ //
63
+ // [1] Adjusts the fixed column max-width / flex-basis if gutters are present.
64
+ // [2] Generate the desired gutters.
65
+ //
66
+ // ----------------------------------------------------------------------------
67
+ // [1] Adjust width / flex-basis numbers
68
+ //
69
+ // HOW IT WORKS:
70
+ // A quick primer on how this mixin works. The TL;DR is we're using a mixin
71
+ // guard to start a loop that'll create all the desired `> .flex--item@{count}`
72
+ // classes.
73
+ //
74
+ // The three mixin parameters are:
75
+ // - @spacing: the desired distance our gutters should be
76
+ // - @num: the number at which we should stop our loop
77
+ // - @count: the current column number
78
+ //
79
+ // The other bit is the mixin guard portion:
80
+ //
81
+ // when (@count =< @num)
82
+ //
83
+ // This checks if we should run the mixin. Using a comparison operator,
84
+ // it's checking to see if the current @count is equal to (=) or less
85
+ // than (<) the desired @num total. If it is, run the mixin.
86
+ //
87
+ // Next the mixin runs as normal. Using the @item-width variable, we
88
+ // calculate the item's width. We do this here because we need to use the
89
+ // CSS calc function and this makes the code a little prettier. Using the
90
+ // variable, we then update the fixed item's flex-basis and width.
91
+ //
92
+ // Finally we call for the mixin again within itself, assigning a new
93
+ // @count value: the current value + 1. This then fires off the mixin
94
+ // again, creating a loop until we've generated updated widths for all
95
+ // of our desired @num.
96
+ //
97
+ // There are two mixins here:
98
+ // • "flex-fixed-item-row" -- This is the baseline mixin.
99
+ // • "flex-fixed-item-column" -- When the ".d-flex" is a column, change
100
+ // the margins, setting a top and bottom margin instead of left
101
+ // and right.
102
+ //
103
+ // ----------------------------------------------------------------------------
104
+ .flex-fixed-item-spacing(@spacing, @num, @count: 1) when (@count =< @num) {
105
+ @itemWidth: (@count * 100% / @num);
106
+
107
+ > .flex--item@{count} {
108
+ margin: calc(~"@{spacing}" / 2);
109
+ }
110
+
111
+ // ------------------------------------------------------------------------
112
+ // [1] FIXED WIDTH ITEMS
113
+ // This makes the fixed width items to account for gutters.
114
+ //
115
+ // [2] UNIFORM CHILD FLEX ITEMS
116
+ // This class allows you to uniformly state the width of `.flex--item`
117
+ // divs within a `.d-flex` element. In particular we adjust the flex-basis
118
+ // and max-width here to account for gutters.
119
+ // ------------------------------------------------------------------------
120
+ > .flex--item@{count}, // [1]
121
+ &.flex__allitems@{count} > .d-flex, // [2]
122
+ &.flex__allitems@{count} > .flex--item { // [2]
123
+ flex-basis: calc(~"@{itemWidth} - @{spacing}");
124
+ }
125
+
126
+ #stacks-internals #flex-builder-helpers .flex-fixed-item-spacing(@spacing, @num, (@count + 1));
127
+ }
128
+
129
+
130
+ // ----------------------------------------------------------------------------
131
+ // 2. Generate the desired gutters
132
+ // We halve the spacing value because the spacing value should be the
133
+ // total space between items--not the total applied to each item,
134
+ // which would effectively double the desired total.
135
+ //
136
+ // The "when" statements here refer to when we declare it's for a
137
+ // row (default) or a column. When a column we need to reset the
138
+ // left and right margins and add in top and bottom margins.
139
+ // ----------------------------------------------------------------------------
140
+ .gutter-spacing(@spacing) {
141
+ #stacks-internals #flex-builder-settings();
142
+
143
+ margin: calc(~"@{spacing}" / 2 * -1);
144
+
145
+ // -- FLUID ITEMS
146
+ > .d-flex,
147
+ > .flex--item {
148
+ margin: calc(~"@{spacing}" / 2);
149
+ }
150
+
151
+ // -- FIXED WIDTH ITEMS
152
+ // Now we call for the above mixin [1] to make sure we adjust the default
153
+ // widths for the new gutters.
154
+ #stacks-internals #flex-builder-helpers .flex-fixed-item-spacing(@spacing, @flex-cols);
155
+ }
156
+ //
157
+ // DEPRECATED - END
158
+
159
+ // -- FLEX GAP
160
+ // ------------------------------------------------------------------------
161
+ // [1] FIXED WIDTH ITEMS
162
+ // This makes the fixed width items to account for gaps.
163
+ //
164
+ // [2] UNIFORM CHILD FLEX ITEMS
165
+ // This class allows you to uniformly state the width of `.flex--item`
166
+ // divs within a `.d-flex` element. In particular we adjust the flex-basis
167
+ // and max-width here to account for gaps.
168
+ // ------------------------------------------------------------------------
169
+ .flex-fixed-item-spacing-gap(@spacing, @num, @count: 1) when (@count =< @num) {
170
+ @itemWidth: (@count * 100% / @num);
171
+ @gapRatio: ((@num - @count) / @num);
172
+
173
+ > .flex--item@{count}, // [1]
174
+ &.flex__allitems@{count} > .d-flex, // [2]
175
+ &.flex__allitems@{count} > .flex--item { // [2]
176
+ flex-basis: calc(~"@{itemWidth} - (@{spacing} * @{gapRatio})");
177
+ }
178
+
179
+ #stacks-internals #flex-builder-helpers .flex-fixed-item-spacing-gap(@spacing, @num, (@count + 1));
180
+ }
181
+
182
+
183
+ .gap-spacing(@spacing) {
184
+ #stacks-internals #flex-builder-settings();
185
+
186
+ #stacks-internals #flex-builder-helpers .flex-fixed-item-spacing-gap(@spacing, @flex-cols);
187
+ }
188
+ }
189
+ }
190
+
191
+ // -- UNIVERSAL FLEX WIDTHS
192
+ // This applies a flex value it to all of a flex's direct children.
193
+ // --------------------------------------------------------------------------
194
+ .flex__fl-shrink0 {
195
+ &,
196
+ > .d-flex,
197
+ > .flex--item {
198
+ flex: 0 auto;
199
+ }
200
+ }
201
+
202
+ .flex__fl-equal {
203
+ &,
204
+ > .d-flex,
205
+ > .flex--item {
206
+ flex: 1 1 0%;
207
+ }
208
+ }
209
+
210
+ .flex__fl-grow1 {
211
+ &,
212
+ > .d-flex,
213
+ > .flex--item {
214
+ flex: 1 auto;
215
+ }
216
+ }
217
+
218
+ & {
219
+ #stacks-internals #flex-builder-settings(); // load @flex-cols
220
+
221
+ // $$ FIXED WIDTH ITEMS
222
+ // ----------------------------------------------------------------------------
223
+ #stacks-internals #flex-builder-helpers .create-fixed-items(@flex-cols);
224
+
225
+ // $$ AUTO FIXED WIDTH ITEMS
226
+ // ----------------------------------------------------------------------------
227
+ #stacks-internals #flex-builder-helpers .create-flex-count-cols(@flex-cols);
228
+ }
229
+ // ============================================================================
230
+ // $ FLEX SPACING
231
+ // Insert spaces or gaps in between flex items
232
+ // ----------------------------------------------------------------------------
233
+ .g0, .gx0, .gy0 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su0)); }
234
+ .g1, .gx1, .gy1 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su1)); }
235
+ .g2, .gx2, .gy2 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su2)); }
236
+ .g4, .gx4, .gy4 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su4)); }
237
+ .g6, .gx6, .gy6 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su6)); }
238
+ .g8, .gx8, .gy8 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su8)); }
239
+ .g12, .gx12, .gy12 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su12)); }
240
+ .g16, .gx16, .gy16 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su16)); }
241
+ .g24, .gx24, .gy24 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su24)); }
242
+ .g32, .gx32, .gy32 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su32)); }
243
+ .g48, .gx48, .gy48 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su48)); }
244
+ .g64, .gx64, .gy64 { #stacks-internals #flex-builder-helpers .gap-spacing(var(--su64)); }
245
+
246
+
247
+ // DEPRECATED - START
248
+ //
249
+ .gs2 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su2)); }
250
+ .gs4 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su4)); }
251
+ .gs6 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su6)); }
252
+ .gs8 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su8)); }
253
+ .gs12 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su12)); }
254
+ .gs16 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su16)); }
255
+ .gs24 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su24)); }
256
+ .gs32 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su32)); }
257
+ .gs48 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su48)); }
258
+ .gs64 { #stacks-internals #flex-builder-helpers .gutter-spacing(var(--su64)); }
259
+
260
+ // On rows, remove top and bottom margins
261
+ .gsx {
262
+ &,
263
+ > .d-flex,
264
+ > [class*="flex--item"] {
265
+ margin-top: 0;
266
+ margin-bottom: 0;
267
+ }
268
+ }
269
+
270
+ // On columns, remove left and right margins
271
+ .gsy {
272
+ &,
273
+ > .d-flex,
274
+ > [class*="flex--item"] {
275
+ margin-right: 0;
276
+ margin-left: 0;
277
+ }
278
+ }
279
+ //
280
+ // DEPRECATED - END
281
+
282
+
283
+ // ============================================================================
284
+ // $ ATOMIC CLASSES
285
+ // ----------------------------------------------------------------------------
286
+ // -- FLEX DIRECTION
287
+ // This determines the direction content flows within a parent container.
288
+ // The default values are row.
289
+ // ----------------------------------------------------------------------------
290
+ #stacks-internals #responsify('.fd-row', { flex-direction: row !important; });
291
+ #stacks-internals #responsify('.fd-row-reverse', { flex-direction: row-reverse !important; });
292
+ #stacks-internals #responsify('.fd-column', { flex-direction: column !important; });
293
+ #stacks-internals #responsify('.fd-column-reverse', { flex-direction: column-reverse !important; });
294
+
295
+ // -- FLEX WRAP
296
+ // This determines if a parent's child items will wrap or not.
297
+ // ----------------------------------------------------------------------------
298
+ #stacks-internals #responsify('.fw-wrap', { flex-wrap: wrap !important; });
299
+ #stacks-internals #responsify('.fw-reverse', { flex-wrap: wrap-reverse !important; });
300
+ #stacks-internals #responsify('.fw-nowrap', { flex-wrap: nowrap !important; });
301
+
302
+ // -- JUSTIFY CONTENT
303
+ // Defines the child alignment along the parent's main axis
304
+ // ----------------------------------------------------------------------------
305
+ #stacks-internals #responsify('.jc-center', { justify-content: center !important; });
306
+ #stacks-internals #responsify('.jc-end', { justify-content: flex-end !important; });
307
+ #stacks-internals #responsify('.jc-space-around', { justify-content: space-around !important; });
308
+ #stacks-internals #responsify('.jc-space-between', { justify-content: space-between !important; });
309
+ #stacks-internals #responsify('.jc-space-evenly', { justify-content: space-evenly !important; });
310
+ #stacks-internals #responsify('.jc-start', { justify-content: flex-start !important; });
311
+
312
+ // -- ALIGN CONTENT
313
+ // Aligns the container's lines when there is extra space in the
314
+ // cross-axis. Note that this only works when a parent container
315
+ // has more than one line.
316
+ // ----------------------------------------------------------------------------
317
+ .ac-center { align-content: center !important; }
318
+ .ac-end { align-content: flex-end !important; }
319
+ .ac-space-around { align-content: space-around !important; }
320
+ .ac-space-between { align-content: space-between !important; }
321
+ .ac-start { align-content: flex-start !important; }
322
+ .ac-stretch { align-content: stretch !important; }
323
+
324
+ // -- ALIGN ITEMS
325
+ // Defines the default behavior for how child items align along
326
+ // the parent's cross axis. Think of it the cross-axis for
327
+ // justify-content.
328
+ // ----------------------------------------------------------------------------
329
+ #stacks-internals #build-classes(
330
+ responsive,
331
+ '.ai',
332
+ {
333
+ .template(@value) when (@value=start), (@value=end) { align-items: ~"flex-@{value}" !important; }
334
+ .template(@value) when (default()) { align-items: @value !important; };
335
+ },
336
+ baseline center end start stretch
337
+ );
338
+
339
+ // -- CENTER ITEMS
340
+ // A common combination of classes is .jc-center and .ai-center.
341
+ // Use this class when you want both.
342
+ // ----------------------------------------------------------------------------
343
+ .flex__center {
344
+ .jc-center;
345
+ .ai-center;
346
+ }
347
+
348
+ // -- ALIGN SELF
349
+ // Allows child containers to re-align themselves regardless
350
+ // of the parent's main axis direction.
351
+ // ----------------------------------------------------------------------------
352
+ #stacks-internals #build-classes(
353
+ responsive,
354
+ '.as',
355
+ {
356
+ .template(@value) when (@value=start), (@value=end) { align-self: ~"flex-@{value}" !important; }
357
+ .template(@value) when (default()) { align-self: @value !important; };
358
+ },
359
+ auto baseline center end start stretch
360
+ );
361
+
362
+ // -- FLEX
363
+ // Graduating scale of flex-grow and flex-shrink values
364
+ // ----------------------------------------------------------------------------
365
+ #stacks-internals #responsify('.fl-grow1', { flex-grow: 1 !important; });
366
+ #stacks-internals #responsify('.fl-grow0', { flex-grow: 0 !important; });
367
+ #stacks-internals #responsify('.fl-shrink1', { flex-shrink: 1 !important; });
368
+ #stacks-internals #responsify('.fl-shrink0', { flex-shrink: 0 !important; });
369
+ #stacks-internals #responsify('.fl-none', { flex: none !important; });
370
+ #stacks-internals #responsify('.fl-initial', { flex: 0 1 auto !important; });
371
+ #stacks-internals #responsify('.fl-auto', { flex: 1 1 auto !important; });
372
+ #stacks-internals #responsify('.fl-equal', { flex: 1 1 0% !important; });
373
+
374
+ // -- Ordering
375
+ // Designate a child container's position.
376
+ // ----------------------------------------------------------------------------
377
+ #stacks-internals #responsify('.order-first', { order: -1 !important; });
378
+ #stacks-internals #responsify('.order-last', { order: 1 !important; });
379
+
380
+
381
+ // ============================================================================
382
+ // $ DEPRECATED CLASSES
383
+ // ----------------------------------------------------------------------------
384
+
385
+ // -- FLEX FLOW
386
+ // This is another shorthand property for flex-direction and flex-wrap.
387
+ // Default value is "row nowrap".
388
+ // ----------------------------------------------------------------------------
389
+ .ff-row-wrap { flex-flow: row wrap !important; }
390
+ .ff-row-nowrap { flex-flow: row nowrap !important; }
391
+ .ff-row-reverse-wrap { flex-flow: row-reverse wrap !important; }
392
+ .ff-row-reverse-nowrap { flex-flow: row-reverse nowrap !important; }
393
+ .ff-column-wrap { flex-flow: column wrap !important; }
394
+ .ff-column-nowrap { flex-flow: column nowrap !important; }
395
+ .ff-column-reverse-wrap { flex-flow: column-reverse wrap !important; }
396
+ .ff-column-reverse-nowrap { flex-flow: column-reverse nowrap !important; }
397
+
398
+ // -- FLEX
399
+ // Graduating scale of flex-grow and flex-shrink values
400
+ // ----------------------------------------------------------------------------
401
+ #stacks-internals #responsify('.fl0', { flex: 0 auto !important; });
402
+ #stacks-internals #responsify('.fl1', { flex: 1 auto !important; });
403
+ .fl2 { flex: 2 auto !important; }
404
+ .fl3 { flex: 3 auto !important; }
405
+ .fl4 { flex: 4 auto !important; }
406
+ .fl5 { flex: 5 auto !important; }
407
+
408
+ // -- FLEX SHRINK
409
+ // Specifies the flex-shrink factor, which states how much an item will
410
+ // shrink relative to other flex items in the container when there isn't
411
+ // enough space in the row. Default value is 1.
412
+ // ----------------------------------------------------------------------------
413
+ .fl-shrink2 { flex-shrink: 2; }
414
+ .fl-shrink3 { flex-shrink: 3; }
415
+ .fl-shrink4 { flex-shrink: 4; }
416
+ .fl-shrink5 { flex-shrink: 5; }
417
+
418
+ // -- FLEX GROW
419
+ // Specifies the flex-shrink grow, which states how much an item will
420
+ // grow relative to other flex items in the container when there isn't
421
+ // enough space in the row. Default value is 1.
422
+ // ----------------------------------------------------------------------------
423
+ .fl-grow2 { flex-grow: 2; }
424
+ .fl-grow3 { flex-grow: 3; }
425
+ .fl-grow4 { flex-grow: 4; }
426
+ .fl-grow5 { flex-grow: 5; }