@carbon/type 10.40.0 → 10.42.0-rc.0

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 (51) hide show
  1. package/es/index.js +73 -2
  2. package/lib/index.js +169 -98
  3. package/package.json +5 -5
  4. package/scss/_inlined/_reset.scss +1 -1
  5. package/scss/_inlined/_scale.scss +1 -1
  6. package/scss/_inlined/_styles.import.scss +3 -3
  7. package/scss/_inlined/_styles.scss +1 -1
  8. package/scss/_styles.import.scss +3 -3
  9. package/scss/modules/_font-family.scss +13 -11
  10. package/scss/modules/_scale.scss +2 -1
  11. package/scss/modules/_styles.scss +9 -12
  12. package/scss/vendor/@carbon/grid/12.scss +41 -0
  13. package/scss/vendor/@carbon/grid/_inlined/12.scss +41 -0
  14. package/scss/vendor/@carbon/grid/_inlined/_mixins.import.scss +431 -0
  15. package/scss/vendor/@carbon/grid/_inlined/_mixins.scss +415 -0
  16. package/scss/vendor/@carbon/grid/_inlined/_prefix.scss +12 -0
  17. package/scss/vendor/@carbon/grid/_mixins.import.scss +431 -0
  18. package/scss/vendor/@carbon/grid/_mixins.scss +415 -0
  19. package/scss/vendor/@carbon/grid/_prefix.scss +12 -0
  20. package/scss/vendor/@carbon/grid/grid.scss +10 -0
  21. package/scss/vendor/@carbon/grid/index.scss +10 -0
  22. package/scss/vendor/@carbon/{layout → grid}/modules/_breakpoint.scss +36 -2
  23. package/scss/vendor/@carbon/grid/modules/_config.scss +18 -0
  24. package/scss/vendor/@carbon/grid/modules/_css-grid.scss +347 -0
  25. package/scss/vendor/@carbon/grid/modules/_flex-grid.scss +374 -0
  26. package/scss/vendor/@carbon/grid/modules/_mixins.scss +336 -0
  27. package/scss/vendor/@carbon/grid/vendor/@carbon/import-once/import-once.scss +27 -0
  28. package/scss/vendor/@carbon/grid/vendor/@carbon/import-once/index.scss +8 -0
  29. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/_breakpoint.scss +0 -0
  30. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/_convert.import.scss +0 -0
  31. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/_convert.scss +0 -0
  32. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/_key-height.import.scss +2 -2
  33. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/_key-height.scss +0 -0
  34. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/_mini-unit.scss +0 -0
  35. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/_spacing.scss +0 -0
  36. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/_utilities.scss +0 -0
  37. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/generated/_container.scss +0 -0
  38. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/generated/_fluid-spacing.scss +0 -0
  39. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/generated/_icon-size.scss +0 -0
  40. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/generated/_layout.scss +0 -0
  41. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/generated/_size.scss +0 -0
  42. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/generated/_spacing.scss +0 -0
  43. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/index.scss +0 -0
  44. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/layout.scss +0 -0
  45. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/modules/_convert.scss +0 -0
  46. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/modules/_spacing.scss +0 -0
  47. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/modules/_utilities.scss +3 -3
  48. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/modules/generated/_fluid-spacing.scss +0 -0
  49. package/scss/vendor/@carbon/{layout → grid/vendor/@carbon/layout}/modules/generated/_spacing.scss +0 -0
  50. package/scss/vendor/@carbon/import-once/import-once.scss +1 -1
  51. package/umd/index.js +173 -100
