|
8 | 8 | @use '../themes-sass' as themes; |
9 | 9 | @use '../functions'; |
10 | 10 |
|
| 11 | + |
11 | 12 | // * -------------------------------------------------------------------------- */ |
12 | 13 | // Font families |
13 | 14 | @mixin font-base { |
|
23 | 24 | } |
24 | 25 |
|
25 | 26 | // * -------------------------------------------------------------------------- */ |
26 | | -// A mixin to output font-size in rems with a px fallback for old browsers. |
| 27 | +// A mixin to output font-size in rems. |
27 | 28 | // Declare sizes in pixels for ease and clarity, the mixin does the math. |
28 | | -// Requires: remify(), pixify() - defined in includes/themes.scss. |
| 29 | +// Requires: remify() - defined in includes/themes.scss. |
29 | 30 | // Usage: |
30 | 31 | // .foo { @include font-size(24px); } |
31 | 32 |
|
|
34 | 35 |
|
35 | 36 | @if math.unit($size) == 'px' { |
36 | 37 | font-size: $size; |
37 | | - font-size: functions.remify($size); |
38 | 38 | } |
39 | 39 |
|
40 | 40 | // When unit is not pixels, show an error |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 |
|
46 | | -// * -------------------------------------------------------------------------- */ |
47 | | -// Consistent font sizes. Avoid sizing text arbitrarily and use this |
48 | | -// set of predefined sizes. Sizes adapt at common breakpoints, and |
49 | | -// there's some redundancy at smaller sizes because we don't want things |
50 | | -// getting too tiny. |
51 | | - |
52 | 46 | // Example usage: |
53 | 47 | // .title { @include text-title-xl; } |
54 | 48 | // .subtitle { @include text-title-lg; } |
55 | 49 | // .intro { @include text-body-lg; } |
56 | 50 |
|
57 | 51 | @mixin text-title-2xl { |
58 | | - @include font-size(themes.$title-xl-size); |
59 | | - line-height: themes.$title-xl-line-height; |
60 | | - |
61 | | - @media #{tokens.$mq-md} { |
62 | | - @include font-size(themes.$title-2xl-size); |
63 | | - line-height: themes.$title-2xl-line-height; |
64 | | - } |
65 | | - |
66 | | - @supports (--css: variables) { |
67 | | - font-size: var(--title-xl-size); |
68 | | - line-height: var(--title-xl-line-height); |
69 | | - |
70 | | - @media #{tokens.$mq-md} { |
71 | | - font-size: var(--title-2xl-size); |
72 | | - line-height: var(--title-2xl-line-height); |
73 | | - } |
74 | | - } |
| 52 | + font-size: var(--title-2xl-size); |
| 53 | + line-height: var(--title-2xl-line-height); |
75 | 54 | } |
76 | 55 |
|
77 | 56 | @mixin text-title-xl { |
78 | | - @include font-size(themes.$title-lg-size); |
79 | | - line-height: themes.$title-lg-line-height; |
80 | | - |
81 | | - @media #{tokens.$mq-md} { |
82 | | - @include font-size(themes.$title-xl-size); |
83 | | - line-height: themes.$title-xl-line-height; |
84 | | - } |
85 | | - |
86 | | - @supports (--css: variables) { |
87 | | - font-size: var(--title-lg-size); |
88 | | - line-height: var(--title-lg-line-height); |
89 | | - |
90 | | - @media #{tokens.$mq-md} { |
91 | | - font-size: var(--title-xl-size); |
92 | | - line-height: var(--title-xl-line-height); |
93 | | - } |
94 | | - } |
| 57 | + font-size: var(--title-xl-size); |
| 58 | + line-height: var(--title-xl-line-height); |
95 | 59 | } |
96 | 60 |
|
97 | 61 | @mixin text-title-lg { |
98 | | - @include font-size(themes.$title-md-size); |
99 | | - line-height: themes.$title-md-line-height; |
100 | | - |
101 | | - @media #{tokens.$mq-md} { |
102 | | - @include font-size(themes.$title-lg-size); |
103 | | - line-height: themes.$title-lg-line-height; |
104 | | - } |
105 | | - |
106 | | - @supports (--css: variables) { |
107 | | - font-size: var(--title-md-size); |
108 | | - line-height: var(--title-md-line-height); |
109 | | - |
110 | | - @media #{tokens.$mq-md} { |
111 | | - font-size: var(--title-lg-size); |
112 | | - line-height: var(--title-lg-line-height); |
113 | | - } |
114 | | - } |
| 62 | + font-size: var(--title-lg-size); |
| 63 | + line-height: var(--title-lg-line-height); |
115 | 64 | } |
116 | 65 |
|
117 | 66 | @mixin text-title-md { |
118 | | - @include font-size(themes.$title-sm-size); |
119 | | - line-height: themes.$title-sm-line-height; |
120 | | - |
121 | | - @media #{tokens.$mq-md} { |
122 | | - @include font-size(themes.$title-md-size); |
123 | | - line-height: themes.$title-md-line-height; |
124 | | - } |
125 | | - |
126 | | - @supports (--css: variables) { |
127 | | - font-size: var(--title-sm-size); |
128 | | - line-height: var(--title-sm-line-height); |
129 | | - |
130 | | - @media #{tokens.$mq-md} { |
131 | | - font-size: var(--title-md-size); |
132 | | - line-height: var(--title-md-line-height); |
133 | | - } |
134 | | - } |
| 67 | + font-size: var(--title-md-size); |
| 68 | + line-height: var(--title-md-line-height); |
135 | 69 | } |
136 | 70 |
|
137 | 71 | @mixin text-title-sm { |
138 | | - @include font-size(themes.$title-xs-size); |
139 | | - line-height: themes.$title-xs-line-height; |
140 | | - |
141 | | - @media #{tokens.$mq-md} { |
142 | | - @include font-size(themes.$title-sm-size); |
143 | | - line-height: themes.$title-sm-line-height; |
144 | | - } |
145 | | - |
146 | | - @supports (--css: variables) { |
147 | | - font-size: var(--title-xs-size); |
148 | | - line-height: var(--title-xs-line-height); |
149 | | - |
150 | | - @media #{tokens.$mq-md} { |
151 | | - font-size: var(--title-sm-size); |
152 | | - line-height: var(--title-sm-line-height); |
153 | | - } |
154 | | - } |
| 72 | + font-size: var(--title-sm-size); |
| 73 | + line-height: var(--title-sm-line-height); |
155 | 74 | } |
156 | 75 |
|
157 | 76 | @mixin text-title-xs { |
158 | | - @include font-size(themes.$title-2xs-size); |
159 | | - line-height: themes.$title-2xs-line-height; |
160 | | - |
161 | | - @media #{tokens.$mq-md} { |
162 | | - @include font-size(themes.$title-xs-size); |
163 | | - line-height: themes.$title-xs-line-height; |
164 | | - } |
165 | | - |
166 | | - @supports (--css: variables) { |
167 | | - font-size: var(--title-2xs-size); |
168 | | - line-height: var(--title-2xs-line-height); |
169 | | - |
170 | | - @media #{tokens.$mq-md} { |
171 | | - font-size: var(--title-xs-size); |
172 | | - line-height: var(--title-xs-line-height); |
173 | | - } |
174 | | - } |
| 77 | + font-size: var(--title-xs-size); |
| 78 | + line-height: var(--title-xs-line-height); |
175 | 79 | } |
176 | 80 |
|
177 | 81 | @mixin text-title-2xs { |
178 | | - @include font-size(themes.$title-3xs-size); |
179 | | - line-height: themes.$title-3xs-line-height; |
180 | | - |
181 | | - @media #{tokens.$mq-md} { |
182 | | - @include font-size(themes.$title-2xs-size); |
183 | | - line-height: themes.$title-2xs-line-height; |
184 | | - } |
185 | | - |
186 | | - @supports (--css: variables) { |
187 | | - font-size: var(--title-3xs-size); |
188 | | - line-height: var(--title-3xs-line-height); |
189 | | - |
190 | | - @media #{tokens.$mq-md} { |
191 | | - font-size: var(--title-2xs-size); |
192 | | - line-height: var(--title-2xs-line-height); |
193 | | - } |
194 | | - } |
| 82 | + font-size: var(--title-2xs-size); |
| 83 | + line-height: var(--title-2xs-line-height); |
195 | 84 | } |
196 | 85 |
|
197 | 86 | @mixin text-title-3xs { |
198 | | - @include font-size(themes.$title-3xs-size); |
199 | | - line-height: themes.$title-3xs-line-height; |
200 | | - |
201 | | - @supports (--css: variables) { |
202 | | - font-size: var(--title-3xs-size); |
203 | | - line-height: var(--title-3xs-line-height); |
204 | | - } |
| 87 | + font-size: var(--title-3xs-size); |
| 88 | + line-height: var(--title-3xs-line-height); |
205 | 89 | } |
206 | 90 |
|
207 | 91 | // body copy |
208 | 92 | @mixin text-body-xl { |
209 | | - @include font-size(themes.$body-xl-size); |
210 | | - line-height: themes.$body-line-height; |
211 | | - |
212 | | - @supports (--css: variables) { |
213 | | - font-size: var(--body-xl-size); |
214 | | - line-height: var(--body-line-height); |
215 | | - } |
| 93 | + font-size: var(--scale-body-xl); |
| 94 | + line-height: var(--title-body-line-height); |
216 | 95 | } |
217 | 96 |
|
218 | 97 | @mixin text-body-lg { |
219 | | - @include font-size(themes.$body-lg-size); |
220 | | - line-height: themes.$body-line-height; |
221 | | - |
222 | | - @supports (--css: variables) { |
223 | | - font-size: var(--body-lg-size); |
224 | | - line-height: var(--body-line-height); |
225 | | - } |
| 98 | + font-size: var(--scale-body-lg); |
| 99 | + line-height: var(--title-body-line-height); |
226 | 100 | } |
227 | 101 |
|
228 | 102 | @mixin text-body-md { |
229 | | - @include font-size(themes.$body-md-size); |
230 | | - line-height: themes.$body-line-height; |
231 | | - |
232 | | - @supports (--css: variables) { |
233 | | - font-size: var(--body-md-size); |
234 | | - line-height: var(--body-line-height); |
235 | | - } |
| 103 | + font-size: var(--scale-body-md); |
| 104 | + line-height: var(--title-body-line-height); |
236 | 105 | } |
237 | 106 |
|
238 | 107 | @mixin text-body-sm { |
239 | | - @include font-size(themes.$body-sm-size); |
240 | | - line-height: themes.$body-line-height; |
241 | | - |
242 | | - @supports (--css: variables) { |
243 | | - font-size: var(--body-sm-size); |
244 | | - line-height: var(--body-line-height); |
245 | | - } |
| 108 | + font-size: var(--scale-body-sm); |
| 109 | + line-height: var(--title-body-line-height); |
246 | 110 | } |
247 | 111 |
|
248 | 112 | @mixin text-body-xs { |
249 | | - @include font-size(themes.$body-xs-size); |
250 | | - line-height: themes.$body-line-height; |
251 | | - |
252 | | - @supports (--css: variables) { |
253 | | - font-size: var(--body-xs-size); |
254 | | - line-height: var(--body-line-height); |
255 | | - } |
| 113 | + font-size: var(--scale-body-xs); |
| 114 | + line-height: var(--title-body-line-height); |
256 | 115 | } |
257 | 116 |
|
| 117 | + |
| 118 | + |
258 | 119 | // Aliases for backwards compatibility |
259 | 120 | $text-body-line-height: themes.$body-line-height; |
260 | 121 | $text-title-line-height: themes.$title-md-line-height; |
|
0 commit comments