-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.html
477 lines (400 loc) · 21.4 KB
/
index.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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
<!DOCTYPE html>
<html lang="en" class="antialiased">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Tailwind Starter Template - Multi Section Form / Scrollspy: Tailwind Toolbox</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@2.2.19/dist/tailwind.min.css"/>
<link href="https://unpkg.com/@tailwindcss/custom-forms/dist/custom-forms.min.css" rel="stylesheet">
<!--Replace with your tailwind.css once created-->
<style>
.max-h-64 {
max-height: 16rem;
}
/*Quick overrides of the form input as using the CDN version*/
.form-input,
.form-textarea,
.form-select,
.form-multiselect {
background-color: #edf2f7;
}
</style>
</head>
<body class="bg-gray-100 text-gray-900 tracking-wider leading-normal">
<nav id="header" class="bg-white fixed w-full z-10 top-0 shadow">
<div class="w-full container mx-auto flex flex-wrap items-center justify-between my-4">
<div class="pl-4 md:pl-0">
<a class="flex items-center text-yellow-600 text-base xl:text-xl no-underline hover:no-underline font-extrabold font-sans" href="#">
<svg class="fill-current h-6 inline-block text-yellow-600 mr-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path d="M16 2h4v15a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V0h16v2zm0 2v13a1 1 0 0 0 1 1 1 1 0 0 0 1-1V4h-2zM2 2v15a1 1 0 0 0 1 1h11.17a2.98 2.98 0 0 1-.17-1V2H2zm2 8h8v2H4v-2zm0 4h8v2H4v-2zM4 4h8v4H4V4z" />
</svg> Multi Section Form / Scrollspy
</a>
</div>
<div class="pr-0 flex justify-end">
<div class="flex relative inline-block float-right">
<div class="relative text-sm">
<button id="userButton" class="flex items-center mr-3 shadow bg-yellow-700 hover:bg-yellow-500 focus:shadow-outline focus:outline-none text-white text-sm md:text-base font-bold py-2 px-4 rounded">
Menu
<svg class="pl-2 h-2 fill-current text-white" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 129 129" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 129 129">
<g>
<path d="m121.3,34.6c-1.6-1.6-4.2-1.6-5.8,0l-51,51.1-51.1-51.1c-1.6-1.6-4.2-1.6-5.8,0-1.6,1.6-1.6,4.2 0,5.8l53.9,53.9c0.8,0.8 1.8,1.2 2.9,1.2 1,0 2.1-0.4 2.9-1.2l53.9-53.9c1.7-1.6 1.7-4.2 0.1-5.8z" />
</g>
</svg>
</button>
<div id="userMenu" class="bg-white rounded shadow-md mt-2 mr-2 absolute mt-12 top-0 right-0 min-w-full overflow-auto z-30 invisible">
<ul class="list-reset">
<li><a href="#" class="px-4 py-2 block hover:bg-gray-400 no-underline hover:no-underline">My account</a></li>
<li><a href="#" class="px-4 py-2 block hover:bg-gray-400 no-underline hover:no-underline">Notifications</a></li>
<li>
<hr class="border-t mx-2 border-gray-400">
</li>
<li><a href="#" class="px-4 py-2 block text-yellow-600 font-bold hover:bg-yellow-600 hover:text-white no-underline hover:no-underline">Logout</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</nav>
<!--Container-->
<div class="container w-full flex flex-wrap mx-auto px-2 pt-8 lg:pt-16 mt-16">
<div class="w-full lg:w-1/5 px-6 text-xl text-gray-800 leading-normal">
<p class="text-base font-bold py-2 lg:pb-6 text-gray-700">Menu</p>
<div class="block lg:hidden sticky inset-0">
<button id="menu-toggle" class="flex w-full justify-end px-3 py-3 bg-white lg:bg-transparent border rounded border-gray-600 hover:border-yellow-600 appearance-none focus:outline-none">
<svg class="fill-current h-3 float-right" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" />
</svg>
</button>
</div>
<div class="w-full sticky inset-0 hidden max-h-64 lg:h-auto overflow-x-hidden overflow-y-auto lg:overflow-y-hidden lg:block mt-0 my-2 lg:my-0 border border-gray-400 lg:border-transparent bg-white shadow lg:shadow-none lg:bg-transparent z-20" style="top:6em;" id="menu-content">
<ul class="list-reset py-2 md:py-0">
<li class="py-1 md:my-2 hover:bg-yellow-100 lg:hover:bg-transparent border-l-4 border-transparent font-bold border-yellow-600">
<a href='#section1' class="block pl-4 align-middle text-gray-700 no-underline hover:text-yellow-600">
<span class="pb-1 md:pb-0 text-sm">Section 1</span>
</a>
</li>
<li class="py-1 md:my-2 hover:bg-yellow-100 lg:hover:bg-transparent border-l-4 border-transparent">
<a href='#section2' class="block pl-4 align-middle text-gray-700 no-underline hover:text-yellow-600">
<span class="pb-1 md:pb-0 text-sm">Section 2</span>
</a>
</li>
<li class="py-1 md:my-2 hover:bg-yellow-100 lg:hover:bg-transparent border-l-4 border-transparent">
<a href='#section3' class="block pl-4 align-middle text-gray-700 no-underline hover:text-yellow-600">
<span class="pb-1 md:pb-0 text-sm">Section 3</span>
</a>
</li>
<li class="py-1 md:my-2 hover:bg-yellow-100 lg:hover:bg-transparent border-l-4 border-transparent">
<a href='#section4' class="block pl-4 align-middle text-gray-700 no-underline hover:text-yellow-600">
<span class="pb-1 md:pb-0 text-sm">Section 4</span>
</a>
</li>
<li class="py-1 md:my-2 hover:bg-yellow-100 lg:hover:bg-transparent border-l-4 border-transparent">
<a href='#section5' class="block pl-4 align-middle text-gray-700 no-underline hover:text-yellow-600">
<span class="pb-1 md:pb-0 text-sm">Section 5</span>
</a>
</li>
</ul>
</div>
</div>
<!--Section container-->
<section class="w-full lg:w-4/5">
<!--Title-->
<h1 class="flex items-center font-sans font-bold break-normal text-gray-700 px-2 text-xl mt-12 lg:mt-0 md:text-2xl">
Multi Section Form with Scrollspy
</h1>
<!--divider-->
<hr class="bg-gray-300 my-12">
<!--Title-->
<h2 id='section1' class="font-sans font-bold break-normal text-gray-700 px-2 pb-8 text-xl">Section 1</h2>
<!--Card-->
<div class="p-8 mt-6 lg:mt-0 leading-normal rounded shadow bg-white">
<li>Using the CDN version of <a class="underline text-yellow-600" href="https://github.com/tailwindcss/custom-forms" target="_blank">Tailwind Custom Forms</a></li>
<li>This template uses jQuery for scrollspy</li>
</div>
<!--/Card-->
<!--divider-->
<hr class="bg-gray-300 my-12">
<!--Title-->
<h2 class="font-sans font-bold break-normal text-gray-700 px-2 pb-8 text-xl">Section 2</h2>
<!--Card-->
<div id='section2' class="p-8 mt-6 lg:mt-0 rounded shadow bg-white">
<form>
<div class="md:flex mb-6">
<div class="md:w-1/3">
<label class="block text-gray-600 font-bold md:text-left mb-3 md:mb-0 pr-4" for="my-textfield">
Text Field
</label>
</div>
<div class="md:w-2/3">
<input class="form-input block w-full focus:bg-white" id="my-textfield" type="text" value="">
<p class="py-2 text-sm text-gray-600">add notes about populating the field</p>
</div>
</div>
<div class="md:flex mb-6">
<div class="md:w-1/3">
<label class="block text-gray-600 font-bold md:text-left mb-3 md:mb-0 pr-4" for="my-select">
Drop down field
</label>
</div>
<div class="md:w-2/3">
<select name="" class="form-select block w-full focus:bg-white" id="my-select">
<option value="Default">Default</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<p class="py-2 text-sm text-gray-600">add notes about populating the field</p>
</div>
</div>
<div class="md:flex mb-6">
<div class="md:w-1/3">
<label class="block text-gray-600 font-bold md:text-left mb-3 md:mb-0 pr-4" for="my-textarea">
Text Area
</label>
</div>
<div class="md:w-2/3">
<textarea class="form-textarea block w-full focus:bg-white" id="my-textarea" value="" rows="8"></textarea>
<p class="py-2 text-sm text-gray-600">add notes about populating the field</p>
</div>
</div>
<div class="md:flex md:items-center">
<div class="md:w-1/3"></div>
<div class="md:w-2/3">
<button class="shadow bg-yellow-700 hover:bg-yellow-500 focus:shadow-outline focus:outline-none text-white font-bold py-2 px-4 rounded" type="button">
Save
</button>
</div>
</div>
</form>
</div>
<!--/Card-->
<!--divider-->
<hr class="bg-gray-300 my-12">
<!--Title-->
<h2 class="font-sans font-bold break-normal text-gray-700 px-2 pb-8 text-xl">Section 3</h2>
<!--Card-->
<div id='section3' class="p-8 mt-6 lg:mt-0 rounded shadow bg-white">
<form>
<div class="md:flex mb-6">
<div class="md:w-1/3">
<label class="block text-gray-600 font-bold md:text-left mb-3 md:mb-0 pr-4" for="my-multiselect">
Multi Select
</label>
</div>
<div class="md:w-2/3">
<select class="form-multiselect block w-full" multiple id="my-multiselect">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<option>Option 4</option>
<option>Option 5</option>
</select>
<p class="py-2 text-sm text-gray-600">add notes about populating the field</p>
</div>
</div>
<div class="md:flex md:items-center">
<div class="md:w-1/3"></div>
<div class="md:w-2/3">
<button class="shadow bg-yellow-700 hover:bg-yellow-500 focus:shadow-outline focus:outline-none text-white font-bold py-2 px-4 rounded" type="button">
Save
</button>
</div>
</div>
</form>
</div>
<!--/Card-->
<!--divider-->
<hr class="bg-gray-300 my-12">
<!--Title-->
<h2 class="font-sans font-bold break-normal text-gray-700 px-2 pb-8 text-xl">Section 4</h2>
<!--Card-->
<div id='section4' class="p-8 mt-6 lg:mt-0 rounded shadow bg-white">
<form>
<div class="md:flex mb-6">
<div class="md:w-1/3">
<label class="block text-gray-600 font-bold md:text-left mb-3 md:mb-0 pr-4" for="my-radio">
Radio Buttons
</label>
</div>
<div class="md:w-2/3">
<div class="mt-2">
<label class="inline-flex items-center">
<input type="radio" class="form-radio text-indigo-600" name="radioOption" value="A">
<span class="ml-2">Radio A</span>
</label>
<label class="inline-flex items-center ml-6">
<input type="radio" class="form-radio" name="radioOption" value="B">
<span class="ml-2">Radio B</span>
</label>
</div>
<p class="py-2 text-sm text-gray-600">add notes about populating the field</p>
</div>
</div>
<div class="md:flex mb-6">
<div class="md:w-1/3">
<label class="block text-gray-600 font-bold md:text-left mb-3 md:mb-0 pr-4" for="my-checkbox">
Checkboxes
</label>
</div>
<div class="md:w-2/3">
<div>
<label class="inline-flex items-center">
<input type="checkbox" class="form-checkbox text-indigo-600" checked>
<span class="ml-2">Option 1</span>
</label>
</div>
<div>
<label class="inline-flex items-center">
<input type="checkbox" class="form-checkbox text-green-500" checked>
<span class="ml-2">Option 2</span>
</label>
</div>
<div>
<label class="inline-flex items-center">
<input type="checkbox" class="form-checkbox text-pink-600" checked>
<span class="ml-2">Option 3</span>
</label>
</div>
<p class="py-2 text-sm text-gray-600">add notes about populating the field</p>
</div>
</div>
<div class="md:flex md:items-center">
<div class="md:w-1/3"></div>
<div class="md:w-2/3">
<button class="shadow bg-yellow-700 hover:bg-yellow-500 focus:shadow-outline focus:outline-none text-white font-bold py-2 px-4 rounded" type="button">
Save
</button>
</div>
</div>
</form>
</div>
<!--/Card-->
<!--divider-->
<hr class="bg-gray-300 my-12">
<!--Title-->
<h2 class="font-sans font-bold break-normal text-gray-700 px-2 pb-8 text-xl">Section 5</h2>
<!--Card-->
<div id='section5' class="p-8 mt-6 lg:mt-0 rounded shadow bg-white">
<blockquote class="border-l-4 border-yellow-600 italic my-4 pl-8 md:pl-12">Final confirmation disclaimer message etc</blockquote>
<div class="pt-8">
<button class="shadow bg-yellow-700 hover:bg-yellow-500 focus:shadow-outline focus:outline-none text-white font-bold py-2 px-4 rounded mr-4" type="button">
Save
</button>
<button class="shadow bg-yellow-100 hover:bg-yellow-200 focus:shadow-outline focus:outline-none text-gray-700 font-bold py-2 px-4 rounded mr-4" type="button">
Additional Action
</button>
<button class="shadow bg-yellow-100 hover:bg-yellow-200 focus:shadow-outline focus:outline-none text-gray-700 font-bold py-2 px-4 rounded" type="button">
Additional Action
</button>
</div>
</div>
<!--/Card-->
</section>
<!--/Section container-->
<!--Back link -->
<div class="w-full lg:w-4/5 lg:ml-auto text-base md:text-sm text-gray-600 px-4 py-24 mb-12">
<span class="text-base text-yellow-600 font-bold"><</span> <a href="#" class="text-base md:text-sm text-yellow-600 font-bold no-underline hover:underline">Back link</a>
</div>
</div>
<!--/container-->
<!-- Toggle dropdown list -->
<script>
/*https://gist.github.com/slavapas/593e8e50cf4cc16ac972afcbad4f70c8*/
var userMenuDiv = document.getElementById("userMenu");
var userMenu = document.getElementById("userButton");
var helpMenuDiv = document.getElementById("menu-content");
var helpMenu = document.getElementById("menu-toggle");
document.onclick = check;
function check(e){
var target = (e && e.target) || (event && event.srcElement);
//User Menu
if (!checkParent(target, userMenuDiv)) {
// click NOT on the menu
if (checkParent(target, userMenu)) {
// click on the link
if (userMenuDiv.classList.contains("invisible")) {
userMenuDiv.classList.remove("invisible");
} else {userMenuDiv.classList.add("invisible");}
} else {
// click both outside link and outside menu, hide menu
userMenuDiv.classList.add("invisible");
}
}
//Help Menu
if (!checkParent(target, helpMenuDiv)) {
// click NOT on the menu
if (checkParent(target, helpMenu)) {
// click on the link
if (helpMenuDiv.classList.contains("hidden")) {
helpMenuDiv.classList.remove("hidden");
} else {helpMenuDiv.classList.add("hidden");}
} else {
// click both outside link and outside menu, hide menu
helpMenuDiv.classList.add("hidden");
}
}
}
function checkParent(t, elm) {
while(t.parentNode) {
if( t == elm ) {return true;}
t = t.parentNode;
}
return false;
}
</script>
<!-- jQuery -->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<!-- Scroll Spy -->
<script>
/* http://jsfiddle.net/LwLBx/ */
// Cache selectors
var lastId,
topMenu = $("#menu-content"),
topMenuHeight = topMenu.outerHeight()+175,
// All list items
menuItems = topMenu.find("a"),
// Anchors corresponding to menu items
scrollItems = menuItems.map(function(){
var item = $($(this).attr("href"));
if (item.length) { return item; }
});
// Bind click handler to menu items
// so we can get a fancy scroll animation
menuItems.click(function(e){
var href = $(this).attr("href"),
offsetTop = href === "#" ? 0 : $(href).offset().top-topMenuHeight+1;
$('html, body').stop().animate({
scrollTop: offsetTop
}, 300);
if (!helpMenuDiv.classList.contains("hidden")) {
helpMenuDiv.classList.add("hidden");
}
e.preventDefault();
});
// Bind to scroll
$(window).scroll(function(){
// Get container scroll position
var fromTop = $(this).scrollTop()+topMenuHeight;
// Get id of current scroll item
var cur = scrollItems.map(function(){
if ($(this).offset().top < fromTop)
return this;
});
// Get the id of the current element
cur = cur[cur.length-1];
var id = cur && cur.length ? cur[0].id : "";
if (lastId !== id) {
lastId = id;
// Set/remove active class
menuItems
.parent().removeClass("font-bold border-yellow-600")
.end().filter("[href='#"+id+"']").parent().addClass("font-bold border-yellow-600");
}
});
</script>
</body>
</html>