-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path_offcanvas.scss
executable file
·357 lines (307 loc) · 10.5 KB
/
_offcanvas.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
// Foundation by ZURB
// foundation.zurb.com
// Licensed under MIT Open Source
@import "global";
@import "type";
// Off Canvas Tab Bar Variables
$include-html-off-canvas-classes: $include-html-classes !default;
$tabbar-bg: #333 !default;
$tabbar-height: rem-calc(45) !default;
$tabbar-icon-width: $tabbar-height !default;
$tabbar-line-height: $tabbar-height !default;
$tabbar-color: #fff !default;
$tabbar-middle-padding: 0 rem-calc(10) !default;
// Off Canvas Divider Styles
$tabbar-left-section-border: solid 1px scale-color($tabbar-bg, $lightness: -50%) !default;
$tabbar-right-section-border: $tabbar-left-section-border;
// Off Canvas Tab Bar Headers
$tabbar-header-color: #fff !default;
$tabbar-header-weight: $font-weight-bold !default;
$tabbar-header-line-height: $tabbar-height !default;
$tabbar-header-margin: 0 !default;
// Off Canvas Menu Variables
$off-canvas-width: rem-calc(250) !default;
$off-canvas-bg: #333 !default;
// Off Canvas Menu List Variables
$off-canvas-label-padding: 0.3rem rem-calc(15) !default;
$off-canvas-label-color: #999 !default;
$off-canvas-label-text-transform: uppercase !default;
$off-canvas-label-font-size: rem-calc(12) !default;
$off-canvas-label-font-weight: $font-weight-bold !default;
$off-canvas-label-bg: #444 !default;
$off-canvas-label-border-top: 1px solid scale-color($off-canvas-label-bg, $lightness: 14%) !default;
$off-canvas-label-border-bottom: none !default;
$off-canvas-label-margin:0 !default;
$off-canvas-link-padding: rem-calc(10, 15) !default;
$off-canvas-link-color: rgba(#FFF, 0.7) !default;
$off-canvas-link-border-bottom: 1px solid scale-color($off-canvas-bg, $lightness: -25%) !default;
// Off Canvas Menu Icon Variables
$tabbar-menu-icon-color: #FFF !default;
$tabbar-menu-icon-hover: scale-color($tabbar-menu-icon-color, $lightness: -30%) !default;
$tabbar-menu-icon-text-indent: rem-calc(35) !default;
$tabbar-menu-icon-width: $tabbar-icon-width !default;
$tabbar-menu-icon-height: $tabbar-height !default;
$tabbar-menu-icon-padding: 0 !default;
$tabbar-hamburger-icon-width: rem-calc(16) !default;
$tabbar-hamburger-icon-left: false !default;
$tabbar-hamburger-icon-top: false !default;
$tabbar-hamburger-icon-thickness: 1px !default;
$tabbar-hamburger-icon-gap: 6px !default;
// Off Canvas Back-Link Overlay
$off-canvas-overlay-transition: background 300ms ease !default;
$off-canvas-overlay-cursor: pointer !default;
$off-canvas-overlay-box-shadow: -4px 0 4px rgba(#000, 0.5), 4px 0 4px rgba(#000, 0.5) !default;
$off-canvas-overlay-background: rgba(#FFF, 0.2) !default;
$off-canvas-overlay-background-hover: rgba(#FFF, 0.05) !default;
// Transition Variables
$menu-slide: "transform 500ms ease" !default;
// MIXINS
// Remove transition flicker on phones
@mixin kill-flicker {
// -webkit-transform: translateZ(0x);
-webkit-backface-visibility: hidden;
}
// Basic properties for the content wraps
@mixin wrap-base {
position: relative;
width: 100%;
}
@mixin translate3d($tx,$ty,$tz) {
-ms-transform: translate($tx,$ty);
-webkit-transform: translate3d($tx,$ty,$tz);
-moz-transform: translate3d($tx,$ty,$tz);
-ms-transform: translate3d($tx,$ty,$tz);
-o-transform: translate3d($tx,$ty,$tz);
transform: translate3d($tx,$ty,$tz)
}
// basic styles for off-canvas menu container
@mixin off-canvas-menu($position) {
@include kill-flicker;
* { @include kill-flicker; }
width: $off-canvas-width;
top: 0;
bottom: 0;
position: absolute;
overflow-y: auto;
background: $off-canvas-bg;
z-index: 1001;
box-sizing: content-box;
transition: transform 500ms ease 0s;
-webkit-overflow-scrolling: touch;
@if $position == left {
@include translate3d(-100%,0,0);
left: 0;
}
@if $position == right {
@include translate3d(100%,0,0);
right: 0;
}
}
// OFF CANVAS WRAP
// Wrap visible content and prevent scroll bars
@mixin off-canvas-wrap {
@include kill-flicker;
@include wrap-base;
overflow: hidden;
&.move-right,
&.move-left { min-height: 100%; -webkit-overflow-scrolling: touch; }
}
// INNER WRAP
// Main content area that moves to reveal the off-canvas nav
@mixin inner-wrap {
@include kill-flicker;
@include wrap-base;
@include clearfix;
-webkit-transition: -webkit-#{$menu-slide};
-moz-transition: -moz-#{$menu-slide};
-ms-transition: -ms-#{$menu-slide};
-o-transition: -o-#{$menu-slide};
transition: #{$menu-slide};
}
// TAB BAR
// This is the tab bar base
@mixin tab-bar-base {
@include kill-flicker;
// base styles
background: $tabbar-bg;
color: $tabbar-color;
height: $tabbar-height;
line-height: $tabbar-line-height;
// make sure it's below the .exit-offcanvas link
position: relative;
// z-index: 999;
// Typography
h1,h2,h3,h4,h5,h6 {
color: $tabbar-header-color;
font-weight: $tabbar-header-weight;
line-height: $tabbar-header-line-height;
margin: $tabbar-header-margin;
}
h1,h2,h3,h4 { font-size: $h5-font-size; }
}
// SMALL SECTIONS
// These are small sections on the left and right that contain the off-canvas toggle buttons;
@mixin tabbar-small-section($position) {
width: $tabbar-icon-width;
height: $tabbar-height;
position: absolute;
top: 0;
@if $position == left {
border-right: $tabbar-left-section-border;
// box-shadow: 1px 0 0 scale-color($tabbar-bg, $lightness: 13%);
left: 0;
}
@if $position == right {
border-left: $tabbar-right-section-border;
// box-shadow: -1px 0 0 scale-color($tabbar-bg, $lightness: -50%);
right:0;
}
}
@mixin tab-bar-section {
padding: $tabbar-middle-padding;
position: absolute;
text-align: center;
height: $tabbar-height;
top: 0;
@media #{$medium-up} { text-align: left; }
// still need to make these non-presentational
&.left {
left: 0;
right: $tabbar-icon-width;
}
&.right {
left: $tabbar-icon-width;
right: 0;
}
&.middle {
left: $tabbar-icon-width;
right: $tabbar-icon-width;
}
}
// OFF CANVAS LIST
// This is the list of links in the off-canvas menu
@mixin off-canvas-list {
list-style-type: none;
padding:0;
margin:0;
li {
label {
display: block;
padding: $off-canvas-label-padding;
color: $off-canvas-label-color;
text-transform: $off-canvas-label-text-transform;
font-size: $off-canvas-label-font-size;
font-weight: $off-canvas-label-font-weight;
background: $off-canvas-label-bg;
border-top: $off-canvas-label-border-top;
border-bottom: $off-canvas-label-border-bottom;
margin: $off-canvas-label-margin;
}
a {
display: block;
padding: $off-canvas-link-padding;
color: $off-canvas-link-color;
border-bottom: $off-canvas-link-border-bottom;
&:hover { background: scale-color($tabbar-bg, $lightness: -30%); }
transition: background 300ms ease;
}
}
}
// BACK LINK
// This is an overlay that, when clicked, will toggle off the off canvas menu
@mixin back-link {
@include kill-flicker;
transition: $off-canvas-overlay-transition;
cursor: $off-canvas-overlay-cursor;
box-shadow: $off-canvas-overlay-box-shadow;
// fill the screen
display: block;
position: absolute;
background: $off-canvas-overlay-background;
top: 0;
bottom: 0;
left:0;
right:0;
z-index: 1002;
-webkit-tap-highlight-color: rgba(0,0,0,0);
@media #{$medium-up} {
&:hover {
background: $off-canvas-overlay-background-hover;
}
}
}
//
// DEFAULT CLASSES
//
@include exports("offcanvas") {
@if $include-html-off-canvas-classes {
.off-canvas-wrap { @include off-canvas-wrap; }
.inner-wrap { @include inner-wrap; }
.tab-bar { @include tab-bar-base; }
.left-small { @include tabbar-small-section($position: left); }
.right-small { @include tabbar-small-section($position: right); }
.tab-bar-section { @include tab-bar-section; }
// MENU BUTTON
// This is a little bonus. You don't need it for off canvas to work. Mixins to be written in the future.
.tab-bar .menu-icon {
text-indent: $tabbar-menu-icon-text-indent;
width: $tabbar-menu-icon-width;
height: $tabbar-menu-icon-height;
display: block;
padding: $tabbar-menu-icon-padding;
color: $tabbar-menu-icon-color;
position: relative;
transform: translate3d(0,0,0);
// @include for the hamburger menu-icon
//
// Arguments as follows: ($width, $left, $top, $thickness, $gap, $color, $hover-color)
// $width - Width of hamburger icon in rem Default: $tabbar-hamburger-icon-width.
// $left - If false, icon will be centered horizontally || explicitly set value in rem Default: $tabbar-hamburger-icon-left= False
// $top - If false, icon will be centered vertically || explicitly set value in rem Default: = False
// $thickness - thickness of lines in hamburger icon, set value in px Default: $tabbar-hamburger-icon-thickness = 1px
// $gap - spacing between the lines in hamburger icon, set value in px Default: $tabbar-hamburger-icon-gap = 6px
// $color - icon color Default: $tabbar-menu-icon-color
// $hover-color - icon color when hovered Default: $tabbar-menu-icon-hover
// $offcanvas - Set to true
@include hamburger($tabbar-hamburger-icon-width, $tabbar-hamburger-icon-left, $tabbar-hamburger-icon-top, $tabbar-hamburger-icon-thickness, $tabbar-hamburger-icon-gap, $tabbar-menu-icon-color, $tabbar-menu-icon-hover, true)
}
.left-off-canvas-menu { @include off-canvas-menu($position: left); }
.right-off-canvas-menu { @include off-canvas-menu($position: right); }
ul.off-canvas-list { @include off-canvas-list; }
// ANIMATION CLASSES
// These classes are added with JS and trigger the actual animation.
.move-right {
> .inner-wrap {
@include translate3d($off-canvas-width,0,0);
}
.exit-off-canvas { @include back-link;}
}
.move-left {
> .inner-wrap {
@include translate3d(-($off-canvas-width),0,0);
}
.exit-off-canvas { @include back-link; }
}
.offcanvas-overlap {
.left-off-canvas-menu, .right-off-canvas-menu {
-ms-transform: none;
-webkit-transform: none;
-moz-transform: none;
-o-transform: none;
transform: none;
z-index: 1003;
}
.exit-offcanvas-menu {
@include back-link;
z-index: 1002;
}
}
// Older browsers
.no-csstransforms {
.left-off-canvas-menu { left: -($off-canvas-width); }
.right-off-canvas-menu { right: -($off-canvas-width); }
.move-left > .inner-wrap { right: $off-canvas-width; }
.move-right > .inner-wrap { left: $off-canvas-width; }
}
}
}