@carbon/type 10.41.0 → 10.43.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 +7 -11
  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 +11 -45
  23. package/scss/vendor/@carbon/grid/modules/_config.scss +94 -0
  24. package/scss/vendor/@carbon/grid/modules/_css-grid.scss +470 -0
  25. package/scss/vendor/@carbon/grid/modules/_flex-grid.scss +363 -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,431 @@
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
+ // Compatibility notes (*.import.scss)
9
+ // ------------------------------------------
10
+ //
11
+ // This file is intended to be consumed and processed with dart-sass.
12
+ // It is incompatible with node-sass/libsass as it contains sass language features
13
+ // or functions that are unavailable in node-sass/libsass, such as `math.div`.
14
+ //
15
+ // The non-`.import` suffixed version of this file eg. `_filename.scss`
16
+ // is intended to be compatible with node-sass/libsass.
17
+ //
18
+ // Styles authored within this file must be duplicated to the corresponding
19
+ // compatibility file to ensure we continue to support node-sass and dart-sass
20
+ // in v10.
21
+
22
+ // Helpers for defining columns, rows, and containers are heavily inspired by,
23
+ // and often derived from, bootstrap:
24
+ // https://github.com/twbs/bootstrap/blob/v4-dev/scss/mixins/_grid.scss
25
+
26
+ @use 'sass:meta';
27
+ @use 'sass:math';
28
+ @import '../vendor/@carbon/layout/breakpoint';
29
+ @import 'prefix';
30
+
31
+ // -----------------------------------------------------------------------------
32
+ // Columns
33
+ // -----------------------------------------------------------------------------
34
+
35
+ /// Used to initialize the default properties for a column class, most notably
36
+ /// for setting width and default gutters when a column's breakpoint has not been
37
+ /// hit yet.
38
+ /// @param {Number} $gutter [$carbon--grid-gutter] - The gutter for the grid system
39
+ /// @param {Number} $collapsed-gutter [$carbon--grid-gutter--condensed] - The condensed mode gutter
40
+ /// @access private
41
+ /// @group @carbon/grid
42
+ @mixin carbon--make-col-ready(
43
+ $gutter: $carbon--grid-gutter,
44
+ $condensed-gutter: $carbon--grid-gutter--condensed
45
+ ) {
46
+ // Prevent columns from becoming too narrow when at smaller grid tiers by
47
+ // always setting `width: 100%;`. This works because we use `flex` values
48
+ // later on to override this initial width.
49
+ width: 100%;
50
+ padding-right: $gutter * 0.5;
51
+ padding-left: $gutter * 0.5;
52
+
53
+ // For our condensed use-case, our gutters collapse to 2px solid, 1px on each
54
+ // side.
55
+ .#{$prefix}--row--condensed &,
56
+ .#{$prefix}--grid--condensed & {
57
+ padding-right: $condensed-gutter * 0.5;
58
+ padding-left: $condensed-gutter * 0.5;
59
+ }
60
+
61
+ // For our narrow use-case, our container hangs 16px into the gutter
62
+ .#{$prefix}--row--narrow &,
63
+ .#{$prefix}--grid--narrow & {
64
+ padding-right: $gutter * 0.5;
65
+ padding-left: 0;
66
+ }
67
+ }
68
+
69
+ /// Define the width of the column for a given span and column count.
70
+ /// A width of 0 will hide the column entirely.
71
+ /// @param {Number} $span - The number of columns covered
72
+ /// @param {Number} $columns - The total number of columns available
73
+ /// @access private
74
+ /// @group @carbon/grid
75
+ @mixin carbon--make-col($span, $columns) {
76
+ @if $span == 0 {
77
+ display: none;
78
+ } @else {
79
+ // Explicitly include `display: block` to override
80
+ display: block;
81
+ // Add a `max-width` to ensure content within each column does not blow out
82
+ // the width of the column. Applies to IE10+ and Firefox. Chrome and Safari
83
+ // do not appear to require this.
84
+ @if meta.function-exists('div', 'math') {
85
+ max-width: percentage(math.div($span, $columns));
86
+ flex: 0 0 percentage(math.div($span, $columns));
87
+ } @else {
88
+ max-width: percentage(($span / $columns));
89
+ flex: 0 0 percentage(($span / $columns));
90
+ }
91
+ }
92
+ }
93
+
94
+ /// Create a column offset for a given span and column count.
95
+ /// @param {Number} $span - The number of columns the offset should cover
96
+ /// @param {Number} $columns - The total number of columns available
97
+ /// @access private
98
+ /// @group @carbon/grid
99
+ @mixin carbon--make-col-offset($span, $columns) {
100
+ $offset: 0;
101
+ @if meta.function-exists('div', 'math') {
102
+ $offset: math.div($span, $columns);
103
+ } @else {
104
+ $offset: ($span / $columns);
105
+ }
106
+ @if $offset == 0 {
107
+ margin-left: 0;
108
+ } @else {
109
+ margin-left: percentage($offset);
110
+ }
111
+ }
112
+
113
+ /// Output the CSS required for all the columns in a given grid system.
114
+ /// @param {Map} $breakpoints [$carbon--grid-breakpoints] - The breakpoints in the grid system
115
+ /// @param {Number} $gutter [$carbon--grid-gutter] - The gutter for the grid system
116
+ /// @access private
117
+ /// @group @carbon/grid
118
+ @mixin carbon--make-grid-columns(
119
+ $breakpoints: $carbon--grid-breakpoints,
120
+ $gutter: $carbon--grid-gutter
121
+ ) {
122
+ .#{$prefix}--col {
123
+ @include carbon--make-col-ready($gutter);
124
+ }
125
+
126
+ @each $breakpoint in map-keys($breakpoints) {
127
+ $infix: carbon--breakpoint-infix($breakpoint);
128
+ $columns: map-get(map-get($breakpoints, $breakpoint), columns);
129
+
130
+ // Allow columns to stretch full width below their breakpoints
131
+ @for $i from 0 through $columns {
132
+ .#{$prefix}--col#{$infix}-#{$i} {
133
+ @include carbon--make-col-ready($gutter);
134
+ }
135
+ }
136
+
137
+ .#{$prefix}--col#{$infix},
138
+ .#{$prefix}--col#{$infix}--auto {
139
+ @include carbon--make-col-ready($gutter);
140
+ }
141
+
142
+ @include carbon--breakpoint($breakpoint, $breakpoints) {
143
+ // Provide basic `.col-{bp}` classes for equal-width flexbox columns
144
+ .#{$prefix}--col,
145
+ .#{$prefix}--col#{$infix} {
146
+ max-width: 100%;
147
+ flex-basis: 0;
148
+ flex-grow: 1;
149
+ }
150
+
151
+ .#{$prefix}--col--auto,
152
+ .#{$prefix}--col#{$infix}--auto {
153
+ width: auto;
154
+ // Reset earlier grid tiers
155
+ max-width: 100%;
156
+ flex: 1 0 0%;
157
+ }
158
+
159
+ @for $i from 0 through $columns {
160
+ .#{$prefix}--col#{$infix}-#{$i} {
161
+ @include carbon--make-col($i, $columns);
162
+ }
163
+ }
164
+
165
+ @for $i from 0 through ($columns - 1) {
166
+ @if not($infix == '') {
167
+ .#{$prefix}--offset#{$infix}-#{$i} {
168
+ @include carbon--make-col-offset($i, $columns);
169
+ }
170
+ }
171
+ }
172
+ }
173
+ }
174
+ }
175
+
176
+ // -----------------------------------------------------------------------------
177
+ // Rows
178
+ // -----------------------------------------------------------------------------
179
+
180
+ /// Define the properties for a selector assigned to a row in the grid system.
181
+ /// @param {Number} $gutter [$carbon--grid-gutter] - The gutter in the grid system
182
+ /// @access private
183
+ /// @group @carbon/grid
184
+ @mixin carbon--make-row($gutter: $carbon--grid-gutter) {
185
+ display: flex;
186
+ flex-wrap: wrap;
187
+ margin-right: -1 * $gutter * 0.5;
188
+ margin-left: -1 * $gutter * 0.5;
189
+ }
190
+
191
+ // -----------------------------------------------------------------------------
192
+ // No gutter
193
+ // -----------------------------------------------------------------------------
194
+
195
+ /// Add `no-gutter` and `no-gutter--{start,end}` classes to the output CSS. These
196
+ /// classes are useful for dropping the gutter in fluid situations.
197
+ /// @access private
198
+ /// @group @carbon/grid
199
+ @mixin carbon--no-gutter {
200
+ .#{$prefix}--no-gutter,
201
+ .#{$prefix}--row.#{$prefix}--no-gutter [class*='#{$prefix}--col'] {
202
+ padding-right: 0;
203
+ padding-left: 0;
204
+ }
205
+
206
+ .#{$prefix}--no-gutter--start,
207
+ .#{$prefix}--row.#{$prefix}--no-gutter--start [class*='#{$prefix}--col'] {
208
+ padding-left: 0;
209
+ }
210
+
211
+ .#{$prefix}--no-gutter--end,
212
+ .#{$prefix}--row.#{$prefix}--no-gutter--end [class*='#{$prefix}--col'] {
213
+ padding-right: 0;
214
+ }
215
+
216
+ // Deprecated ☠️
217
+ .#{$prefix}--no-gutter--left,
218
+ .#{$prefix}--row.#{$prefix}--no-gutter--left [class*='#{$prefix}--col'] {
219
+ padding-left: 0;
220
+ }
221
+
222
+ .#{$prefix}--no-gutter--right,
223
+ .#{$prefix}--row.#{$prefix}--no-gutter--right [class*='#{$prefix}--col'] {
224
+ padding-right: 0;
225
+ }
226
+ }
227
+
228
+ // -----------------------------------------------------------------------------
229
+ // Hang
230
+ // -----------------------------------------------------------------------------
231
+
232
+ /// Add `hang--start` and `hang--end` classes for a given gutter. These classes are
233
+ /// used alongside `no-gutter--start` and `no-gutter--end` to "hang" type.
234
+ /// @param {Number} $gutter [$carbon--grid-gutter] - The gutter in the grid system
235
+ /// @access private
236
+ /// @group @carbon/grid
237
+ @mixin carbon--hang($gutter: $carbon--grid-gutter) {
238
+ .#{$prefix}--hang--start {
239
+ padding-left: $gutter * 0.5;
240
+ }
241
+
242
+ .#{$prefix}--hang--end {
243
+ padding-right: $gutter * 0.5;
244
+ }
245
+
246
+ // Deprecated ☠️
247
+ .#{$prefix}--hang--left {
248
+ padding-left: $gutter * 0.5;
249
+ }
250
+
251
+ .#{$prefix}--hang--right {
252
+ padding-right: $gutter * 0.5;
253
+ }
254
+ }
255
+
256
+ // -----------------------------------------------------------------------------
257
+ // Aspect ratio
258
+ // -----------------------------------------------------------------------------
259
+
260
+ /// The aspect ratios that are used to generate corresponding aspect ratio
261
+ /// classes in code
262
+ /// @type List
263
+ /// @access public
264
+ /// @group @carbon/grid
265
+ $carbon--aspect-ratios: (
266
+ (16, 9),
267
+ (9, 16),
268
+ (2, 1),
269
+ (1, 2),
270
+ (4, 3),
271
+ (3, 4),
272
+ (3, 2),
273
+ (2, 3),
274
+ (1, 1)
275
+ );
276
+
277
+ /// Generates the CSS classname utilities for the aspect ratios
278
+ ///
279
+ /// CSS Tricks article on aspect ratios and all the different ways it can be done.
280
+ /// https://css-tricks.com/aspect-ratio-boxes/#article-header-id-6
281
+ ///
282
+ /// That article references an earlier article on the topic.
283
+ /// https://keithjgrant.com/posts/2017/03/aspect-ratios/
284
+ ///
285
+ /// @param {Number} $width width from an aspect ratio
286
+ /// @param {Number} $height height from an aspect ratio
287
+ /// @access private
288
+ /// @group @carbon/grid
289
+ @mixin carbon--aspect-ratio($aspect-ratios: $carbon--aspect-ratios) {
290
+ .#{$prefix}--aspect-ratio {
291
+ position: relative;
292
+ }
293
+
294
+ .#{$prefix}--aspect-ratio::before {
295
+ width: 1px;
296
+ height: 0;
297
+ margin-left: -1px;
298
+ content: '';
299
+ float: left;
300
+ }
301
+
302
+ .#{$prefix}--aspect-ratio::after {
303
+ display: table;
304
+ clear: both;
305
+ content: '';
306
+ }
307
+
308
+ @each $aspect-ratio in $aspect-ratios {
309
+ $width: nth($aspect-ratio, 1);
310
+ $height: nth($aspect-ratio, 2);
311
+
312
+ .#{$prefix}--aspect-ratio--#{$width}x#{$height}::before {
313
+ @if meta.function-exists('div', 'math') {
314
+ padding-top: percentage(math.div($height, $width));
315
+ } @else {
316
+ padding-top: percentage(($height / $width));
317
+ }
318
+ }
319
+ }
320
+
321
+ // leaving here for legacy support
322
+ .#{$prefix}--aspect-ratio--object {
323
+ position: absolute;
324
+ top: 0;
325
+ left: 0;
326
+ width: 100%;
327
+ height: 100%;
328
+ }
329
+ }
330
+
331
+ // -----------------------------------------------------------------------------
332
+ // Grid
333
+ // -----------------------------------------------------------------------------
334
+
335
+ /// Create the container for a grid. Will cause full-bleed for the grid unless
336
+ /// max-width properties are added with `make-container-max-widths`
337
+ /// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
338
+ /// @access private
339
+ /// @group @carbon/grid
340
+ @mixin carbon--make-container($breakpoints: $carbon--grid-breakpoints) {
341
+ margin-right: auto;
342
+ margin-left: auto;
343
+
344
+ @include carbon--set-largest-breakpoint();
345
+
346
+ @each $name, $value in $breakpoints {
347
+ $prev-breakpoint: map-get($breakpoints, carbon--breakpoint-prev($name));
348
+ $margin: map-get($value, margin);
349
+
350
+ @if $prev-breakpoint {
351
+ $prev-margin: map-get($prev-breakpoint, margin);
352
+ @if $prev-margin != $margin {
353
+ @include carbon--breakpoint($name) {
354
+ padding-right: #{($carbon--grid-gutter * 0.5) + $margin};
355
+ padding-left: #{($carbon--grid-gutter * 0.5) + $margin};
356
+ }
357
+ }
358
+ } @else {
359
+ @include carbon--breakpoint($name) {
360
+ padding-right: #{($carbon--grid-gutter * 0.5) + $margin};
361
+ padding-left: #{($carbon--grid-gutter * 0.5) + $margin};
362
+ }
363
+ }
364
+ }
365
+ }
366
+
367
+ /// Get the last breakpoint width and set max-width to its value
368
+ /// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
369
+ /// @access private
370
+ /// @group @carbon/grid
371
+ @mixin carbon--set-largest-breakpoint($breakpoints: $carbon--grid-breakpoints) {
372
+ $largest-breakpoint: last-map-item($breakpoints);
373
+
374
+ max-width: map-get($largest-breakpoint, 'width');
375
+ }
376
+
377
+ /// Add in the max-widths for each breakpoint to the container
378
+ /// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
379
+ /// @access private
380
+ /// @group @carbon/grid
381
+ @mixin carbon--make-container-max-widths(
382
+ $breakpoints: $carbon--grid-breakpoints
383
+ ) {
384
+ @each $name, $value in $breakpoints {
385
+ @include carbon--breakpoint($name) {
386
+ max-width: map-get($value, width);
387
+ }
388
+ }
389
+ }
390
+
391
+ /// Generate the CSS for a grid for the given breakpoints and gutters
392
+ /// @param {Map} $breakpoints [$carbon--grid-breakpoints] - The default breakpoints
393
+ /// @param {Number} $grid-gutter [$carbon--grid-gutter] - The default gutters
394
+ /// @param {Number} $condensed-gutter [$carbon--grid-gutter--condensed] - The condensed mode gutter
395
+ /// @access public
396
+ /// @group @carbon/grid
397
+ @mixin carbon--grid(
398
+ $breakpoints: $carbon--grid-breakpoints,
399
+ $grid-gutter: $carbon--grid-gutter,
400
+ $condensed-gutter: $carbon--grid-gutter--condensed
401
+ ) {
402
+ .#{$prefix}--grid {
403
+ @include carbon--make-container($breakpoints);
404
+ }
405
+
406
+ @include carbon--largest-breakpoint($breakpoints) {
407
+ .#{$prefix}--grid--full-width {
408
+ max-width: 100%;
409
+ }
410
+ }
411
+
412
+ .#{$prefix}--row {
413
+ @include carbon--make-row();
414
+ }
415
+
416
+ .#{$prefix}--row-padding [class*='#{$prefix}--col'],
417
+ .#{$prefix}--col-padding {
418
+ padding-top: $grid-gutter * 0.5;
419
+ padding-bottom: $grid-gutter * 0.5;
420
+ }
421
+
422
+ .#{$prefix}--grid--condensed [class*='#{$prefix}--col'] {
423
+ padding-top: $condensed-gutter * 0.5;
424
+ padding-bottom: $condensed-gutter * 0.5;
425
+ }
426
+
427
+ @include carbon--make-grid-columns($breakpoints, $grid-gutter);
428
+ @include carbon--no-gutter();
429
+ @include carbon--hang($grid-gutter);
430
+ @include carbon--aspect-ratio();
431
+ }