@carbon/type 10.0.0-rc.0 → 10.2.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 (44) hide show
  1. package/CHANGELOG.md +525 -0
  2. package/LICENSE +2 -2
  3. package/README.md +25 -21
  4. package/es/index.js +26 -38
  5. package/lib/index.js +31 -37
  6. package/package.json +7 -7
  7. package/scss/_classes.scss +3 -0
  8. package/scss/_font-family.scss +17 -4
  9. package/scss/_inlined/_classes.scss +41 -0
  10. package/scss/_inlined/_font-family.scss +70 -0
  11. package/scss/_inlined/_prefix.scss +11 -0
  12. package/scss/_inlined/_reset.scss +43 -0
  13. package/scss/_inlined/_scale.scss +59 -0
  14. package/scss/_inlined/_styles.scss +673 -0
  15. package/scss/_inlined/font-face/_mono.scss +430 -0
  16. package/scss/_inlined/font-face/_sans.scss +497 -0
  17. package/scss/_inlined/font-face/_serif.scss +430 -0
  18. package/scss/_inlined/font-face/_settings.scss +12 -0
  19. package/scss/_prefix.scss +3 -0
  20. package/scss/_reset.scss +20 -7
  21. package/scss/_scale.scss +16 -5
  22. package/scss/_styles.scss +145 -49
  23. package/scss/font-face/_mono.scss +41 -0
  24. package/scss/font-face/_sans.scss +144 -36
  25. package/scss/font-face/_serif.scss +77 -36
  26. package/scss/font-face/_settings.scss +12 -0
  27. package/scss/index.scss +11 -0
  28. package/scss/type.scss +4 -4
  29. package/scss/vendor/@carbon/import-once/import-once.scss +27 -0
  30. package/scss/vendor/@carbon/import-once/index.scss +8 -0
  31. package/scss/vendor/@carbon/layout/_breakpoint.scss +237 -0
  32. package/scss/vendor/@carbon/layout/_convert.scss +30 -0
  33. package/scss/vendor/@carbon/layout/_key-height.scss +97 -0
  34. package/scss/vendor/@carbon/layout/_mini-unit.scss +23 -0
  35. package/scss/vendor/@carbon/layout/_spacing.scss +328 -0
  36. package/scss/vendor/@carbon/layout/_utilities.scss +41 -0
  37. package/scss/vendor/@carbon/layout/index.scss +8 -0
  38. package/scss/vendor/@carbon/layout/layout.scss +12 -0
  39. package/src/__tests__/__snapshots__/styles-test.js.snap +121 -87
  40. package/src/__tests__/exports-test.js +43 -37
  41. package/src/__tests__/fluid-test.js +0 -1
  42. package/src/reset.js +3 -0
  43. package/src/styles.js +22 -38
  44. package/umd/index.js +31 -37
package/scss/_styles.scss CHANGED
@@ -6,123 +6,192 @@
6
6
  //
7
7
 
8
8
  @import '@carbon/layout/scss/breakpoint';
9
- @import 'font-family';
10
9
  @import 'scale';
11
10
 
11
+ /// @type Map
12
+ /// @access public
13
+ /// @group @carbon/type
12
14
  $caption-01: (
13
- font-family: carbon--font-family('sans'),
14
15
  font-size: carbon--type-scale(1),
15
16
  font-weight: carbon--font-weight('regular'),
16
17
  line-height: carbon--rem(16px),
17
18
  letter-spacing: 0.32px,
18
19
  ) !default;
19
20
 
21
+ /// @type Map
22
+ /// @access public
23
+ /// @group @carbon/type
20
24
  $label-01: (
21
- font-family: carbon--font-family('sans'),
22
25
  font-size: carbon--type-scale(1),
23
26
  font-weight: carbon--font-weight('regular'),
24
27
  line-height: carbon--rem(16px),
25
28
  letter-spacing: 0.32px,
26
29
  ) !default;
27
30
 
