type-heading 0.0.13 → 0.0.14
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 +28 -12
- data/stylesheets/type-heading/_settings.scss +57 -24
- data/stylesheets/type-heading/functions/_core.scss +67 -32
- data/stylesheets/type-heading/functions/_heading.scss +99 -102
- data/stylesheets/type-heading/functions/_helpers.scss +336 -267
- data/stylesheets/type-heading/functions/_property.scss +288 -296
- data/stylesheets/type-heading/mixins/_breakpoint.scss +19 -20
- data/stylesheets/type-heading/mixins/_core.scss +148 -31
- data/stylesheets/type-heading/mixins/_heading.scss +65 -144
- data/stylesheets/type-heading/mixins/_property.scss +237 -129
- metadata +2 -2
@@ -1,25 +1,53 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
////
|
2
|
+
/// Helpers
|
3
|
+
/// @group Helpers
|
4
|
+
/// @access private
|
5
|
+
////
|
6
|
+
|
7
|
+
// Logic
|
8
|
+
// ------------------------------
|
9
|
+
|
10
|
+
// th-if()
|
11
|
+
/// Shorthand if else statement.
|
12
|
+
///
|
13
|
+
/// @since 0.0.14
|
14
|
+
/// @return {mixed} The return value of the condition.
|
15
|
+
///
|
16
|
+
/// @param {boolean} $condition - The condition to pass.
|
17
|
+
/// @param {mixed} $if-value - The return value if condition is true.
|
18
|
+
/// @param {mixed} $else-value - The return value if condition is false.
|
19
|
+
///
|
20
|
+
/// @example scss - If 2 plus 2 equals 8, return 10px, else return 20px.
|
21
|
+
/// th-if(2 + 2, 10px, 20px);
|
22
|
+
/// // 20px
|
23
|
+
|
24
|
+
@function th-if(
|
25
|
+
$condition,
|
26
|
+
$if-value,
|
27
|
+
$else-value
|
28
|
+
){
|
29
|
+
@if ($condition == true) {
|
30
|
+
@return $if-value;
|
31
|
+
} @else {
|
32
|
+
@return $else-value;
|
33
|
+
}
|
34
|
+
}
|
5
35
|
|
6
36
|
// Math
|
7
37
|
// ------------------------------
|
8
38
|
|
9
|
-
//
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
//
|
21
|
-
// // th-math-power(10, 3)
|
22
|
-
// // // 1000
|
39
|
+
// th-math-power()
|
40
|
+
/// Returns a powered number by exponent.
|
41
|
+
///
|
42
|
+
/// @since 0.0.11
|
43
|
+
/// @return {number} The powered number.
|
44
|
+
///
|
45
|
+
/// @param {number} $number - The base number.
|
46
|
+
/// @param {number} $exponent - The base number's exponent.
|
47
|
+
///
|
48
|
+
/// @example scss - Calculate 10 to the power of 3.
|
49
|
+
/// th-math-power(10, 3)
|
50
|
+
/// // 1000
|
23
51
|
|
24
52
|
@function th-math-power(
|
25
53
|
$number,
|
@@ -39,22 +67,18 @@
|
|
39
67
|
@return $_return;
|
40
68
|
}
|
41
69
|
|
42
|
-
//
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
//
|
54
|
-
//
|
55
|
-
// @example scss Round 1.234 to 2 decimal places.
|
56
|
-
// // th-math-round-to(1.234, 2)
|
57
|
-
// // // 1.23
|
70
|
+
// th-math-round-to()
|
71
|
+
/// Returns a floated number rounded to a decimal point.
|
72
|
+
///
|
73
|
+
/// @since 0.0.11
|
74
|
+
/// @return {number} The rounded number.
|
75
|
+
///
|
76
|
+
/// @param {number} $number - The number to round from.
|
77
|
+
/// @param {number} $decimal - The decimal place to round to.
|
78
|
+
///
|
79
|
+
/// @example scss - Round 1.234 to 2 decimal places.
|
80
|
+
/// th-math-round-to(1.234, 2)
|
81
|
+
/// // 1.23
|
58
82
|
|
59
83
|
@function th-math-round-to(
|
60
84
|
$number,
|
@@ -69,20 +93,18 @@
|
|
69
93
|
// Lists
|
70
94
|
// ------------------------------
|
71
95
|
|
72
|
-
//
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
//
|
84
|
-
// // @debug th-list-has-index((a, b, c), 2);
|
85
|
-
// // // true
|
96
|
+
// th-list-has-index()
|
97
|
+
/// Check list for a index.
|
98
|
+
///
|
99
|
+
/// @since 0.0.11
|
100
|
+
/// @return {boolean} If list contains index.
|
101
|
+
///
|
102
|
+
/// @param {list} $list - List to search.
|
103
|
+
/// @param {number} $index - The list index to retrieve.
|
104
|
+
///
|
105
|
+
/// @example scss - Check list for 2n index.
|
106
|
+
/// th-list-has-index((a, b, c), 2);
|
107
|
+
/// // true
|
86
108
|
|
87
109
|
@function th-list-has-index(
|
88
110
|
$list,
|
@@ -95,23 +117,18 @@
|
|
95
117
|
@return $_return;
|
96
118
|
}
|
97
119
|
|
98
|
-
//
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
//
|
110
|
-
// @returns {list} The index of the found value.
|
111
|
-
//
|
112
|
-
// @example scss Get the index of 'f' in (a, b, (c, d, (e, f))).
|
113
|
-
// // th-list-get-index-deep( (a, b, (c, d, (e, f))), f )
|
114
|
-
// // // 3 3 2
|
120
|
+
// th-list-get-index-deep()
|
121
|
+
/// Return the index of a value within multiple lists.
|
122
|
+
///
|
123
|
+
/// @since 0.0.11
|
124
|
+
/// @return {list} The index of the found value.
|
125
|
+
///
|
126
|
+
/// @param {list} $list - The list to search through.
|
127
|
+
/// @param {number | string} $find - The value to find.
|
128
|
+
///
|
129
|
+
/// @example scss - Get the index of 'f' in (a, b, (c, d, (e, f))).
|
130
|
+
/// th-list-get-index-deep( (a, b, (c, d, (e, f))), f )
|
131
|
+
/// // 3 3 2
|
115
132
|
|
116
133
|
@function th-list-get-index-deep(
|
117
134
|
$list,
|
@@ -137,20 +154,18 @@
|
|
137
154
|
@return $_return;
|
138
155
|
}
|
139
156
|
|
140
|
-
//
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
//
|
152
|
-
// // th-list-has((a b c), b);
|
153
|
-
// // // true
|
157
|
+
// th-list-has()
|
158
|
+
/// Check list for a value.
|
159
|
+
///
|
160
|
+
/// @since 0.0.11
|
161
|
+
/// @return {boolean} If list contains value.
|
162
|
+
///
|
163
|
+
/// @param {list} $list - List to search.
|
164
|
+
/// @param {number | string} $find - Value to find.
|
165
|
+
///
|
166
|
+
/// @example scss - Check list for 'b'.
|
167
|
+
/// th-list-has((a b c), b);
|
168
|
+
/// // true
|
154
169
|
|
155
170
|
@function th-list-has(
|
156
171
|
$list,
|
@@ -165,20 +180,51 @@
|
|
165
180
|
@return $_return;
|
166
181
|
}
|
167
182
|
|
168
|
-
//
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
//
|
180
|
-
|
181
|
-
|
183
|
+
// th-list-get-nth-deep()
|
184
|
+
/// Return a nested value by index (recursive).
|
185
|
+
///
|
186
|
+
/// @since 0.0.14
|
187
|
+
/// @return {mixed} The nested list value.
|
188
|
+
///
|
189
|
+
/// @param {list} $list - List to search through.
|
190
|
+
/// @param {list} $indexes - List of indexes to recurse.
|
191
|
+
///
|
192
|
+
/// @example scss - Get (3 3 2)n in (a, b, (c, d, (e, f))).
|
193
|
+
/// th-list-get-nth-deep(3 3 2)
|
194
|
+
/// // f
|
195
|
+
|
196
|
+
@function th-list-get-nth-deep(
|
197
|
+
$list,
|
198
|
+
$indexes
|
199
|
+
){
|
200
|
+
$_return: false;
|
201
|
+
@if list == type-of($list) {
|
202
|
+
$_return: $list;
|
203
|
+
@for $i from 1 through length($indexes) {
|
204
|
+
@if th-list-has-index($_return, nth($indexes, $i)) {
|
205
|
+
$_return: nth($_return, nth($indexes, $i));
|
206
|
+
} @else if $i == 1 {
|
207
|
+
$_return: false;
|
208
|
+
}
|
209
|
+
}
|
210
|
+
} @else if $indexes == 1 {
|
211
|
+
$_return: $list;
|
212
|
+
}
|
213
|
+
@return $_return;
|
214
|
+
}
|
215
|
+
|
216
|
+
// th-list-has-deep()
|
217
|
+
/// Check list for a value (recursive).
|
218
|
+
///
|
219
|
+
/// @since 0.0.10
|
220
|
+
/// @return {boolean} If list contains value.
|
221
|
+
///
|
222
|
+
/// @param {list} $list - List to search.
|
223
|
+
/// @param {number | string} $find - Value to find.
|
224
|
+
///
|
225
|
+
/// @example scss - Check for 'f' in (a b (c d (e f))).
|
226
|
+
/// th-list-has-deep((a b (c d (e f))), f)
|
227
|
+
/// // true
|
182
228
|
|
183
229
|
@function th-list-has-deep(
|
184
230
|
$list,
|
@@ -200,19 +246,47 @@
|
|
200
246
|
// Units
|
201
247
|
// ------------------------------
|
202
248
|
|
203
|
-
//
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
//
|
249
|
+
// _th-unit-convert()
|
250
|
+
/// Coverts a number into another unit.
|
251
|
+
///
|
252
|
+
/// @since 0.0.14
|
253
|
+
/// @return {number} The converted number.
|
254
|
+
///
|
255
|
+
/// @param {string} $unit - (px|em|rem|rel|percent) A unit to convert the number to.
|
256
|
+
/// @param {number} $number - The number to convert.
|
257
|
+
/// @param {number} $base-font-size [$th-base-font-size] - Font size used for relative calculations.
|
258
|
+
///
|
259
|
+
/// @example scss - Convert 14px to em.
|
260
|
+
/// _th-unit-convert($unit: em, $number: 14px)
|
261
|
+
/// // 0.875em
|
262
|
+
/// @example scss - Convert 14px with base font size of 20px to em.
|
263
|
+
/// _th-unit-convert($unit: em, $number: 14px, $base-font-size: 20px)
|
264
|
+
/// // 0.700em
|
265
|
+
|
266
|
+
@function th-unit-convert(
|
267
|
+
$unit,
|
268
|
+
$number,
|
269
|
+
$base-font-size: $th-base-font-size
|
270
|
+
){
|
271
|
+
$function: th-unit-convert-#{$unit};
|
272
|
+
@if function-exists($function) and unit($number) != $unit {
|
273
|
+
@return call($function, $number, $base-font-size);
|
274
|
+
} @else {
|
275
|
+
@return $number;
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
// th-unit-strip()
|
280
|
+
/// Strips the unit from a number.
|
281
|
+
///
|
282
|
+
/// @since 0.0.11
|
283
|
+
/// @return {number} The stripped number.
|
284
|
+
///
|
285
|
+
/// @param {number} $number - Number to strip unit from.
|
286
|
+
///
|
287
|
+
/// @example scss - Strip px from 24px.
|
288
|
+
/// th-unit-strip(24px)
|
289
|
+
/// // 24
|
216
290
|
|
217
291
|
@function th-unit-strip(
|
218
292
|
$number
|
@@ -221,20 +295,18 @@
|
|
221
295
|
@return $_return;
|
222
296
|
}
|
223
297
|
|
224
|
-
//
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
//
|
236
|
-
// // th-unit-cast(24, px);
|
237
|
-
// // // 24px
|
298
|
+
// th-unit-cast()
|
299
|
+
/// Creates a number with a unit.
|
300
|
+
///
|
301
|
+
/// @since 0.0.11
|
302
|
+
/// @return {number} The number with new unit.
|
303
|
+
///
|
304
|
+
/// @param {number} $number - The unitless number to create.
|
305
|
+
/// @param {string} $unit - The type of unit to create.
|
306
|
+
///
|
307
|
+
/// @example scss - Change 24 to 24px.
|
308
|
+
/// th-unit-cast(24, px);
|
309
|
+
/// // 24px
|
238
310
|
|
239
311
|
@function th-unit-cast(
|
240
312
|
$number,
|
@@ -250,25 +322,20 @@
|
|
250
322
|
@return $_return;
|
251
323
|
}
|
252
324
|
|
253
|
-
//
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
//
|
265
|
-
|
266
|
-
|
267
|
-
// @example scss Convert 24px to 24em.
|
268
|
-
// // th-unit-convert(24px, em)
|
269
|
-
// // // 24em
|
270
|
-
|
271
|
-
@function th-unit-convert(
|
325
|
+
// th-unit-convert-number()
|
326
|
+
/// Converts the unit of a number.
|
327
|
+
///
|
328
|
+
/// @since 0.0.11
|
329
|
+
/// @return {number} The converted number.
|
330
|
+
///
|
331
|
+
/// @param {number} $number - The numbered unit to convert.
|
332
|
+
/// @param {string} $unit - The unit to convert to.
|
333
|
+
///
|
334
|
+
/// @example scss - Convert unit of 24px to em.
|
335
|
+
/// th-unit-convert-number(24px, em)
|
336
|
+
/// // 24em
|
337
|
+
|
338
|
+
@function th-unit-convert-number(
|
272
339
|
$number,
|
273
340
|
$unit
|
274
341
|
){
|
@@ -280,28 +347,22 @@
|
|
280
347
|
@return $_return;
|
281
348
|
}
|
282
349
|
|
283
|
-
//
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
//
|
296
|
-
|
297
|
-
|
298
|
-
//
|
299
|
-
// @example scss Convert 2em to px.
|
300
|
-
// // th-unit-convert-absolute(2em, px)
|
301
|
-
// // // 32px
|
302
|
-
// @example scss Convert 2em to px with base font size of 10px.
|
303
|
-
// // th-unit-convert-absolute(2em, px, 10px);
|
304
|
-
// // // 20px
|
350
|
+
// th-unit-convert-absolute()
|
351
|
+
/// Converts a relative number to an absolute number.
|
352
|
+
///
|
353
|
+
/// @since 0.0.11
|
354
|
+
/// @return {number} The converted absolute number.
|
355
|
+
///
|
356
|
+
/// @param {number} $number - The number to convert.
|
357
|
+
/// @param {string} $unit - The type of absolute unit.
|
358
|
+
/// @param {number} $base-font-size [$th-base-font-size] - Font size used for relative calculations.
|
359
|
+
///
|
360
|
+
/// @example scss - Convert 2em to px.
|
361
|
+
/// th-unit-convert-absolute(2em, px)
|
362
|
+
/// // 32px
|
363
|
+
/// @example scss - Convert 2em to px with base font size of 10px.
|
364
|
+
/// th-unit-convert-absolute(2em, px, 10px);
|
365
|
+
/// // 20px
|
305
366
|
|
306
367
|
@function th-unit-convert-absolute(
|
307
368
|
$number,
|
@@ -312,33 +373,27 @@
|
|
312
373
|
$_return: th-unit-strip($number) * th-unit-strip($base-font-size);
|
313
374
|
$_return: th-math-round-to($_return, 5);
|
314
375
|
@if $unit {
|
315
|
-
$_return: th-unit-convert($_return, $unit);
|
376
|
+
$_return: th-unit-convert-number($_return, $unit);
|
316
377
|
}
|
317
378
|
@return $_return;
|
318
379
|
}
|
319
380
|
|
320
|
-
//
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
//
|
333
|
-
|
334
|
-
|
335
|
-
//
|
336
|
-
// @example scss Convert 24px to em.
|
337
|
-
// // th-unit-convert-relative(24px, em)
|
338
|
-
// // // 1.5
|
339
|
-
// @example scss Convert 24px to em with a base font size of 32px.
|
340
|
-
// // th-unit-convert-relative(24px, em, 32px)
|
341
|
-
// // // 0.75em
|
381
|
+
// th-unit-convert-relative()
|
382
|
+
/// Converts an absolute number to a relative number.
|
383
|
+
///
|
384
|
+
/// @since 0.0.11
|
385
|
+
/// @return {number} The converted relative number.
|
386
|
+
///
|
387
|
+
/// @param {number} $number - The number to convert.
|
388
|
+
/// @param {string} $unit - The type of relative unit.
|
389
|
+
/// @param {number} $base-font-size [$th-base-font-size] - Font size used for relative calculations.
|
390
|
+
///
|
391
|
+
/// @example scss - Convert 24px to em.
|
392
|
+
/// th-unit-convert-relative(24px, em)
|
393
|
+
/// // 1.5
|
394
|
+
/// @example scss - Convert 24px to em with a base font size of 32px.
|
395
|
+
/// th-unit-convert-relative(24px, em, 32px)
|
396
|
+
/// // 0.75em
|
342
397
|
|
343
398
|
@function th-unit-convert-relative(
|
344
399
|
$number,
|
@@ -347,125 +402,139 @@
|
|
347
402
|
){
|
348
403
|
$_return: $number;
|
349
404
|
$_return: th-unit-strip($number) / th-unit-strip($base-font-size);
|
350
|
-
$_return: th-math-round-to($_return, 5);
|
351
405
|
@if $unit {
|
352
|
-
$_return: th-unit-convert($_return, $unit);
|
406
|
+
$_return: th-unit-convert-number($_return, $unit);
|
353
407
|
}
|
354
408
|
@return $_return;
|
355
409
|
}
|
356
410
|
|
357
|
-
//
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
//
|
369
|
-
|
370
|
-
|
371
|
-
//
|
372
|
-
// // // 1.5
|
373
|
-
// @example scss Convert 24px to em with a base font size of 32px.
|
374
|
-
// // th-unit-convert-em(24px, 32px)
|
375
|
-
// // // 0.75em
|
411
|
+
// th-unit-convert-em()
|
412
|
+
/// Converts an absolute number to an em number.
|
413
|
+
///
|
414
|
+
/// @since 0.0.11
|
415
|
+
/// @return {number} The converted number with em unit.
|
416
|
+
///
|
417
|
+
/// @param {number} $number - The number to convert.
|
418
|
+
/// @param {number} $base-font-size [$th-base-font-size] - Font size used for relative calculations.
|
419
|
+
///
|
420
|
+
/// @example scss - Convert 24px to em.
|
421
|
+
/// th-unit-convert-em(24px)
|
422
|
+
/// // 1.5em
|
423
|
+
/// @example scss - Convert 24px to em with a base font size of 32px.
|
424
|
+
/// th-unit-convert-em(24px, 32px)
|
425
|
+
/// // 0.75em
|
376
426
|
|
377
427
|
@function th-unit-convert-em(
|
378
428
|
$number,
|
379
429
|
$base-font-size: $th-base-font-size
|
380
430
|
){
|
381
431
|
$_return: $number;
|
382
|
-
$_return: th-
|
432
|
+
$_return: th-math-round-to($_return, 5);
|
433
|
+
$_return: th-unit-convert-relative($_return, em, $base-font-size);
|
383
434
|
@return $_return;
|
384
435
|
}
|
385
436
|
|
386
|
-
//
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
//
|
398
|
-
|
399
|
-
|
400
|
-
//
|
401
|
-
// // // 1.5
|
402
|
-
// @example scss Convert 24px to rem with a base font size of 32px.
|
403
|
-
// // th-unit-convert-rem(24px, 32px)
|
404
|
-
// // // 0.75rem
|
437
|
+
// th-unit-convert-rem()
|
438
|
+
/// Converts an absolute number to an rem number.
|
439
|
+
///
|
440
|
+
/// @since 0.0.11
|
441
|
+
/// @return {number} The converted number with rem unit.
|
442
|
+
///
|
443
|
+
/// @param {number} $number - The number to convert.
|
444
|
+
/// @param {number} $base-font-size [$th-rem-base] - Font size used for rem calculations.
|
445
|
+
///
|
446
|
+
/// @example scss - Convert 24px to rem.
|
447
|
+
/// th-unit-convert-rem(24px)
|
448
|
+
/// // 1.5rem
|
449
|
+
/// @example scss - Convert 24px to rem with a rem base of 32px.
|
450
|
+
/// th-unit-convert-rem(24px, 32px)
|
451
|
+
/// // 0.75rem
|
405
452
|
|
406
453
|
@function th-unit-convert-rem(
|
407
454
|
$number,
|
408
|
-
$base-font-size: $th-base
|
455
|
+
$base-font-size: $th-rem-base
|
409
456
|
){
|
410
457
|
$_return: $number;
|
411
|
-
$_return: th-
|
458
|
+
$_return: th-math-round-to($_return, 5);
|
459
|
+
$_return: th-unit-convert-relative($_return, rem, $th-rem-base);
|
412
460
|
@return $_return;
|
413
461
|
}
|
414
462
|
|
415
|
-
//
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
//
|
427
|
-
|
428
|
-
|
429
|
-
//
|
430
|
-
// // // 1.5
|
431
|
-
// @example scss Convert 24px to a relative number with a base font size of 32px.
|
432
|
-
// // th-unit-convert-rel(24px, 32px)
|
433
|
-
// // // 0.75
|
463
|
+
// th-unit-convert-rel
|
464
|
+
/// Converts an absolute number to a relative number.
|
465
|
+
///
|
466
|
+
/// @since 0.0.11
|
467
|
+
/// @return {number} The converted relative number.
|
468
|
+
///
|
469
|
+
/// @param {number} $number - The number to convert.
|
470
|
+
/// @param {number} $base-font-size [$th-base-font-size] - Font size used for relative calculations.
|
471
|
+
///
|
472
|
+
/// @example scss - Convert 24px to a relative number.
|
473
|
+
/// th-unit-convert-rel(24px)
|
474
|
+
/// // 1.5
|
475
|
+
/// @example scss - 24px to a relative number with a base font size of 32px.
|
476
|
+
/// th-unit-convert-rel(24px, 32px)
|
477
|
+
/// // 0.75
|
434
478
|
|
435
479
|
@function th-unit-convert-rel(
|
436
480
|
$number,
|
437
481
|
$base-font-size: $th-base-font-size
|
438
482
|
){
|
439
483
|
$_return: $number;
|
440
|
-
$_return: th-
|
484
|
+
$_return: th-math-round-to($_return, 5);
|
485
|
+
$_return: th-unit-convert-relative($_return, false, $base-font-size);
|
441
486
|
@return $_return;
|
442
487
|
}
|
443
488
|
|
444
|
-
//
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
//
|
456
|
-
|
457
|
-
|
458
|
-
//
|
459
|
-
// // // 32px
|
460
|
-
// @example scss Convert 2em to a px number with a base font size of 18px.
|
461
|
-
// // th-unit-convert-px(2em, 18px)
|
462
|
-
// // // 36px
|
489
|
+
// th-unit-convert-px()
|
490
|
+
/// Converts a relative number to a px number.
|
491
|
+
///
|
492
|
+
/// @since 0.0.11
|
493
|
+
/// @return {number} The converted absolute number.
|
494
|
+
///
|
495
|
+
/// @param {number} $number - The number to convert.
|
496
|
+
/// @param {number} $base-font-size [$th-base-font-size] - Font size used for relative calculations.
|
497
|
+
///
|
498
|
+
/// @example scss - Convert 2em to a px number.
|
499
|
+
/// th-unit-convert-absolute(2em)
|
500
|
+
/// // 32px
|
501
|
+
/// @example scss - Convert 2em to a px number with a base font size of 18px.
|
502
|
+
/// th-unit-convert-px(2em, 18px)
|
503
|
+
/// // 36px
|
463
504
|
|
464
505
|
@function th-unit-convert-px(
|
465
506
|
$number,
|
466
507
|
$base-font-size: $th-base-font-size
|
467
508
|
){
|
468
509
|
$_return: $number;
|
469
|
-
$_return: th-
|
510
|
+
$_return: th-math-round-to($_return, 5);
|
511
|
+
$_return: th-unit-convert-absolute($_return, px, $base-font-size);
|
512
|
+
@return $_return;
|
513
|
+
}
|
514
|
+
|
515
|
+
// th-unit-convert-percent
|
516
|
+
/// Converts an absolute number to a percentage.
|
517
|
+
///
|
518
|
+
/// @since 0.0.11
|
519
|
+
/// @return {number} The converted percentage number.
|
520
|
+
///
|
521
|
+
/// @param {number} $number - The number to convert.
|
522
|
+
/// @param {number} $base-font-size [$th-base-font-size] - Font size used for relative calculations.
|
523
|
+
///
|
524
|
+
/// @example scss - Convert 24px to a percentage.
|
525
|
+
/// th-unit-convert-rel(24px)
|
526
|
+
/// // 150%
|
527
|
+
/// @example scss - Convert 24px to a percentage with a base font size of 32px.
|
528
|
+
/// th-unit-convert-rel(24px, 32px)
|
529
|
+
/// // 75%
|
530
|
+
|
531
|
+
@function th-unit-convert-percent(
|
532
|
+
$number,
|
533
|
+
$base-font-size: $th-base-font-size
|
534
|
+
){
|
535
|
+
$_return: $number;
|
536
|
+
$_return: th-math-round-to($_return, 7);
|
537
|
+
$_return: th-unit-convert-relative($number, false, $base-font-size);
|
538
|
+
$_return: $_return * 100%;
|
470
539
|
@return $_return;
|
471
540
|
}
|