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