@carbon/grid 10.42.0 → 11.0.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 (45) hide show
  1. package/index.scss +4 -7
  2. package/package.json +4 -5
  3. package/scss/{modules/_breakpoint.scss → _breakpoint.scss} +4 -72
  4. package/scss/_config.scss +94 -0
  5. package/scss/_css-grid.scss +470 -0
  6. package/scss/{modules/_flex-grid.scss → _flex-grid.scss} +28 -59
  7. package/scss/_inlined/_breakpoint.scss +198 -0
  8. package/scss/_inlined/_config.scss +94 -0
  9. package/scss/_inlined/_css-grid.scss +470 -0
  10. package/scss/{modules/_mixins.scss → _inlined/_flex-grid.scss} +45 -38
  11. package/scss/_inlined/_mixins.scss +89 -188
  12. package/scss/_mixins.scss +89 -188
  13. package/scss/vendor/@carbon/layout/_convert.import.scss +2 -4
  14. package/scss/vendor/@carbon/layout/_convert.scss +18 -23
  15. package/scss/vendor/@carbon/layout/_spacing.scss +2 -5
  16. package/scss/vendor/@carbon/layout/_utilities.scss +4 -4
  17. package/scss/vendor/@carbon/layout/generated/_container.scss +13 -43
  18. package/scss/vendor/@carbon/layout/generated/_fluid-spacing.scss +11 -35
  19. package/scss/vendor/@carbon/layout/generated/_icon-size.scss +8 -17
  20. package/scss/vendor/@carbon/layout/generated/_size.scss +1 -1
  21. package/scss/vendor/@carbon/layout/generated/_spacing.scss +29 -107
  22. package/scss/vendor/@carbon/layout/modules/_convert.scss +2 -4
  23. package/scss/12.scss +0 -41
  24. package/scss/_inlined/12.scss +0 -41
  25. package/scss/_inlined/_mixins.import.scss +0 -431
  26. package/scss/_inlined/_prefix.scss +0 -12
  27. package/scss/_mixins.import.scss +0 -431
  28. package/scss/_prefix.scss +0 -12
  29. package/scss/grid.scss +0 -10
  30. package/scss/index.scss +0 -10
  31. package/scss/modules/_config.scss +0 -18
  32. package/scss/modules/_css-grid.scss +0 -347
  33. package/scss/vendor/@carbon/import-once/import-once.scss +0 -27
  34. package/scss/vendor/@carbon/import-once/index.scss +0 -8
  35. package/scss/vendor/@carbon/layout/_breakpoint.scss +0 -246
  36. package/scss/vendor/@carbon/layout/_key-height.import.scss +0 -117
  37. package/scss/vendor/@carbon/layout/_key-height.scss +0 -111
  38. package/scss/vendor/@carbon/layout/_mini-unit.scss +0 -23
  39. package/scss/vendor/@carbon/layout/generated/_layout.scss +0 -97
  40. package/scss/vendor/@carbon/layout/index.scss +0 -8
  41. package/scss/vendor/@carbon/layout/layout.scss +0 -12
  42. package/scss/vendor/@carbon/layout/modules/_spacing.scss +0 -9
  43. package/scss/vendor/@carbon/layout/modules/_utilities.scss +0 -41
  44. package/scss/vendor/@carbon/layout/modules/generated/_fluid-spacing.scss +0 -37
  45. package/scss/vendor/@carbon/layout/modules/generated/_spacing.scss +0 -91
@@ -9,6 +9,7 @@
9
9
  // and often derived from, bootstrap:
10
10
  // https://github.com/twbs/bootstrap/blob/v4-dev/scss/mixins/_grid.scss
11
11
 
12
+ @use 'sass:list';
12
13
  @use 'sass:meta';
13
14
  @use 'sass:math';
14
15
  @use 'sass:map';
@@ -24,12 +25,12 @@
24
25
  /// for setting width and default gutters when a column's breakpoint has not been
25
26
  /// hit yet.
26
27
  /// @param {Number} $gutter [$grid-gutter] - The gutter for the grid system
27
- /// @param {Number} $collapsed-gutter [$grid-gutter--condensed] - The condensed mode gutter
28
+ /// @param {Number} $collapsed-gutter [$grid-gutter-condensed] - The condensed mode gutter
28
29
  /// @access private
29
30
  /// @group @carbon/grid
30
31
  @mixin -make-col-ready(
31
32
  $gutter: $grid-gutter,
32
- $condensed-gutter: $grid-gutter--condensed
33
+ $condensed-gutter: $grid-gutter-condensed
33
34
  ) {
34
35
  // Prevent columns from becoming too narrow when at smaller grid tiers by
35
36
  // always setting `width: 100%;`. This works because we use `flex` values
@@ -200,17 +201,6 @@
200
201
  .#{$prefix}--row.#{$prefix}--no-gutter--end [class*='#{$prefix}--col'] {
201
202
  padding-right: 0;
202
203
  }
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
204
  }