@@ -0,0 +1,347 @@
1
+ //
2
+ // Copyright IBM Corp. 2018, 2018
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ @use 'sass:list';
9
+ @use 'sass:map';
10
+ @use "sass:math";
11
+ @use 'sass:meta';
12
+ @use 'config' as *;
13
+ @use 'breakpoint' as *;
14
+
15
+ @mixin css-grid() {
16
+ display: grid;
17
+ max-width: 99rem;
18
+ padding-right: calc(var(--cds-grid-margin) + var(--cds-grid-gutter) / 2);
19
+ padding-left: calc(var(--cds-grid-margin) + var(--cds-grid-gutter) / 2);
20
+ margin-right: auto;
21
+ margin-left: auto;
22
+ column-gap: var(--cds-grid-gutter);
23
+ grid-template-columns: repeat(
24
+ var(--cds-grid-columns),
25
+ minmax(0, var(--cds-grid-column-size))
26
+ );
27
+ }
28
+
29
+ @mixin subgrid() {
30
+ display: grid;
31
+ column-gap: var(--cds-grid-gutter);
32
+ grid-template-columns: repeat(
33
+ var(--cds-grid-columns),
34
+ minmax(0, var(--cds-grid-column-size))
35
+ );
36
+ }
37
+
38
+ :root {
39
+ --cds-grid-columns: 4;
40
+ --cds-grid-column-size: 1fr;
41
+ --cds-grid-gutter: 2rem;
42
+ // Used to configure appropriate margins for condensed subgrids inside wide grids
43
+ --cds-grid-gutter-wide: 2rem;
44
+ --cds-grid-hang: 1rem;
45
+ --cds-grid-margin: 0;
46
+
47
+ @include breakpoint(md) {
48
+ --cds-grid-columns: 8;
49
+ --cds-grid-margin: 1rem;
50
+ }
51
+
52
+ @include breakpoint(lg) {
53
+ --cds-grid-columns: 16;
54
+ }
55
+
56
+ @include breakpoint(max) {
57
+ --cds-grid-margin: 1.5rem;
58
+ }
59
+ }
60
+
61
+ .#{$prefix}--css-grid {
62
+ @include css-grid();
63
+ }
64
+
65
+ .#{$prefix}--css-grid--12 {
66
+ @include css-grid();
67
+ @include breakpoint(lg) {
68
+ --cds-grid-columns: 12;
69
+ }
70
+ }
71
+
72
+ .#{$prefix}--subgrid {
73
+ @include subgrid();
74
+ }
75
+
76
+ .#{$prefix}--subgrid[class*='col'] {
77
+ display: grid;
78
+ }
79
+
80
+ // -----------------------------------------------------------------------------
81
+ // Condensed
82
+ // -----------------------------------------------------------------------------
83
+ .#{$prefix}--css-grid--condensed {
84
+ --cds-grid-gutter: 1px;
85
+
86
+ column-gap: var(--cds-grid-gutter);
87
+ row-gap: var(--cds-grid-gutter);
88
+ }
89
+
90
+ // condensed subgrid inside wide
91
+ .#{$prefix}--css-grid .bx--subgrid.#{$prefix}--css-grid--condensed {
92
+ margin-right: calc((var(--cds-grid-gutter-wide) / 2) * -1);
93
+ margin-left: calc((var(--cds-grid-gutter-wide) / 2) * -1);
94
+ }
95
+
96
+ // -----------------------------------------------------------------------------
97
+ // No Gutter
98
+ // -----------------------------------------------------------------------------
99
+ .#{$prefix}--css-grid--no-gutter {
100
+ // This is set to 0px (versus 0) so that the calc expression for padding for
101
+ // a grid container works as expected. Without the unit, the calc() will
102
+ // result in a value of 0.
103
+ // stylelint-disable-next-line length-zero-no-unit
104
+ --cds-grid-gutter: 0px;
105
+
106
+ column-gap: var(--cds-grid-gutter);
107
+ }
108
+
109
+ // -----------------------------------------------------------------------------
110
+ // Full width
111
+ // -----------------------------------------------------------------------------
112
+ .#{$prefix}--css-grid--full-width {
113
+ max-width: 100%;
114
+ }
115
+
116
+ // -----------------------------------------------------------------------------
117
+ // Column span
118
+ // -----------------------------------------------------------------------------
119
+ @mixin -column-span($i) {
120
+ @if $i == 0 {
121
+ display: none;
122
+ } @else {
123
+ --cds-grid-columns: #{$i};
124
+
125
+ display: block;
126
+ grid-column: span $i / span $i;
127
+ }
128
+ }
129
+
130
+ @for $i from 0 through 16 {
131
+ .#{$prefix}--col-span-#{$i} {
132
+ @include -column-span($i);
133
+ }
134
+ }
135
+
136
+ .#{$prefix}--col-span-auto {
137
+ grid-column: auto;
138
+ }
139
+
140
+ .#{$prefix}--col-span-100 {
141
+ grid-column: 1 / -1;
142
+ }
143
+
144
+ .#{$prefix}--col-span-25 {
145
+ --cds-grid-columns: 1;
146
+
147
+ grid-column: span 1;
148
+
149
+ @include breakpoint(md) {
150
+ --cds-grid-columns: 2;
151
+
152
+ grid-column: span 2;
153
+ }
154
+
155
+ @include breakpoint(lg) {
156
+ --cds-grid-columns: 4;
157
+
158
+ grid-column: span 4;
159
+ }
160
+ }
161
+
162
+ .#{$prefix}--col-span-50 {
163
+ --cds-grid-columns: 2;
164
+
165
+ grid-column: span 2;
166
+
167
+ @include breakpoint(md) {
168
+ --cds-grid-columns: 4;
169
+
170
+ grid-column: span 4;
171
+ }
172
+
173
+ @include breakpoint(lg) {
174
+ --cds-grid-columns: 8;
175
+
176
+ grid-column: span 8;
177
+ }
178
+ }
179
+
180
+ .#{$prefix}--col-span-75 {
181
+ --cds-grid-columns: 3;
182
+
183
+ grid-column: span 3;
184
+
185
+ @include breakpoint(md) {
186
+ --cds-grid-columns: 6;
187
+
188
+ grid-column: span 6;
189
+ }
190
+
191
+ @include breakpoint(lg) {
192
+ --cds-grid-columns: 12;
193
+
194
+ grid-column: span 12;
195
+ }
196
+ }
197
+
198
+ @each $name, $value in $grid-breakpoints {
199
+ $columns: map.get($value, columns);
200
+
201
+ @include breakpoint($name) {
202
+ @for $i from 0 through $columns {
203
+ .#{$prefix}--#{$name}\:col-span-#{$i} {
204
+ @include -column-span($i);
205
+ }
206
+ }
207
+
208
+ .#{$prefix}--#{$name}\:col-span-auto {
209
+ grid-column: auto;
210
+ }
211
+
212
+ .#{$prefix}--#{$name}\:col-span-100 {
213
+ grid-column: 1 / -1;
214
+ }
215
+
216
+ $quarterGridColumns: math.div($columns, 4);
217
+
218
+ .#{$prefix}--#{$name}\:col-span-75 {
219
+ $calc: $quarterGridColumns * 3;
220
+ --cds-grid-columns: #{$calc};
221
+
222
+ grid-column: span $calc / span $calc;
223
+ }
224
+
225
+ .#{$prefix}--#{$name}\:col-span-50 {
226
+ $calc: $quarterGridColumns * 2;
227
+ --cds-grid-columns: #{$calc};
228
+
229
+ grid-column: span $calc / span $calc;
230
+ }
231
+
232
+ .#{$prefix}--#{$name}\:col-span-25 {
233
+ --cds-grid-columns: #{$quarterGridColumns};
234
+
235
+ grid-column: span $quarterGridColumns / span $quarterGridColumns;
236
+ }
237
+ }
238
+ }
239
+
240
+ // -----------------------------------------------------------------------------
241
+ // Column offset
242
+ // -----------------------------------------------------------------------------
243
+ @for $i from 1 through 17 {
244
+ .#{$prefix}--col-start-#{$i} {
245
+ grid-column-start: $i;
246
+ }
247
+
248
+ .#{$prefix}--col-end-#{$i} {
249
+ grid-column-start: $i;
250
+ }
251
+ }
252
+
253
+ .#{$prefix}--col-start-auto {
254
+ grid-column-start: auto;
255
+ }
256
+
257
+ .#{$prefix}--col-end-auto {
258
+ grid-column-start: end;
259
+ }
260
+
261
+ @each $name, $value in $grid-breakpoints {
262
+ $columns: map.get($value, columns);
263
+
264
+ @include breakpoint($name) {
265
+ // The `grid-column-start` property is *not* inclusive.
266
+ // It starts the column *at* the column, not *on* the column. We must
267
+ // ensure that there is one additional class available for each breakpoint.
268
+ @for $i from 1 through $columns + 1 {
269
+ .#{$prefix}--#{$name}\:col-start-#{$i} {
270
+ grid-column-start: $i;
271
+ }
272
+
273
+ .#{$prefix}--#{$name}\:col-end-#{$i} {
274
+ grid-column-end: $i;
275
+ }
276
+ }
277
+
278
+ .#{$prefix}--#{$name}\:col-start-auto {
279
+ grid-column-start: auto;
280
+ }
281
+
282
+ .#{$prefix}--#{$name}\:col-end-auto {
283
+ grid-column-start: end;
284
+ }
285
+ }
286
+ }
287
+
288
+ // -----------------------------------------------------------------------------
289
+ // Hang
290
+ // -----------------------------------------------------------------------------
291
+ .#{$prefix}--hang {
292
+ padding-left: var(--cds-grid-hang);
293
+ }
294
+
295
+ // -----------------------------------------------------------------------------
296
+ // Column gutter
297
+ // -----------------------------------------------------------------------------
298
+ .#{$prefix}--gutter {
299
+ padding-right: var(--cds-grid-hang);
300
+ padding-left: var(--cds-grid-hang);
301
+ }
302
+
303
+ .#{$prefix}--gutter-start {
304
+ padding-left: var(--cds-grid-hang);
305
+ }
306
+
307
+ [dir='rtl'] .#{$prefix}--gutter-start {
308
+ padding-right: var(--cds-grid-hang);
309
+ }
310
+
311
+ .#{$prefix}--gutter-end {
312
+ padding-right: var(--cds-grid-hang);
313
+ }
314
+
315
+ [dir='rtl'] .#{$prefix}--gutter-end {
316
+ padding-left: var(--cds-grid-hang);
317
+ }
318
+
319
+ // -----------------------------------------------------------------------------
320
+ // Utilities
321
+ // -----------------------------------------------------------------------------
322
+
323
+ /// Justify items
324
+ .#{$prefix}--justify-items-start {
325
+ justify-items: start;
326
+ }
327
+
328
+ .#{$prefix}--justify-items-end {
329
+ justify-items: end;
330
+ }
331
+
332
+ .#{$prefix}--justify-items-center {
333
+ justify-items: center;
334
+ }
335
+
336
+ /// Align items
337
+ .#{$prefix}--align-items-start {
338
+ align-items: start;
339
+ }
340
+
341
+ .#{$prefix}--align-items-end {
342
+ align-items: end;
343
+ }
344
+
345
+ .#{$prefix}--align-items-center {
346
+ align-items: center;
347
+ }
@@ -0,0 +1,374 @@
1
+ //
2
+ // Copyright IBM Corp. 2018, 2018
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ // Helpers for defining columns, rows, and containers are heavily inspired by,
9
+ // and often derived from, bootstrap:
10
+ // https://github.com/twbs/bootstrap/blob/v4-dev/scss/mixins/_grid.scss
11
+
12
+ @use 'sass:meta';
13
+ @use 'sass:math';
14
+ @use 'sass:map';
15
+
16
+ @use 'config' as *;
17
+ @use 'breakpoint' as *;
18
+
19
+ // -----------------------------------------------------------------------------
20
+ // Columns
21
+ // -----------------------------------------------------------------------------
22
+
23
+ /// Used to initialize the default properties for a column class, most notably
24
+ /// for setting width and default gutters when a column's breakpoint has not been
25
+ /// hit yet.
26
+ /// @param {Number} $gutter [$grid-gutter] - The gutter for the grid system
27
+ /// @param {Number} $collapsed-gutter [$grid-gutter--condensed] - The condensed mode gutter
28
+ /// @access private
29
+ /// @group @carbon/grid
30
+ @mixin -make-col-ready(
31
+ $gutter: $grid-gutter,
32
+ $condensed-gutter: $grid-gutter--condensed
33
+ ) {
34
+ // Prevent columns from becoming too narrow when at smaller grid tiers by
35
+ // always setting `width: 100%;`. This works because we use `flex` values
36
+ // later on to override this initial width.
37
+ width: 100%;
38
+ padding-right: $gutter * 0.5;
39
+ padding-left: $gutter * 0.5;
40
+
41
+ // For our condensed use-case, our gutters collapse to 2px solid, 1px on each
42
+ // side.
43
+ .#{$prefix}--row--condensed &,
44
+ .#{$prefix}--grid--condensed & {
45
+ padding-right: $condensed-gutter * 0.5;
46
+ padding-left: $condensed-gutter * 0.5;
47
+ }
48
+
49
+ // For our narrow use-case, our container hangs 16px into the gutter
50
+ .#{$prefix}--row--narrow &,
51
+ .#{$prefix}--grid--narrow & {
52
+ padding-right: $gutter * 0.5;
53
+ padding-left: 0;
54
+ }
55
+ }
56
+
57
+ /// Define the width of the column for a given span and column count.
58
+ /// A width of 0 will hide the column entirely.
59
+ /// @param {Number} $span - The number of columns covered
60
+ /// @param {Number} $columns - The total number of columns available
61
+ /// @access private
62
+ /// @group @carbon/grid
63
+ @mixin -make-col($span, $columns) {
64
+ @if $span == 0 {
65
+ display: none;
66
+ } @else {
67
+ // Explicitly include `display: block` to override
68
+ display: block;
69
+ // Add a `max-width` to ensure content within each column does not blow out
70
+ // the width of the column. Applies to IE10+ and Firefox. Chrome and Safari
71
+ // do not appear to require this.
72
+ @if meta.function-exists('div', 'math') {
73
+ max-width: math.percentage(math.div($span, $columns));
74
+ flex: 0 0 math.percentage(math.div($span, $columns));
75
+ } @else {
76
+ max-width: math.percentage(($span / $columns));
77
+ flex: 0 0 math.percentage(($span / $columns));
78
+ }
79
+ }
80
+ }
81
+
82
+ /// Create a column offset for a given span and column count.
83
+ /// @param {Number} $span - The number of columns the offset should cover
84
+ /// @param {Number} $columns - The total number of columns available
85
+ /// @access private
86
+ /// @group @carbon/grid
87
+ @mixin -make-col-offset($span, $columns) {
88
+ $offset: 0;
89
+ @if meta.function-exists('div', 'math') {
90
+ $offset: math.div($span, $columns);
91
+ } @else {
92
+ $offset: ($span / $columns);
93
+ }
94
+ @if $offset == 0 {
95
+ margin-left: 0;
96
+ } @else {
97
+ margin-left: math.percentage($offset);
98
+ }
99
+ }
100
+
101
+ /// Output the CSS required for all the columns in a given grid system.
102
+ /// @param {Map} $breakpoints [$grid-breakpoints] - The breakpoints in the grid system
103
+ /// @param {Number} $gutter [$grid-gutter] - The gutter for the grid system
104
+ /// @access private
105
+ /// @group @carbon/grid
106
+ @mixin -make-grid-columns(
107
+ $breakpoints: $grid-breakpoints,
108
+ $gutter: $grid-gutter
109
+ ) {
110
+ .#{$prefix}--col {
111
+ @include -make-col-ready($gutter);
112
+ }
113
+
114
+ @each $breakpoint in map-keys($breakpoints) {
115
+ $infix: breakpoint-infix($breakpoint);
116
+ $columns: map.get(map.get($breakpoints, $breakpoint), columns);
117
+
118
+ // Allow columns to stretch full width below their breakpoints
119
+ @for $i from 0 through $columns {
120
+ .#{$prefix}--col#{$infix}-#{$i} {
121
+ @include -make-col-ready($gutter);
122
+ }
123
+ }
124
+
125
+ .#{$prefix}--col#{$infix},
126
+ .#{$prefix}--col#{$infix}--auto {
127
+ @include -make-col-ready($gutter);
128
+ }
129
+
130
+ @include breakpoint($breakpoint, $breakpoints) {
131
+ // Provide basic `.col-{bp}` classes for equal-width flexbox columns
132
+ .#{$prefix}--col,
133
+ .#{$prefix}--col#{$infix} {
134
+ max-width: 100%;
135
+ flex-basis: 0;
136
+ flex-grow: 1;
137
+ }
138
+
139
+ .#{$prefix}--col--auto,
140
+ .#{$prefix}--col#{$infix}--auto {
141
+ width: auto;
142
+ // Reset earlier grid tiers
143
+ max-width: 100%;
144
+ flex: 1 0 0%;
145
+ }
146
+
147
+ @for $i from 0 through $columns {
148
+ .#{$prefix}--col#{$infix}-#{$i} {
149
+ @include -make-col($i, $columns);
150
+ }
151
+ }
152
+
153
+ @for $i from 0 through ($columns - 1) {
154
+ @if not($infix == '') {
155
+ .#{$prefix}--offset#{$infix}-#{$i} {
156
+ @include -make-col-offset($i, $columns);
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }
163
+
164
+ // -----------------------------------------------------------------------------
165
+ // Rows
166
+ // -----------------------------------------------------------------------------
167
+
168
+ /// Define the properties for a selector assigned to a row in the grid system.
169
+ /// @param {Number} $gutter [$grid-gutter] - The gutter in the grid system
170
+ /// @access private
171
+ /// @group @carbon/grid
172
+ @mixin -make-row($gutter: $grid-gutter) {
173
+ display: flex;
174
+ flex-wrap: wrap;
175
+ margin-right: -1 * $gutter * 0.5;
176
+ margin-left: -1 * $gutter * 0.5;
177
+ }
178
+
179
+ // -----------------------------------------------------------------------------
180
+ // No gutter
181
+ // -----------------------------------------------------------------------------
182
+
183
+ /// Add `no-gutter` and `no-gutter--{start,end}` classes to the output CSS. These
184
+ /// classes are useful for dropping the gutter in fluid situations.
185
+ /// @access private
186
+ /// @group @carbon/grid
187
+ @mixin -no-gutter {
188
+ .#{$prefix}--no-gutter,
189
+ .#{$prefix}--row.#{$prefix}--no-gutter [class*='#{$prefix}--col'] {
190
+ padding-right: 0;
191
+ padding-left: 0;
192
+ }
193
+
194
+ .#{$prefix}--no-gutter--start,
195
+ .#{$prefix}--row.#{$prefix}--no-gutter--start [class*='#{$prefix}--col'] {
196
+ padding-left: 0;
197
+ }
198
+
199
+ .#{$prefix}--no-gutter--end,
200
+ .#{$prefix}--row.#{$prefix}--no-gutter--end [class*='#{$prefix}--col'] {
201
+ padding-right: 0;
202
+ }
203
+
204
+ // Deprecated ☠️
205
+ .#{$prefix}--no-gutter--left,
206
+ .#{$prefix}--row.#{$prefix}--no-gutter--left [class*='#{$prefix}--col'] {
207
+ padding-left: 0;
208
+ }
209
+
210
+ .#{$prefix}--no-gutter--right,
211
+ .#{$prefix}--row.#{$prefix}--no-gutter--right [class*='#{$prefix}--col'] {
212
+ padding-right: 0;
213
+ }
214
+ }
215
+
216
+ // -----------------------------------------------------------------------------
217
+ // Hang
218
+ // -----------------------------------------------------------------------------
219
+
220
+ /// Add `hang--start` and `hang--end` classes for a given gutter. These classes are
221
+ /// used alongside `no-gutter--start` and `no-gutter--end` to "hang" type.
222
+ /// @param {Number} $gutter [$grid-gutter] - The gutter in the grid system
223
+ /// @access private
224
+ /// @group @carbon/grid
225
+ @mixin -hang($gutter: $grid-gutter) {
226
+ .#{$prefix}--hang--start {
227
+ padding-left: $gutter * 0.5;
228
+ }
229
+
230
+ .#{$prefix}--hang--end {
231
+ padding-right: $gutter * 0.5;
232
+ }
233
+
234
+ // Deprecated ☠️
235
+ .#{$prefix}--hang--left {
236
+ padding-left: $gutter * 0.5;
237
+ }
238
+
239
+ .#{$prefix}--hang--right {
240
+ padding-right: $gutter * 0.5;
241
+ }
242
+ }
243
+
244
+ // -----------------------------------------------------------------------------
245
+ // Grid
246
+ // -----------------------------------------------------------------------------
247
+
248
+ /// Create the container for a grid. Will cause full-bleed for the grid unless
249
+ /// max-width properties are added with `make-container-max-widths`
250
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
251
+ /// @access private
252
+ /// @group @carbon/grid
253
+ @mixin -make-container($breakpoints: $grid-breakpoints) {
254
+ margin-right: auto;
255
+ margin-left: auto;
256
+
257
+ @include -set-largest-breakpoint();
258
+
259
+ @each $name, $value in $breakpoints {
260
+ $prev-breakpoint: map.get($breakpoints, breakpoint-prev($name));
261
+ $margin: map.get($value, margin);
262
+
263
+ @if $prev-breakpoint {
264
+ $prev-margin: map.get($prev-breakpoint, margin);
265
+ @if $prev-margin != $margin {
266
+ @include breakpoint($name) {
267
+ padding-right: #{($grid-gutter * 0.5) + $margin};
268
+ padding-left: #{($grid-gutter * 0.5) + $margin};
269
+ }
270
+ }
271
+ } @else {
272
+ @include breakpoint($name) {
273
+ padding-right: #{($grid-gutter * 0.5) + $margin};
274
+ padding-left: #{($grid-gutter * 0.5) + $margin};
275
+ }
276
+ }
277
+ }
278
+ }
279
+
280
+ /// Get the last breakpoint width and set max-width to its value
281
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
282
+ /// @access private
283
+ /// @group @carbon/grid
284
+ @mixin -set-largest-breakpoint($breakpoints: $grid-breakpoints) {
285
+ $largest-breakpoint: last-map-item($breakpoints);
286
+
287
+ max-width: map.get($largest-breakpoint, 'width');
288
+ }
289
+
290
+ /// Add in the max-widths for each breakpoint to the container
291
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
292
+ /// @access private
293
+ /// @group @carbon/grid
294
+ @mixin -make-container-max-widths($breakpoints: $grid-breakpoints) {
295
+ @each $name, $value in $breakpoints {
296
+ @include breakpoint($name) {
297
+ max-width: map.get($value, width);
298
+ }
299
+ }
300
+ }
301
+
302
+ /// Generate the CSS for a grid for the given breakpoints and gutters
303
+ /// @param {Map} $breakpoints [$grid-breakpoints] - The default breakpoints
304
+ /// @param {Number} $grid-gutter [$grid-gutter] - The default gutters
305
+ /// @param {Number} $condensed-gutter [$grid-gutter--condensed] - The condensed mode gutter
306
+ /// @access public
307
+ /// @group @carbon/grid
308
+ @mixin flex-grid(
309
+ $breakpoints: $grid-breakpoints,
310
+ $grid-gutter: $grid-gutter,
311
+ $condensed-gutter: $grid-gutter--condensed
312
+ ) {
313
+ .#{$prefix}--grid {
314
+ @include -make-container($breakpoints);
315
+ }
316
+
317
+ @include largest-breakpoint($breakpoints) {
318
+ .#{$prefix}--grid--full-width {
319
+ max-width: 100%;
320
+ }
321
+ }
322
+
323
+ .#{$prefix}--row {
324
+ @include -make-row();
325
+ }
326
+
327
+ .#{$prefix}--row-padding [class*='#{$prefix}--col'],
328
+ .#{$prefix}--col-padding {
329
+ padding-top: $grid-gutter * 0.5;
330
+ padding-bottom: $grid-gutter * 0.5;
331
+ }
332
+
333
+ .#{$prefix}--grid--condensed [class*='#{$prefix}--col'] {
334
+ padding-top: $condensed-gutter * 0.5;
335
+ padding-bottom: $condensed-gutter * 0.5;
336
+ }
337
+
338
+ @include -make-grid-columns($breakpoints, $grid-gutter);
339
+ @include -no-gutter();
340
+ @include -hang($grid-gutter);
341
+ }
342
+
343
+ @if $flex-grid-columns == 12 {
344
+ $flex-12-column-grid: map.merge(
345
+ $grid-breakpoints,
346
+ (
347
+ lg:
348
+ map.merge(
349
+ map.get($grid-breakpoints, lg),
350
+ (
351
+ columns: 12,
352
+ )
353
+ ),
354
+ xlg:
355
+ map.merge(
356
+ map.get($grid-breakpoints, xlg),
357
+ (
358
+ columns: 12,
359
+ )
360
+ ),
361
+ max:
362
+ map.merge(
363
+ map.get($grid-breakpoints, max),
364
+ (
365
+ columns: 12,
366
+ )
367
+ ),
368
+ )
369
+ );
370
+
371
+ @include flex-grid($breakpoints: $flex-12-column-grid);
372
+ } @else {
373
+ @include flex-grid();
374
+ }