piecss 0.1.6 → 0.1.6.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.
@@ -4,17 +4,10 @@
4
4
  // Content
5
5
  // 1. Functions
6
6
  // value-map
7
+ // is-value-map
8
+ // value-map-to-unit
9
+ // -sides
7
10
  // 2. Mixins
8
- // padding
9
- // padding-top
10
- // padding-right
11
- // padding-bottom
12
- // padding-left
13
- // margin
14
- // margin-top
15
- // margin-right
16
- // margin-bottom
17
- // margin-left
18
11
  // -unit-sides
19
12
  // -sides
20
13
 
@@ -23,90 +16,121 @@
23
16
 
24
17
 
25
18
  /**
26
- * Takes a list of values and returns a spacing map
19
+ * Takes a list of values and keys and returns a spacing map.
27
20
  *
28
21
  * @since 0.1
29
22
  *
30
- * @param {*} $sides - A list of value arguments like CSS's normal padding (0 0 0 0)
23
+ * @param {List} $values - A list of value arguments like CSS's normal padding (0 0 0 0)
31
24
  * @param {String} $property (padding) - The property to which the values should be applied
32
25
  */
33
26
 
34
- @function value-map($sides, $property: padding)
35
- {
36
- // SASS appends a comma to the $sides list,
37
- // don't know how to get around this but list the values
38
- $sides: nth($sides,1);
27
+ @function value-map($values, $keys: $keys-side) {
39
28
 
40
- @if is-value-map($sides) {
41
- @return $sides;
29
+ // Make sure we have all sides, except when a map is used as an argument
30
+ @if type-of($values)==map {
31
+ @return $values;
42
32
  }
33
+ $values: -sides($values);
34
+
35
+ $-list: zip($keys, $values);
43
36
 
44
- // Create map to hold our spacing values;
45
- $spacing: ();
37
+ $map: ();
38
+ @each $pair in $-list {
39
+ $map: map-merge($map, (nth($pair, 1): nth($pair, 2)));
40
+ }
46
41
 
47
- @if $property==padding or $property==margin {
48
- $length: length($sides);
49
- @if $length==1 {
50
- $spacing: (top:$sides,right:$sides,bottom:$sides,left:$sides);
51
- }
52
- @elseif $length==2 {
53
- $spacing: (top:nth($sides,1),right:nth($sides,2),bottom:nth($sides,1),left:nth($sides,2));
54
- }
55
- @elseif $length==3 {
56
- $spacing: (top:nth($sides,1),right:nth($sides,2),bottom:nth($sides,3),left:nth($sides,2));
57
- }
58
- @else {
59
- $spacing: (top:nth($sides,1),right:nth($sides,2),bottom:nth($sides,3),left:nth($sides,4));
42
+ @return $map;
43
+ }
44
+
45
+ /**
46
+ * Checks if a Map is a proper value-map by checking for specific keys.
47
+ *
48
+ * @since 0.1
49
+ *
50
+ * @param {List} $values - The value to test, can be a single number or a list
51
+ * @param {List} $keys ($keys-side) - A list of keys to match
52
+ *
53
+ * @return {Bool}
54
+ */
55
+
56
+ @function is-value-map($values, $keys: $keys-side) {
57
+
58
+ // Start by assuming $values is not a map
59
+ $is-map: false;
60
+
61
+ // Simple test for a match to $keys, passes if there is a single match
62
+ @if type-of($values)==map {
63
+
64
+ @each $key in $keys {
65
+ @if map-has-key($values, $key)==true {
66
+ $is-map: true;
67
+ }
60
68
  }
61
69
  }
62
70
 
63
- @elseif str-index($property, top) {
64
- $spacing: (top: $sides);
65
- }
71
+ @return $is-map;
72
+ }
66
73
 
67
- @elseif str-index($property, right) {
68
- $spacing: (right: $sides);
69
- }
74
+ /**
75
+ * Converts values in a (one-dimensional) map to the specified [unit](./#variable-unit).
76
+ *
77
+ * @since 0.1
78
+ *
79
+ * @throws Argument $map needs to be a map.
80
+ *
81
+ * @param {List} $values - The value to test, can be a single number or a list
82
+ * @param {Number} $unit ($unit) - A list of keys to match
83
+ *
84
+ * @return {Map}
85
+ */
70
86
 
71
- @elseif str-index($property, bottom) {
72
- $spacing: (bottom: $sides);
73
- }
87
+ @function value-map-to-unit($map, $unit: $unit) {
74
88
 
75
- @elseif str-index($property, left) {
76
- $spacing: (left: $sides);
89
+ @if not(type-of($map)==map) {
90
+ @warn 'Argument $map needs to be a map.';
91
+ @return $map;
77
92
  }
78
93
 
79
- @return $spacing;
94
+ // Convert to units
95
+ @each $key, $value in $map {
96
+ $map: map-merge($map, ($key: to-unit($value, $unit)));
97
+ }
98
+
99
+ @return $map;
80
100
  }
81
101
 
82
102
  /**
83
- * Checks if a Map is a proper value-map (side:value).
103
+ * This function takes a space separated list of padding or margin values and completes it into a list of four side values.
84
104
  *
85
105
  * @since 0.1
106
+ * @access private
86
107
  *
87
- * @param {Map} - A value map
108
+ * @throws Argument $values needs to be a list.
88
109
  *
89
- * @return {Bool}
110
+ * @param {List} $values - The value to test, can be a single number or a list
111
+ *
112
+ * @return {List}
90
113
  */
114
+ @function -sides($values) {
91
115
 
92
- @function is-value-map($values)
93
- {
94
- // Inspect the $sides array, is it alreay a spacing map?
95
- $is-map: false;
96
- @if map-has-key($values, top)==true {
97
- $is-map: true;
98
- }
99
- @elseif map-has-key($values, right)==true {
100
- $is-map: true;
101
- }
102
- @elseif map-has-key($values, bottom)==true {
103
- $is-map: true;
116
+ @if type-of($values)==map {
117
+ @warn 'Argument $values needs to be a list or a single value.';
118
+ @return $values;
104
119
  }
105
- @elseif map-has-key($values, left)==true {
106
- $is-map: true;
120
+
121
+ // Check for the number of values and convert to a value map
122
+ $length: length($values);
123
+ @if $length==1 {
124
+ $values: $values $values $values $values;
125
+ } @elseif $length==2 {
126
+ $values: nth($values, 1) nth($values, 2) nth($values, 1) nth($values, 2);
127
+ } @elseif $length==3 {
128
+ $values: nth($values, 1) nth($values, 2) nth($values, 3) nth($values, 2);
129
+ } @elseif $length==4 {
130
+ $values: nth($values, 1) nth($values, 2) nth($values, 3) nth($values, 4);
107
131
  }
108
132
 
109
- @return $is-map;
133
+ @return $values;
110
134
  }
111
135
 
112
136
 
@@ -121,66 +145,58 @@
121
145
  * @param {Map} $sides - A spacing map in px (top:0,right:0,bottom:0,left:0)
122
146
  */
123
147
 
124
- @mixin padding($sides...)
125
- {
126
- $sides: value-map($sides, padding);
127
- @include -unit-sides($sides, padding);
148
+ @mixin padding($values) {
149
+
150
+ @include -unit-sides($values, padding);
128
151
  }
129
- /**
130
- * Mixin top padding in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
131
- *
132
- * @since 0.1
133
- *
134
- * @param {Number} $value - A value in px
135
- */
136
-
137
- @mixin padding-top($value)
138
- {
139
- $sides: value-map($value, padding-top);
140
- @include -unit-sides($sides, padding);
141
- }
142
152
 
143
- /**
144
- * Mixin right padding in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
145
- *
146
- * @since 0.1
147
- *
148
- * @param {Number} $value - A value in px
149
- */
150
-
151
- @mixin padding-right($value)
152
- {
153
- $sides: value-map($value, padding-right);
154
- @include -unit-sides($sides, padding);
155
- }
153
+ /**
154
+ * Mixin top padding in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
155
+ *
156
+ * @since 0.1
157
+ *
158
+ * @param {Number} $value - A value in px
159
+ */
156
160
 
157
- /**
158
- * Mixin bottom padding in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
159
- *
160
- * @since 0.1
161
- *
162
- * @param {Number} $value - A value in px
163
- */
164
-
165
- @mixin padding-bottom($value)
166
- {
167
- $sides: value-map($value, padding-bottom);
168
- @include -unit-sides($sides, padding);
169
- }
161
+ @mixin padding-top($value) {
162
+ @include -unit-sides((top: $value), padding);
163
+ }
170
164
 
171
- /**
172
- * Mixin left padding in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
173
- *
174
- * @since 0.1
175
- *
176
- * @param {Number} $value - A value in px
177
- */
178
-
179
- @mixin padding-left($value)
180
- {
181
- $sides: value-map($value, padding-left);
182
- @include -unit-sides($sides, padding);
183
- }
165
+ /**
166
+ * Mixin right padding in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
167
+ *
168
+ * @since 0.1
169
+ *
170
+ * @param {Number} $value - A value in px
171
+ */
172
+
173
+ @mixin padding-right($value) {
174
+ @include -unit-sides((right: $value), padding);
175
+ }
176
+
177
+ /**
178
+ * Mixin bottom padding in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
179
+ *
180
+ * @since 0.1
181
+ *
182
+ * @param {Number} $value - A value in px
183
+ */
184
+
185
+ @mixin padding-bottom($value) {
186
+ @include -unit-sides((bottom: $value), padding);
187
+ }
188
+
189
+ /**
190
+ * Mixin left padding in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
191
+ *
192
+ * @since 0.1
193
+ *
194
+ * @param {Number} $value - A value in px
195
+ */
196
+
197
+ @mixin padding-left($value) {
198
+ @include -unit-sides((left: $value), padding);
199
+ }
184
200
 
185
201
 
186
202
  /**
@@ -191,66 +207,59 @@
191
207
  * @param {Map} $sides - A spacing map in px (top:0,right:0,bottom:0,left:0)
192
208
  */
193
209
 
194
- @mixin margin($sides...)
195
- {
196
- $sides: value-map($sides, margin);
197
- @include -unit-sides($sides, margin);
210
+ @mixin margin($values) {
211
+
212
+ @include -unit-sides($values, margin);
198
213
  }
199
- /**
200
- * Mixin top margin in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
201
- *
202
- * @since 0.1
203
- *
204
- * @param {Number} $value - A value in px
205
- */
206
-
207
- @mixin margin-top($value)
208
- {
209
- $sides: value-map($value, margin-top);
210
- @include -unit-sides($sides, margin);
211
- }
212
214
 
213
- /**
214
- * Mixin right margin in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
215
- *
216
- * @since 0.1
217
- *
218
- * @param {Number} $value - A value in px
219
- */
220
-
221
- @mixin margin-right($value)
222
- {
223
- $sides: value-map($value, margin-right);
224
- @include -unit-sides($sides, margin);
225
- }
215
+ /**
216
+ * Mixin top margin in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
217
+ *
218
+ * @since 0.1
219
+ *
220
+ * @param {Number} $value - A value in px
221
+ */
226
222
 
227
- /**
228
- * Mixin bottom margin in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
229
- *
230
- * @since 0.1
231
- *
232
- * @param {Number} $value - A value in px
233
- */
234
-
235
- @mixin margin-bottom($value)
236
- {
237
- $sides: value-map($value, margin-bottom);
238
- @include -unit-sides($sides, margin);
239
- }
223
+ @mixin margin-top($value) {
224
+ @include -unit-sides((top: $value), margin);
225
+ }
226
+
227
+ /**
228
+ * Mixin right margin in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
229
+ *
230
+ * @since 0.1
231
+ *
232
+ * @param {Number} $value - A value in px
233
+ */
234
+
235
+ @mixin margin-right($value) {
236
+ @include -unit-sides((right: $value), margin);
237
+ }
238
+
239
+ /**
240
+ * Mixin bottom margin in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
241
+ *
242
+ * @since 0.1
243
+ *
244
+ * @param {Number} $value - A value in px
245
+ */
246
+
247
+ @mixin margin-bottom($value) {
248
+ @include -unit-sides((bottom: $value), margin);
249
+ }
250
+
251
+ /**
252
+ * Mixin right margin in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
253
+ *
254
+ * @since 0.1
255
+ *
256
+ * @param {Number} $value - A value in px
257
+ */
258
+
259
+ @mixin margin-left($value) {
260
+ @include -unit-sides((left: $value), margin);
261
+ }
240
262
 
241
- /**
242
- * Mixin right margin in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
243
- *
244
- * @since 0.1
245
- *
246
- * @param {Number} $value - A value in px
247
- */
248
-
249
- @mixin margin-left($value)
250
- {
251
- $sides: value-map($value, margin-left);
252
- @include -unit-sides($sides, margin);
253
- }
254
263
 
255
264
  /**
256
265
  * Like [-sides](./#mixin--sides), but with rem fallback if the final unit is rem
@@ -261,45 +270,25 @@
261
270
  *
262
271
  * @param {Map} $sides - A spacing map in final values (top:0,right:0,bottom:0,left:0)
263
272
  * @param {String} $property - The property to apply the values to (padding, margin)
273
+ * @param {Number} $unit ($unit) - The final unit to which $target-px is converted, e.g. 1px, 1rem, 1em, 1%
264
274
  */
265
275
 
266
- @mixin -unit-sides($sides, $property: padding)
267
- {
268
- // Convert the values into the final unit of output
269
- $unit-values: ();
270
- $fallback-values: ();
271
-
272
- $keys: map-keys($sides);
273
- @each $side in $keys {
274
-
275
- // Isolate the value
276
- $value: nth(map-get($sides, $side), 1);
276
+ @mixin -unit-sides($values, $property: padding, $unit: $unit) {
277
277
 
278
- // Catch 0 values
279
- @if strip-unit($value)==0 {
280
- $value: 0px;
281
- }
282
- // Catch rhythm values
283
- @if unitless($value) {
284
- @if $side==top or $side==bottom {
285
- $value: vrhythm($value);
286
- }
287
- @if $side==right or $side==left {
288
- $value: hrhythm($value);
289
- }
290
- }
291
-
292
- // Create new maps
293
- @if unit($unit)==rem {
294
- $fallback-values: map-merge($fallback-values, ($side: to-unit($value, $fallback-values)) );
295
- }
296
- $unit-values: map-merge($unit-values, ($side: to-unit($value)) )
278
+ // This mixin needs a value-map to work, so convert argument if it is not a value-map;
279
+ @if not(is-value-map($values, $keys-side)) {
280
+ $values: value-map(-sides($values), $keys-side);
297
281
  }
298
282
 
283
+ // now, Convert to units
284
+ $unit-values: ();
285
+ @each $key, $value in $values {
286
+ $unit-values: map-merge($unit-values, ($key: to-unit($value, $unit)));
287
+ }
299
288
 
300
289
  // Now, render the property and include rem fallback if needed
301
290
  @if unit($unit)==rem {
302
- @include -sides($fallback-values, $property);
291
+ @include -sides($values, $property);
303
292
  }
304
293
  @include -sides($unit-values, $property);
305
294
  }
@@ -311,66 +300,69 @@
311
300
  * @access private
312
301
  *
313
302
  * @since 0.1
303
+ *
304
+ * @throws 'Argument $map needs to be a value map of four side (top, right, bottom, left) values. Mixin -sides aborted.';
314
305
  *
315
306
  * @param {Map} $sides - A spacing map in final values (top:0,right:0,bottom:0,left:0)
316
307
  * @param {String} $property - The property to apply the values to (padding, margin)
317
308
  */
318
309
 
319
- @mixin -sides($sides, $property: padding)
320
- {
321
- // Initialize some variables
322
- $top: '';
323
- $right: '';
324
- $bottom: '';
325
- $left: '';
326
-
327
- @if map-has-key($sides, top) {
328
- $top: map-get($sides, top);
329
- $top: if(abs($top)==0, 0, $top);
330
- }
310
+ @mixin -sides($values, $property: padding) {
331
311
 
332
- @if map-has-key($sides, right) {
333
- $right: map-get($sides, right);
334
- $right: if(abs($right)==0, 0, $right);
335
- }
312
+ @if not(is-value-map($values, $keys-side)) {
313
+ @warn 'Argument $map needs to be a value map of four side (top, right, bottom, left) values. Mixin -sides aborted.';
314
+ } @else {
336
315
 
337
- @if map-has-key($sides, bottom) {
338
- $bottom: map-get($sides, bottom);
339
- $bottom: if(abs($bottom)==0, 0, $bottom);
340
- }
341
-
342
- @if map-has-key($sides, left) {
343
- $left: map-get($sides, left);
344
- $left: if(abs($left)==0, 0, $left);
345
- }
316
+ // Initialize some variables
317
+ $top: null;
318
+ $right: null;
319
+ $bottom: null;
320
+ $left: null;
346
321
 
347
- @if length($sides)==4 {
322
+ @if map-has-key($values, top) {
323
+ $top: map-get($values, top);
324
+ }
348
325
 
349
- @if ($top==$bottom and $right==$left and $top==$right) {
350
- #{$property}: #{$top};
326
+ @if map-has-key($values, right) {
327
+ $right: map-get($values, right);
351
328
  }
352
- @elseif ($top==$bottom and $right==$left) {
353
- #{$property}: #{$top} #{$right};
329
+
330
+ @if map-has-key($values, bottom) {
331
+ $bottom: map-get($values, bottom);
354
332
  }
355
- @else {
356
- #{$property}: #{$top} #{$right} #{$bottom} #{$left};
333
+
334
+ @if map-has-key($values, left) {
335
+ $left: map-get($values, left);
357
336
  }
358
337
 
359
- }
360
- @else {
338
+ @if length($values)==4 {
339
+
340
+ @if ($top==$bottom and $right==$left and $top==$right) {
341
+ #{$property}: #{$top};
342
+ }
343
+ @elseif ($top==$bottom and $right==$left) {
344
+ #{$property}: #{$top} #{$right};
345
+ }
346
+ @else {
347
+ #{$property}: #{$top} #{$right} #{$bottom} #{$left};
348
+ }
361
349
 
362
- @if $top {
363
- #{$property}-top: #{$top};
364
- }
365
- @if $right {
366
- #{$property}-right: #{$right};
367
- }
368
- @if $bottom {
369
- #{$property}-bottom: #{$bottom};
370
- }
371
- @if $left {
372
- #{$property}-left: #{$left};
373
350
  }
351
+ @else {
374
352
 
353
+ @if $top {
354
+ #{$property}-top: #{$top};
355
+ }
356
+ @if $right {
357
+ #{$property}-right: #{$right};
358
+ }
359
+ @if $bottom {
360
+ #{$property}-bottom: #{$bottom};
361
+ }
362
+ @if $left {
363
+ #{$property}-left: #{$left};
364
+ }
365
+
366
+ }
375
367
  }
376
368
  }
@@ -106,28 +106,25 @@
106
106
 
107
107
 
108
108
  /**
109
- * Find the optimal line-height for a given font-size.
110
- * If the specified span is too small for the font-size, find the next best one based on the specified increment.
109
+ * Convert a px value to a new unit, within the context of it's containing element
111
110
  *
112
111
  * @since 0.1
113
112
  *
114
- * @param {Number} $font-size - the font-size in px
115
- * @param {Number} $span (1) - the desired line-height in rhythm-units, 1 equals 1 $rhythm
116
- * @param {Number} $increment (1) - the increment in rhythm-units
113
+ * @param {Number} $target-px - the line-height in px
114
+ * @param {Number} $context ($default-font-size) - The context of the targeted element, for calculations to em
115
+ * @param {Number} $unit ($line-height-unit) - The final unit to which $target-px is converted, e.g. 1px, 1rem, 1em, 1% or 1 for unitless
117
116
  *
118
117
  * @return {Number} - line-height in px
119
118
  */
120
119
 
121
- @function line-height($font-size: $default-font-size, $span: 1, $increment: 1)
120
+ @function line-height($target-px, $context: $default-font-size, $unit: $line-height-unit)
122
121
  {
123
- $line-height: $span * $rhythm;
124
122
 
125
- @if $font-size >= $line-height {
126
- // call line-height again, but increase span with increment
127
- @return line-height($font-size, $span + $increment, $increment);
123
+ @if unitless($unit) {
124
+ @return strip-unit($target-px/$context);
125
+ } @else {
126
+ @return to-unit($target-px, $unit, $context);
128
127
  }
129
-
130
- @return $line-height;
131
128
  }
132
129
 
133
130
 
@@ -177,6 +174,9 @@
177
174
  * @param {Number} $line-height ($default-line-height) - line-height in the final unit of output
178
175
  */
179
176
 
177
+
178
+ // font: font-style font-variant font-weight font-size/line-height font-family;
179
+
180
180
  @mixin font($type, $font-size:$default-font-size, $line-height:$default-line-height)
181
181
  {
182
182
  @if unit($unit)==rem {
@@ -266,30 +266,25 @@
266
266
  @mixin font-size($target-px, $unit: $unit, $context: $default-font-size)
267
267
  {
268
268
  @if unit($unit) == rem {
269
- font-size: $target-px;
269
+ font-size: to-unit($target-px, $rem-fallback-unit, $context);
270
270
  }
271
271
  font-size: to-unit($target-px, $unit, $context);
272
272
  }
273
273
 
274
274
  /**
275
- * Takes the font-size as an argument and calculates the best possible line-height for it.
276
- * If the $line-height-unit equals to 1%, it is used to calculate the line-height instead.
277
- * More info: [$default-font-size](./#variable-default-font-size), [$line-height-unit](./#variable-line-height-unit)
275
+ * Mixin for line-height, automatically converts the value to a new unit, within the context of it's containing element
278
276
  *
279
277
  * @since 0.1
280
278
  *
281
- * @param {Number} $span - The number of rhythm-units - whole or fraction - to span
282
- * @param {Value} $context ($default-font-size) - The font-size context
283
- * @param {Number} $unit ($line-height-unit) - The final unit to which $target-px is converted, e.g.px | rem | em | %
279
+ * @param {Number} $target-px - the line-height in px
280
+ * @param {Number} $context ($default-font-size) - The context of the targeted element, for calculations to em
281
+ * @param {Number} $unit ($line-height-unit) - The final unit to which $target-px is converted, e.g. 1px, 1rem, 1em, 1% or 1 for unitless
284
282
  */
285
283
 
286
- @mixin line-height($span, $context: $default-font-size, $line-height-unit: $line-height-unit)
284
+ @mixin line-height($target-px, $context: $default-font-size, $unit: $line-height-unit)
287
285
  {
288
-
289
- @if unit($line-height-unit) == "%" {
290
- line-height: $span * $default-line-height / $context * 100%;
291
- }
292
- @else {
293
- @include vrhythm($span, 'line-height', $context);
294
- }
286
+ @if unit($unit)==rem {
287
+ line-height: line-height($target-px, $context, $unit: $rem-fallback-unit);
288
+ }
289
+ line-height: line-height($target-px, $context, $unit);
295
290
  }