-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
mixins.scss
51 lines (46 loc) · 1.32 KB
/
mixins.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
51
@mixin cq-prolyfill($query) {
&#{cq-prolyfill($query)} {
@content;
}
}
@function cq-prolyfill($query) {
@return unquote(".\\:container\\(" + cq-prolyfill-escape(cq-prolyfill-strip-spaces(to-lower-case($query))) + "\\)");
}
@function cq-prolyfill-add-backslash($string, $search) {
$index: str-index($string, $search);
@while $index {
$string: str-insert($string, '\\', $index);
$newIndex: if(
str-length($string) < $index + 2,
null,
str-index(str-slice($string, $index + 2), $search)
);
$index: if($newIndex, $index + 1 + $newIndex, null);
}
@return $string;
}
@function cq-prolyfill-remove($string, $search) {
$index: str-index($string, $search);
@while $index {
$string: str-slice($string, 1, $index - 1) + str-slice($string, $index + 1);
$index: str-index($string, $search);
}
@return $string;
}
@function cq-prolyfill-escape($string) {
@each $char in '[' ']' '!' '"' '#' '$' '%' '&' "'" '(' ')' '*' '+' ',' '.' '/' ':' ';' '<' '=' '>' '?' '@' '^' '`' '{' '|' '}' '~' {
$string: cq-prolyfill-add-backslash($string, $char);
}
@return $string;
}
@function cq-prolyfill-strip-spaces($string) {
// tab, line feed, carriage return and space
$chars: "\9\a\d\20";
@for $i from 1 through str-length($chars) {
$string: cq-prolyfill-remove(
$string,
str-slice($chars, $i, $i)
);
}
@return $string;
}