@carbon/type 10.43.2 → 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 (78) hide show
  1. package/README.md +2 -6
  2. package/index.scss +7 -7
  3. package/package.json +6 -6
  4. package/scss/_classes.scss +8 -7
  5. package/scss/{modules/_default-type.scss → _default-type.scss} +0 -0
  6. package/scss/_font-family.scss +51 -17
  7. package/scss/_inlined/_classes.scss +8 -7
  8. package/scss/_inlined/_default-type.scss +55 -0
  9. package/scss/_inlined/_font-family.scss +51 -17
  10. package/scss/_inlined/_reset.scss +11 -59
  11. package/scss/_inlined/_scale.scss +13 -15
  12. package/scss/_inlined/_styles.scss +146 -214
  13. package/scss/_reset.scss +11 -59
  14. package/scss/_scale.scss +13 -15
  15. package/scss/_styles.scss +146 -214
  16. package/scss/vendor/@carbon/grid/{modules/_breakpoint.scss → _breakpoint.scss} +1 -1
  17. package/scss/vendor/@carbon/grid/{modules/_config.scss → _config.scss} +1 -1
  18. package/scss/vendor/@carbon/grid/{modules/_css-grid.scss → _css-grid.scss} +0 -0
  19. package/scss/vendor/@carbon/grid/{modules/_flex-grid.scss → _flex-grid.scss} +0 -20
  20. package/scss/vendor/@carbon/grid/_inlined/_breakpoint.scss +198 -0
  21. package/scss/vendor/@carbon/grid/_inlined/_config.scss +94 -0
  22. package/scss/vendor/@carbon/grid/_inlined/_css-grid.scss +470 -0
  23. package/scss/vendor/@carbon/grid/{modules/_mixins.scss → _inlined/_flex-grid.scss} +45 -38
  24. package/scss/vendor/@carbon/grid/_inlined/_mixins.scss +89 -188
  25. package/scss/vendor/@carbon/grid/_mixins.scss +89 -188
  26. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_convert.import.scss +2 -4
  27. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_convert.scss +18 -23
  28. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_spacing.scss +2 -5
  29. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_utilities.scss +4 -4
  30. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/generated/_container.scss +13 -43
  31. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/generated/_fluid-spacing.scss +11 -35
  32. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/generated/_icon-size.scss +8 -17
  33. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/generated/_size.scss +1 -1
  34. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/generated/_spacing.scss +29 -107
  35. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/modules/_convert.scss +2 -4
  36. package/scss/_inlined/_styles.import.scss +0 -766
  37. package/scss/_inlined/font-face/_mono.scss +0 -430
  38. package/scss/_inlined/font-face/_sans-condensed.scss +0 -302
  39. package/scss/_inlined/font-face/_sans.scss +0 -497
  40. package/scss/_inlined/font-face/_serif.scss +0 -430
  41. package/scss/_inlined/font-face/_settings.scss +0 -12
  42. package/scss/_styles.import.scss +0 -766
  43. package/scss/font-face/_mono.scss +0 -430
  44. package/scss/font-face/_sans-condensed.scss +0 -302
  45. package/scss/font-face/_sans.scss +0 -497
  46. package/scss/font-face/_serif.scss +0 -430
  47. package/scss/font-face/_settings.scss +0 -12
  48. package/scss/index.scss +0 -8
  49. package/scss/modules/_classes.scss +0 -42
  50. package/scss/modules/_font-family.scss +0 -104
  51. package/scss/modules/_prefix.scss +0 -11
  52. package/scss/modules/_reset.scss +0 -44
  53. package/scss/modules/_scale.scss +0 -57
  54. package/scss/modules/_styles.scss +0 -876
  55. package/scss/type.scss +0 -8
  56. package/scss/vendor/@carbon/grid/12.scss +0 -41
  57. package/scss/vendor/@carbon/grid/_inlined/12.scss +0 -41
  58. package/scss/vendor/@carbon/grid/_inlined/_mixins.import.scss +0 -431
  59. package/scss/vendor/@carbon/grid/_inlined/_prefix.scss +0 -12
  60. package/scss/vendor/@carbon/grid/_mixins.import.scss +0 -431
  61. package/scss/vendor/@carbon/grid/_prefix.scss +0 -12
  62. package/scss/vendor/@carbon/grid/grid.scss +0 -10
  63. package/scss/vendor/@carbon/grid/index.scss +0 -10
  64. package/scss/vendor/@carbon/grid/vendor/@carbon/import-once/import-once.scss +0 -27
  65. package/scss/vendor/@carbon/grid/vendor/@carbon/import-once/index.scss +0 -8
  66. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_breakpoint.scss +0 -246
  67. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_key-height.import.scss +0 -117
  68. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_key-height.scss +0 -111
  69. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/_mini-unit.scss +0 -23
  70. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/generated/_layout.scss +0 -97
  71. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/index.scss +0 -8
  72. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/layout.scss +0 -12
  73. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/modules/_spacing.scss +0 -9
  74. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/modules/_utilities.scss +0 -41
  75. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/modules/generated/_fluid-spacing.scss +0 -37
  76. package/scss/vendor/@carbon/grid/vendor/@carbon/layout/modules/generated/_spacing.scss +0 -91
  77. package/scss/vendor/@carbon/import-once/import-once.scss +0 -27
  78. package/scss/vendor/@carbon/import-once/index.scss +0 -8
