@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,336 @@
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:meta';
9
+ @use "sass:math";
10
+
11
+ @use 'config' as *;
12
+ @use 'breakpoint' as *;
13
+
14
+ // -----------------------------------------------------------------------------
15
+ // Columns
16
+ // -----------------------------------------------------------------------------
17
+
18
+ /// Used to initialize the default properties for a column class, most notably
19
+ /// for setting width and default gutters when a column's breakpoint has not been
20
+ /// hit yet.
21
+ /// @param {Number} $gutter [$grid-gutter] - The gutter for the grid system
22
+ /// @param {Number} $collapsed-gutter [$grid-gutter--condensed] - The condensed mode gutter
23
+ /// @access private
24
+ /// @group @carbon/grid
25
+ @mixin -make-col-ready(
26
+ $gutter: $grid-gutter,
27
+ $condensed-gutter: $grid-gutter--condensed
28
+ ) {
29
+ // Prevent columns from becoming too narrow when at smaller grid tiers by
30
+ // always setting `width: 100%;`. This works because we use `flex` values
31
+ // later on to override this initial width.
32
+ width: 100%;
33
+ padding-right: ($gutter * 0.5);
34
+ padding-left: ($gutter * 0.5);
35
+
36
+ // For our condensed use-case, our gutters collapse to 2px solid, 1px on each
37
+ // side.
38
+ .#{$prefix}--row--condensed &,
39
+ .#{$prefix}--grid--condensed & {
40
+ padding-right: ($condensed-gutter * 0.5);
41
+ padding-left: ($condensed-gutter * 0.5);
42
+ }
43
+
44
+ // For our narrow use-case, our container hangs 16px into the gutter
45
+ .#{$prefix}--row--narrow &,
46
+ .#{$prefix}--grid--narrow & {
47
+ padding-right: ($gutter * 0.5);
48
+ padding-left: 0;
49
+ }
50
+ }
51
+
52
+ /// Define the width of the column for a given span and column count.
53
+ /// A width of 0 will hide the column entirely.
54
+ /// @param {Number} $span - The number of columns covered
55
+ /// @param {Number} $columns - The total number of columns available
56
+ /// @access private
57
+ /// @group @carbon/grid
58
+ @mixin -make-col($span, $columns) {
59
+ @if $span == 0 {
60
+ display: none;
61
+ } @else {
62
+ // Explicitly include `display: block` to override
63
+ display: block;
64
+ // Add a `max-width` to ensure content within each column does not blow out
65
+ // the width of the column. Applies to IE10+ and Firefox. Chrome and Safari
66
+ // do not appear to require this.
67
+ @if meta.function-exists('div', 'math') {
68
+ max-width: math.percentage(math.div($span, $columns));
69
+ flex: 0 0 math.percentage(math.div($span, $columns));
70
+ } @else {
71
+ max-width: math.percentage(($span / $columns));
72
+ flex: 0 0 math.percentage(($span / $columns));
73
+ }
74
+ }
75
+ }
76
+
77
+ /// Create a column offset for a given span and column count.
78
+ /// @param {Number} $span - The number of columns the offset should cover
79
+ /// @param {Number} $columns - The total number of columns available
80
+ /// @access private
81
+ /// @group @carbon/grid
82
+ @mixin -make-col-offset($span, $columns) {
83
+ $offset: 0;
84
+ @if meta.function-exists('div', 'math') {
85
+ $offset: math.div($span, $columns);
86
+ } @else {
87
+ $offset: ($span / $columns);
88
+ }
89
+ @if $offset == 0 {
90
+ margin-left: 0;
91
+ } @else {
92
+ margin-left: math.percentage($offset);
93
+ }
94
+ }
95
+
96
+ /// Output the CSS required for all the columns in a given grid system.
97
+ /// @param {Map} $breakpoints [$grid-breakpoints] - The breakpoints in the grid system
98
+ /// @param {Number} $gutter [$grid-gutter] - The gutter for the grid system
99
+ /// @access private
100
+ /// @group @carbon/grid
101
+ @mixin -make-grid-columns(
102
+ $breakpoints: $grid-breakpoints,
103
+ $gutter: $grid-gutter
104
+ ) {
105
+ .#{$prefix}--col {
106
+ @include -make-col-ready($gutter);
107
+ }
108
+
109
+ @each $breakpoint in map-keys($breakpoints) {
110
+ $infix: breakpoint-infix($breakpoint);
111
+ $columns: map.get(map.get($breakpoints, $breakpoint), columns);
112
+
113
+ // Allow columns to stretch full width below their breakpoints
114
+ @for $i from 0 through $columns {
115
+ .#{$prefix}--col#{$infix}-#{$i} {
116
+ @include -make-col-ready($gutter);
117
+ }
118
+ }
119
+
120
+ .#{$prefix}--col#{$infix},
121
+ .#{$prefix}--col#{$infix}--auto {
122
+ @include -make-col-ready($gutter);
123
+ }
124
+
125
+ @include breakpoint($breakpoint, $breakpoints) {
126
+ // Provide basic `.col-{bp}` classes for equal-width flexbox columns
127
+ .#{$prefix}--col,
128
+ .#{$prefix}--col#{$infix} {
129
+ max-width: 100%;
130
+ flex-basis: 0;
131
+ flex-grow: 1;
132
+ }
133
+
134
+ .#{$prefix}--col--auto,
135
+ .#{$prefix}--col#{$infix}--auto {
136
+ width: auto;
137
+ // Reset earlier grid tiers
138
+ max-width: 100%;
139
+ flex: 1 0 0%;
140
+ }
141
+
142
+ @for $i from 0 through $columns {
143
+ .#{$prefix}--col#{$infix}-#{$i} {
144
+ @include -make-col($i, $columns);
145
+ }
146
+ }
147
+
148
+ @for $i from 0 through ($columns - 1) {
149
+ @if not($infix == '') {
150
+ .#{$prefix}--offset#{$infix}-#{$i} {
151
+ @include -make-col-offset($i, $columns);
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
158
+
159
+ // -----------------------------------------------------------------------------
160
+ // Rows
161
+ // -----------------------------------------------------------------------------
162
+
163
+ /// Define the properties for a selector assigned to a row in the grid system.
164
+ /// @param {Number} $gutter [$grid-gutter] - The gutter in the grid system
165
+ /// @access private
166
+ /// @group @carbon/grid
167
+ @mixin make-row($gutter: $grid-gutter) {
168
+ display: flex;
169
+ flex-wrap: wrap;
170
+ margin-right: -1 * $gutter * 0.5;
171
+ margin-left: -1 * $gutter * 0.5;
172
+ }
173
+
174
+ // -----------------------------------------------------------------------------
175
+ // No gutter
176
+ // -----------------------------------------------------------------------------
177
+
178
+ /// Add `no-gutter` and `no-gutter--{start,end}` classes to the output CSS. These
179
+ /// classes are useful for dropping the gutter in fluid situations.
180
+ /// @access private
181
+ /// @group @carbon/grid
182
+ @mixin -no-gutter {
183
+ .#{$prefix}--no-gutter,
184
+ .#{$prefix}--row.#{$prefix}--no-gutter [class*='#{$prefix}--col'] {
185
+ padding-right: 0;
186
+ padding-left: 0;
187
+ }
188
+
189
+ .#{$prefix}--no-gutter--start,
190
+ .#{$prefix}--row.#{$prefix}--no-gutter--start [class*='#{$prefix}--col'] {
191
+ padding-left: 0;
192
+ }
193
+
194
+ .#{$prefix}--no-gutter--end,
195
+ .#{$prefix}--row.#{$prefix}--no-gutter--end [class*='#{$prefix}--col'] {
196
+ padding-right: 0;
197
+ }
198
+
199
+ // Deprecated ☠️
200
+ .#{$prefix}--no-gutter--left,
201
+ .#{$prefix}--row.#{$prefix}--no-gutter--left [class*='#{$prefix}--col'] {
202
+ padding-left: 0;
203
+ }
204
+
205
+ .#{$prefix}--no-gutter--right,
206
+ .#{$prefix}--row.#{$prefix}--no-gutter--right [class*='#{$prefix}--col'] {
207
+ padding-right: 0;
208
+ }
209
+ }
210
+
211
+ // -----------------------------------------------------------------------------
212
+ // Hang
213
+ // -----------------------------------------------------------------------------
214
+
215
+ /// Add `hang--start` and `hang--end` classes for a given gutter. These classes are
216
+ /// used alongside `no-gutter--start` and `no-gutter--end` to "hang" type.
217
+ /// @param {Number} $gutter [$grid-gutter] - The gutter in the grid system
218
+ /// @access private
219
+ /// @group @carbon/grid
220
+ @mixin -hang($gutter: $grid-gutter) {
221
+ .#{$prefix}--hang--start {
222
+ padding-left: ($gutter * 0.5);
223
+ }
224
+
225
+ .#{$prefix}--hang--end {
226
+ padding-right: ($gutter * 0.5);
227
+ }
228
+
229
+ // Deprecated ☠️
230
+ .#{$prefix}--hang--left {
231
+ padding-left: ($gutter * 0.5);
232
+ }
233
+
234
+ .#{$prefix}--hang--right {
235
+ padding-right: ($gutter * 0.5);
236
+ }
237
+ }
238
+
239
+ // -----------------------------------------------------------------------------
240
+ // Grid
241
+ // -----------------------------------------------------------------------------
242
+
243
+ /// Create the container for a grid. Will cause full-bleed for the grid unless
244
+ /// max-width properties are added with `-make-container-max-widths`
245
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
246
+ /// @access private
247
+ /// @group @carbon/grid
248
+ @mixin -make-container($breakpoints: $grid-breakpoints) {
249
+ margin-right: auto;
250
+ margin-left: auto;
251
+
252
+ @include -set-largest-breakpoint();
253
+
254
+ @each $name, $value in $breakpoints {
255
+ $prev-breakpoint: map.get($breakpoints, breakpoint-prev($name));
256
+ $margin: map.get($value, margin);
257
+
258
+ @if $prev-breakpoint {
259
+ $prev-margin: map.get($prev-breakpoint, margin);
260
+ @if $prev-margin != $margin {
261
+ @include breakpoint($name) {
262
+ padding-right: #{($grid-gutter * 0.5) + $margin};
263
+ padding-left: #{($grid-gutter * 0.5) + $margin};
264
+ }
265
+ }
266
+ } @else {
267
+ @include breakpoint($name) {
268
+ padding-right: #{($grid-gutter * 0.5) + $margin};
269
+ padding-left: #{($grid-gutter * 0.5) + $margin};
270
+ }
271
+ }
272
+ }
273
+ }
274
+
275
+ /// Get the last breakpoint width and set max-width to its value
276
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
277
+ /// @access private
278
+ /// @group @carbon/grid
279
+ @mixin -set-largest-breakpoint($breakpoints: $grid-breakpoints) {
280
+ $largest-breakpoint: last-map-item($breakpoints);
281
+
282
+ max-width: map.get($largest-breakpoint, 'width');
283
+ }
284
+
285
+ /// Add in the max-widths for each breakpoint to the container
286
+ /// @param {Map} $breakpoints [$grid-breakpoints] - A map of breakpoints where the key is the name
287
+ /// @access private
288
+ /// @group @carbon/grid
289
+ @mixin -make-container-max-widths($breakpoints: $grid-breakpoints) {
290
+ @each $name, $value in $breakpoints {
291
+ @include breakpoint($name) {
292
+ max-width: map.get($value, width);
293
+ }
294
+ }
295
+ }
296
+
297
+ /// Generate the CSS for a grid for the given breakpoints and gutters
298
+ /// @param {Map} $breakpoints [$grid-breakpoints] - The default breakpoints
299
+ /// @param {Number} $grid-gutter [$grid-gutter] - The default gutters
300
+ /// @param {Number} $condensed-gutter [$grid-gutter--condensed] - The condensed mode gutter
301
+ /// @access public
302
+ /// @group @carbon/grid
303
+ @mixin grid(
304
+ $breakpoints: $grid-breakpoints,
305
+ $grid-gutter: $grid-gutter,
306
+ $condensed-gutter: $grid-gutter--condensed
307
+ ) {
308
+ .#{$prefix}--grid {
309
+ @include -make-container($breakpoints);
310
+ }
311
+
312
+ @include largest-breakpoint($breakpoints) {
313
+ .#{$prefix}--grid--full-width {
314
+ max-width: 100%;
315
+ }
316
+ }
317
+
318
+ .#{$prefix}--row {
319
+ @include make-row();
320
+ }
321
+
322
+ .#{$prefix}--row-padding [class*='#{$prefix}--col'],
323
+ .#{$prefix}--col-padding {
324
+ padding-top: $grid-gutter * 0.5;
325
+ padding-bottom: $grid-gutter * 0.5;
326
+ }
327
+
328
+ .#{$prefix}--grid--condensed [class*='#{$prefix}--col'] {
329
+ padding-top: $condensed-gutter * 0.5;
330
+ padding-bottom: $condensed-gutter * 0.5;
331
+ }
332
+
333
+ @include -make-grid-columns($breakpoints, $grid-gutter);
334
+ @include -no-gutter();
335
+ @include -hang($grid-gutter);
336
+ }
@@ -0,0 +1,27 @@
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
+ /// Used by `exports` mixin to track which modules have been imported
9
+ /// @type Map
10
+ /// @access public
11
+ /// @group @carbon/import-once
12
+ $imported-modules: () !default;
13
+
14
+ /// Module export mixin that helps making sure a module is imported once and only once
15
+ /// @access public
16
+ /// @param {String} $name - Name of exported module
17
+ /// @param {Bool} $warn [false] - Warn when a module has been already imported
18
+ /// @content Declaration blocks to be imported
19
+ /// @group @carbon/import-once
20
+ @mixin exports($name, $warn: false) {
21
+ @if not(index($imported-modules, $name)) {
22
+ $imported-modules: append($imported-modules, $name) !global;
23
+ @content;
24
+ } @else if $warn == true {
25
+ @warn 'Module `#{$name}` has already been imported.';
26
+ }
27
+ }
@@ -0,0 +1,8 @@
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
+ @import 'import-once';
@@ -21,8 +21,8 @@
21
21
 
