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