-
Notifications
You must be signed in to change notification settings - Fork 11
/
_visibility.scss
131 lines (109 loc) · 3.25 KB
/
_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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Foundation for Sites by ZURB
// foundation.zurb.com
// Licensed under MIT Open Source
/// Hide an element by default, only displaying it above a certain screen size.
/// @param {Keyword} $size - Breakpoint to use. **Must be a breakpoint defined in `$breakpoints`.**
@mixin show-for($size) {
$size: map-get($breakpoints, $size);
$size: -zf-bp-to-em($size) - (1/16);
@include breakpoint($size down) {
display: none !important;
}
}
/// Hide an element by default, only displaying it within a certain breakpoint.
/// @param {Keyword} $size - Breakpoint to use. **Must be a breakpoint defined in `$breakpoints`.**
@mixin show-for-only($size) {
$lower-bound-size: map-get($breakpoints, $size);
$upper-bound-size: -zf-map-next($breakpoints, $size);
// more often than not this will be correct, just one time round the loop it won't so set in scope here
$lower-bound: -zf-bp-to-em($lower-bound-size) - (1/16);
// test actual lower-bound-size, if 0 set it to 0em
@if strip-unit($lower-bound-size) == 0 {
$lower-bound: -zf-bp-to-em($lower-bound-size);
}
@if $upper-bound-size == null {
@media screen and (max-width: $lower-bound) {
display: none !important;
}
}
@else {
$upper-bound: -zf-bp-to-em($upper-bound-size);
@media screen and (max-width: $lower-bound), screen and (min-width: $upper-bound) {
display: none !important;
}
}
}
/// Show an element by default, and hide it above a certain screen size.
/// @param {Keyword} $size - Breakpoint to use. **Must be a breakpoint defined in `$breakpoints`.**
@mixin hide-for($size) {
@include breakpoint($size) {
display: none !important;
}
}
/// Show an element by default, and hide it above a certain screen size.
/// @param {Keyword} $size - Breakpoint to use. **Must be a breakpoint defined in `$breakpoints`.**
@mixin hide-for-only($size) {
@include breakpoint($size only) {
display: none !important;
}
}
@mixin foundation-visibility-classes {
// Basic hiding classes
.hide {
display: none !important;
}
.invisible {
visibility: hidden;
}
// Responsive visibility classes
@each $size in $breakpoint-classes {
@if $size != small {
.hide-for-#{$size} {
@include hide-for($size);
}
.show-for-#{$size} {
@include show-for($size);
}
}
.hide-for-#{$size}-only {
@include hide-for-only($size);
}
.show-for-#{$size}-only {
@include show-for-only($size);
}
}
// Screen reader visibility classes
// Need a "hide-for-sr" class? Add aria-hidden='true' to the element
.show-for-sr,
.show-on-focus {
@include element-invisible;
}
// Only display the element when it's focused
.show-on-focus {
&:active,
&:focus {
@include element-invisible-off;
}
}
// Landscape and portrait visibility
.show-for-landscape,
.hide-for-portrait {
display: block !important;
@include breakpoint(landscape) {
display: block !important;
}
@include breakpoint(portrait) {
display: none !important;
}
}
.hide-for-landscape,
.show-for-portrait {
display: none !important;
@include breakpoint(landscape) {
display: none !important;
}
@include breakpoint(portrait) {
display: block !important;
}
}
}