31
+ /// @type Map
32
+ /// @access public
33
+ /// @group @carbon/type
28
34
  $helper-text-01: (
29
- font-family: carbon--font-family('sans'),
30
35
  font-size: carbon--type-scale(1),
31
36
  font-style: italic,
32
37
  line-height: carbon--rem(16px),
33
38
  letter-spacing: 0.32px,
34
39
  ) !default;
35
40
 
41
+ /// @type Map
42
+ /// @access public
43
+ /// @group @carbon/type
36
44
  $body-short-01: (
37
- font-family: carbon--font-family('sans'),
38
45
  font-size: carbon--type-scale(2),
39
46
  font-weight: carbon--font-weight('regular'),
40
47
  line-height: carbon--rem(18px),
41
48
  letter-spacing: 0.16px,
42
49
  ) !default;
43
50
 
51
+ /// @type Map
52
+ /// @access public
53
+ /// @group @carbon/type
44
54
  $body-long-01: (
45
- font-family: carbon--font-family('sans'),
46
55
  font-size: carbon--type-scale(2),
47
56
  font-weight: carbon--font-weight('regular'),
48
57
  line-height: carbon--rem(20px),
49
58
  letter-spacing: 0.16px,
50
59
  ) !default;
51
60
 
61
+ /// @type Map
62
+ /// @access public
63
+ /// @group @carbon/type
52
64
  $body-short-02: (
53
- font-family: carbon--font-family('sans'),
54
65
  font-size: carbon--type-scale(3),
55
66
  font-weight: carbon--font-weight('regular'),
56
67
  line-height: carbon--rem(22px),
57
68
  letter-spacing: 0,
58
69
  ) !default;
59
70
 
71
+ /// @type Map
72
+ /// @access public
73
+ /// @group @carbon/type
60
74
  $body-long-02: (
61
- font-family: carbon--font-family('sans'),
62
75
  font-size: carbon--type-scale(3),
63
76
  font-weight: carbon--font-weight('regular'),
64
77
  line-height: carbon--rem(24px),
65
78
  letter-spacing: 0,
66
79
  ) !default;
67
80
 
81
+ /// @type Map
82
+ /// @access public
83
+ /// @group @carbon/type
68
84
  $code-01: (
69
- font-family: carbon--font-family('mono'),
70
85
  font-size: carbon--type-scale(1),
71
86
  font-weight: carbon--font-weight('regular'),
72
87
  line-height: carbon--rem(16px),
73
88
  letter-spacing: 0.32px,
74
89
  ) !default;
75
90
 
91
+ /// @type Map
92
+ /// @access public
93
+ /// @group @carbon/type
76
94
  $code-02: (
77
- font-family: carbon--font-family('mono'),
78
95
  font-size: carbon--type-scale(2),
79
96
  font-weight: carbon--font-weight('regular'),
80
97
  line-height: carbon--rem(20px),
81
98
  letter-spacing: 0.32px,
82
99
  ) !default;
83
100
 
101
+ /// @type Map
102
+ /// @access public
103
+ /// @group @carbon/type
84
104
  $heading-01: (
85
- font-family: carbon--font-family('sans'),
86
105
  font-size: carbon--type-scale(2),
87
106
  font-weight: carbon--font-weight('semibold'),
88
107
  line-height: carbon--rem(18px),
89
108
  letter-spacing: 0.16px,
90
109
  ) !default;
91
110
 
111
+ /// @type Map
112
+ /// @access public
113
+ /// @group @carbon/type
114
+ $productive-heading-01: $heading-01 !default;
115
+
116
+ /// @type Map
117
+ /// @access public
118
+ /// @group @carbon/type
92
119
  $heading-02: (
93
- font-family: carbon--font-family('sans'),
94
120
  font-size: carbon--type-scale(3),
95
121
  font-weight: carbon--font-weight('semibold'),
96
122
  line-height: carbon--rem(22px),
97
123
  letter-spacing: 0,
98
124
  ) !default;
99
125
 
126
+ /// @type Map
127
+ /// @access public
128
+ /// @group @carbon/type
129
+ $productive-heading-02: $heading-02 !default;
130
+
131
+ /// @type Map
132
+ /// @access public
133
+ /// @group @carbon/type
100
134
  $productive-heading-03: (
101
- font-family: carbon--font-family('sans'),
102
135
  font-size: carbon--type-scale(5),
103
136
  font-weight: carbon--font-weight('regular'),
104
137
  line-height: carbon--rem(26px),
105
138
  letter-spacing: 0,
106
139
  ) !default;
