-
Notifications
You must be signed in to change notification settings - Fork 5
/
_responsive-visibility.scss
68 lines (62 loc) · 1.75 KB
/
_responsive-visibility.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* remove removes element from list returns the others
*/
@function remove($key, $list) {
$newList: ();
@each $item in $list {
@if $item != $key {
$newList: append($newList, $item, "comma");
}
}
@return $newList;
}
/**
* mixin responsive-visibility
* $visibility-breakpoints {[list]} list of breakpoints you want to interact with
* $overwrite {[boolean]} if set true will generate classes that overwrite what ever visibility is active on that element
*
* exact:
* @include responsive-visibility("only-mobile" "only-tablet" "only-desktop", true);
*
* up:
* @include responsive-visibility("mobile" "tablet" "desktop", false);
*/
@mixin responsive-visibility (
$visibility-breakpoints,
$overwrite: false,
$displayTypes: "inline" "inline-block"
){
@each $breakpoint-active in $visibility-breakpoints {
@include breakpoint($breakpoint-active) {
$visibles: "";
$invisibles: "";
$visibles: unquote($visibles + ".is-visible-#{$breakpoint-active},");
$invisibles: unquote($invisibles + ".is-hidden-#{$breakpoint-active},");
@if $overwrite == true {
$others: remove($breakpoint-active, $visibility-breakpoints);
$othersRule: "";
@each $other in $others {
$invisibles: unquote($invisibles + ".is-visible-#{$other},");
}
}
#{$visibles} {
display: block !important;
visibility: visible;
@each $display in $displayTypes {
&--#{$display} {
display: #{$display};
}
}
}
#{$invisibles} {
display: none !important;
visibility: hidden;
@each $display in $displayTypes {
&--#{$display} {
display: none !important;
}
}
}
}
}
}