type-director 0.8
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.
- checksums.yaml +7 -0
- data/README.md +207 -0
- data/lib/type-director.rb +30 -0
- data/stylesheets/_type-director.scss +10 -0
- data/stylesheets/type-director/_build-font-scale.scss +57 -0
- data/stylesheets/type-director/_build-scale.scss +41 -0
- data/stylesheets/type-director/_build-typography.scss +46 -0
- data/stylesheets/type-director/_map-deep-get.scss +6 -0
- data/stylesheets/type-director/_round.scss +8 -0
- data/stylesheets/type-director/_set-font-size.scss +136 -0
- data/templates/project/config.rb +27 -0
- data/templates/project/fonts/feather-webfont.eot +0 -0
- data/templates/project/fonts/feather-webfont.svg +158 -0
- data/templates/project/fonts/feather-webfont.ttf +0 -0
- data/templates/project/fonts/feather-webfont.woff +0 -0
- data/templates/project/manifest.rb +18 -0
- data/templates/project/sass/_icons.scss +572 -0
- data/templates/project/sass/_typography-config.scss +78 -0
- data/templates/project/sass/_typography.scss +84 -0
- data/templates/project/sass/main.scss +162 -0
- data/templates/project/stylesheets/main.css +1240 -0
- data/templates/project/type-specimen.html +147 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7f3c69ad4cffb5ad9de8771730d4896f8d70bea8
|
4
|
+
data.tar.gz: 157eda8173d909e5d61baf484ea462a47adb1d1c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 26eae284ce0b33847e048e2b8e194c243e88632e8ce1924c7e409796a5c6ce57bfe45beebad8d3329f2f66b787174c7bc737874549b7086f6e2c7cbbadb287e3
|
7
|
+
data.tar.gz: 463a852223ec99cfe9921f983b8c0deb23a780e8a1ab460c5371a3bf9f694a20ddcfa078d364b54d38edabfa1059688686e8f8a39852dce922c2ec9683b7672f
|
data/README.md
ADDED
@@ -0,0 +1,207 @@
|
|
1
|
+
|
2
|
+
# Type Director
|
3
|
+
|
4
|
+
Type Director is a SASS framework for defining and applying typographic styles. Its goal is to generate a complex, nuanced typographic system from only a few key variables.
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
## Features
|
9
|
+
|
10
|
+
1. Modular. Typographic measurements are based on proportional lists of values.
|
11
|
+
2. Responsive. Typography adjusts to the constraints of each breakpoint.
|
12
|
+
3. Font rebalancing. Different fonts set to the same size often don't appear to be. Fonts are normalized, so every font appears to be exactly the size you intend.
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
## Install
|
17
|
+
|
18
|
+
* Terminal: `gem install type-director`
|
19
|
+
* Compass config.rb: `require 'type-director'`
|
20
|
+
* SCSS: `@import 'type-director';`
|
21
|
+
|
22
|
+
Or create a new project with a sample config and type specimen:
|
23
|
+
|
24
|
+
* Terminal: `compass create project-name -r type-director --using type-director`
|
25
|
+
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
### Declare your fonts
|
30
|
+
|
31
|
+
Fonts are defined via SASS maps in the following format:
|
32
|
+
|
33
|
+
```scss
|
34
|
+
// Default font
|
35
|
+
|
36
|
+
$font-georgia: (
|
37
|
+
"family": unquote("Georgia, serif"),
|
38
|
+
"font-size-adjustment": 1.00,
|
39
|
+
"line-height-adjustment": 1.00
|
40
|
+
);
|
41
|
+
|
42
|
+
// Additional fonts
|
43
|
+
|
44
|
+
$font-verdana: (
|
45
|
+
"family": unquote("Verdana, sans-serif"),
|
46
|
+
"font-size-adjustment": 0.89,
|
47
|
+
"line-height-adjustment": 0.93
|
48
|
+
);
|
49
|
+
|
50
|
+
$font-feather: (
|
51
|
+
"family": unquote("'Feather'"),
|
52
|
+
"font-size-adjustment": 0.95,
|
53
|
+
"line-height-adjustment": 1.00
|
54
|
+
);
|
55
|
+
```
|
56
|
+
|
57
|
+
Oftentimes two fonts set to the same size do not appear to be. This is because the heights of their lowercase letters are not equal. By using the `font-size-adjustment` property, additional fonts can be normalized to the default font. This will ensure they align to the modular scale.
|
58
|
+
|
59
|
+
For example, Verdana appears 11% larger than Georgia. To normalize it with Georgia, we can set a `font-size-adjustment: 0.89`. This will cause Verdana to be 11% smaller than Georgia when set to the same size.
|
60
|
+
|
61
|
+
Similarly, you can also apply an adjustment to line-height on a font-by-font basis by specifying a `line-height-adjustment`.
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
### Build font scales
|
66
|
+
|
67
|
+
From a few constraints, `td-build-typography` builds a modular scale for each specified media query.
|
68
|
+
|
69
|
+
```scss
|
70
|
+
$typography: td-build-typography((
|
71
|
+
|
72
|
+
// Define your font scales and their constraints.
|
73
|
+
"scales": (
|
74
|
+
|
75
|
+
// Phone sizes
|
76
|
+
"default": (
|
77
|
+
"base-font-size": 16px,
|
78
|
+
"base-line-height": 1.5,
|
79
|
+
"max-font-size": 28px,
|
80
|
+
"max-line-height": 1.35
|
81
|
+
),
|
82
|
+
|
83
|
+
// Tablet sizes and larger
|
84
|
+
"tablet": (
|
85
|
+
"media-query": "screen and (min-width: 768px)",
|
86
|
+
"base-font-size": 18px,
|
87
|
+
"base-line-height": 1.6,
|
88
|
+
"max-font-size": 42px,
|
89
|
+
"max-line-height": 1.25
|
90
|
+
)
|
91
|
+
),
|
92
|
+
|
93
|
+
// Other than the base, how many sizes do you need?
|
94
|
+
"numb-smaller-sizes": 1,
|
95
|
+
"numb-larger-sizes": 4
|
96
|
+
));
|
97
|
+
```
|
98
|
+
For each scale, you'll need to specify font-size and line-height for both a base size and a max size. Additional font-sizes and line-heights will be interpolated from these constraints.
|
99
|
+
|
100
|
+
A `media-query` property should also be set for each, exluding the "default" scale. Feel free to name the other scales whatever you like.
|
101
|
+
|
102
|
+
That's it! Note that `$typography` is a key variable. This map will be used by the following mixins to lookup and apply sizes.
|
103
|
+
|
104
|
+
If you need a bit of typographic guidance, [Responsive Typography: The Basics](https://ia.net/know-how/responsive-typography-the-basics "Responsive Typography: The Basics") by Information Architects is an excellent read.
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
### Apply responsize sizing
|
109
|
+
|
110
|
+
Use `@include td-set-responsive-font-size($font, $size)` to apply a responsive size. The sizes available to you are based on your parameters:
|
111
|
+
* 0 is your base size.
|
112
|
+
* 1, 2, 3... are your increasingly larger sizes.
|
113
|
+
* -1, -2, -3... are your increasingly smaller sizes.
|
114
|
+
|
115
|
+
```scss
|
116
|
+
.lead {
|
117
|
+
@include td-set-responsive-font-size($font-georgia, 1);
|
118
|
+
}
|
119
|
+
```
|
120
|
+
We just applied responsive styling to the lead paragraph style. It will use media queries to apply `$font-georgia` at size `1` from the corresponding scale: 18.4px by default, and then resizing to 22.2px for tablets and larger.
|
121
|
+
|
122
|
+
```scss
|
123
|
+
.h4 {
|
124
|
+
@include td-set-responsive-font-size($font-verdana, 1);
|
125
|
+
}
|
126
|
+
```
|
127
|
+
We used the same size for the `.h4` heading, but with `$font-verdana`. This will result in a font-size of 16.4px by default and 19.8px for tablets and larger. Mathematically different, but visually equal.
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
### Apply static sizing
|
132
|
+
|
133
|
+
You might occassionally want finer-grained control of your type styles. For these cases, use the `td-set-font-size()` mixin which accepts an additional `$breakpoint` parameter:
|
134
|
+
|
135
|
+
```scss
|
136
|
+
.h4 {
|
137
|
+
@include td-set-font-size($font-verdana, 1, "tablet");
|
138
|
+
}
|
139
|
+
```
|
140
|
+
|
141
|
+
Here we just styled our h4 to have the size 1 for only the tablet breakpoint. With `td-set-responsive-font-size()` the corresponding sizes for each other breakpoint would have also been applied.
|
142
|
+
|
143
|
+
|
144
|
+
## Advanced Usage
|
145
|
+
|
146
|
+
### Rounding
|
147
|
+
|
148
|
+
Rounding to any precision is supported.
|
149
|
+
|
150
|
+
```scss
|
151
|
+
$typography: td-build-typography((
|
152
|
+
|
153
|
+
// Define your font scales and their constraints.
|
154
|
+
"scales": (
|
155
|
+
|
156
|
+
// Phone sizes
|
157
|
+
"default": (
|
158
|
+
"base-font-size": 16px,
|
159
|
+
"base-line-height": 1.5,
|
160
|
+
"max-font-size": 28px,
|
161
|
+
"max-line-height": 1.35,
|
162
|
+
"font-size-precision": 0.1,
|
163
|
+
"line-height-precision": 0.01
|
164
|
+
),
|
165
|
+
|
166
|
+
// ...
|
167
|
+
));
|
168
|
+
```
|
169
|
+
|
170
|
+
### Solid and tight line-height
|
171
|
+
|
172
|
+
Oftentimes you may need to set very narrow lines of text, causing your line-height to look too loose. For a tighter line-height, use the `"line-height": "tight"` option.
|
173
|
+
|
174
|
+
```scss
|
175
|
+
.caption-tight {
|
176
|
+
@include td-set-responsive-font-size($font-verdana, -1, $opts: ("line-height": "tight"));
|
177
|
+
}
|
178
|
+
```
|
179
|
+
|
180
|
+
Other times you may want to set text to be solid (meaning no "leading"). In terms of CSS, this setting the line-height to be equal to the font-size. To do this, use the `"line-height": "solid"` option.
|
181
|
+
|
182
|
+
```scss
|
183
|
+
.btn {
|
184
|
+
@include td-set-responsive-font-size($font-verdana, 1, $opts: ("line-height": "solid"));
|
185
|
+
}
|
186
|
+
```
|
187
|
+
|
188
|
+
### Uppercase styles
|
189
|
+
|
190
|
+
If you'd like to set something in all caps and have it align to your font scales, include an `uppercase-adjustment` when defining fonts:
|
191
|
+
|
192
|
+
```scss
|
193
|
+
$font-verdana: (
|
194
|
+
"family": unquote("Verdana, sans-serif"),
|
195
|
+
"font-size-adjustment": 0.89,
|
196
|
+
"line-height-adjustment": 0.94,
|
197
|
+
"uppercase-adjustment": 0.85
|
198
|
+
);
|
199
|
+
```
|
200
|
+
|
201
|
+
Apply an uppercase style like so:
|
202
|
+
```scss
|
203
|
+
.h4 {
|
204
|
+
@include td-set-responsive-font-size($font-verdana, 1, $opts: ("uppercase": true));
|
205
|
+
}
|
206
|
+
```
|
207
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# All gems that are required for this extension to work should go here.
|
2
|
+
# These are the requires you would normally put in your config.rb file
|
3
|
+
# By default, you should always included Compass. Do not include your
|
4
|
+
# extension.
|
5
|
+
require 'compass'
|
6
|
+
require 'sassy-math'
|
7
|
+
|
8
|
+
# This tells Compass what your Compass extension is called,
|
9
|
+
# and where to find its files. Replace 'extension' with the
|
10
|
+
# name of your extension. Spaces allowed.
|
11
|
+
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
12
|
+
Compass::Frameworks.register('type-director', :path => extension_path)
|
13
|
+
|
14
|
+
# Version and date of version for your Compass extension.
|
15
|
+
# Replace Extension with the name of your extension. Letters,
|
16
|
+
# numbers, and underscores only. Version is a number. If a
|
17
|
+
# version contains alphas, it will be created as a
|
18
|
+
# prerelease version. Date is in the form of YYYY-MM-DD
|
19
|
+
module TypeDirector
|
20
|
+
VERSION = "0.8"
|
21
|
+
DATE = "2016-08-14"
|
22
|
+
end
|
23
|
+
|
24
|
+
# This is where any custom SassScript should be placed. The functions will be
|
25
|
+
# available on require of your extension without the need for users to import
|
26
|
+
# any partials. Uncomment below.
|
27
|
+
|
28
|
+
# module Sass::Script::Functions
|
29
|
+
#
|
30
|
+
# end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
@import "type-director/map-deep-get";
|
2
|
+
@import "type-director/build-scale";
|
3
|
+
@import "type-director/build-font-scale";
|
4
|
+
@import "type-director/build-typography";
|
5
|
+
|
6
|
+
$typography: td-build-typography() !default;
|
7
|
+
|
8
|
+
@import "type-director/round";
|
9
|
+
@import "type-director/set-font-size";
|
10
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
|
2
|
+
// Create a modular font scale.
|
3
|
+
// Returns a nested list of font-size and line-height values.
|
4
|
+
|
5
|
+
@function td-build-font-scale($opts: ()) {
|
6
|
+
|
7
|
+
// Extend default opts
|
8
|
+
$opts: map-merge((
|
9
|
+
"base-font-size": 16px,
|
10
|
+
"base-line-height": 1.5,
|
11
|
+
"max-font-size": 28px,
|
12
|
+
"max-line-height": 1.35,
|
13
|
+
"numb-smaller-sizes": 1,
|
14
|
+
"numb-larger-sizes": 4
|
15
|
+
), $opts);
|
16
|
+
|
17
|
+
// Create font-size scale
|
18
|
+
$font-size-scale: td-build-scale((
|
19
|
+
"base-value": map-get($opts, "base-font-size"),
|
20
|
+
"max-value": map-get($opts, "max-font-size"),
|
21
|
+
"numb-smaller-values": map-get($opts, "numb-smaller-sizes"),
|
22
|
+
"numb-larger-values": map-get($opts, "numb-larger-sizes")
|
23
|
+
));
|
24
|
+
|
25
|
+
// Create line-height scale
|
26
|
+
$line-height-scale: td-build-scale((
|
27
|
+
"base-value": map-get($opts, "base-line-height"),
|
28
|
+
"max-value": map-get($opts, "max-line-height"),
|
29
|
+
"numb-smaller-values": map-get($opts, "numb-smaller-sizes"),
|
30
|
+
"numb-larger-values": map-get($opts, "numb-larger-sizes")
|
31
|
+
));
|
32
|
+
|
33
|
+
$sizes: ();
|
34
|
+
|
35
|
+
// Pair each size with the correponding font-size
|
36
|
+
// and line-height, then add the size to the scale.
|
37
|
+
@for $i from -(map-get($opts, "numb-smaller-sizes")) to map-get($opts, "numb-larger-sizes") + 1 {
|
38
|
+
|
39
|
+
// Calculate array position in order to lookup sizes in lists.
|
40
|
+
$arr-position: $i + map-get($opts, "numb-smaller-sizes") + 1;
|
41
|
+
|
42
|
+
// Key for size
|
43
|
+
$name-of-size: $i;
|
44
|
+
|
45
|
+
// Values for size
|
46
|
+
$values: (
|
47
|
+
"font-size": nth($font-size-scale, $arr-position),
|
48
|
+
"line-height": nth($line-height-scale, $arr-position)
|
49
|
+
);
|
50
|
+
|
51
|
+
// Add to size array.
|
52
|
+
$sizes: map-merge($sizes, ($name-of-size: $values));
|
53
|
+
}
|
54
|
+
|
55
|
+
$font-scale: map-merge($opts, ("sizes": $sizes));
|
56
|
+
@return $font-scale;
|
57
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
// Create a modular scale. Returns a list of values.
|
3
|
+
|
4
|
+
@function td-build-scale($opts: ()) {
|
5
|
+
|
6
|
+
// Extend default opts
|
7
|
+
$opts: map-merge((
|
8
|
+
"base-value": 16px,
|
9
|
+
"max-value": 28px,
|
10
|
+
"numb-smaller-values": 1,
|
11
|
+
"numb-larger-values": 4
|
12
|
+
), $opts);
|
13
|
+
|
14
|
+
$base-value: map-get($opts, "base-value");
|
15
|
+
$max-value: map-get($opts, "max-value");
|
16
|
+
$numb-larger-values: map-get($opts, "numb-larger-values");
|
17
|
+
$numb-smaller-values: map-get($opts, "numb-smaller-values");
|
18
|
+
|
19
|
+
// Build the scale.
|
20
|
+
$scale: ();
|
21
|
+
|
22
|
+
// The ratio we'll use to calculate the missing sizes.
|
23
|
+
$scaling-ratio: nth-root($max-value / $base-value, $numb-larger-values);
|
24
|
+
|
25
|
+
// Calculate and add smaller values to the scale.
|
26
|
+
@for $i from -$numb-smaller-values through -1 {
|
27
|
+
$size: $base-value * power($scaling-ratio, $i);
|
28
|
+
$scale: append($scale, $size);
|
29
|
+
}
|
30
|
+
|
31
|
+
// Add the base value to the scale.
|
32
|
+
$scale: append($scale, $base-value);
|
33
|
+
|
34
|
+
// Calculate and add larger values to the scale.
|
35
|
+
@for $i from 1 through ($numb-larger-values) {
|
36
|
+
$size: $base-value * power($scaling-ratio, $i);
|
37
|
+
$scale: append($scale, $size);
|
38
|
+
}
|
39
|
+
|
40
|
+
@return $scale;
|
41
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
// Augments a breakpoint map by building a "scale" property
|
3
|
+
// containing the specified sizes to each breakpoint.
|
4
|
+
|
5
|
+
@function td-build-typography($opts: ()) {
|
6
|
+
|
7
|
+
// Extend default opts
|
8
|
+
$opts: map-merge((
|
9
|
+
"scales": (
|
10
|
+
"default": (
|
11
|
+
"base-font-size": 16px,
|
12
|
+
"base-line-height": 1.5,
|
13
|
+
"max-font-size": 28px,
|
14
|
+
"max-line-height": 1.35
|
15
|
+
),
|
16
|
+
"tablet": (
|
17
|
+
"media-query": "screen and (min-width: 768px)",
|
18
|
+
"base-font-size": 18px,
|
19
|
+
"base-line-height": 1.6,
|
20
|
+
"max-font-size": 42px,
|
21
|
+
"max-line-height": 1.25
|
22
|
+
)
|
23
|
+
),
|
24
|
+
"numb-smaller-sizes": 1,
|
25
|
+
"numb-larger-sizes": 4
|
26
|
+
), $opts);
|
27
|
+
|
28
|
+
// The object we'll return.
|
29
|
+
$typography: ();
|
30
|
+
|
31
|
+
// Create a scale for each breakpoint.
|
32
|
+
@each $font-scale-name, $font-scale-opts in map-get($opts, "scales") {
|
33
|
+
|
34
|
+
// Merge global opts with scale-specific opts
|
35
|
+
$font-scale-opts: map-merge($font-scale-opts, (
|
36
|
+
"numb-smaller-sizes": map-get($opts, "numb-smaller-sizes"),
|
37
|
+
"numb-larger-sizes": map-get($opts, "numb-larger-sizes")
|
38
|
+
));
|
39
|
+
|
40
|
+
// Create a font scale.
|
41
|
+
$font-scale: td-build-font-scale($font-scale-opts);
|
42
|
+
$typography: map-merge($typography, ($font-scale-name: $font-scale));
|
43
|
+
}
|
44
|
+
|
45
|
+
@return $typography;
|
46
|
+
}
|
@@ -0,0 +1,136 @@
|
|
1
|
+
/******************************************************
|
2
|
+
* MIXINS
|
3
|
+
******************************************************/
|
4
|
+
|
5
|
+
// Apply styles for a specific font, breakpoint, and size.
|
6
|
+
@mixin td-apply-font-styles($font, $size, $scale-name, $opts: ()) {
|
7
|
+
|
8
|
+
// Extend default opts
|
9
|
+
$opts: map-merge((
|
10
|
+
"uppercase": false,
|
11
|
+
"line-height": "normal"
|
12
|
+
), $opts);
|
13
|
+
|
14
|
+
// FONT SIZE
|
15
|
+
// Get and apply adjustments.
|
16
|
+
|
17
|
+
$unadjusted-font-size: map-deep-get($typography, $scale-name, "sizes", $size, "font-size");
|
18
|
+
$font-size-adjustment: map-get($font, "font-size-adjustment") or 1.00;
|
19
|
+
$uppercase-adjustment: map-get($font, "uppercase-adjustment") or 1.00;
|
20
|
+
|
21
|
+
@if map-get($opts, "uppercase") {
|
22
|
+
$font-size-adjustment: $font-size-adjustment * $uppercase-adjustment;
|
23
|
+
}
|
24
|
+
|
25
|
+
$font-size: $unadjusted-font-size * $font-size-adjustment;
|
26
|
+
|
27
|
+
// Round font-size.
|
28
|
+
$font-size-precision: map-deep-get($typography, $scale-name, "font-size-precision") or null;
|
29
|
+
@if ($font-size-precision) {
|
30
|
+
$font-size: td-round($font-size, $font-size-precision);
|
31
|
+
}
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
// LINE HEIGHT
|
36
|
+
// Get and apply adjustments.
|
37
|
+
|
38
|
+
$line-height-setting: map-get($opts, "line-height");
|
39
|
+
$unadjusted-line-height: null;
|
40
|
+
$line-height: null;
|
41
|
+
|
42
|
+
// Use line-height associated with scale and size.
|
43
|
+
$normal-line-height: map-deep-get($typography, $scale-name, "sizes", $size, "line-height");
|
44
|
+
|
45
|
+
// No space between lines. 1.0 if unitless, otherwise equal to font-size.
|
46
|
+
$solid-line-height: if(unitless($normal-line-height), 1.0, $font-size);
|
47
|
+
|
48
|
+
// Halfway between default and solid line-height.
|
49
|
+
$tight-line-height: (($normal-line-height - $solid-line-height) / 2) + $solid-line-height;
|
50
|
+
|
51
|
+
// If line-height is set to solid, use 1.0 or font-size.
|
52
|
+
@if $line-height-setting == "solid" {
|
53
|
+
$line-height: $solid-line-height;
|
54
|
+
|
55
|
+
} @else {
|
56
|
+
|
57
|
+
// Line-height setting determines corresponding basis.
|
58
|
+
@if $line-height-setting == "tight" {
|
59
|
+
$unadjusted-line-height: $tight-line-height;
|
60
|
+
} @else {
|
61
|
+
$unadjusted-line-height: $normal-line-height;
|
62
|
+
}
|
63
|
+
|
64
|
+
// Apply adjustments.
|
65
|
+
$line-height-adjustment: map-get($font, "line-height-adjustment") or 1.00;
|
66
|
+
|
67
|
+
// If using relative line heights, the font-size-adjustment will
|
68
|
+
// affect the line-height. This removes the unwanted effect.
|
69
|
+
@if unitless($unadjusted-line-height) {
|
70
|
+
$line-height-adjustment: $line-height-adjustment * (1 / $font-size-adjustment);
|
71
|
+
}
|
72
|
+
|
73
|
+
$line-height: $unadjusted-line-height * $line-height-adjustment;
|
74
|
+
}
|
75
|
+
|
76
|
+
// Round line-height.
|
77
|
+
$line-height-precision: map-deep-get($typography, $scale-name, "line-height-precision") or null;
|
78
|
+
@if ($line-height-precision) {
|
79
|
+
$line-height: td-round($line-height, $line-height-precision);
|
80
|
+
}
|
81
|
+
|
82
|
+
font-size: $font-size;
|
83
|
+
line-height: $line-height;
|
84
|
+
}
|
85
|
+
|
86
|
+
// Apply non-responsive styling. Only the size used for
|
87
|
+
// the specified media query will be applied.
|
88
|
+
@mixin td-set-font-size($font, $size, $scale-name, $opts: ()) {
|
89
|
+
|
90
|
+
// Extend default opts
|
91
|
+
$opts: map-merge((
|
92
|
+
"uppercase": false,
|
93
|
+
"line-height": "normal"
|
94
|
+
), $opts);
|
95
|
+
|
96
|
+
font-family: map-get($font, "family");
|
97
|
+
|
98
|
+
@if map-get($opts, "uppercase") {
|
99
|
+
text-transform: uppercase;
|
100
|
+
}
|
101
|
+
|
102
|
+
@include td-apply-font-styles($font, $size, $scale-name, $opts);
|
103
|
+
}
|
104
|
+
|
105
|
+
// Apply responsive styling. Corresponding sizes for
|
106
|
+
// each media query will be applied.
|
107
|
+
@mixin td-set-responsive-font-size($font, $size: 0, $opts: ()) {
|
108
|
+
|
109
|
+
// Extend default opts
|
110
|
+
$opts: map-merge((
|
111
|
+
"uppercase": false,
|
112
|
+
"line-height": "normal"
|
113
|
+
), $opts);
|
114
|
+
|
115
|
+
font-family: map-get($font, "family");
|
116
|
+
|
117
|
+
@if map-get($opts, "uppercase") {
|
118
|
+
text-transform: uppercase;
|
119
|
+
}
|
120
|
+
|
121
|
+
@each $scale-name, $scale-value in $typography {
|
122
|
+
|
123
|
+
// For the default styles, don't include a media query.
|
124
|
+
@if $scale-name == "default" {
|
125
|
+
@include td-apply-font-styles($font, $size, $scale-name, $opts);
|
126
|
+
}
|
127
|
+
|
128
|
+
// For other breakpoints, set style with a media query.
|
129
|
+
@else {
|
130
|
+
$media-query: map-deep-get($typography, $scale-name, "media-query");
|
131
|
+
@media #{$media-query} {
|
132
|
+
@include td-apply-font-styles($font, $size, $scale-name, $opts);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|