107
140
 
141
+ /// @type Map
142
+ /// @access public
143
+ /// @group @carbon/type
108
144
  $productive-heading-04: (
109
- font-family: carbon--font-family('sans'),
110
145
  font-size: carbon--type-scale(7),
111
146
  font-weight: carbon--font-weight('regular'),
112
147
  line-height: carbon--rem(36px),
113
148
  letter-spacing: 0,
114
149
  ) !default;
115
150
 
151
+ /// @type Map
152
+ /// @access public
153
+ /// @group @carbon/type
116
154
  $productive-heading-05: (
117
- font-family: carbon--font-family('sans'),
118
155
  font-size: carbon--type-scale(8),
119
156
  font-weight: carbon--font-weight('regular'),
120
157
  line-height: carbon--rem(40px),
121
158
  letter-spacing: 0,
122
159
  ) !default;
123
160
 
161
+ /// @type Map
162
+ /// @access public
163
+ /// @group @carbon/type
164
+ $productive-heading-06: (
165
+ font-size: carbon--type-scale(8),
166
+ font-weight: carbon--font-weight('light'),
167
+ line-height: carbon--rem(50px),
168
+ letter-spacing: 0,
169
+ ) !default;
170
+
171
+ /// @type Map
172
+ /// @access public
173
+ /// @group @carbon/type
174
+ $productive-heading-07: (
175
+ font-size: carbon--type-scale(10),
176
+ font-weight: carbon--font-weight('light'),
177
+ line-height: carbon--rem(64px),
178
+ letter-spacing: 0,
179
+ ) !default;
180
+
181
+ /// @type Map
182
+ /// @access public
183
+ /// @group @carbon/type
184
+ $expressive-heading-01: $heading-01 !default;
185
+
186
+ /// @type Map
187
+ /// @access public
188
+ /// @group @carbon/type
189
+ $expressive-heading-02: $heading-02 !default;
190
+
191
+ /// @type Map
192
+ /// @access public
193
+ /// @group @carbon/type
124
194
  $expressive-heading-03: (
125
- font-family: carbon--font-family('sans'),
126
195
  font-size: carbon--type-scale(5),
127
196
  font-weight: carbon--font-weight('regular'),
128
197
  line-height: 130%,
@@ -138,8 +207,10 @@ $expressive-heading-03: (
138
207
  ),
139
208
  ) !default;
140
209
 
210
+ /// @type Map
211
+ /// @access public
212
+ /// @group @carbon/type
141
213
  $expressive-heading-04: (
142
- font-family: carbon--font-family('sans'),
143
214
  font-size: carbon--type-scale(7),
144
215
  font-weight: carbon--font-weight('regular'),
145
216
  line-height: 129%,
@@ -155,8 +226,10 @@ $expressive-heading-04: (
155
226
  ),
156
227
  ) !default;
157
228
 
229
+ /// @type Map
230
+ /// @access public
231
+ /// @group @carbon/type
158
232
  $expressive-heading-05: (
159
- font-family: carbon--font-family('sans'),
160
233
  font-size: carbon--type-scale(8),
161
234
  font-weight: carbon--font-weight('regular'),
162
235
  line-height: 125%,
@@ -180,8 +253,10 @@ $expressive-heading-05: (
180
253
  ),
181
254
  ) !default;
182
255
 
256
+ /// @type Map
257
+ /// @access public
258
+ /// @group @carbon/type
183
259
  $expressive-heading-06: (
184
- font-family: carbon--font-family('sans'),
185
260
  font-size: carbon--type-scale(8),
186
261
  font-weight: carbon--font-weight('semibold'),
187
262
  line-height: 125%,
@@ -205,8 +280,10 @@ $expressive-heading-06: (
205
280
  ),
206
281
  ) !default;
207
282
 
