@carbon/type 10.1.1 → 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.
@@ -0,0 +1,59 @@
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
+ @import '../vendor/@carbon/layout/convert';
9
+
10
+ /// Compute the type size for the given type scale step
11
+ /// @param {Number} $step
12
+ /// @return {Number} In px
13
+ /// @access public
14
+ /// @group @carbon/type
15
+ @function carbon--get-type-size($step) {
16
+ @if $step == 1 {
17
+ @return 12px;
18
+ }
19
+ // Yn = Yn-1 + {INT[(n-2)/4] + 1} * 2
20
+ @return carbon--get-type-size($step - 1) + (floor(($step - 2) / 4) + 1) * 2;
21
+ }
22
+
23
+ /// Type scole follows a custom formula for determining each step size and supports sizes from 12px to 92px
24
+ /// @type Map
25
+ /// @access public
26
+ /// @group @carbon/type
27
+ $carbon--type-scale: ();
28
+ @for $i from 1 through 23 {
29
+ $carbon--type-scale: append(
30
+ $carbon--type-scale,
31
+ carbon--rem(carbon--get-type-size($i))
32
+ );
33
+ }
34
+
35
+ /// Get the value of a specific step in the typescale
36
+ /// @param {Number} $step
37
+ /// @return {Number} In rem
38
+ /// @access public
39
+ /// @group @carbon/type
40
+ @function carbon--type-scale($step) {
41
+ @return nth($carbon--type-scale, $step);
42
+ }
43
+
44
+ /// Set the font-size value of a selector with the value at the given `$step`
45
+ /// @param {Number} $step
46
+ /// @access public
47
+ /// @group @carbon/type
48
+ @mixin carbon--type-scale($step) {
49
+ font-size: carbon--type-scale($step);
50
+ }
51
+
52
+ /// Alias of `type-scale` mixin.
53
+ /// @param {Number} $step
54
+ /// @alias carbon--type-scale
55
+ /// @access public
56
+ /// @group @carbon/type
57
+ @mixin carbon--font-size($step) {
58
+ font-size: carbon--type-scale($step);
59
+ }