typey 1.0.0.alpha.5 → 1.0.0.beta.1
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 +4 -4
- data/README.md +305 -13
- data/stylesheets/_typey.scss +3 -2
- data/stylesheets/typey/_defaults.scss +17 -12
- data/stylesheets/typey/_font-size.scss +33 -40
- data/stylesheets/typey/_font-stacks.scss +4 -4
- data/stylesheets/typey/_helpers.scss +109 -11
- data/stylesheets/typey/_line-height.scss +18 -35
- data/stylesheets/typey/_margin.scss +46 -36
- data/stylesheets/typey/_padding.scss +46 -36
- data/stylesheets/typey/_type-layout.scss +49 -0
- data/stylesheets/typey/_weight.scss +32 -0
- data/typey.gemspec +3 -3
- metadata +12 -11
- data/stylesheets/typey/_font-weight.scss +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aca87ffaf531d2f1e51eb2be6c9da355dfb02a44
|
4
|
+
data.tar.gz: 4bfeb8f07ef93d64305edaf294b16dfffa7aec8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cd59c665668d4e34b6b4e24afbe69dbf077cfaa1126300dc2fced7ea96368c43484610917102531bac7891f6929aae7cce0b9159b289718433ff9539c647b31
|
7
|
+
data.tar.gz: 564260d9dab2c9647eb2e00f55a12bf680b1caba17f6700ffcc55853cf4028c41818bd622fdcc99e9ecfb8d61ad3ae953ba44050ce8ea8baeed8acdf26391641
|
data/README.md
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
# typey
|
2
2
|
Do typography better.
|
3
3
|
|
4
|
-
|
4
|
+
**Typey is in beta! Use it to your hearts content on _all_ your projects!**
|
5
|
+
|
5
6
|
|
6
7
|
### Features
|
7
8
|
|
8
|
-
* Use px
|
9
|
+
* Use px to define font sizes and have them output in rem or em.
|
9
10
|
* Define font sizes inside a sass map as t-shirt sizes (m, l, xl, xxl, etc).
|
10
11
|
* Define line-height as multiples of the base line height OR as static values.
|
11
12
|
* Automatic px fallbacks when using rem as the base unit.
|
13
|
+
* Easily convert px values to rem or em.
|
12
14
|
* Define font weights inside a sass map.
|
13
|
-
* Ready to go web safe font stacks that are easy to extend.
|
15
|
+
* Ready to go web safe font stacks that are easy to extend.
|
14
16
|
|
15
17
|
### Requirements
|
16
18
|
|
@@ -32,11 +34,11 @@ Bower
|
|
32
34
|
Vanilla Sass
|
33
35
|
|
34
36
|
* Terminal: 'git clone git@github.com:jptaranto/typey.git
|
35
|
-
* SCSS: `@import '../link_to_component_dir/typey/stylesheets/typey'`
|
37
|
+
* SCSS: `@import '../link_to_component_dir/typey/stylesheets/typey'`
|
36
38
|
|
37
39
|
### CSS units used in typey
|
38
40
|
|
39
|
-
`px`
|
41
|
+
`px`
|
40
42
|
|
41
43
|
By far the simplest unit you can use to size typography on the web. It translates very easily from mockups produced in a certain over-rated graphics suite. In typey, all base sizes are specified in `px` (or `pt`) and are automatically converted to your `$base-unit`.
|
42
44
|
|
@@ -58,7 +60,7 @@ Just like in compass Vertical Rhythm we define our base font size and line heigh
|
|
58
60
|
|
59
61
|
```sass
|
60
62
|
$base-font-size: 16px;
|
61
|
-
$base-line-height:
|
63
|
+
$base-line-height: 24px;
|
62
64
|
```
|
63
65
|
|
64
66
|
We also need to define the base unit that the functions and mixins will output. you can use `px`, `pt` (for print stylesheets), `rem` or `em`.
|
@@ -124,12 +126,20 @@ h4 {
|
|
124
126
|
}
|
125
127
|
```
|
126
128
|
|
129
|
+
Or for short hand you can use the `type-layout()` mixin.
|
130
|
+
|
131
|
+
```sass
|
132
|
+
h4 {
|
133
|
+
@include type-layout(xl, 2);
|
134
|
+
}
|
135
|
+
```
|
136
|
+
|
127
137
|
When using `em` as your `$base-unit`, each function accepts a second parameter so your `em` value will be relative to it's parent or element `font-size`. The second parameter can either accept a t-shirt size or a static value for granular control.
|
128
138
|
|
129
139
|
```sass
|
130
140
|
h4 {
|
131
141
|
font-size: font-size(xl);
|
132
|
-
|
142
|
+
|
133
143
|
span {
|
134
144
|
font-size: font-size(s, xl);
|
135
145
|
line-height: line-height(2, 14px);
|
@@ -161,8 +171,8 @@ We also have a pair of mixins which (you guessed it!) automatically add fallback
|
|
161
171
|
|
162
172
|
```sass
|
163
173
|
div {
|
164
|
-
@include margin(1
|
165
|
-
@include padding(1
|
174
|
+
@include margin(2 1);
|
175
|
+
@include padding(2 1);
|
166
176
|
}
|
167
177
|
```
|
168
178
|
|
@@ -171,7 +181,7 @@ If you are using `em`, both the `margin()` and `padding()` functions/mixins acce
|
|
171
181
|
```sass
|
172
182
|
div {
|
173
183
|
font-size: font-size(s)
|
174
|
-
|
184
|
+
|
175
185
|
span {
|
176
186
|
@include margin(1 2, s);
|
177
187
|
@include padding(1 2, s);
|
@@ -197,13 +207,295 @@ $font-weight: (
|
|
197
207
|
);
|
198
208
|
```
|
199
209
|
|
200
|
-
You can then use typey's built in
|
210
|
+
You can then use typey's built in `weight()` function to call these values in an easy and readable way.
|
201
211
|
|
202
212
|
```sass
|
203
213
|
strong {
|
204
|
-
font-weight:
|
214
|
+
font-weight: weight(bold)
|
205
215
|
}
|
206
216
|
```
|
207
217
|
|
218
|
+
## Reference
|
219
|
+
|
220
|
+
### Variables
|
221
|
+
|
222
|
+
```sass
|
223
|
+
$browser-font-size: 16px !default;
|
224
|
+
```
|
225
|
+
|
226
|
+
The browser font size default. No need to change this.
|
227
|
+
|
228
|
+
|
229
|
+
```sass
|
230
|
+
$base-font-size: 16px !default;
|
231
|
+
```
|
232
|
+
|
233
|
+
The base font size will be used for most calculations involving font-size.
|
234
|
+
Allowed units: px or pt
|
235
|
+
|
236
|
+
|
237
|
+
```sass
|
238
|
+
$base-line-height: 21px !default;
|
239
|
+
```
|
240
|
+
|
241
|
+
The base line height will be used for most calculations involving height.
|
242
|
+
Allowed units: Must be the same as $base-line-height
|
243
|
+
|
244
|
+
|
245
|
+
```sass
|
246
|
+
$base-unit: rem !default;
|
247
|
+
```
|
248
|
+
|
249
|
+
Allowed units: px, pt, em or rem.
|
250
|
+
|
251
|
+
|
252
|
+
```sass
|
253
|
+
$rem-fallback: true !default;
|
254
|
+
```
|
255
|
+
|
256
|
+
By default we will provide fallbacks when rem is the base unit.
|
257
|
+
|
258
|
+
|
259
|
+
```sass
|
260
|
+
$font-size: (
|
261
|
+
xxxl: 60px,
|
262
|
+
xxl: 46px,
|
263
|
+
xl: 32px,
|
264
|
+
l: 24px,
|
265
|
+
m: 16px,
|
266
|
+
s: 14px,
|
267
|
+
xs: 12px
|
268
|
+
) !default;
|
269
|
+
```
|
270
|
+
|
271
|
+
Default font sizes
|
272
|
+
Once you redefine the $font-size map it will overwrite all sizes here.
|
273
|
+
Allowed units: Must be the same as $base-line-height
|
274
|
+
|
275
|
+
|
276
|
+
```sass
|
277
|
+
$font-weight: (
|
278
|
+
bold: 700,
|
279
|
+
normal: 400,
|
280
|
+
lighter: 200
|
281
|
+
) !default;
|
282
|
+
```
|
283
|
+
|
284
|
+
Default font weights
|
285
|
+
This map and accompanying function help provide granular control over setting and retrieving static font weights.
|
286
|
+
|
287
|
+
### Mixins
|
288
|
+
|
289
|
+
```sass
|
290
|
+
define-type-sizing($base-font-size: $base-font-size, $base-line-height: $base-line-height)
|
291
|
+
```
|
292
|
+
|
293
|
+
Outputs the base font-size property and the base line-height property. Font-size is outputted as a % of the base browser font size. A fallback for rem is provided for the line-height property.
|
294
|
+
|
295
|
+
*@param number $base-font-size*
|
296
|
+
(optional) Use to set to anything other than the base value. Allowed units: px or pt
|
297
|
+
|
298
|
+
*@param number $base-line-height(optional)*
|
299
|
+
Use to set to anything other than the base value. Allowed units: px or pt
|
300
|
+
|
301
|
+
|
302
|
+
```sass
|
303
|
+
type-layout($size, $x, $context: $size)
|
304
|
+
```
|
305
|
+
|
306
|
+
Outputs both line-height and font-size properties, providing fallbacks when rem is the base unit.
|
307
|
+
|
308
|
+
*@param number|string $size*
|
309
|
+
A size from the $font-size map or a px/pt value.
|
310
|
+
|
311
|
+
*@param number $x*
|
312
|
+
Multiple of line height to be used or px/pt value to be converted.
|
313
|
+
|
314
|
+
*@param number|string $context*
|
315
|
+
(optional) Only used if em is the $base-unit. The value of the elements/parents font-size if it differs from $base-font-size. Specified as a t-shirt size or value in the same unit as the $font-size map.
|
316
|
+
|
317
|
+
|
318
|
+
```sass
|
319
|
+
font-size($size, $context: $base-font-size)
|
320
|
+
```
|
321
|
+
|
322
|
+
Outputs font-size property, providing fallbacks when rem is the base unit.
|
323
|
+
|
324
|
+
*@param number|string $size*
|
325
|
+
A size from the $font-size map or px/pt value to be converted
|
326
|
+
|
327
|
+
*@param number|string $context*
|
328
|
+
(optional) Only used if em is the $base-unit. The value of the parent font-size if it differs from $base-font-size. Specified as a t-shirt size or value in the same unit as the $font-size map.
|
329
|
+
|
330
|
+
|
331
|
+
```sass
|
332
|
+
line-height($x, $context: $base-font-size)
|
333
|
+
```
|
334
|
+
|
335
|
+
Outputs line-height property, providing fallbacks when rem is the base unit.
|
336
|
+
|
337
|
+
*@param number $x*
|
338
|
+
Multiple of line height to be used or px/pt value to be converted.
|
208
339
|
|
209
|
-
|
340
|
+
*@param number|string $context*
|
341
|
+
(optional) Only used if em is the $base-unit. The value of the elements/parentsfont-size if it differs from $base-font-size. Specified as a t-shirt size or value in the same unit as the $font-size map.
|
342
|
+
|
343
|
+
|
344
|
+
```sass
|
345
|
+
margin($x, $context: $base-font-size)
|
346
|
+
```
|
347
|
+
|
348
|
+
Outputs margin property, providing fallbacks when rem is the base unit.
|
349
|
+
|
350
|
+
*@param number|list $x*
|
351
|
+
Multiple of line height to be used or px/pt value to be converted.
|
352
|
+
Uses the same parameters as the CSS margin property:
|
353
|
+
i.e. top right bottom left, 1 0 2 0.
|
354
|
+
|
355
|
+
*@param number|string $context*
|
356
|
+
(optional) Only used if em is the $base-unit. The value of the elements/parents font-size if it differs from $base-font-size. Specified as a t-shirt size or value in the same unit as the $font-size map.
|
357
|
+
|
358
|
+
|
359
|
+
```sass
|
360
|
+
padding($x, $context: $base-font-size)
|
361
|
+
```
|
362
|
+
|
363
|
+
Outputs padding property, providing fallbacks when rem is the base unit.
|
364
|
+
|
365
|
+
*@param number|list $x*
|
366
|
+
Multiple of line height to be used or px/pt value to be converted.
|
367
|
+
Uses the same parameters as the CSS margin property:
|
368
|
+
i.e. top right bottom left, 1 0 2 0.
|
369
|
+
|
370
|
+
*@param number|string $context*
|
371
|
+
(optional) Only used if em is the $base-unit. The value of the elements/parents font-size if it differs from $base-font-size. Specified as a t-shirt size or value in the same unit as the $font-size map.
|
372
|
+
|
373
|
+
|
374
|
+
```sass
|
375
|
+
margin-top($x, $context: $base-font-size)
|
376
|
+
margin-right($x, $context: $base-font-size)
|
377
|
+
margin-bottom($x, $context: $base-font-size)
|
378
|
+
margin-left($x, $context: $base-font-size)
|
379
|
+
```
|
380
|
+
|
381
|
+
Outputs corresponding margin property, providing fallbacks when rem is the base unit.
|
382
|
+
|
383
|
+
*@param number|list $x*
|
384
|
+
Multiple of line height to be used or px/pt value to be converted.
|
385
|
+
|
386
|
+
*@param number|string $context*
|
387
|
+
(optional) Only used if em is the $base-unit. The value of the elements/parents font-size if it differs from $base-font-size. Specified as a t-shirt size or value in the same unit as the $font-size map.
|
388
|
+
|
389
|
+
|
390
|
+
```sass
|
391
|
+
padding-top($x, $context: $base-font-size)
|
392
|
+
padding-right($x, $context: $base-font-size)
|
393
|
+
padding-bottom($x, $context: $base-font-size)
|
394
|
+
padding-left($x, $context: $base-font-size)
|
395
|
+
```
|
396
|
+
|
397
|
+
Outputs corresponding padding property, providing fallbacks when rem is the base unit.
|
398
|
+
|
399
|
+
*@param number|list $x*
|
400
|
+
Multiple of line height to be used or px/pt value to be converted.
|
401
|
+
|
402
|
+
*@param number|string $context*
|
403
|
+
(optional) Only used if em is the $base-unit. The value of the elements/parents font-size if it differs from $base-font-size. Specified as a t-shirt size or value in the same unit as the $font-size map.
|
404
|
+
|
405
|
+
### Functions
|
406
|
+
|
407
|
+
```sass
|
408
|
+
font-size($size, $context: $base-font-size)
|
409
|
+
```
|
410
|
+
|
411
|
+
*@param number|string $size*
|
412
|
+
A size from the $font-size map or px/pt value to be converted
|
413
|
+
|
414
|
+
*@param number|string $context*
|
415
|
+
(optional) Only used if em is the $base-unit. The value of the parent font-size if it differs from $base-font-size. Specified as a t-shirt size or value in the same unit as the $font-size map.
|
416
|
+
|
417
|
+
*@return number*
|
418
|
+
The selected font-size in $base-unit.
|
419
|
+
|
420
|
+
|
421
|
+
```sass
|
422
|
+
line-height($x, $context: $base-font-size)
|
423
|
+
```
|
424
|
+
|
425
|
+
*@param number $x*
|
426
|
+
Multiple of line height to be used or px/pt value to be converted.
|
427
|
+
|
428
|
+
*@param number|string $context*
|
429
|
+
(optional) Only used if em is the $base-unit. The value of the elements/parentsfont-size if it differs from $base-font-size. Specified as a t-shirt size or value in the same unit as the $font-size map.
|
430
|
+
|
431
|
+
*@return number*
|
432
|
+
The calculated height in $base-unit.
|
433
|
+
|
434
|
+
|
435
|
+
```sass
|
436
|
+
margin($x, $context: $base-font-size)
|
437
|
+
```
|
438
|
+
|
439
|
+
*@param number $x*
|
440
|
+
Multiple of line height to be used or px/pt value to be converted.
|
441
|
+
|
442
|
+
*@param number|string $context*
|
443
|
+
(optional) Only used if em is the $base-unit. The value of the elements/parents font-size if it differs from $base-font-size. Specified as a t-shirt size or value in the same unit as the $font-size map.
|
444
|
+
|
445
|
+
*@return number*
|
446
|
+
The calculated height in $base-unit.
|
447
|
+
|
448
|
+
|
449
|
+
```sass
|
450
|
+
padding($x, $context: $base-font-size)
|
451
|
+
```
|
452
|
+
|
453
|
+
*@param number $x*
|
454
|
+
Multiple of line height to be used or px/pt value to be converted.
|
455
|
+
|
456
|
+
*@param number|string $context*
|
457
|
+
(optional) Only used if em is the $base-unit. The value of the elements/parents font-size if it differs from $base-font-size. Specified as a t-shirt size or value in the same unit as the $font-size map.
|
458
|
+
|
459
|
+
*@return number*
|
460
|
+
The calculated height in $base-unit.
|
461
|
+
|
462
|
+
|
463
|
+
```sass
|
464
|
+
weight($weight)
|
465
|
+
```
|
466
|
+
|
467
|
+
*@param string $weight*
|
468
|
+
A weight from the $font-weight map.
|
469
|
+
|
470
|
+
*@return string*
|
471
|
+
The selected font-weight.
|
472
|
+
|
473
|
+
|
474
|
+
```sass
|
475
|
+
extend-font-stack($font, $font-stack)
|
476
|
+
```
|
477
|
+
|
478
|
+
*Example usage:*
|
479
|
+
$new-font-stack: extend-font-stack("Open sans", $sans-serif-stack);
|
480
|
+
|
481
|
+
*@param string $font*
|
482
|
+
The name of the font. Use inverted commas if there are spaces in the font name. i.e "Open sans"
|
483
|
+
|
484
|
+
*@param list $font-stack*
|
485
|
+
The font stack variable to extend.
|
486
|
+
|
487
|
+
### Included font stacks
|
488
|
+
|
489
|
+
```sass
|
490
|
+
// Three standard do-all stacks.
|
491
|
+
$serif-stack: TimesNewRoman, "Times New Roman", Times, Baskerville, Georgia, serif;
|
492
|
+
$sans-serif-stack: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
493
|
+
$monospaced-stack: "Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace;
|
494
|
+
|
495
|
+
// Specific font stacks.
|
496
|
+
$arial-stack: Arial, "Helvetica Neue", Helvetica, sans-serif;
|
497
|
+
$helvetica-stack: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
498
|
+
$baskerville-stack: Baskerville, "Baskerville Old Face", "Hoefler Text", Garamond, "Times New Roman", serif;
|
499
|
+
$monaco-stack: Monaco, Consolas, "Lucida Console", monospace;
|
500
|
+
$trebuchet-ms-stack: "Trebuchet MS", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, sans-serif;
|
501
|
+
```
|
data/stylesheets/_typey.scss
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
// The browser font size default. No need to change this.
|
2
|
-
$browser-font-size: 16px;
|
2
|
+
$browser-font-size: 16px !default;
|
3
3
|
|
4
4
|
// The base font size will be used for most calculations involving font-size.
|
5
5
|
// Allowed units: px or pt
|
@@ -12,6 +12,9 @@ $base-line-height: 21px !default;
|
|
12
12
|
// Allowed units: px, pt, em or rem.
|
13
13
|
$base-unit: rem !default;
|
14
14
|
|
15
|
+
// By default we will provide fallbacks when rem is the base unit.
|
16
|
+
$rem-fallback: true !default;
|
17
|
+
|
15
18
|
// Default font sizes
|
16
19
|
// Once you redefine the $font-size map it will overwrite all sizes here.
|
17
20
|
// Allowed units: Must be the same as $base-line-height
|
@@ -26,7 +29,7 @@ $font-size: (
|
|
26
29
|
) !default;
|
27
30
|
|
28
31
|
// Default font weights
|
29
|
-
// This map and accompanying function help provide granular control over
|
32
|
+
// This map and accompanying function help provide granular control over
|
30
33
|
// setting and retrieving static font weights.
|
31
34
|
$font-weight: (
|
32
35
|
bold: 700,
|
@@ -36,21 +39,21 @@ $font-weight: (
|
|
36
39
|
|
37
40
|
// Warnings for $base-unit.
|
38
41
|
@if $base-unit != px and $base-unit != pt and $base-unit != rem and $base-unit != em {
|
39
|
-
@
|
42
|
+
@error "$base-unit must be one of the following unit types: px, pt, rem, em";
|
40
43
|
}
|
41
44
|
|
42
45
|
// Warnings for $base-font-size and $base-line-height.
|
43
46
|
@if unit($base-font-size) != px and unit($base-font-size) != pt {
|
44
|
-
@
|
47
|
+
@error "$base-font-size must be one of the following unit types: px, pt";
|
45
48
|
}
|
46
49
|
@if unit($base-line-height) != unit($base-font-size) {
|
47
|
-
@
|
50
|
+
@error "$base-line-height must use the same unit as $base-font-size.";
|
48
51
|
}
|
49
52
|
|
50
53
|
// Warnings for $font-size
|
51
54
|
@each $key, $size in $font-size {
|
52
55
|
@if unit($size) != unit($base-font-size) {
|
53
|
-
@
|
56
|
+
@error "Size '#{$key}' in $font-size map does not match the $base-font-size unit.";
|
54
57
|
}
|
55
58
|
}
|
56
59
|
|
@@ -63,17 +66,19 @@ $font-weight: (
|
|
63
66
|
// (optional) Use to set to anything other than the base value.
|
64
67
|
// Allowed units: px or pt
|
65
68
|
@mixin define-type-sizing($base-font-size: $base-font-size, $base-line-height: $base-line-height) {
|
66
|
-
@if $base-unit == px or $base-unit == pt {
|
67
|
-
font-size: $base-font-size;
|
68
|
-
line-height: $base-line-height;
|
69
|
-
}
|
70
69
|
@if $base-unit == rem {
|
71
70
|
font-size: $base-font-size / $browser-font-size * 100%;
|
72
|
-
|
71
|
+
@if $rem-fallback == true {
|
72
|
+
line-height: $base-line-height;
|
73
|
+
}
|
73
74
|
line-height: output-unit($base-line-height / $base-font-size);
|
74
75
|
}
|
76
|
+
@if $base-unit == px or $base-unit == pt {
|
77
|
+
font-size: $base-font-size;
|
78
|
+
line-height: $base-line-height;
|
79
|
+
}
|
75
80
|
@if $base-unit == em {
|
76
81
|
font-size: $base-font-size / $browser-font-size * 100%;
|
77
82
|
line-height: output-unit($base-line-height / $base-font-size);
|
78
|
-
}
|
83
|
+
}
|
79
84
|
}
|
@@ -1,10 +1,10 @@
|
|
1
|
-
// Takes a sizing from the $font-size map (m, xl, xxl, etc) and convert it to
|
2
|
-
// the base unit.
|
1
|
+
// Takes a sizing from the $font-size map (m, xl, xxl, etc) and convert it to
|
2
|
+
// the base unit. Alternatively convert a px/pt font-size into the base unit.
|
3
3
|
//
|
4
|
-
// @param string $size
|
5
|
-
// A size from the $font-size map
|
4
|
+
// @param number|string $size
|
5
|
+
// A size from the $font-size map or px/pt value to be converted
|
6
6
|
// @param number|string $context
|
7
|
-
// (optional) Only used if em is the $base-unit. The value of the parent
|
7
|
+
// (optional) Only used if em is the $base-unit. The value of the parent
|
8
8
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
9
9
|
// value in the same unit as the $font-size map.
|
10
10
|
//
|
@@ -12,52 +12,45 @@
|
|
12
12
|
// The selected font-size in $base-unit.
|
13
13
|
@function font-size($size, $context: $base-font-size) {
|
14
14
|
@if type-of($size) == 'string' {
|
15
|
-
@
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@if $base-unit == rem {
|
21
|
-
@return output-unit(($map-size / $base-font-size));
|
22
|
-
}
|
23
|
-
@if $base-unit == em {
|
24
|
-
@if type-of($context) == 'string' {
|
25
|
-
@if map-has-key($font-size, $context) {
|
26
|
-
$context-map-size: map-get($font-size, $context);
|
27
|
-
@return output-unit(($map-size / $context-map-size));
|
28
|
-
}
|
29
|
-
@else {
|
30
|
-
@warn "'#{$context}' not found in $font-size map.";
|
31
|
-
}
|
32
|
-
}
|
33
|
-
@if type-of($context) == 'number' {
|
34
|
-
@if unit($context) == unit($base-font-size) {
|
35
|
-
@return output-unit(($map-size / $context));
|
36
|
-
}
|
37
|
-
@else {
|
38
|
-
@warn "The unit used for $context does not match the $base-font-size unit.";
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
15
|
+
@return output-from-font-size-map($size, $context);
|
16
|
+
}
|
17
|
+
@if type-of($size) == 'number' and not unitless($size) {
|
18
|
+
@if unit($size) == unit($base-font-size) {
|
19
|
+
@return convert-unit($size, $context);
|
42
20
|
}
|
43
21
|
@else {
|
44
|
-
@
|
22
|
+
@error "font-size() only accepts values with the same unit as $base-font-size.";
|
45
23
|
}
|
46
24
|
}
|
25
|
+
@else {
|
26
|
+
@error "font-size() only accepts keys from the font map or values in px or pt.";
|
27
|
+
}
|
47
28
|
}
|
48
29
|
|
49
|
-
// Define font-size (with fallback)
|
30
|
+
// Define font-size (with fallback)
|
50
31
|
//
|
51
|
-
// @param string $size
|
52
|
-
// A size from the $font-size map
|
32
|
+
// @param number|string $size
|
33
|
+
// A size from the $font-size map or px/pt value to be converted
|
53
34
|
// @param number|string $context
|
54
|
-
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
35
|
+
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
55
36
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
56
37
|
// value in the same unit as the $font-size map.
|
57
38
|
@mixin font-size($size, $context: $base-font-size) {
|
58
|
-
$map-size: map-get($font-size, $size);
|
59
39
|
@if $base-unit == rem {
|
60
|
-
|
40
|
+
@if $rem-fallback == true {
|
41
|
+
@if type-of($size) == 'string' {
|
42
|
+
$map-size: map-get($font-size, $size);
|
43
|
+
font-size: $map-size;
|
44
|
+
}
|
45
|
+
@if type-of($size) == 'number' and not unitless($size) {
|
46
|
+
@if unit($size) == unit($base-font-size) {
|
47
|
+
font-size: $size;
|
48
|
+
}
|
49
|
+
@else {
|
50
|
+
@error "font-size() only accepts values with the same unit as $base-font-size.";
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
61
54
|
}
|
62
55
|
font-size: font-size($size, $context);
|
63
|
-
}
|
56
|
+
}
|
@@ -1,11 +1,11 @@
|
|
1
1
|
// Three standard do-all stacks.
|
2
|
-
$serif-stack:
|
2
|
+
$serif-stack: TimesNewRoman, "Times New Roman", Times, Baskerville, Georgia, serif;
|
3
3
|
$sans-serif-stack: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
4
4
|
$monospaced-stack: "Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace;
|
5
5
|
|
6
6
|
// Specific font stacks.
|
7
7
|
$arial-stack: Arial, "Helvetica Neue", Helvetica, sans-serif;
|
8
|
-
$helvetica-stack:
|
8
|
+
$helvetica-stack: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
9
9
|
$baskerville-stack: Baskerville, "Baskerville Old Face", "Hoefler Text", Garamond, "Times New Roman", serif;
|
10
10
|
$monaco-stack: Monaco, Consolas, "Lucida Console", monospace;
|
11
11
|
$trebuchet-ms-stack: "Trebuchet MS", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, sans-serif;
|
@@ -16,10 +16,10 @@ $trebuchet-ms-stack: "Trebuchet MS", "Lucida Grande", "Lucida Sans Unicode", "L
|
|
16
16
|
// $new-font-stack: extend-font-stack("Open sans", $sans-serif-stack);
|
17
17
|
//
|
18
18
|
// @param string $font
|
19
|
-
// The name of the font. Use inverted commas if there are spaces in the font
|
19
|
+
// The name of the font. Use inverted commas if there are spaces in the font
|
20
20
|
// name. i.e "Open sans"
|
21
21
|
// @param list $font-stack
|
22
22
|
// The font stack variable to extend.
|
23
23
|
@function extend-font-stack($font, $font-stack) {
|
24
24
|
@return join($font, $font-stack, $separator: comma);
|
25
|
-
}
|
25
|
+
}
|