215
205
 
216
206
  // -----------------------------------------------------------------------------
@@ -230,15 +220,6 @@
230
220
  .#{$prefix}--hang--end {
231
221
  padding-right: $gutter * 0.5;
232
222
  }
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
223
  }
243
224
 
244
225
  // -----------------------------------------------------------------------------
@@ -254,7 +235,7 @@
254
235
  margin-right: auto;
255
236
  margin-left: auto;
256
237
 
257
- @include -set-largest-breakpoint();
238
+ @include -set-largest-breakpoint($breakpoints);
258
239
 
259
240
  @each $name, $value in $breakpoints {
260
241
  $prev-breakpoint: map.get($breakpoints, breakpoint-prev($name));
@@ -282,7 +263,7 @@
282
263
  /// @access private
283
264
  /// @group @carbon/grid
284
265
  @mixin -set-largest-breakpoint($breakpoints: $grid-breakpoints) {
285
- $largest-breakpoint: last-map-item($breakpoints);
266
+ $largest-breakpoint: -last-map-item($breakpoints);
286
267
 
287
268
  max-width: map.get($largest-breakpoint, 'width');
288
269
  }
@@ -299,16 +280,37 @@
299
280
  }
300
281
  }
301
282
 
283
+ /// Pass in a map, and get the last one in the list back
284
+ /// @access public
285
+ /// @param {Map} $map - Map
286
+ /// @return {*} Desired value
287
+ /// @group @carbon/layout
288
+ @function -last-map-item($map) {
289
+ $total-length: list.length($map);
290
+ @return map-get($map, -key-by-index($map, $total-length));
291
+ }
292
+
293
+ /// Provide a map and index, and get back the relevant key value
294
+ /// @access public
295
+ /// @param {Map} $map - Map
296
+ /// @param {Integer} $index - Key chain
297
+ /// @return {String} Desired value
298
+ /// @group @carbon/layout
299
+ @function -key-by-index($map, $index) {
300
+ $keys: map.keys($map);
301
+ @return nth($keys, $index);
302
+ }
303
+
302
304
  /// Generate the CSS for a grid for the given breakpoints and gutters
303
305
  /// @param {Map} $breakpoints [$grid-breakpoints] - The default breakpoints
304
306
  /// @param {Number} $grid-gutter [$grid-gutter] - The default gutters
305
- /// @param {Number} $condensed-gutter [$grid-gutter--condensed] - The condensed mode gutter
307
+ /// @param {Number} $condensed-gutter [$grid-gutter-condensed] - The condensed mode gutter
306
308
  /// @access public
307
309
  /// @group @carbon/grid