283
+ /// @type Map
284
+ /// @access public
285
+ /// @group @carbon/type
208
286
  $expressive-paragraph-01: (
209
- font-family: carbon--font-family('sans'),
210
287
  font-size: carbon--type-scale(6),
211
288
  font-weight: carbon--font-weight('light'),
212
289
  line-height: 125%,
@@ -223,8 +300,10 @@ $expressive-paragraph-01: (
223
300
  ),
224
301
  );
225
302
 
303
+ /// @type Map
304
+ /// @access public
305
+ /// @group @carbon/type
226
306
  $quotation-01: (
227
- font-family: carbon--font-family('serif'),
228
307
  font-size: carbon--type-scale(5),
229
308
  font-weight: carbon--font-weight('regular'),
230
309
  line-height: 130%,
@@ -248,8 +327,10 @@ $quotation-01: (
248
327
  ),
249
328
  ) !default;
250
329
 
330
+ /// @type Map
331
+ /// @access public
332
+ /// @group @carbon/type
251
333
  $quotation-02: (
252
- font-family: carbon--font-family('serif'),
253
334
  font-size: carbon--type-scale(8),
254
335
  font-weight: carbon--font-weight('light'),
255
336
  line-height: 125%,
@@ -273,8 +354,10 @@ $quotation-02: (
273
354
  ),
274
355
  ) !default;
275
356
 
357
+ /// @type Map
358
+ /// @access public
359
+ /// @group @carbon/type
276
360
  $display-01: (
277
- font-family: carbon--font-family('sans'),
278
361
  font-size: carbon--type-scale(10),
279
362
  font-weight: carbon--font-weight('light'),
280
363
  line-height: 119%,
@@ -297,8 +380,10 @@ $display-01: (
297
380
  ),
298
381
  ) !default;
299
382
 
383
+ /// @type Map
384
+ /// @access public
385
+ /// @group @carbon/type
300
386
  $display-02: (
301
- font-family: carbon--font-family('sans'),
302
387
  font-size: carbon--type-scale(10),
303
388
  font-weight: carbon--font-weight('semibold'),
304
389
  line-height: 119%,
@@ -321,8 +406,10 @@ $display-02: (
321
406
  ),
322
407
  ) !default;
323
408
 
409
+ /// @type Map
410
+ /// @access public
411
+ /// @group @carbon/type
324
412
  $display-03: (
325
- font-family: carbon--font-family('sans'),
326
413
  font-size: carbon--type-scale(10),
327
414
  font-weight: carbon--font-weight('light'),
328
415
  line-height: 119%,
@@ -350,8 +437,10 @@ $display-03: (
350
437
  ),
351
438
  ) !default;
352
439
 
440
+ /// @type Map
441
+ /// @access public
442
+ /// @group @carbon/type
353
443
  $display-04: (
354
- font-family: carbon--font-family('sans'),
355
444
  font-size: carbon--type-scale(10),
356
445
  font-weight: carbon--font-weight('semibold'),
357
446
  line-height: 119%,
@@ -379,53 +468,56 @@ $display-04: (
379
468
  ),
380
469
  ) !default;
381
470
 
382
- // prettier-ignore
471
+ /// @type Map
472
+ /// @access public
473
+ /// @group @carbon/type
383
474
  $tokens: (
384
- // Universal tokens
385
475
  caption-01: $caption-01,
386
476
  label-01: $label-01,
387
-
388
477
  helper-text-01: $helper-text-01,
389
-
390
478
  body-short-01: $body-short-01,
391
479
  body-short-02: $body-short-02,
392
-
393
480
  body-long-01: $body-long-01,
394
481
  body-long-02: $body-long-02,
395
-
396
482
  code-01: $code-01,
397
483
  code-02: $code-02,
398
-
399
484
  heading-01: $heading-01,
400
485
  heading-02: $heading-02,
401
-
402
- // Product layout, fixed
486
+ productive-heading-01: $productive-heading-01,
487
+ productive-heading-02: $productive-heading-02,
403
488
  productive-heading-03: $productive-heading-03,
404
489
  productive-heading-04: $productive-heading-04,
405
490
  productive-heading-05: $productive-heading-05,
406
-
407
- // Editorial layout, fluid
491
+ productive-heading-06: $productive-heading-06,
492
+ productive-heading-07: $productive-heading-07,
408
493
  expressive-paragraph-01: $expressive-paragraph-01,
494
+ expressive-heading-01: $expressive-heading-01,
495
+ expressive-heading-02: $expressive-heading-02,
409
496
  expressive-heading-03: $expressive-heading-03,
410
497
  expressive-heading-04: $expressive-heading-04,
411
498
  expressive-heading-05: $expressive-heading-05,
412
499
  expressive-heading-06: $expressive-heading-06,
413
-
414
500
  quotation-01: $quotation-01,
415
501
  quotation-02: $quotation-02,
416
-
417
502
  display-01: $display-01,
418
503
  display-02: $display-02,
419
504
  display-03: $display-03,
420
505
  display-04: $display-04,
421
506
  );