@@ -1,766 +0,0 @@
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
- @use "sass:meta";
23
- @use "sass:math";
24
- @import '@carbon/layout/scss/breakpoint';
25
- @import 'font-family';
26
- @import 'scale';
27
-
28
- /// @type Map
29
- /// @access public
30
- /// @group @carbon/type
31
- $caption-01: (
32
- font-size: carbon--type-scale(1),
33
- font-weight: carbon--font-weight('regular'),
34
- line-height: 1.34,
35
- letter-spacing: 0.32px,
36
- ) !default;
37
-
38
- /// @type Map
39
- /// @access public
40
- /// @group @carbon/type
41
- $caption-02: (
42
- font-size: carbon--type-scale(2),
43
- font-weight: carbon--font-weight('regular'),
44
- line-height: 1.29,
45
- letter-spacing: 0.32px,
46
- ) !default;
47
-
48
- /// @type Map
49
- /// @access public
50
- /// @group @carbon/type
51
- $label-01: (
52
- font-size: carbon--type-scale(1),
53
- font-weight: carbon--font-weight('regular'),
54
- line-height: 1.34,
55
- letter-spacing: 0.32px,
56
- ) !default;
57
-
58
- /// @type Map
59
- /// @access public
60
- /// @group @carbon/type
61
- $label-02: (
62
- font-size: carbon--type-scale(2),
63
- font-weight: carbon--font-weight('regular'),
64
- line-height: 1.29,
65
- letter-spacing: 0.32px,
66
- ) !default;
67
-
68
- /// @type Map
69
- /// @access public
70
- /// @group @carbon/type
71
- $helper-text-01: (
72
- font-size: carbon--type-scale(1),
73
- line-height: 1.34,
74
- letter-spacing: 0.32px,
75
- ) !default;
76
-
77
- /// @type Map
78
- /// @access public
79
- /// @group @carbon/type
80
- $helper-text-02: (
81
- font-size: carbon--type-scale(2),
82
- font-weight: carbon--font-weight('regular'),
83
- line-height: 1.29,
84
- letter-spacing: 0.32px,
85
- ) !default;
86
-
87
- /// @type Map
88
- /// @access public
89
- /// @group @carbon/type
90
- $body-short-01: (
91
- font-size: carbon--type-scale(2),
92
- font-weight: carbon--font-weight('regular'),
93
- line-height: 1.29,
94
- letter-spacing: 0.16px,
95
- ) !default;
96
-
97
- /// @type Map
98
- /// @access public
99
- /// @group @carbon/type
100
- $body-long-01: (
101
- font-size: carbon--type-scale(2),
102
- font-weight: carbon--font-weight('regular'),
103
- line-height: 1.43,
104
- letter-spacing: 0.16px,
105
- ) !default;
106
-
107
- /// @type Map
108
- /// @access public
109
- /// @group @carbon/type
110
- $body-short-02: (
111
- font-size: carbon--type-scale(3),
112
- font-weight: carbon--font-weight('regular'),
113
- line-height: 1.375,
114
- letter-spacing: 0,
115
- ) !default;
116
-
117
- /// @type Map
118
- /// @access public
119
- /// @group @carbon/type
120
- $body-long-02: (
121
- font-size: carbon--type-scale(3),
122
- font-weight: carbon--font-weight('regular'),
123
- line-height: 1.5,
124
- letter-spacing: 0,
125
- ) !default;
126
-
127
- /// @type Map
128
- /// @access public
129
- /// @group @carbon/type
130
- $code-01: (
131
- font-family: carbon--font-family('mono'),
132
- font-size: carbon--type-scale(1),
133
- font-weight: carbon--font-weight('regular'),
134
- line-height: 1.34,
135
- letter-spacing: 0.32px,
136
- ) !default;
137
-
138
- /// @type Map
139
- /// @access public
140
- /// @group @carbon/type
141
- $code-02: (
142
- font-family: carbon--font-family('mono'),
143
- font-size: carbon--type-scale(2),
144
- font-weight: carbon--font-weight('regular'),
145
- line-height: 1.43,
146
- letter-spacing: 0.32px,
147
- ) !default;
148
-
149
- /// @type Map
150
- /// @access public
151
- /// @group @carbon/type
152
- $heading-01: (
153
- font-size: carbon--type-scale(2),
154
- font-weight: carbon--font-weight('semibold'),
155
- line-height: 1.29,
156
- letter-spacing: 0.16px,
157
- ) !default;
158
-
159
- /// @type Map
160
- /// @access public
161
- /// @group @carbon/type
162
- $productive-heading-01: $heading-01 !default;
163
-
164
- /// @type Map
165
- /// @access public
166
- /// @group @carbon/type
167
- $heading-02: (
168
- font-size: carbon--type-scale(3),
169
- font-weight: carbon--font-weight('semibold'),
170
- line-height: 1.375,
171
- letter-spacing: 0,
172
- ) !default;
173
-
174
- /// @type Map
175
- /// @access public
176
- /// @group @carbon/type
177
- $productive-heading-02: $heading-02 !default;
178
-
179
- /// @type Map
180
- /// @access public
181
- /// @group @carbon/type
182
- $productive-heading-03: (
183
- font-size: carbon--type-scale(5),
184
- font-weight: carbon--font-weight('regular'),
185
- line-height: 1.4,
186
- letter-spacing: 0,
187
- ) !default;
188
-
189
- /// @type Map
190
- /// @access public
191
- /// @group @carbon/type
192
- $productive-heading-04: (
193
- font-size: carbon--type-scale(7),
194
- font-weight: carbon--font-weight('regular'),
195
- line-height: 1.29,
196
- letter-spacing: 0,
197
- ) !default;
198
-
199
- /// @type Map
200
- /// @access public
201
- /// @group @carbon/type
202
- $productive-heading-05: (
203
- font-size: carbon--type-scale(8),
204
- font-weight: carbon--font-weight('regular'),
205
- line-height: 1.25,
206
- letter-spacing: 0,
207
- ) !default;
208
-
209
- /// @type Map
210
- /// @access public
211
- /// @group @carbon/type
212
- $productive-heading-06: (
213
- font-size: carbon--type-scale(8),
214
- font-weight: carbon--font-weight('light'),
215
- // Extra digit needed for precision in Chrome
216
- line-height: 1.199,
217
- letter-spacing: 0,
218
- ) !default;
219
-
220
- /// @type Map
221
- /// @access public
222
- /// @group @carbon/type
223
- $productive-heading-07: (
224
- font-size: carbon--type-scale(10),
225
- font-weight: carbon--font-weight('light'),
226
- line-height: 1.19,
227
- letter-spacing: 0,
228
- ) !default;
229
-
230
- /// @type Map
231
- /// @access public
232
- /// @group @carbon/type
233
- $expressive-heading-01: map-merge(
234
- $heading-01,
235
- (
236
- line-height: 1.25,
237
- )
238
- ) !default;
239
-
240
- /// @type Map
241
- /// @access public
242
- /// @group @carbon/type
243
- $expressive-heading-02: map-merge(
244
- $heading-02,
245
- (
246
- line-height: 1.5,
247
- )
248
- ) !default;
249
-
250
- /// @type Map
251
- /// @access public
252
- /// @group @carbon/type
253
- $expressive-heading-03: (
254
- font-size: carbon--type-scale(5),
255
- font-weight: carbon--font-weight('regular'),
256
- line-height: 1.4,
257
- letter-spacing: 0,
258
- breakpoints: (
259
- xlg: (
260
- font-size: carbon--type-scale(5),
261
- line-height: 1.25,
262
- ),
263
- max: (
264
- font-size: carbon--type-scale(6),
265
- line-height: 1.334,
266
- ),
267
- ),
268
- ) !default;
269
-
270
- /// @type Map
271
- /// @access public
272
- /// @group @carbon/type
273
- $expressive-heading-04: (
274
- font-size: carbon--type-scale(7),
275
- font-weight: carbon--font-weight('regular'),
276
- line-height: 1.29,
277
- letter-spacing: 0,
278
- breakpoints: (
279
- xlg: (
280
- font-size: carbon--type-scale(7),
281
- line-height: 1.25,
282
- ),
283
- max: (
284
- font-size: carbon--type-scale(8),
285
- ),
286
- ),
287
- ) !default;
288
-
289
- /// @type Map
290
- /// @access public
291
- /// @group @carbon/type
292
- $expressive-heading-05: (
293
- font-size: carbon--type-scale(8),
294
- font-weight: carbon--font-weight('regular'),
295
- line-height: 1.25,
296
- letter-spacing: 0,
297
- breakpoints: (
298
- md: (
299
- font-size: carbon--type-scale(9),
300
- font-weight: carbon--font-weight('light'),
301
- line-height: 1.22,
302
- ),
303
- lg: (
304
- font-size: carbon--type-scale(10),
305
- line-height: 1.19,
306
- ),
307
- xlg: (
308
- font-size: carbon--type-scale(11),
309
- line-height: 1.17,
310
- ),
311
- max: (
312
- font-size: carbon--type-scale(13),
313
- ),
314
- ),
315
- ) !default;
316
-
317
- /// @type Map
318
- /// @access public
319
- /// @group @carbon/type
320
- $expressive-heading-06: (
321
- font-size: carbon--type-scale(8),
322
- font-weight: carbon--font-weight('semibold'),
323
- line-height: 1.25,
324
- letter-spacing: 0,
325
- breakpoints: (
326
- md: (
327
- font-size: carbon--type-scale(9),
328
- line-height: 1.22,
329
- ),
330
- lg: (
331
- font-size: carbon--type-scale(10),
332
- line-height: 1.19,
333
- ),
334
- xlg: (
335
- font-size: carbon--type-scale(11),
336
- line-height: 1.17,
337
- ),
338
- max: (
339
- font-size: carbon--type-scale(13),
340
- ),
341
- ),
342
- ) !default;
343
-
344
- /// @type Map
345
- /// @access public
346
- /// @group @carbon/type
347
- $expressive-paragraph-01: (
348
- font-size: carbon--type-scale(6),
349
- font-weight: carbon--font-weight('light'),
350
- line-height: 1.334,
351
- letter-spacing: 0,
352
- breakpoints: (
353
- lg: (
354
- font-size: carbon--type-scale(7),
355
- line-height: 1.29,
356
- ),
357
- max: (
358
- font-size: carbon--type-scale(8),
359
- line-height: 1.25,
360
- ),
361
- ),
362
- );
363
-
364
- /// @type Map
365
- /// @access public
366
- /// @group @carbon/type
367
- $quotation-01: (
368
- font-size: carbon--type-scale(5),
369
- font-weight: carbon--font-weight('regular'),
370
- line-height: 1.3,
371
- letter-spacing: 0,
372
- breakpoints: (
373
- md: (
374
- font-size: carbon--type-scale(5),
375
- ),
376
- lg: (
377
- font-size: carbon--type-scale(6),
378
- line-height: 1.334,
379
- ),
380
- xlg: (
381
- font-size: carbon--type-scale(7),
382
- line-height: 1.29,
383
- ),
384
- max: (
385
- font-size: carbon--type-scale(8),
386
- line-height: 1.25,
387
- ),
388
- ),
389
- ) !default;
390
-
391
- /// @type Map
392
- /// @access public
393
- /// @group @carbon/type
394
- $quotation-02: (
395
- font-size: carbon--type-scale(8),
396
- font-weight: carbon--font-weight('light'),
397
- line-height: 1.25,
398
- letter-spacing: 0,
399
- breakpoints: (
400
- md: (
401
- font-size: carbon--type-scale(9),
402
- line-height: 1.22,
403
- ),
404
- lg: (
405
- font-size: carbon--type-scale(10),
406
- line-height: 1.19,
407
- ),
408
- xlg: (
409
- font-size: carbon--type-scale(11),
410
- line-height: 1.17,
411
- ),
412
- max: (
413
- font-size: carbon--type-scale(13),
414
- ),
415
- ),
416
- ) !default;
417
-
418
- /// @type Map
419
- /// @access public
420
- /// @group @carbon/type
421
- $display-01: (
422
- font-size: carbon--type-scale(10),
423
- font-weight: carbon--font-weight('light'),
424
- line-height: 1.19,
425
- letter-spacing: 0,
426
- breakpoints: (
427
- md: (
428
- font-size: carbon--type-scale(10),
429
- ),
430
- lg: (
431
- font-size: carbon--type-scale(12),
432
- ),
433
- xlg: (
434
- font-size: carbon--type-scale(13),
435
- line-height: 1.17,
436
- ),
437
- max: (
438
- font-size: carbon--type-scale(15),
439
- line-height: 1.13,
440
- ),
441
- ),
442
- ) !default;
443
-
444
- /// @type Map
445
- /// @access public
446
- /// @group @carbon/type
447
- $display-02: (
448
- font-size: carbon--type-scale(10),
449
- font-weight: carbon--font-weight('semibold'),
450
- line-height: 1.19,
451
- letter-spacing: 0,
452
- breakpoints: (
453
- md: (
454
- font-size: carbon--type-scale(10),
455
- ),
456
- lg: (
457
- font-size: carbon--type-scale(12),
458
- ),
459
- xlg: (
460
- font-size: carbon--type-scale(13),
461
- line-height: 1.16,
462
- ),
463
- max: (
464
- font-size: carbon--type-scale(15),
465
- line-height: 1.13,
466
- ),
467
- ),
468
- ) !default;
469
-
470
- /// @type Map
471
- /// @access public
472
- /// @group @carbon/type
473
- $display-03: (
474
- font-size: carbon--type-scale(10),
475
- font-weight: carbon--font-weight('light'),
476
- line-height: 1.19,
477
- letter-spacing: 0,
478
- breakpoints: (
479
- md: (
480
- font-size: carbon--type-scale(14),
481
- line-height: 1.15,
482
- ),
483
- lg: (
484
- font-size: carbon--type-scale(17),
485
- line-height: 1.11,
486
- letter-spacing: -0.64px,
487
- ),
488
- xlg: (
489
- font-size: carbon--type-scale(20),
490
- line-height: 1.07,
491
- letter-spacing: -0.64px,
492
- ),
493
- max: (
494
- font-size: carbon--type-scale(23),
495
- line-height: 1.05,
496
- letter-spacing: -0.96px,
497
- ),
498
- ),
499
- ) !default;
500
-
501
- /// @type Map
502
- /// @access public
503
- /// @group @carbon/type
504
- $display-04: (
505
- font-size: carbon--type-scale(10),
506
- font-weight: carbon--font-weight('semibold'),
507
- line-height: 1.19,
508
- letter-spacing: 0,
509
- breakpoints: (
510
- md: (
511
- font-size: carbon--type-scale(14),
512
- line-height: 1.15,
513
- ),
514
- lg: (
515
- font-size: carbon--type-scale(17),
516
- line-height: 1.11,
517
- letter-spacing: -0.64px,
518
- ),
519
- xlg: (
520
- font-size: carbon--type-scale(20),
521
- line-height: 1.07,
522
- letter-spacing: -0.64px,
523
- ),
524
- max: (
525
- font-size: carbon--type-scale(23),
526
- line-height: 1.05,
527
- letter-spacing: -0.96px,
528
- ),
529
- ),
530
- ) !default;
531
-
532
- /// @type Map
533
- /// @access public
534
- /// @group @carbon/type
535
- $tokens: (
536
- caption-01: $caption-01,
537
- caption-02: $caption-02,
538
- label-01: $label-01,
539
- label-02: $label-02,
540
- helper-text-01: $helper-text-01,
541
- helper-text-02: $helper-text-02,
542
- body-short-01: $body-short-01,
543
- body-short-02: $body-short-02,
544
- body-long-01: $body-long-01,
545
- body-long-02: $body-long-02,
546
- code-01: $code-01,
547
- code-02: $code-02,
548
- heading-01: $heading-01,
549
- heading-02: $heading-02,
550
- productive-heading-01: $productive-heading-01,
551
- productive-heading-02: $productive-heading-02,
552
- productive-heading-03: $productive-heading-03,
553
- productive-heading-04: $productive-heading-04,
554
- productive-heading-05: $productive-heading-05,
555
- productive-heading-06: $productive-heading-06,
556
- productive-heading-07: $productive-heading-07,
557
- expressive-paragraph-01: $expressive-paragraph-01,
558
- expressive-heading-01: $expressive-heading-01,
559
- expressive-heading-02: $expressive-heading-02,
560
- expressive-heading-03: $expressive-heading-03,
561
- expressive-heading-04: $expressive-heading-04,
562
- expressive-heading-05: $expressive-heading-05,
563
- expressive-heading-06: $expressive-heading-06,
564
- quotation-01: $quotation-01,
565
- quotation-02: $quotation-02,
566
- display-01: $display-01,
567
- display-02: $display-02,
568
- display-03: $display-03,
569
- display-04: $display-04,
570
- );
571
-
572
- /// @param {Map} $map
573
- /// @access public
574
- /// @group @carbon/type
575
- @mixin properties($map) {
576
- @each $name, $value in $map {
577
- #{$name}: $value;
578
- }
579
- }
580
-
581
- /// @param {Number} $value - Number with units
582
- /// @return {Number} Without units
583
- /// @access public
584
- /// @group @carbon/type
585
- @function strip-unit($value) {
586
- @if meta.function-exists('div', 'math') {
587
- @return math.div($value, $value * 0 + 1);
588
- } @else {
589
- @return $value / ($value * 0 + 1);
590
- }
591
- }
592
-
593
- /// This helper includes fluid type styles for the given token value. Fluid type
594
- /// means that the `font-size` is computed using `calc()` in order to be
595
- /// determined by the screen size instead of a breakpoint. As a result, fluid
596
- /// styles should be used with caution in fixed width contexts.
597
- ///
598
- /// In addition, we make use of %-based line-heights so that the line-height of
599
- /// each type style is computed correctly due to the dynamic nature of the
600
- /// `font-size`.
601
- ///
602
- /// Most of the logic for this work comes from CSS Tricks:
603
- /// https://css-tricks.com/snippets/css/fluid-typography/
604
- ///
605
- /// @param {Map} $type-styles - The value of a given type token
606
- /// @param {Map} $breakpoints [$carbon--grid-breakpoints] - Custom breakpoints to use
607
- /// @access public
608
- /// @group @carbon/type
609
- @mixin fluid-type($type-styles, $breakpoints: $carbon--grid-breakpoints) {
610
- // Include the initial styles for the given token by default without any
611
- // media query guard. This includes `font-size` as a fallback in the case
612
- // that a browser does not support `calc()`
613
- @include properties(map-remove($type-styles, breakpoints));
614
- // We also need to include the `sm` styles by default since they don't
615
- // appear in the fluid styles for tokens
616
- @include fluid-type-size($type-styles, sm, $breakpoints);
617
-
618
- // Finally, we need to go through all the breakpoints defined in the type
619
- // token and apply the properties and fluid type size for that given
620
- // breakpoint
621
- @each $name, $values in map-get($type-styles, breakpoints) {
622
- @include carbon--breakpoint($name) {
623
- @include properties($values);
624
- @include fluid-type-size($type-styles, $name, $breakpoints);
625
- }
626
- }
627
- }
628
-
629
- /// Computes the fluid `font-size` for a given type style and breakpoint
630
- /// @param {Map} $type-styles - The styles for a given token
631
- /// @param {String} $name - The name of the breakpoint to which we apply the fluid
632
- /// @param {Map} $breakpoints [$carbon--grid-breakpoints] - The breakpoints for the grid system
633
- /// @access public
634
- /// @group @carbon/type
635
- @mixin fluid-type-size(
636
- $type-styles,
637
- $name,
638
- $breakpoints: $carbon--grid-breakpoints
639
- ) {
640
- // Get the information about the breakpoint we're currently working in. Useful
641
- // for getting initial width information
642
- $breakpoint: map-get($breakpoints, $name);
643
-
644
- // Our fluid styles are captured under the 'breakpoints' property in our type
645
- // styles map. These define what values to treat as `max-` variables below
646
- $fluid-sizes: map-get($type-styles, breakpoints);
647
- $fluid-breakpoint: ();
648
- // Special case for `sm` because the styles for small are on the type style
649
- // directly
650
- @if $name == sm {
651
- $fluid-breakpoint: map-remove($type-styles, breakpoints);
652
- } @else {
653
- $fluid-breakpoint: map-get($fluid-sizes, $name);
654
- }
655
-
656
- // Initialize our font-sizes to the default size for the type style
657
- $max-font-size: map-get($type-styles, font-size);
658
- $min-font-size: map-get($type-styles, font-size);
659
- @if map-has-key($fluid-breakpoint, font-size) {
660
- $min-font-size: map-get($fluid-breakpoint, font-size);
661
- }
662
-
663
- // Initialize our min and max width to the width of the current breakpoint
664
- $max-vw: map-get($breakpoint, width);
665
- $min-vw: map-get($breakpoint, width);
666
-
667
- // We can use `breakpoint-next` to see if there is another breakpoint we can
668
- // use to update `max-font-size` and `max-vw` with larger values
669
- $next-breakpoint-available: carbon--breakpoint-next($name, $breakpoints);
670
- $next-fluid-breakpoint-name: null;
671
-
672
- // We need to figure out what the next available fluid breakpoint is for our
673
- // given $type-styles. In this loop we try and iterate through breakpoints
674
- // until we either manually set $next-breakpoint-available to null or
675
- // `breakpoint-next` returns null.
676
- @while $next-breakpoint-available {
677
- @if map-has-key($fluid-sizes, $next-breakpoint-available) {
678
- $next-fluid-breakpoint-name: $next-breakpoint-available;
679
- $next-breakpoint-available: null;
680
- } @else {
681
- $next-breakpoint-available: carbon--breakpoint-next(
682
- $next-breakpoint-available,
683
- $breakpoints
684
- );
685
- }
686
- }
687
-
688
- // If we have found the next available fluid breakpoint name, then we know
689
- // that we have values that we can use to set max-font-size and max-vw as both
690
- // values derive from the next breakpoint
691
- @if $next-fluid-breakpoint-name {
692
- $next-fluid-breakpoint: map-get($breakpoints, $next-fluid-breakpoint-name);
693
- $max-font-size: map-get(
694
- map-get($fluid-sizes, $next-fluid-breakpoint-name),
695
- font-size
696
- );
697
- $max-vw: map-get($next-fluid-breakpoint, width);
698
-
699
- // prettier-ignore
700
- font-size: calc(#{$min-font-size} +
701
- #{strip-unit($max-font-size - $min-font-size)} *
702
- ((100vw - #{$min-vw}) / #{strip-unit($max-vw - $min-vw)})
703
- );
704
- } @else {
705
- // Otherwise, just default to setting the font size found from the type
706
- // style or the given fluid breakpoint in the type style
707
- font-size: $min-font-size;
708
- }
709
- }
710
-
711
- // TODO move following variable and `custom-property` mixin into shared file for
712
- // both `@carbon/type` and `@carbon/themes`
713
-
714
- /// @access private
715
- /// @group @carbon/type
716
- $custom-property-prefix: 'cds' !default;
717
-
718
- /// @access private
719
- /// @group @carbon/type
720
- @mixin custom-properties($name, $value) {
721
- @each $property, $value in $value {
722
- #{$property}: var(
723
- --#{$custom-property-prefix}-#{$name}-#{$property},
724
- #{$value}
725
- );
726
- }
727
- }
728
-
729
- /// Helper mixin to include the styles for a given token in any selector in your
730
- /// project. Also includes an optional fluid option that will enable fluid
731
- /// styles for the token if they are defined. Fluid styles will cause the
732
- /// token's font-size to be computed based on the viewport size. As a result, use
733
- /// with caution in fixed contexts.
734
- /// @param {String} $name - The name of the token to get the styles for
735
- /// @param {Boolean} $fluid [false] - Specify whether to include fluid styles for the
736
- /// @param {Map} $breakpoints [$carbon--grid-breakpoints] - Provide a custom breakpoint map to use
737
- /// @access public
738
- /// @group @carbon/type
739
- @mixin carbon--type-style(
740
- $name,
741
- $fluid: false,
742
- $breakpoints: $carbon--grid-breakpoints
743
- ) {
744
- @if not map-has-key($tokens, $name) {
745
- @error 'Unable to find a token with the name: `#{$name}`';
746
- }
747
-
748
- $token: map-get($tokens, $name);
749
-
750
- // If $fluid is set to true and the token has breakpoints defined for fluid
751
- // styles, delegate to the fluid-type helper for the given token
752
- // Otherwise remove token breakpoints
753
- @if $fluid == true and map-has-key($token, 'breakpoints') {
754
- @include fluid-type($token, $breakpoints);
755
- } @else {
756
- @if global-variable-exists('feature-flags') and
757
- map-get($feature-flags, 'enable-css-custom-properties')
758
- {
759
- @include custom-properties($name, map-remove($token, 'breakpoints'));
760
- } @else {
761
- // Otherwise, we just include all the property declarations directly on the
762
- // selector
763
- @include properties(map-remove($token, 'breakpoints'));
764
- }
765
- }
766
- }