308
310
  @mixin flex-grid(
309
311
  $breakpoints: $grid-breakpoints,
310
312
  $grid-gutter: $grid-gutter,
311
- $condensed-gutter: $grid-gutter--condensed
313
+ $condensed-gutter: $grid-gutter-condensed
312
314
  ) {
313
315
  .#{$prefix}--grid {
314
316
  @include -make-container($breakpoints);
@@ -339,36 +341,3 @@
339
341
  @include -no-gutter();
340
342
  @include -hang($grid-gutter);
341
343
  }
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
- }
@@ -0,0 +1,198 @@
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:meta';
11
+ @use '@carbon/layout/scss/convert';
12
+ @use 'config' as *;
13
+
14
+ /// Provide a map and index, and get back the relevant key value
15
+ /// @access public
16
+ /// @param {Map} $map - Map
17
+ /// @param {Integer} $index - Key chain
18
+ /// @return {String} Desired value
19
+ /// @group @carbon/layout
20
+ @function -key-by-index($map, $index) {
21
+ $keys: map.keys($map);
22
+ @return nth($keys, $index);
23
+ }
24
+
25
+ /// Get the value of the next breakpoint, or null for the last breakpoint
26
+ /// @param {String} $name - The name of the breakpoint
27
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name of the breakpoint and the value is the values for the breakpoint
28
+ /// @param {List} $breakpoint-names [map-keys($breakpoints)] - A list of names from the `$breakpoints` map
29
+ /// @return {String}
30
+ /// @access public
31
+ /// @group @carbon/layout
32
+ @function breakpoint-next(
33
+ $name,
34
+ $breakpoints: $grid-breakpoints,
35
+ $breakpoint-names: map.keys($breakpoints)
36
+ ) {
37
+ $n: list.index($breakpoint-names, $name);
38
+ @if $n != null and $n < list.length($breakpoint-names) {
39
+ @return list.nth($breakpoint-names, $n + 1);
40
+ }
41
+ @return null;
42
+ }
43
+
44
+ /// Get the value of the previous breakpoint, or null for the first breakpoint
45
+ /// @param {String} $name - The name of the breakpoint
46
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name of the breakpoint and the value is the values for the breakpoint
47
+ /// @param {List} $breakpoint-names [map-keys($breakpoints)] - A list of names from the `$breakpoints` map
48
+ /// @return {String}
49
+ /// @access public
50
+ /// @group @carbon/layout
51
+ @function breakpoint-prev(
52
+ $name,
53
+ $breakpoints: $grid-breakpoints,
54
+ $breakpoint-names: map.keys($breakpoints)
55
+ ) {
56
+ $n: list.index($breakpoint-names, $name);
57
+ @if $n != null and $n > 1 {
58
+ @return list.nth($breakpoint-names, $n - 1);
59
+ }
60
+ @return null;
61
+ }
62
+
63
+ /// Check to see if the given breakpoint name
64
+ /// @param {String} $name - The name of the breakpoint
65
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name of the breakpoint and the value is the values for the breakpoint
66
+ /// @return {Bool}
67
+ /// @access public
68
+ /// @group @carbon/layout
69
+ @function is-smallest-breakpoint($name, $breakpoints: $grid-breakpoints) {
70
+ @return list.index(map.keys($breakpoints), $name) == 1;
71
+ }
72
+
73
+ /// Returns the largest breakpoint name
74
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
75
+ /// @return {String}
76
+ /// @access public
77
+ /// @group @carbon/layout
78
+ @function largest-breakpoint-name($breakpoints: $grid-breakpoints) {
79
+ $total-breakpoints: list.length($breakpoints);
80
+ @return -key-by-index($breakpoints, $total-breakpoints);
81
+ }
82
+
83
+ /// Get the infix for a given breakpoint in a list of breakpoints. Useful for generating the size part in a selector, for example: `.prefix--col-sm-2`.
84
+ /// @param {String} $name - The name of the breakpoint
85
+ /// @return {String}
86
+ /// @access public
87
+ /// @group @carbon/layout
88
+ @function breakpoint-infix($name) {
89
+ @return '-#{$name}';
90
+ }
91
+
92
+ /// Generate a media query from the width of the given breakpoint to infinity
93
+ /// @param {String | Number} $name
94
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
95
+ /// @content
96
+ /// @access public
97
+ /// @group @carbon/layout
98
+ @mixin breakpoint-up($name, $breakpoints: $grid-breakpoints) {
99
+ @if meta.type-of($name) == 'number' {
100
+ @media (min-width: $name) {
101
+ @content;
102
+ }
103
+ } @else if map.has-key($breakpoints, $name) {
104
+ $breakpoint: map.get($breakpoints, $name);
105
+ $width: map.get($breakpoint, width);
106
+ @if is-smallest-breakpoint($name, $breakpoints) {
107
+ @content;
108
+ } @else {
109
+ @media (min-width: $width) {
110
+ @content;
111
+ }
112
+ }
113
+ } @else {
114
+ @error 'Unable to find a breakpoint with name `#{$name}`. Expected one of: (#{map.keys($breakpoints)})';
115
+ }
116
+ }
117
+
118
+ /// Generate a media query for the maximum width of the given styles
119
+ /// @param {String | Number} $name
120
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
121
+ /// @content
122
+ /// @access public
123
+ /// @group @carbon/layout
124
+ @mixin breakpoint-down($name, $breakpoints: $grid-breakpoints) {
125
+ @if meta.type-of($name) == 'number' {
126
+ @media (max-width: $name) {
127
+ @content;
128
+ }
129
+ } @else if map.has-key($breakpoints, $name) {
130
+ // We borrow this logic from bootstrap for specifying the value of the
131
+ // max-width. The maximum width is calculated by finding the breakpoint and
132
+ // subtracting .02 from its value. This value is used instead of .01 to
133
+ // avoid rounding issues in Safari
134
+ // https://github.com/twbs/bootstrap/blob/c5b1919deaf5393fcca9e9b9d7ce9c338160d99d/scss/mixins/_breakpoints.scss#L34-L46
135
+ $breakpoint: map.get($breakpoints, $name);
136
+ $width: map.get($breakpoint, width) - 0.02;
137
+ @media (max-width: $width) {
138
+ @content;
139
+ }
140
+ } @else {
141
+ @error 'Unable to find a breakpoint with name `#{$name}`. Expected one of: (#{map.keys($breakpoints)})';
142
+ }
143
+ }
144
+
145
+ /// Generate a media query for the range between the lower and upper breakpoints
146
+ /// @param {String | Number} $lower
147
+ /// @param {String | Number} $upper
148
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
149
+ /// @content
150
+ /// @access public
151
+ /// @group @carbon/layout
152
+ @mixin breakpoint-between($lower, $upper, $breakpoints: $grid-breakpoints) {
153
+ $is-number-lower: meta.type-of($lower) == 'number';
154
+ $is-number-upper: meta.type-of($upper) == 'number';
155
+ $min: if($is-number-lower, $lower, map.get($breakpoints, $lower));
156
+ $max: if($is-number-upper, $upper, map.get($breakpoints, $upper));
157
+
158
+ @if $min and $max {
159
+ $min-width: if(not $is-number-lower and $min, map.get($min, width), $min);
160
+ $max-width: if(not $is-number-upper and $max, map.get($max, width), $max);
161
+ @media (min-width: $min-width) and (max-width: $max-width) {
162
+ @content;
163
+ }
164
+ } @else if $min != null and $max == null {
165
+ @include breakpoint-up($lower) {
166
+ @content;
167
+ }
168
+ } @else if $min == null and $max != null {
169
+ @include breakpoint-down($upper) {
170
+ @content;
171
+ }
172
+ } @else {
173
+ @error 'Unable to find a breakpoint to satisfy: (#{$lower},#{$upper}). Expected both to be one of (#{map.keys($breakpoints)}).';
174
+ }
175
+ }
176
+
177
+ /// Generate media query for the largest breakpoint
178
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
179
+ /// @content
180
+ /// @access public
181
+ /// @group @carbon/layout
182
+ @mixin largest-breakpoint($breakpoints: $grid-breakpoints) {
183
+ @include breakpoint(largest-breakpoint-name()) {
184
+ @content;
185
+ }
186
+ }
187
+
188
+ /// Generate a media query for a given breakpoint
189
+ /// @param {String | Number} $name
190
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
191
+ /// @content
192
+ /// @access public
193
+ /// @group @carbon/layout
194
+ @mixin breakpoint($name, $breakpoints: $grid-breakpoints) {
195
+ @include breakpoint-up($name, $breakpoints) {
196
+ @content;
197
+ }
198
+ }
@@ -0,0 +1,94 @@
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:map';
9
+ @use '@carbon/layout/scss/convert';
10
+
11
+ /// Namespace prefix
12
+ /// @type String
13
+ /// @access public
14
+ /// @group @carbon/grid
15
+ $prefix: 'cds' !default;
16
+
17
+ /// Total columns used in the flex grid
18
+ /// @type Number
19
+ /// @access public
20
+ /// @group @carbon/grid
21
+ $flex-grid-columns: 16 !default;
22
+
23
+ /// Carbon gutter size in rem
24
+ /// @type Number
25
+ /// @access public
26
+ /// @group @carbon/layout
27
+ $grid-gutter: convert.rem(32px) !default;
28
+
29
+ /// Carbon condensed gutter size in rem
30
+ /// @type Number
31
+ /// @access public
32
+ /// @group @carbon/layout
33
+ $grid-gutter-condensed: convert.rem(1px) !default;
34
+
35
+ // Initial map of our breakpoints and their values
36
+ /// @type Map
37
+ /// @access public
38
+ /// @group @carbon/layout
39
+ $grid-breakpoints: (
40
+ sm: (
41
+ columns: 4,
42
+ margin: 0,
43
+ width: convert.rem(320px),
44
+ ),
45
+ md: (
46
+ columns: 8,
47
+ margin: convert.rem(16px),
48
+ width: convert.rem(672px),
49
+ ),
50
+ lg: (
51
+ columns: 16,
52
+ margin: convert.rem(16px),
53
+ width: convert.rem(1056px),
54
+ ),
55
+ xlg: (
56
+ columns: 16,
57
+ margin: convert.rem(16px),
58
+ width: convert.rem(1312px),
59
+ ),
60
+ max: (
61
+ columns: 16,
62
+ margin: convert.rem(24px),
63
+ width: convert.rem(1584px),
64
+ ),
65
+ ) !default;
66
+
67
+ @if $flex-grid-columns == 12 {
68
+ $grid-breakpoints: map.merge(
69
+ $grid-breakpoints,
70
+ (
71
+ lg:
72
+ map.merge(
73
+ map.get($grid-breakpoints, lg),
74
+ (
75
+ columns: 12,
76
+ )
77
+ ),
78
+ xlg:
79
+ map.merge(
80
+ map.get($grid-breakpoints, xlg),
81
+ (
82
+ columns: 12,
83
+ )
84
+ ),
85
+ max:
86
+ map.merge(
87
+ map.get($grid-breakpoints, max),
88
+ (
89
+ columns: 12,
90
+ )
91
+ ),
92
+ )
93
+ );
94
+ }