422
507
 
508
+ /// @param {Map} $map
509
+ /// @access public
510
+ /// @group @carbon/type
423
511
  @mixin properties($map) {
424
512
  @each $name, $value in $map {
425
513
  #{$name}: $value;
426
514
  }
427
515
  }
428
516
 
517
+ /// @param {Number} $value - Number with units
518
+ /// @return {Number} Without units
519
+ /// @access public
520
+ /// @group @carbon/type
429
521
  @function strip-unit($value) {
430
522
  @return $value / ($value * 0 + 1);
431
523
  }
@@ -442,8 +534,10 @@ $tokens: (
442
534
  /// Most of the logic for this work comes from CSS Tricks:
443
535
  /// https://css-tricks.com/snippets/css/fluid-typography/
444
536
  ///
445
- /// @param {Map} $type-styles - the value of a given type token
446
- /// @param {?Map} $breakpoints - custom breakpoints to use
537
+ /// @param {Map} $type-styles - The value of a given type token
538
+ /// @param {Map} $breakpoints [$carbon--grid-breakpoints] - Custom breakpoints to use
539
+ /// @access public
540
+ /// @group @carbon/type
447
541
  @mixin fluid-type($type-styles, $breakpoints: $carbon--grid-breakpoints) {
448
542
  // Include the initial styles for the given token by default without any
449
543
  // media query guard. This includes `font-size` as a fallback in the case
@@ -465,10 +559,11 @@ $tokens: (
465
559
  }
466
560
 
467
561
  /// Computes the fluid `font-size` for a given type style and breakpoint
468
- /// @param {Map} $type-styles - the styles for a given token
469
- /// @param {String} $name - the name of the breakpoint to which we apply the fluid
470
- /// styles
471
- /// @param {?Map} $breakpoints - the breakpoints for the grid system
562
+ /// @param {Map} $type-styles - The styles for a given token
563
+ /// @param {String} $name - The name of the breakpoint to which we apply the fluid
564
+ /// @param {Map} $breakpoints [$carbon--grid-breakpoints] - The breakpoints for the grid system
565
+ /// @access public
566
+ /// @group @carbon/type
472
567
  @mixin fluid-type-size(
473
568
  $type-styles,
474
569
  $name,
@@ -550,10 +645,11 @@ $tokens: (
550
645
  /// styles for the token if they are defined. Fluid styles will cause the
551
646
  /// token's font-size to be computed based on the viewport size. As a result, use
552
647
  /// with caution in fixed contexts.
553
- /// @param {String} $name - the name of the token to get the styles for
554
- /// @param {?Boolean} $fluid - specify whether to include fluid styles for the
555
- /// @param {?Map} $breakpoints - provide a custom breakpoint map to use
556
- /// token
648
+ /// @param {String} $name - The name of the token to get the styles for
649
+ /// @param {Boolean} $fluid [false] - Specify whether to include fluid styles for the
650
+ /// @param {Map} $breakpoints [$carbon--grid-breakpoints] - Provide a custom breakpoint map to use
651
+ /// @access public
652
+ /// @group @carbon/type
557
653
  @mixin carbon--type-style(
558
654
  $name,
559
655
  $fluid: false,