forked from supple-kit/supple-css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_rem.scss
50 lines (42 loc) · 1.31 KB
/
_rem.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* =========================================================================
tools.rem
functions an mixins to make life with `rem` units easy
========================================================================= */
/* Use/Forward rules
`@use` or `@forward` everything you need here from other files.
These can include variables, mixins & other includes.
========================================================================= */
@use 'sass:math';
@use 'sass:meta';
@use '../settings/defaults';
/* Module
========================================================================= */
/**
* to-rem
* Converts a single px value to a rem unit based on the current browser context
*/
@function to-rem($value) {
@if meta.type-of($value) == string or math.is-unitless($value) == true or math.unit($value) != 'px' {
@return $value;
} @else {
@return ($value/defaults.$font-size * 1rem);
}
}
/**
* Rem
* Converts all `px` values in a set of values to `rem` values.
* Usage:
rem.convert(0 auto 300px);
rem.convert(26px);
*/
@function convert($value) {
@if meta.type-of($value) == list {
$all: ();
@for $i from 1 through list.length($value) {
$all: list.append($all, to-rem(list.nth($value, $i)));
}
@return $all;
} @else {
@return to-rem($value);
}
}