22
22
  @use 'sass:meta';
23
23
  @use "sass:math";
24
- @import 'breakpoint'; /* stylelint-disable-line no-invalid-position-at-import-rule */
25
- @import 'utilities'; /* stylelint-disable-line no-invalid-position-at-import-rule */
24
+ @import 'breakpoint';
25
+ @import 'utilities';
26
26
 
27
27
  /// Get the column width for a given breakpoint
28
28
  /// @param {String} $breakpoint
@@ -14,7 +14,7 @@
14
14
  /// @group @carbon/layout
15
15
  @function map-deep-get($map, $keys...) {
16
16
  @each $key in $keys {
17
- $map: map-get($map, $key);
17
+ $map: map.get($map, $key);
18
18
  }
19
19
  @return $map;
20
20
  }
@@ -26,7 +26,7 @@
26
26
  /// @return {String} Desired value
27
27
  /// @group @carbon/layout
28
28
  @function key-by-index($map, $index) {
29
- $keys: map-keys($map);
29
+ $keys: map.keys($map);
30
30
  @return nth($keys, $index);
31
31
  }
32
32
 
@@ -36,6 +36,6 @@
36
36
  /// @return {*} Desired value
37
37
  /// @group @carbon/layout
38
38
  @function last-map-item($map) {
39
- $total-length: length($map);
39
+ $total-length: list.length($map);
40
40
  @return map-get($map, carbon--key-by-index($map, $total-length));
41
41
  }
@@ -18,7 +18,7 @@ $imported-modules: () !default;
18
18
  /// @content Declaration blocks to be imported
19
19
  /// @group @carbon/import-once
20
20
  @mixin exports($name, $warn: false) {
21
- @if (index($imported-modules, $name) == null) {
21
+ @if not(index($imported-modules, $name)) {
22
22
  $imported-modules: append($imported-modules, $name) !global;
23
23
  @content;
24
24
  } @else if $warn == true {