-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
sidenav.html
403 lines (369 loc) · 12.7 KB
/
sidenav.html
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
<!DOCTYPE html>
<html lang="en">
<head> {{> head }} </head>
<body>
{{> navbar }}
<main>
{{> intro}}
<div class="container">
<div class="row">
<div class="col s12 m8 offset-m1 xl7 offset-xl1">
<div id="structure" class="section scrollspy">
<p class="caption">
This is a slide out menu. You can add a dropdown to your sidebar by using our collapsible component. If you want to see a
demo, our sidebar will use this on smaller screens. To use this in conjunction with a fullscreen navigation, you
have to use two copies of the same UL.
</p>
<p>
<strong>Please note that the sidenav HTML should not be contained within the navbar HTML.</strong>
</p>
<a href="#" data-target="slide-out" class="sidenav-trigger btn">Side nav demo</a>
<ul id="slide-out" class="sidenav">
<li>
<div class="user-view">
<div class="background">
<img src="images/office.jpg">
</div>
<a href="#user">
<img class="circle" src="images/yuna.jpg">
</a>
<a href="#name">
<span class="white-text name">John Doe</span>
</a>
<a href="#email">
<span class="white-text email">[email protected]</span>
</a>
</div>
</li>
<li>
<a href="#!">
<i class="material-icons">cloud</i>First Link With Icon</a>
</li>
<li>
<a href="#!">Second Link</a>
</li>
<li>
<div class="divider"></div>
</li>
<li>
<a class="subheader">Subheader</a>
</li>
<li>
<a class="waves-effect" href="#!">Third Link With Waves</a>
</li>
</ul>
<pre><code class="language-html">
<xmp>
<nav> <!-- navbar content here --> </nav>
<ul id="slide-out" class="sidenav">
<li><div class="user-view">
<div class="background">
<img src="images/office.jpg">
</div>
<a href="#user"><img class="circle" src="images/yuna.jpg"></a>
<a href="#name"><span class="white-text name">John Doe</span></a>
<a href="#email"><span class="white-text email">[email protected]</span></a>
</div></li>
<li><a href="#!"><i class="material-icons">cloud</i>First Link With Icon</a></li>
<li><a href="#!">Second Link</a></li>
<li><div class="divider"></div></li>
<li><a class="subheader">Subheader</a></li>
<li><a class="waves-effect" href="#!">Third Link With Waves</a></li>
</ul>
<a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
</xmp>
</code></pre>
</div>
<div id="initialization" class="section scrollspy">
<h3 class="header">Initialization</h3>
<pre><code class="language-javascript col s12">
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.sidenav');
var instances = M.Sidenav.init(elems, {
// specify options here
});
});
// Initialize collapsible (uncomment the lines below if you use the dropdown variation)
// var collapsibleElem = document.querySelector('.collapsible');
// var collapsibleInstance = M.Collapsible.init(collapsibleElem, {
// // specify options here
// });
</code></pre>
</div>
<div id="options" class="scrollspy section">
<h3 class="header">Options</h3>
<table class="striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>edge</td>
<td>String</td>
<td>'left'</td>
<td>Side of screen on which Sidenav appears.</td>
</tr>
<tr>
<td>draggable</td>
<td>Boolean</td>
<td>true</td>
<td>Allow swipe gestures to open/close Sidenav.</td>
</tr>
<tr>
<td>dragTargetWidth</td>
<td>String</td>
<td>'10px'</td>
<td>Width of the area where you can start dragging.</td>
</tr>
<tr>
<td>inDuration</td>
<td>Number</td>
<td>250</td>
<td>Length in ms of enter transition.</td>
</tr>
<tr>
<td>outDuration</td>
<td>Number</td>
<td>200</td>
<td>Length in ms of exit transition.</td>
</tr>
<tr>
<td>onOpenStart</td>
<td>Function</td>
<td>null</td>
<td>Function called when sidenav starts entering.</td>
</tr>
<tr>
<td>onOpenEnd</td>
<td>Function</td>
<td>null</td>
<td>Function called when sidenav finishes entering.</td>
</tr>
<tr>
<td>onCloseStart</td>
<td>Function</td>
<td>null</td>
<td>Function called when sidenav starts exiting.</td>
</tr>
<tr>
<td>onCloseEnd</td>
<td>Function</td>
<td>null</td>
<td>Function called when sidenav finishes exiting.</td>
</tr>
<tr>
<td>preventScrolling</td>
<td>Boolean</td>
<td>true</td>
<td>Prevent page from scrolling while sidenav is open.</td>
</tr>
</tbody>
</table>
</div>
<div id="methods" class="scrollspy section">
<h3 class="header">Methods</h3>
<blockquote>
<p>All the methods are called on the plugin instance. You can get the plugin instance like this: </p>
<pre><code class="language-javascript col s12">
var instance = M.Sidenav.getInstance(elem);
</code></pre>
</blockquote>
<h5 class="method-header">
.open();
</h5>
<p>Opens Sidenav.</p>
<pre><code class="language-javascript col s12">
instance.open();
</code></pre>
class="method-header">
.close();
</h5>
<p>Closes Sidenav.</p>
<pre><code class="language-javascript col s12">
instance.close();
</code></pre>
class="method-header">
.destroy();
</h5>
<p>Destroy plugin instance and teardown</p>
<pre><code class="language-javascript col s12">
instance.destroy();
</code></pre>
</div>
<div id="properties" class="scrollspy section">
<h3 class="header">Properties</h3>
<table class="striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>el</td>
<td>Element</td>
<td>The DOM element the plugin was initialized with.</td>
</tr>
<tr>
<td>options</td>
<td>Object</td>
<td>The options the instance was initialized with.</td>
</tr>
<tr>
<td>isOpen</td>
<td>Boolean</td>
<td>Describes open/close state of Sidenav.</td>
</tr>
<tr>
<td>isFixed</td>
<td>Boolean</td>
<td>Describes if sidenav is fixed.</td>
</tr>
<tr>
<td>isDragged</td>
<td>Boolean</td>
<td>Describes if Sidenav is being dragged.</td>
</tr>
</tbody>
</table>
</div>
<div id="close-trigger" class="section scrollspy">
<h3 class="header">Close Trigger</h3>
<p>Add the class
<code class="language-html">.sidenav-close</code> to an element inside the sidenav and any click event on that element will cause the sidenav to close. This is
useful in Single Page Apps where the page does not refresh on link clicks.</p>
<pre><code class="language-html">
<xmp>
<ul id="slide-out" class="sidenav">
<li><a class="sidenav-close" href="#!">Clicking this will close Sidenav</a></li>
</ul>
<a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
</xmp>
</code></pre>
</div>
<div id="variations" class="scrollspy section">
<h3 class="header">Variations</h3>
<p class="caption">
Here are some useful variations and additional elements you can add to your sidebar.
</p>
<h4>Dropdown HTML Structure</h4>
<p>Add collapsible menus to your sidebar.</p>
<pre><code class="language-html">
<xmp>
<ul id="slide-out" class="sidenav">
<li><a href="#!">First Sidebar Link</a></li>
<li><a href="#!">Second Sidebar Link</a></li>
<li class="no-padding">
<ul class="collapsible collapsible-accordion">
<li>
<a class="collapsible-header">Dropdown<i class="material-icons">arrow_drop_down</i></a>
<div class="collapsible-body">
<ul>
<li><a href="#!">First</a></li>
<li><a href="#!">Second</a></li>
<li><a href="#!">Third</a></li>
<li><a href="#!">Fourth</a></li>
</ul>
</div>
</li>
</ul>
</li>
</ul>
<ul class="right hide-on-med-and-down">
<li><a href="#!">First Sidebar Link</a></li>
<li><a href="#!">Second Sidebar Link</a></li>
<li><a class="dropdown-trigger" href="#!" data-target="dropdown1">Dropdown<i class="material-icons right">arrow_drop_down</i></a></li>
<ul id='dropdown1' class='dropdown-content'>
<li><a href="#!">First</a></li>
<li><a href="#!">Second</a></li>
<li><a href="#!">Third</a></li>
<li><a href="#!">Fourth</a></li>
</ul>
</ul>
<a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
</xmp>
</code></pre>
Fullscreen HTML Structure</h4>
<p>If you want the menu to be accessible on all screensizes you just have to add a simple helper class
<code class="language-html">show-on-large</code> to the
<code class="language-html">.sidenav-trigger</code>. </p>
<pre><code class="language-html">
<xmp>
<ul id="slide-out" class="sidenav">
<li><a href="#!">First Sidebar Link</a></li>
<li><a href="#!">Second Sidebar Link</a></li>
</ul>
<a href="#" data-target="slide-out" class="sidenav-trigger show-on-large"><i class="material-icons">menu</i></a>
</xmp>
</code></pre>
Fixed HTML Structure</h4>
<p>Add the class
<code class="language-html">sidenav-fixed</code> to have the sidenav be fixed and open on large screens and hides to the regular functionality on smaller screens.
Our sidenav on the left is an example of this.</p>
<pre><code class="language-html">
<xmp>
<ul id="slide-out" class="sidenav sidenav-fixed">
<li><a href="#!">First Sidebar Link</a></li>
<li><a href="#!">Second Sidebar Link</a></li>
</ul>
<a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
</xmp>
</code></pre>
<p>If you are planning on using this you will have to offset your content by the width of the side menu. Place the padding
on where the offset content will be, which in our case is in header, main and footer.</p>
<pre><code class="language-css col s12">
header, main, footer {
padding-left: 300px;
}
@media only screen and (max-width : 992px) {
header, main, footer {
padding-left: 0;
}
}
</code></pre>
</div>
</div>
<!-- Table of Contents -->
<div class="col hide-on-small-only m3 xl3">
<div class="toc-wrapper">
<div style="height: 1px;">
<ul class="section table-of-contents">
<li>
<a href="#structure">Structure</a>
</li>
<li>
<a href="#initialization">Initialization</a>
</li>
<li>
<a href="#options">Options</a>
</li>
<li>
<a href="#methods">Methods</a>
</li>
<li>
<a href="#properties">Properties</a>
</li>
<li>
<a href="#close-trigger">Close Trigger</a>
</li>
<li>
<a href="#variations">Variations</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</main>
{{> footer }}
<script type="module" src="/src/main.ts"></script>
</body>
</html>