-
Notifications
You must be signed in to change notification settings - Fork 0
/
mixins.scss
54 lines (49 loc) · 1015 Bytes
/
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
52
53
54
// Custom Breakpoints
$breakpoints: (
sm: 768,
md: 1024,
lg: 1200
);
// Media-Query Mixin
@mixin media(
$from: false,
$until: false,
$and: false,
$media-type: all,
) {
$min-width: 0;
$max-width: 0;
$query: "";
//FROM: this breakpoint (inclusive)
@if $from {
@if type-of($from) == number {
$min-width: $from;
} @else {
$min-width: map-get($breakpoints, $from);
}
}
//UNTIL: this breakpoint (exclusive)
@if $until {
@if type-of($until) == number {
$max-width: $until - 1px;
} @else {
$max-width: map-get($breakpoints, $until) - 1px;
}
}
@if $min-width != 0 {
$query: "#{$query} and (min-width: #{$min-width})";
}
@if $max-width != 0 {
$query: "#{$query} and (max-width: #{$max-width})";
}
@if $and {
$query: "#{$query} and (#{$and})";
}
@if ($media-type == "all" and $query != "") {
$media-type: "";
$query: str-slice(unquote($query), 6);
}
@media #{$media-type + $query} {
@content;
}
}