typey 1.0.0.beta.2 → 1.0.0.beta.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +64 -40
- data/stylesheets/typey/_defaults.scss +41 -15
- data/stylesheets/typey/_font-size.scss +10 -10
- data/stylesheets/typey/_helpers.scss +23 -31
- data/stylesheets/typey/_line-height.scss +11 -6
- data/stylesheets/typey/_margin.scss +12 -12
- data/stylesheets/typey/_padding.scss +12 -12
- data/stylesheets/typey/_type-layout.scss +6 -6
- data/typey.gemspec +3 -4
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c34a6c9a1229a5c6480eda7888c845b2d1e0d87
|
4
|
+
data.tar.gz: 3f1739d241e3b08ce58012fc3df38d543686be51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c63e99105893f1bcd7f745d0fb5993e82447eb9236aa29e210b4631791b465229b6cdb8d4c3f1ef462c092bcabfab7f94b73c91476799af458898a41065a156
|
7
|
+
data.tar.gz: 38058da73fcf796f85e441fa34ccaaa6d8475dc46280c7fde25e87efaeba41ec7c286f6ad2a4945a12f4f4a6793635349db293560f8851b05b7afa4b7c6cc860
|
data/README.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# typey
|
2
|
-
|
2
|
+
|
3
|
+
A complete framework for working with typography on the web.
|
3
4
|
|
4
5
|
### Features
|
5
6
|
|
6
|
-
Supports outputting in rem,
|
7
|
+
Supports outputting in rem, em and px.
|
7
8
|
|
8
9
|
```sass
|
9
10
|
$base-unit: rem;
|
@@ -41,9 +42,13 @@ button {
|
|
41
42
|
}
|
42
43
|
```
|
43
44
|
|
45
|
+
Automatic print media font sizing when using rem or em.
|
46
|
+
|
44
47
|
```css
|
45
|
-
|
46
|
-
|
48
|
+
@media print {
|
49
|
+
html {
|
50
|
+
font-size: 12pt;
|
51
|
+
}
|
47
52
|
}
|
48
53
|
```
|
49
54
|
|
@@ -100,14 +105,14 @@ Vanilla Sass
|
|
100
105
|
|
101
106
|
### Getting started
|
102
107
|
|
103
|
-
Just like in compass Vertical Rhythm we define our base font size and line height first. In typey, all sizes are defined in `px`
|
108
|
+
Just like in compass Vertical Rhythm we define our base font size and line height first. In typey, all sizes are defined in `px` only.
|
104
109
|
|
105
110
|
```sass
|
106
111
|
$base-font-size: 16px;
|
107
112
|
$base-line-height: 24px;
|
108
113
|
```
|
109
114
|
|
110
|
-
We also need to define the base unit that the functions and mixins will output. you can use `
|
115
|
+
We also need to define the base unit that the functions and mixins will output. you can use `rem`, `em` or `px`.
|
111
116
|
|
112
117
|
```sass
|
113
118
|
$base-unit: rem;
|
@@ -121,7 +126,7 @@ html {
|
|
121
126
|
}
|
122
127
|
```
|
123
128
|
|
124
|
-
Define the `$font-size` map
|
129
|
+
Define the `$font-size` map with t-shirt sizes (which are easier to keep track of then individual values).
|
125
130
|
|
126
131
|
```sass
|
127
132
|
$font-size: (
|
@@ -132,6 +137,12 @@ $font-size: (
|
|
132
137
|
);
|
133
138
|
```
|
134
139
|
|
140
|
+
To create print friendly stylesheets you must use a relative base unit (rem or em) - then all the work is taken care of for you. Optionally you can set the base print size like so:
|
141
|
+
|
142
|
+
```sass
|
143
|
+
$print-font-size: 12pt;
|
144
|
+
```
|
145
|
+
|
135
146
|
### Line height and font sizing examples
|
136
147
|
|
137
148
|
The simplest way to set font size is via the `font-size` mixin.
|
@@ -166,7 +177,7 @@ h4 {
|
|
166
177
|
}
|
167
178
|
```
|
168
179
|
|
169
|
-
When using `em` as your `$base-unit`, each mixin accepts a `$context` parameter so your `em` value will be relative to it's parent or element `font-size`. The `$context` parameter can either accept a t-shirt size or a static value
|
180
|
+
When using `em` as your `$base-unit`, each mixin accepts a `$context` parameter so your `em` value will be relative to it's parent or element `font-size`. The `$context` parameter can either accept a t-shirt size or a static value in px. See the reference section below for more information.
|
170
181
|
|
171
182
|
```sass
|
172
183
|
h4 {
|
@@ -180,7 +191,7 @@ h4 {
|
|
180
191
|
|
181
192
|
### Margin and padding examples
|
182
193
|
|
183
|
-
The same mixins that we have for `line-height` also exist for `margin` and `padding`, and
|
194
|
+
The same mixins that we have for `line-height` also exist for `margin` and `padding`, and work exactly the same way.
|
184
195
|
|
185
196
|
```sass
|
186
197
|
div {
|
@@ -207,7 +218,7 @@ div {
|
|
207
218
|
}
|
208
219
|
```
|
209
220
|
|
210
|
-
If you are using `em`, both the `margin()` and `padding()` functions/mixins accept a
|
221
|
+
If you are using `em`, both the `margin()` and `padding()` functions/mixins accept a `$context` parameter.
|
211
222
|
|
212
223
|
```sass
|
213
224
|
div {
|
@@ -259,7 +270,7 @@ $base-font-size: 16px !default;
|
|
259
270
|
```
|
260
271
|
|
261
272
|
The base font size will be used for most calculations involving font-size.
|
262
|
-
Allowed units: px
|
273
|
+
Allowed units: px
|
263
274
|
|
264
275
|
|
265
276
|
```sass
|
@@ -267,14 +278,14 @@ $base-line-height: 21px !default;
|
|
267
278
|
```
|
268
279
|
|
269
280
|
The base line height will be used for most calculations involving height.
|
270
|
-
Allowed units:
|
281
|
+
Allowed units: px
|
271
282
|
|
272
283
|
|
273
284
|
```sass
|
274
285
|
$base-unit: rem !default;
|
275
286
|
```
|
276
287
|
|
277
|
-
Allowed units:
|
288
|
+
Allowed units: rem, em or px.
|
278
289
|
|
279
290
|
|
280
291
|
```sass
|
@@ -283,6 +294,19 @@ $rem-fallback: true !default;
|
|
283
294
|
|
284
295
|
By default we will provide fallbacks when rem is the base unit.
|
285
296
|
|
297
|
+
```sass
|
298
|
+
$auto-print-sizing: true !default;
|
299
|
+
```
|
300
|
+
|
301
|
+
By default, when rem or em are the base unit we will output a print suitable media query with the define-type-sizing() mixin. This will take care of all print media type sizing effortlessly.
|
302
|
+
|
303
|
+
```sass
|
304
|
+
$print-font-size: 12pt !default;
|
305
|
+
```
|
306
|
+
|
307
|
+
The pt font-size to be used with the print media query when $auto-print-sizing is enabled.
|
308
|
+
Allowed units: pt
|
309
|
+
|
286
310
|
|
287
311
|
```sass
|
288
312
|
$font-size: (
|
@@ -298,7 +322,7 @@ $font-size: (
|
|
298
322
|
|
299
323
|
Default font sizes
|
300
324
|
Once you redefine the $font-size map it will overwrite all sizes here.
|
301
|
-
Allowed units:
|
325
|
+
Allowed units: px
|
302
326
|
|
303
327
|
|
304
328
|
```sass
|
@@ -309,7 +333,7 @@ $font-weight: (
|
|
309
333
|
) !default;
|
310
334
|
```
|
311
335
|
|
312
|
-
Default font weights
|
336
|
+
Default font weights
|
313
337
|
This map and accompanying function help provide granular control over setting and retrieving static font weights.
|
314
338
|
|
315
339
|
### Mixins
|
@@ -321,10 +345,10 @@ define-type-sizing($base-font-size: $base-font-size, $base-line-height: $base-li
|
|
321
345
|
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.
|
322
346
|
|
323
347
|
*@param number $base-font-size*
|
324
|
-
(optional) Use to set to anything other than the base value. Allowed units: px
|
348
|
+
(optional) Use to set to anything other than the base value. Allowed units: px
|
325
349
|
|
326
350
|
*@param number $base-line-height(optional)*
|
327
|
-
Use to set to anything other than the base value. Allowed units: px
|
351
|
+
Use to set to anything other than the base value. Allowed units: px
|
328
352
|
|
329
353
|
|
330
354
|
```sass
|
@@ -334,13 +358,13 @@ type-layout($size, $x, $context: $size)
|
|
334
358
|
Outputs both line-height and font-size properties, providing fallbacks when rem is the base unit.
|
335
359
|
|
336
360
|
*@param number|string $size*
|
337
|
-
A size from the $font-size map or a px
|
361
|
+
A size from the $font-size map or a px value.
|
338
362
|
|
339
363
|
*@param number $x*
|
340
|
-
Multiple of line height to be used or px
|
364
|
+
Multiple of line height to be used or px value to be converted.
|
341
365
|
|
342
366
|
*@param number|string $context*
|
343
|
-
(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
|
367
|
+
(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 px.
|
344
368
|
|
345
369
|
|
346
370
|
```sass
|
@@ -350,10 +374,10 @@ font-size($size, $context: $base-font-size)
|
|
350
374
|
Outputs font-size property, providing fallbacks when rem is the base unit.
|
351
375
|
|
352
376
|
*@param number|string $size*
|
353
|
-
A size from the $font-size map or px
|
377
|
+
A size from the $font-size map or px value to be converted
|
354
378
|
|
355
379
|
*@param number|string $context*
|
356
|
-
(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
|
380
|
+
(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 px.
|
357
381
|
|
358
382
|
|
359
383
|
```sass
|
@@ -363,10 +387,10 @@ line-height($x, $context: $base-font-size)
|
|
363
387
|
Outputs line-height property, providing fallbacks when rem is the base unit.
|
364
388
|
|
365
389
|
*@param number $x*
|
366
|
-
Multiple of line height to be used or px
|
390
|
+
Multiple of line height to be used or px value to be converted.
|
367
391
|
|
368
392
|
*@param number|string $context*
|
369
|
-
(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
|
393
|
+
(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 px.
|
370
394
|
|
371
395
|
|
372
396
|
```sass
|
@@ -376,12 +400,12 @@ margin($x, $context: $base-font-size)
|
|
376
400
|
Outputs margin property, providing fallbacks when rem is the base unit.
|
377
401
|
|
378
402
|
*@param number|list $x*
|
379
|
-
Multiple of line height to be used or px
|
403
|
+
Multiple of line height to be used or px value to be converted.
|
380
404
|
Uses the same parameters as the CSS margin property:
|
381
405
|
i.e. top right bottom left, 1 0 2 0.
|
382
406
|
|
383
407
|
*@param number|string $context*
|
384
|
-
(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
|
408
|
+
(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 px.
|
385
409
|
|
386
410
|
|
387
411
|
```sass
|
@@ -391,12 +415,12 @@ padding($x, $context: $base-font-size)
|
|
391
415
|
Outputs padding property, providing fallbacks when rem is the base unit.
|
392
416
|
|
393
417
|
*@param number|list $x*
|
394
|
-
Multiple of line height to be used or px
|
418
|
+
Multiple of line height to be used or px value to be converted.
|
395
419
|
Uses the same parameters as the CSS margin property:
|
396
420
|
i.e. top right bottom left, 1 0 2 0.
|
397
421
|
|
398
422
|
*@param number|string $context*
|
399
|
-
(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
|
423
|
+
(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 px.
|
400
424
|
|
401
425
|
|
402
426
|
```sass
|
@@ -409,10 +433,10 @@ margin-left($x, $context: $base-font-size)
|
|
409
433
|
Outputs corresponding margin property, providing fallbacks when rem is the base unit.
|
410
434
|
|
411
435
|
*@param number|list $x*
|
412
|
-
Multiple of line height to be used or px
|
436
|
+
Multiple of line height to be used or px value to be converted.
|
413
437
|
|
414
438
|
*@param number|string $context*
|
415
|
-
(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
|
439
|
+
(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 px.
|
416
440
|
|
417
441
|
|
418
442
|
```sass
|
@@ -425,10 +449,10 @@ padding-left($x, $context: $base-font-size)
|
|
425
449
|
Outputs corresponding padding property, providing fallbacks when rem is the base unit.
|
426
450
|
|
427
451
|
*@param number|list $x*
|
428
|
-
Multiple of line height to be used or px
|
452
|
+
Multiple of line height to be used or px value to be converted.
|
429
453
|
|
430
454
|
*@param number|string $context*
|
431
|
-
(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
|
455
|
+
(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 px.
|
432
456
|
|
433
457
|
### Functions
|
434
458
|
|
@@ -437,10 +461,10 @@ font-size($size, $context: $base-font-size)
|
|
437
461
|
```
|
438
462
|
|
439
463
|
*@param number|string $size*
|
440
|
-
A size from the $font-size map or px
|
464
|
+
A size from the $font-size map or px value to be converted
|
441
465
|
|
442
466
|
*@param number|string $context*
|
443
|
-
(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
|
467
|
+
(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 px.
|
444
468
|
|
445
469
|
*@return number*
|
446
470
|
The selected font-size in $base-unit.
|
@@ -451,10 +475,10 @@ line-height($x, $context: $base-font-size)
|
|
451
475
|
```
|
452
476
|
|
453
477
|
*@param number $x*
|
454
|
-
Multiple of line height to be used or px
|
478
|
+
Multiple of line height to be used or px value to be converted.
|
455
479
|
|
456
480
|
*@param number|string $context*
|
457
|
-
(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
|
481
|
+
(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 px.
|
458
482
|
|
459
483
|
*@return number*
|
460
484
|
The calculated height in $base-unit.
|
@@ -465,10 +489,10 @@ margin($x, $context: $base-font-size)
|
|
465
489
|
```
|
466
490
|
|
467
491
|
*@param number $x*
|
468
|
-
Multiple of line height to be used or px
|
492
|
+
Multiple of line height to be used or px value to be converted.
|
469
493
|
|
470
494
|
*@param number|string $context*
|
471
|
-
(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
|
495
|
+
(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 px.
|
472
496
|
|
473
497
|
*@return number*
|
474
498
|
The calculated height in $base-unit.
|
@@ -479,10 +503,10 @@ padding($x, $context: $base-font-size)
|
|
479
503
|
```
|
480
504
|
|
481
505
|
*@param number $x*
|
482
|
-
Multiple of line height to be used or px
|
506
|
+
Multiple of line height to be used or px value to be converted.
|
483
507
|
|
484
508
|
*@param number|string $context*
|
485
|
-
(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
|
509
|
+
(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 px.
|
486
510
|
|
487
511
|
*@return number*
|
488
512
|
The calculated height in $base-unit.
|
@@ -1,23 +1,34 @@
|
|
1
1
|
// The browser font size default. No need to change this.
|
2
|
+
// Allowed units: px
|
2
3
|
$browser-font-size: 16px !default;
|
3
4
|
|
4
5
|
// The base font size will be used for most calculations involving font-size.
|
5
|
-
// Allowed units: px
|
6
|
+
// Allowed units: px
|
6
7
|
$base-font-size: 16px !default;
|
7
8
|
|
8
9
|
// The base line height will be used for most calculations involving height.
|
9
|
-
// Allowed units:
|
10
|
+
// Allowed units: px
|
10
11
|
$base-line-height: 21px !default;
|
11
12
|
|
12
|
-
// Allowed units:
|
13
|
+
// Allowed units: rem, em or px
|
13
14
|
$base-unit: rem !default;
|
14
15
|
|
15
16
|
// By default we will provide fallbacks when rem is the base unit.
|
16
17
|
$rem-fallback: true !default;
|
17
18
|
|
19
|
+
// By default, when rem or em are the base unit we will output a print suitable
|
20
|
+
// media query with the define-type-sizing() mixin. This will take care of all
|
21
|
+
// print media type sizing effortlessly.
|
22
|
+
$auto-print-sizing: true !default;
|
23
|
+
|
24
|
+
// The pt font-size to be used with the print media query when
|
25
|
+
// $auto-print-sizing is enabled.
|
26
|
+
// Allowed units: pt
|
27
|
+
$print-font-size: 12pt !default;
|
28
|
+
|
18
29
|
// Default font sizes
|
19
30
|
// Once you redefine the $font-size map it will overwrite all sizes here.
|
20
|
-
// Allowed units:
|
31
|
+
// Allowed units: px
|
21
32
|
$font-size: (
|
22
33
|
xxxl: 60px,
|
23
34
|
xxl: 46px,
|
@@ -38,22 +49,27 @@ $font-weight: (
|
|
38
49
|
) !default;
|
39
50
|
|
40
51
|
// Warnings for $base-unit.
|
41
|
-
@if $base-unit != px and $base-unit !=
|
42
|
-
@error "$base-unit must be one of the following unit types:
|
52
|
+
@if $base-unit != px and $base-unit != rem and $base-unit != em {
|
53
|
+
@error "$base-unit must be one of the following unit types: rem, em or px";
|
43
54
|
}
|
44
55
|
|
45
56
|
// Warnings for $base-font-size and $base-line-height.
|
46
|
-
@if unit($base-font-size) != px
|
47
|
-
@error "$base-font-size must be
|
57
|
+
@if unit($base-font-size) != px {
|
58
|
+
@error "$base-font-size must be in px";
|
48
59
|
}
|
49
|
-
@if unit($base-line-height) !=
|
50
|
-
@error "$base-line-height must
|
60
|
+
@if unit($base-line-height) != px {
|
61
|
+
@error "$base-line-height must be in px";
|
62
|
+
}
|
63
|
+
|
64
|
+
// Warnings for $print-font-size.
|
65
|
+
@if unit($print-font-size) != pt {
|
66
|
+
@error "$print-font-size must be in pt";
|
51
67
|
}
|
52
68
|
|
53
69
|
// Warnings for $font-size
|
54
70
|
@each $key, $size in $font-size {
|
55
|
-
@if unit($size) !=
|
56
|
-
@error "Size '#{$key}' in $font-size map
|
71
|
+
@if unit($size) != px {
|
72
|
+
@error "Size '#{$key}' in $font-size map is not specified in px";
|
57
73
|
}
|
58
74
|
}
|
59
75
|
|
@@ -61,10 +77,10 @@ $font-weight: (
|
|
61
77
|
//
|
62
78
|
// @param number $base-font-size
|
63
79
|
// (optional) Use to set to anything other than the base value.
|
64
|
-
// Allowed units: px
|
80
|
+
// Allowed units: px
|
65
81
|
// @param number $base-line-height
|
66
82
|
// (optional) Use to set to anything other than the base value.
|
67
|
-
// Allowed units: px
|
83
|
+
// Allowed units: px
|
68
84
|
@mixin define-type-sizing($base-font-size: $base-font-size, $base-line-height: $base-line-height) {
|
69
85
|
@if $base-unit == rem {
|
70
86
|
font-size: $base-font-size / $browser-font-size * 100%;
|
@@ -73,7 +89,7 @@ $font-weight: (
|
|
73
89
|
}
|
74
90
|
line-height: output-unit($base-line-height / $base-font-size);
|
75
91
|
}
|
76
|
-
@if $base-unit == px
|
92
|
+
@if $base-unit == px {
|
77
93
|
font-size: $base-font-size;
|
78
94
|
line-height: $base-line-height;
|
79
95
|
}
|
@@ -81,4 +97,14 @@ $font-weight: (
|
|
81
97
|
font-size: $base-font-size / $browser-font-size * 100%;
|
82
98
|
line-height: output-unit($base-line-height / $base-font-size);
|
83
99
|
}
|
100
|
+
@if $auto-print-sizing == true {
|
101
|
+
@if $base-unit == rem or $base-unit == em {
|
102
|
+
@media print {
|
103
|
+
font-size: $print-font-size;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
@else {
|
107
|
+
@warn "As you are not using a relative base unit (rem or em) automatic print media sizing will not work. Set $auto-print-sizing to false to hide this warning"
|
108
|
+
}
|
109
|
+
}
|
84
110
|
}
|
@@ -1,12 +1,12 @@
|
|
1
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
|
2
|
+
// the base unit. Alternatively convert a px font-size into the base unit.
|
3
3
|
//
|
4
4
|
// @param number|string $size
|
5
|
-
// A size from the $font-size map or px
|
5
|
+
// A size from the $font-size map or px value to be converted
|
6
6
|
// @param number|string $context
|
7
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
|
-
// value in
|
9
|
+
// value in px.
|
10
10
|
//
|
11
11
|
// @return number
|
12
12
|
// The selected font-size in $base-unit.
|
@@ -15,26 +15,26 @@
|
|
15
15
|
@return output-from-font-size-map($size, $context);
|
16
16
|
}
|
17
17
|
@if type-of($size) == "number" and not unitless($size) {
|
18
|
-
@if unit($size) ==
|
18
|
+
@if unit($size) == px {
|
19
19
|
@return convert-unit($size, $context);
|
20
20
|
}
|
21
21
|
@else {
|
22
|
-
@error "font-size() only accepts
|
22
|
+
@error "font-size() only accepts keys from the $font-size map or values in px";
|
23
23
|
}
|
24
24
|
}
|
25
25
|
@else {
|
26
|
-
@error "font-size() only accepts keys from the font map or values in px
|
26
|
+
@error "font-size() only accepts keys from the $font-size map or values in px";
|
27
27
|
}
|
28
28
|
}
|
29
29
|
|
30
30
|
// Define font-size (with fallback)
|
31
31
|
//
|
32
32
|
// @param number|string $size
|
33
|
-
// A size from the $font-size map or px
|
33
|
+
// A size from the $font-size map or px value to be converted
|
34
34
|
// @param number|string $context
|
35
35
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
36
36
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
37
|
-
// value in
|
37
|
+
// value in px.
|
38
38
|
@mixin font-size($size, $context: $base-font-size) {
|
39
39
|
@if $base-unit == rem {
|
40
40
|
@if $rem-fallback == true {
|
@@ -43,11 +43,11 @@
|
|
43
43
|
font-size: $map-size;
|
44
44
|
}
|
45
45
|
@if type-of($size) == "number" and not unitless($size) {
|
46
|
-
@if unit($size) ==
|
46
|
+
@if unit($size) == px {
|
47
47
|
font-size: $size;
|
48
48
|
}
|
49
49
|
@else {
|
50
|
-
@error "font-size() only accepts
|
50
|
+
@error "font-size() only accepts keys from the $font-size map or values in px";
|
51
51
|
}
|
52
52
|
}
|
53
53
|
}
|
@@ -12,9 +12,6 @@
|
|
12
12
|
@if $base-unit == px {
|
13
13
|
@return $number * 1px;
|
14
14
|
}
|
15
|
-
@if $base-unit == pt {
|
16
|
-
@return $number * 1pt;
|
17
|
-
}
|
18
15
|
@if $base-unit == em {
|
19
16
|
@return $number * 1em;
|
20
17
|
}
|
@@ -34,30 +31,25 @@
|
|
34
31
|
@return $number;
|
35
32
|
}
|
36
33
|
|
37
|
-
// Convert px
|
34
|
+
// Convert px to the $base-unit.
|
38
35
|
//
|
39
36
|
// @param number $number
|
40
|
-
// The number (with unit) to convert. Allowed units: px
|
37
|
+
// The number (with unit) to convert. Allowed units: px
|
41
38
|
// @param number|string $context
|
42
39
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
43
40
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
44
|
-
// value in
|
41
|
+
// value in px.
|
45
42
|
//
|
46
43
|
// @return number
|
47
44
|
// The number converted to the base unit.
|
48
45
|
@function convert-unit($number, $context: $base-font-size) {
|
49
46
|
@if type-of($number) == "number" and not unitless($number) {
|
50
47
|
$unit: unit($number);
|
51
|
-
@if $unit == px
|
48
|
+
@if $unit == px {
|
52
49
|
@if $base-unit == rem {
|
53
|
-
@
|
54
|
-
@return output-unit(($number / $base-font-size));
|
55
|
-
}
|
56
|
-
@else {
|
57
|
-
@error "convert-unit() only accepts values with the same unit as $base-font-size.";
|
58
|
-
}
|
50
|
+
@return output-unit(($number / $base-font-size));
|
59
51
|
}
|
60
|
-
@if $base-unit == px
|
52
|
+
@if $base-unit == px {
|
61
53
|
@return output-unit(strip-unit($number));
|
62
54
|
}
|
63
55
|
@if $base-unit == em {
|
@@ -67,21 +59,21 @@
|
|
67
59
|
@return output-unit(($number / $context-map-size));
|
68
60
|
}
|
69
61
|
@else {
|
70
|
-
@error "'#{$context}' not found in $font-size map
|
62
|
+
@error "'#{$context}' not found in $font-size map";
|
71
63
|
}
|
72
64
|
}
|
73
|
-
@if type-of($context) == "number" {
|
74
|
-
@if unit($context) ==
|
65
|
+
@if type-of($context) == "number" and not unitless($number) {
|
66
|
+
@if unit($context) == px {
|
75
67
|
@return output-unit(($number / $context));
|
76
68
|
}
|
77
69
|
@else {
|
78
|
-
@error "The unit used for $context
|
70
|
+
@error "The unit used for $context must be px";
|
79
71
|
}
|
80
72
|
}
|
81
73
|
}
|
82
74
|
}
|
83
75
|
@else {
|
84
|
-
@error "convert-unit() only accepts values in px
|
76
|
+
@error "convert-unit() only accepts values in px";
|
85
77
|
}
|
86
78
|
}
|
87
79
|
}
|
@@ -93,7 +85,7 @@
|
|
93
85
|
// @param number|string $context
|
94
86
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
95
87
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
96
|
-
// value in
|
88
|
+
// value in px.
|
97
89
|
//
|
98
90
|
// @return number
|
99
91
|
// The value of the line-height multiple converted to the base unit.
|
@@ -101,16 +93,16 @@
|
|
101
93
|
@if $base-unit == rem {
|
102
94
|
@return output-unit(($x * $base-line-height) / $base-font-size);
|
103
95
|
}
|
104
|
-
@if $base-unit == px
|
96
|
+
@if $base-unit == px {
|
105
97
|
@return output-unit(strip-unit($x * $base-line-height));
|
106
98
|
}
|
107
99
|
@if $base-unit == em {
|
108
100
|
@if type-of($context) == "number" {
|
109
|
-
@if unit($context) ==
|
101
|
+
@if unit($context) == px {
|
110
102
|
@return output-unit(($x * $base-line-height) / $context);
|
111
103
|
}
|
112
104
|
@else {
|
113
|
-
@error "The unit used for $context
|
105
|
+
@error "The unit used for $context must be px";
|
114
106
|
}
|
115
107
|
}
|
116
108
|
@if type-of($context) == "string" {
|
@@ -119,11 +111,11 @@
|
|
119
111
|
@return output-unit(($x * $base-line-height) / $context-map-size);
|
120
112
|
}
|
121
113
|
@else {
|
122
|
-
@error "'#{$context}' not found in $font-size map
|
114
|
+
@error "'#{$context}' not found in $font-size map";
|
123
115
|
}
|
124
116
|
}
|
125
117
|
@else {
|
126
|
-
@error "$context must be a px
|
118
|
+
@error "$context must be a px value or a key from the $font-size map";
|
127
119
|
}
|
128
120
|
}
|
129
121
|
}
|
@@ -137,7 +129,7 @@
|
|
137
129
|
// @param number|string $context
|
138
130
|
// (optional) Only used if em is the $base-unit. The value of the parent
|
139
131
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
140
|
-
// value in
|
132
|
+
// value in px.
|
141
133
|
//
|
142
134
|
// @return number
|
143
135
|
// The selected font-size in $base-unit.
|
@@ -157,23 +149,23 @@
|
|
157
149
|
@return output-unit(($map-size / $context-map-size));
|
158
150
|
}
|
159
151
|
@else {
|
160
|
-
@error "'#{$context}' not found in $font-size map
|
152
|
+
@error "'#{$context}' not found in $font-size map";
|
161
153
|
}
|
162
154
|
}
|
163
155
|
@if type-of($context) == "number" {
|
164
|
-
@if unit($context) ==
|
156
|
+
@if unit($context) == px {
|
165
157
|
@return output-unit(($map-size / $context));
|
166
158
|
}
|
167
159
|
@else {
|
168
|
-
@error "The unit used for $context
|
160
|
+
@error "The unit used for $context must be px";
|
169
161
|
}
|
170
162
|
}
|
171
163
|
@else {
|
172
|
-
@error "$context must be a px
|
164
|
+
@error "$context must be a px value or a key from the $font-size map";
|
173
165
|
}
|
174
166
|
}
|
175
167
|
}
|
176
168
|
@else {
|
177
|
-
@error "'#{$size}' not found in $font-size map
|
169
|
+
@error "'#{$size}' not found in $font-size map";
|
178
170
|
}
|
179
171
|
}
|
@@ -12,7 +12,7 @@
|
|
12
12
|
// @param number|string $context
|
13
13
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
14
14
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
15
|
-
// value in
|
15
|
+
// value in px.
|
16
16
|
//
|
17
17
|
// @return number
|
18
18
|
// The calculated height in $base-unit.
|
@@ -21,15 +21,15 @@
|
|
21
21
|
@return output-from-multiplier($x, $context);
|
22
22
|
}
|
23
23
|
@if type-of($x) == "number" and not unitless($x) {
|
24
|
-
@if unit($x) ==
|
24
|
+
@if unit($x) == px {
|
25
25
|
@return convert-unit($x, $context);
|
26
26
|
}
|
27
27
|
@else {
|
28
|
-
@error "line-height() only accepts
|
28
|
+
@error "line-height() only accepts unitless numbers or values in px";
|
29
29
|
}
|
30
30
|
}
|
31
31
|
@else {
|
32
|
-
@error "line-height() only accepts unitless numbers or values in px
|
32
|
+
@error "line-height() only accepts unitless numbers or values in px";
|
33
33
|
}
|
34
34
|
}
|
35
35
|
|
@@ -42,7 +42,7 @@
|
|
42
42
|
// @param number|string $context
|
43
43
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
44
44
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
45
|
-
// value in
|
45
|
+
// value in px.
|
46
46
|
@mixin line-height($x, $context: $base-font-size) {
|
47
47
|
@if $base-unit == rem {
|
48
48
|
@if $rem-fallback == true {
|
@@ -50,7 +50,12 @@
|
|
50
50
|
line-height: $x * $base-line-height;
|
51
51
|
}
|
52
52
|
@if type-of($x) == "number" and not unitless($x) {
|
53
|
-
|
53
|
+
@if unit($size) == px {
|
54
|
+
line-height: $x;
|
55
|
+
}
|
56
|
+
@else {
|
57
|
+
@error "line-height() only accepts unitless numbers or values in px";
|
58
|
+
}
|
54
59
|
}
|
55
60
|
}
|
56
61
|
}
|
@@ -8,11 +8,11 @@
|
|
8
8
|
// margin: margin(18px);
|
9
9
|
//
|
10
10
|
// @param number $x
|
11
|
-
// Multiple of line height to be used or px
|
11
|
+
// Multiple of line height to be used or px value to be converted.
|
12
12
|
// @param number|string $context
|
13
13
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
14
14
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
15
|
-
// value in
|
15
|
+
// value in px.
|
16
16
|
//
|
17
17
|
// @return number
|
18
18
|
// The calculated height in $base-unit.
|
@@ -25,13 +25,13 @@
|
|
25
25
|
// using rem as $base-unit.
|
26
26
|
//
|
27
27
|
// @param number|list $x
|
28
|
-
// Multiple of line height to be used or px
|
28
|
+
// Multiple of line height to be used or px value to be converted.
|
29
29
|
// Uses the same parameters as the CSS margin property:
|
30
30
|
// i.e. top right bottom left, 1 0 2 0.
|
31
31
|
// @param number|string $context
|
32
32
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
33
33
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
34
|
-
// value in
|
34
|
+
// value in px.
|
35
35
|
@mixin margin($list, $context: $base-font-size) {
|
36
36
|
$px-list: ();
|
37
37
|
$converted-list: ();
|
@@ -61,11 +61,11 @@
|
|
61
61
|
// using rem as $base-unit.
|
62
62
|
//
|
63
63
|
// @param number $x
|
64
|
-
// Multiple of line height to be used or px
|
64
|
+
// Multiple of line height to be used or px value to be converted.
|
65
65
|
// @param number|string $context
|
66
66
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
67
67
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
68
|
-
// value in
|
68
|
+
// value in px.
|
69
69
|
@mixin margin-top($x, $context: $base-font-size) {
|
70
70
|
@if $base-unit == rem {
|
71
71
|
@if $rem-fallback == true {
|
@@ -85,11 +85,11 @@
|
|
85
85
|
// using rem as $base-unit.
|
86
86
|
//
|
87
87
|
// @param number $x
|
88
|
-
// Multiple of line height to be used or px
|
88
|
+
// Multiple of line height to be used or px value to be converted.
|
89
89
|
// @param number|string $context
|
90
90
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
91
91
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
92
|
-
// value in
|
92
|
+
// value in px.
|
93
93
|
@mixin margin-bottom($x, $context: $base-font-size) {
|
94
94
|
@if $base-unit == rem {
|
95
95
|
@if $rem-fallback == true {
|
@@ -109,11 +109,11 @@
|
|
109
109
|
// using rem as $base-unit.
|
110
110
|
//
|
111
111
|
// @param number $x
|
112
|
-
// Multiple of line height to be used or px
|
112
|
+
// Multiple of line height to be used or px value to be converted.
|
113
113
|
// @param number|string $context
|
114
114
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
115
115
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
116
|
-
// value in
|
116
|
+
// value in px.
|
117
117
|
@mixin margin-left($x, $context: $base-font-size) {
|
118
118
|
@if $base-unit == rem {
|
119
119
|
@if $rem-fallback == true {
|
@@ -133,11 +133,11 @@
|
|
133
133
|
// using rem as $base-unit.
|
134
134
|
//
|
135
135
|
// @param number $x
|
136
|
-
// Multiple of line height to be used or px
|
136
|
+
// Multiple of line height to be used or px value to be converted.
|
137
137
|
// @param number|string $context
|
138
138
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
139
139
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
140
|
-
// value in
|
140
|
+
// value in px.
|
141
141
|
@mixin margin-right($x, $context: $base-font-size) {
|
142
142
|
@if $base-unit == rem {
|
143
143
|
@if $rem-fallback == true {
|
@@ -8,11 +8,11 @@
|
|
8
8
|
// padding: padding(18px);
|
9
9
|
//
|
10
10
|
// @param number $x
|
11
|
-
// Multiple of line height to be used or px
|
11
|
+
// Multiple of line height to be used or px value to be converted.
|
12
12
|
// @param number|string $context
|
13
13
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
14
14
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
15
|
-
// value in
|
15
|
+
// value in px.
|
16
16
|
//
|
17
17
|
// @return number
|
18
18
|
// The calculated height in $base-unit.
|
@@ -25,13 +25,13 @@
|
|
25
25
|
// using rem as $base-unit.
|
26
26
|
//
|
27
27
|
// @param number|list $x
|
28
|
-
// Multiple of line height to be used or px
|
28
|
+
// Multiple of line height to be used or px value to be converted.
|
29
29
|
// Uses the same parameters as the CSS padding property:
|
30
30
|
// i.e. top right bottom left, 1 0 2 0.
|
31
31
|
// @param number|string $context
|
32
32
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
33
33
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
34
|
-
// value in
|
34
|
+
// value in px.
|
35
35
|
@mixin padding($list, $context: $base-font-size) {
|
36
36
|
$px-list: ();
|
37
37
|
$converted-list: ();
|
@@ -61,11 +61,11 @@
|
|
61
61
|
// using rem as $base-unit.
|
62
62
|
//
|
63
63
|
// @param number $x
|
64
|
-
// Multiple of line height to be used or px
|
64
|
+
// Multiple of line height to be used or px value to be converted.
|
65
65
|
// @param number|string $context
|
66
66
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
67
67
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
68
|
-
// value in
|
68
|
+
// value in px.
|
69
69
|
@mixin padding-top($x, $context: $base-font-size) {
|
70
70
|
@if $base-unit == rem {
|
71
71
|
@if $rem-fallback == true {
|
@@ -85,11 +85,11 @@
|
|
85
85
|
// using rem as $base-unit.
|
86
86
|
//
|
87
87
|
// @param number $x
|
88
|
-
// Multiple of line height to be used or px
|
88
|
+
// Multiple of line height to be used or px value to be converted.
|
89
89
|
// @param number|string $context
|
90
90
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
91
91
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
92
|
-
// value in
|
92
|
+
// value in px.
|
93
93
|
@mixin padding-bottom($x, $context: $base-font-size) {
|
94
94
|
@if $base-unit == rem {
|
95
95
|
@if $rem-fallback == true {
|
@@ -109,11 +109,11 @@
|
|
109
109
|
// using rem as $base-unit.
|
110
110
|
//
|
111
111
|
// @param number $x
|
112
|
-
// Multiple of line height to be used or px
|
112
|
+
// Multiple of line height to be used or px value to be converted.
|
113
113
|
// @param number|string $context
|
114
114
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
115
115
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
116
|
-
// value in
|
116
|
+
// value in px.
|
117
117
|
@mixin padding-left($x, $context: $base-font-size) {
|
118
118
|
@if $base-unit == rem {
|
119
119
|
@if $rem-fallback == true {
|
@@ -133,11 +133,11 @@
|
|
133
133
|
// using rem as $base-unit.
|
134
134
|
//
|
135
135
|
// @param number $x
|
136
|
-
// Multiple of line height to be used or px
|
136
|
+
// Multiple of line height to be used or px value to be converted.
|
137
137
|
// @param number|string $context
|
138
138
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
139
139
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
140
|
-
// value in
|
140
|
+
// value in px.
|
141
141
|
@mixin padding-right($x, $context: $base-font-size) {
|
142
142
|
@if $base-unit == rem {
|
143
143
|
@if $rem-fallback == true {
|
@@ -1,13 +1,13 @@
|
|
1
1
|
// Define a type layout (font-size and line-height).
|
2
2
|
//
|
3
3
|
// @param number|string $size
|
4
|
-
// A size from the $font-size map or a px
|
4
|
+
// A size from the $font-size map or a px value.
|
5
5
|
// @param number $x
|
6
|
-
// Multiple of line height to be used or px
|
6
|
+
// Multiple of line height to be used or px value to be converted.
|
7
7
|
// @param number|string $context
|
8
8
|
// (optional) Only used if em is the $base-unit. The value of the elements/parents
|
9
9
|
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
|
10
|
-
// value in
|
10
|
+
// value in px.
|
11
11
|
@mixin type-layout($size, $x, $context: $size) {
|
12
12
|
@if $base-unit == rem {
|
13
13
|
@if $rem-fallback == true {
|
@@ -17,11 +17,11 @@
|
|
17
17
|
}
|
18
18
|
@if type-of($size) == "number" and not unitless($size) {
|
19
19
|
$unit: unit($size);
|
20
|
-
@if $unit == px
|
20
|
+
@if $unit == px {
|
21
21
|
font-size: $size;
|
22
22
|
}
|
23
23
|
@else {
|
24
|
-
@warn "font-size() only accepts values in px
|
24
|
+
@warn "font-size() only accepts values in px";
|
25
25
|
}
|
26
26
|
}
|
27
27
|
@if type-of($x) == "number" and unitless($x) {
|
@@ -32,7 +32,7 @@
|
|
32
32
|
}
|
33
33
|
}
|
34
34
|
}
|
35
|
-
@if $base-unit == rem or $base-unit == px
|
35
|
+
@if $base-unit == rem or $base-unit == px {
|
36
36
|
font-size: font-size($size);
|
37
37
|
line-height: line-height($x);
|
38
38
|
}
|
data/typey.gemspec
CHANGED
@@ -3,14 +3,13 @@
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'typey'
|
5
5
|
|
6
|
-
spec.summary = %q{
|
7
|
-
spec.description = %q{Tools to help you manage font sizing and css units.}
|
6
|
+
spec.summary = %q{A complete framework for working with typography on the web.}
|
8
7
|
|
9
8
|
spec.homepage = 'http://github.com/jptaranto/typey'
|
10
9
|
spec.rubyforge_project =
|
11
10
|
|
12
|
-
spec.version = '1.0.0.beta.
|
13
|
-
spec.date = '2015-
|
11
|
+
spec.version = '1.0.0.beta.4'
|
12
|
+
spec.date = '2015-07-01'
|
14
13
|
spec.licenses = ['GPL-2']
|
15
14
|
|
16
15
|
spec.authors = ['Jack Taranto']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.beta.
|
4
|
+
version: 1.0.0.beta.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Taranto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.3'
|
27
|
-
description:
|
27
|
+
description:
|
28
28
|
email: jacktaranto@gmail.com
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
@@ -64,9 +64,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: 1.3.1
|
66
66
|
requirements: []
|
67
|
-
rubyforge_project: 1.0.0.beta.
|
67
|
+
rubyforge_project: 1.0.0.beta.4
|
68
68
|
rubygems_version: 2.4.6
|
69
69
|
signing_key:
|
70
70
|
specification_version: 4
|
71
|
-
summary:
|
71
|
+
summary: A complete framework for working with typography on the web.
|
72
72
|
test_files: []
|