-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.html
948 lines (809 loc) · 38.1 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
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JS-SnackBar - A simple snackbar/toast tool</title>
<meta name="description"
content="JS-SnackBar is a simple, jQuery-free tool that enables a notification to be shown on screen, follow Google's Material UI design.">
<meta name="author" content="Michael Mickelson">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="dist/js-snackbar.css?v=1.4" />
<link rel="stylesheet" href="site.css?v=1.2" />
</head>
<body>
<header class="header">
<button id="header-button" type="menu" class="button button--inverse nav-opener">
<span class="material-icons">menu</span>
Menu
</button>
<h1>JS-Snackbar</h1>
</header>
<div class="main-body">
<nav id="nav" class="nav">
<div id="title" class="nav-title">
JS-Snackbar
<button type="menu" class="nav-opener nav-close">
<span class="material-icons">close</span>
</button>
</div>
<ul class="nav-ul">
<li class="nav-li">
<a href="#message" class="nav-a">Content</a>
</li>
<li class="nav-li">
<a href="#width" class="nav-a">Width</a>
</li>
<li class="nav-li">
<a href="#Colors" class="nav-a">
Context Colors
</a>
</li>
<li class="nav-li">
<a href="#icons" class="nav-a">
Icons
</a>
</li>
<li class="nav-li">
<a href="#Timeout" class="nav-a">
Timeout
</a>
</li>
<li class="nav-li">
<a href="#speed" class="nav-a">
Animation Speed
</a>
</li>
<li class="nav-li">
<a href="#Positioning" class="nav-a">
Positioning
</a>
</li>
<li class="nav-li">
<a href="#Fixed" class="nav-a">
Fixed Position
</a>
</li>
<li class="nav-li">
<a href="#Actions" class="nav-a">
Actions
</a>
</li>
<li class="nav-li">
<a href="#Containers" class="nav-a">
Containers
</a>
</li>
<li class="nav-li">
<a href="#tryit" class="nav-a">
Try it Yourself
</a>
</li>
</ul>
<p class="nav-footer">
Created by <a href="https://github.com/mickelsonmichael" target="_blank">Michael Mickelson</a>
<br />
<a href="https://github.com/mickelsonmichael/js-snackbar/blob/master/LICENSE" target="_blank">MIT
License</a>
</p>
</nav>
<section class="content">
<div class="display">
<span>JS-Snackbar</span>
</div>
<article class="section">
<h2 class="section-title">What is a Snackbar?</h2>
<p>
According to <a href="https://material.io/design/components/snackbars.html">Material Design</a> a
Snackbar or Toast provides "brief messages about app processes at the bottom of the screen."
</p>
<p>
Generally, they should not have an icon associated with it and should be only one line on most
devices.
</p>
<p>
While this version of a Snackbar follows the Material Design semantics closely, it strays in several
major ways.
You can read more about those differences on the <a href="https://github.com/mickelsonmichael/js-snackbar" target="_blank">GitHub</a> page.
</p>
</article>
<article id="message" class="section">
<h2 class="section-title">Message Content</h2>
<p>
The most basic option, and probably the one that will be used with every SnackBar.
By default, the snackbar will display the message <code>"Operation performed successfully"</code>.
Messages should be short and descriptive;
If your message expands to a second line, it is probably too long.
</p>
<code block>SnackBar({
message: "Hi there"
})</code>
<button type=button class="button" onclick="demoContent();">Send Ping</button>
<p>
The message can be any HTML string, but it is best to keep the HTML simple, using tags like
<code><em></code> and <code><strong></code> to provide emphasis. For links, you should utilize the
<a href="#Actions">actions</a> instead, to provide a pre-formatted link.
</p>
<code block>SnackBar({
message: "Do <em>NOT</em> do that again"
})</code>
<button type="button" class="button" onclick="demoHtml();">Don't Click Me</button>
<p>
<small>Don't listen to the button above, just click it</small>
</p>
<script>
var demoContent = function () {
var message = SnackBar({
message: "PONG"
});
}
var demoHtml = function() {
SnackBar({
message: "I told you <strong>not</strong> to click it"
})
}
</script>
</article>
<article id="width" class="section">
<h2 class="section-title">Fixed Width</h2>
<p>
The SnackBars will resize based on the content passed in to them.
However it may be desirable for them to have a fixed width,
which you can set using the <code>width</code> property on the options.
The width can be set to any valid CSS value for the width property.
</p>
<code block>SnackBar({
width: "1000px"
})</code>
<p>
<strong>
If you set your width too low, the snackbar will not display correctly.
</strong>
For example, setting a width of <code>1rem</code> is far
too small for any text to fit within, and the text will
collapse fully and be hidden.
The width must, at minimum, fit a whole word for the
SnackBar to be displayed correct.
Use this feature with caution.
</p>
<p>
<button onclick="width_500px()" class="button">500px</button>
<button onclick="width_100vw()" class="button">100vw</button>
<button onclick="width_30rem()" class="button">30rem</button>
</p>
<script>
var width_500px = function() {
SnackBar({
width: "500px",
message: "I'm 500px wide"
})
}
var width_100vw = function() {
SnackBar({
width: "100vw",
message: "I'm the width of the viewport",
})
}
var width_30rem = function() {
SnackBar({
width: "30rem",
message: "I'm 30 rem"
})
}
</script>
</article>
<article id="Colors" class="section">
<h2 class="section-title">Context Colors</h2>
<p>
By default, there are several color options for showing notifications.
When a notification is displayed, it can either have one of these context colors attached to it, or no indicator at all (the default behavior). Click one of the buttons below to view an example.
</p>
<code block>Snackbar({
status: "success"
})</code>
<button type="button" class="button" onclick="colors_Default();">Default</button>
<button type="button" class="button" onclick="colors_Success();">Success</button>
<button type="button" class="button" onclick="colors_Error();">Error</button>
<button type="button" class="button" onclick="colors_Warning();">Warning</button>
<button type="button" class="button" onclick="colors_Info();">Info</button>
<p>
The possible options can be found in the table below
</p>
<table>
<thead>
<tr>
<td>Color</td>
<td>Indicates</td>
<td>Value(s)</td>
<td>Example</td>
</tr>
</thead>
<tbody>
<tr>
<td>None</td>
<td>None</td>
<td>
<code>undefined</code>,
<code>null</code>,
<code>""</code>
</td>
<td>
<span class="js-snackbar js-snackbar--show">
<span class="js-snackbar__status"></span>
<div class="js-snackbar__message-wrapper">
<span class="js-snackbar__message demo-message">Default</span>
</div>
</span>
</td>
</tr>
<tr>
<td>Green</td>
<td>Success</td>
<td>
<code>"green"</code>,
<code>"success"</code>
</td>
<td>
<span class="js-snackbar js-snackbar--show">
<span class="js-snackbar__status js-snackbar--success"></span>
<div class="js-snackbar__message-wrapper">
<span class="js-snackbar__message demo-message">Success</span>
</div>
</span>
</td>
</tr>
<tr>
<td>Orange</td>
<td>Warning</td>
<td>
<code>"warning"</code>,
<code>"alert"</code>,
<code>"orange"</code>
</td>
<td>
<span class="js-snackbar js-snackbar--show">
<span class="js-snackbar__status js-snackbar--warning"></span>
<div class="js-snackbar__message-wrapper">
<span class="js-snackbar__message demo-message">Warning</span>
</div>
</span>
</td>
</tr>
<tr>
<td>Red</td>
<td>Danger</td>
<td>
<code>"danger"</code>,
<code>"error"</code>,
<code>"red"</code>
</td>
<td>
<span class="js-snackbar js-snackbar--show">
<span class="js-snackbar__status js-snackbar--danger"></span>
<div class="js-snackbar__message-wrapper">
<span class="js-snackbar__message demo-message">Danger</span>
</div>
</span>
</td>
</tr>
<tr>
<td>Blue</td>
<td>Info</td>
<td>
<code>"info"</code> or any other string
</td>
<td>
<span class="js-snackbar js-snackbar--show">
<span class="js-snackbar__status js-snackbar--info"></span>
<div class="js-snackbar__message-wrapper">
<span class="js-snackbar__message demo-message">Info</span>
</div>
</span>
</td>
</tr>
</tbody>
</table>
<script>
var colors_Default = function () {
SnackBar({
message: "Hello World!"
})
};
var colors_Success = function () {
SnackBar({
message: "Snackbar created successfully!",
status: "success"
});
};
var colors_Error = function () {
SnackBar({
message: "Could not do the thing!",
status: "danger"
})
}
var colors_Warning = function () {
SnackBar({
message: "Alert! Something is happening that you may not expect!",
status: "warning"
})
}
var colors_Info = function () {
SnackBar({
message: "Here's some information for you",
status: "info"
})
}
</script>
</article>
<article id="icons" class="section">
<h2 class="section-title">Icons</h2>
<p>
Icons can add additional flair to your messages, so the SnackBar comes with several built-in.
These icons are simply monospace text, and so can also be customized to any single character.
Keep in mind, however, that monospaces characters are serif fonts in all modern browsers.
If you are looking for more customization, then you'll need to roll some custom CSS to
target the icons.
</p>
<code block>Snackbar({
status: "success",
icon: "plus"
})</code>
<p class="alert">
While the icons and the colors can be mixed and matched, the icons
<strong>require a <a href="#Colors">status color</a> to be set</strong> in order to appear.
</p>
<table>
<thead>
<tr>
<td>Icon</td>
<td>Value(s)</td>
<td>Example</td>
</tr>
</thead>
<tbody>
<tr>
<td>!</td>
<td>
<code>"exclamation"</code>,
<code>"warn"</code>,
<code>"danger"</code>
</td>
<td>
<span class="js-snackbar js-snackbar--show">
<span class="js-snackbar__status js-snackbar--danger">
<span class="js-snackbar__icon">!</span>
</span>
<div class="js-snackbar__message-wrapper">
<span class="js-snackbar__message demo-message">Exclamation</span>
</div>
</span>
</td>
</tr>
<tr>
<td>?</td>
<td>
<code>"question"</code>,
<code>"question-mark"</code>,
<code>"info"</code>
</td>
<td>
<span class="js-snackbar js-snackbar--show">
<span class="js-snackbar__status js-snackbar--warning">
<span class="js-snackbar__icon">?</span>
</span>
<div class="js-snackbar__message-wrapper">
<span class="js-snackbar__message demo-message">Question</span>
</div>
</span>
</td>
</tr>
<tr>
<td>+</td>
<td>
<code>"add"</code>,
<code>"plus"</code>
</td>
<td>
<span class="js-snackbar js-snackbar--show">
<span class="js-snackbar__status js-snackbar--success">
<span class="js-snackbar__icon">+</span>
</span>
<div class="js-snackbar__message-wrapper">
<span class="js-snackbar__message demo-message">Plus</span>
</div>
</span>
</td>
</tr>
<tr>
<td>Custom</td>
<td>
Any character
</td>
<td>
<span class="js-snackbar js-snackbar--show">
<span class="js-snackbar__status js-snackbar--info">
<span class="js-snackbar__icon">R</span>
</span>
<div class="js-snackbar__message-wrapper">
<span class="js-snackbar__message demo-message">Custom</span>
</div>
</span>
</td>
</tr>
</tbody>
</table>
<button class="button" onclick="icons_exclamation()">!</button>
<button class="button" onclick="icons_question()">?</button>
<button class="button" onclick="icons_add()">+</button>
<button class="button" onclick="icons_any()">Custom</button>
<script>
var icons_exclamation = function() {
SnackBar({
message: "How exciting",
icon: "exclamation",
status: "danger",
})
}
var icons_question = function() {
SnackBar({
message: "That's questionable",
icon: "question",
status: "warn"
});
}
var icons_add = function() {
SnackBar({
message: "You've added it successfully",
icon: "add",
status: "success"
})
}
var icons_any = function() {
SnackBar({
message: "My name is Mike",
icon: "M",
status: "info"
})
}
</script>
</article>
<article id="Timeout" class="section">
<h2 class="section-title">Timeout Options</h2>
<p>
A snackbar can be configured to stay on screen for a certain amount of time.
For warnings or messages with actions, it is best to increase this time.
<strong>In general, the timeout should be no shorter than 4 seconds long.</strong>
</p>
<code block>SnackBar({
timeout: 5000 // ms
})</code>
<p>
Additionally, a SnackBar can also be configured to hide its close button.
This is useful in scenarios where a message is particularly important, or where the message has a custom close
<a href="#Actions">action</a>.
</p>
<code block>SnackBar({
dismissible: false
})</code>
<p>
If you don't want to the SnackBar to timeout and instead want the user to manually intervene,
you can set the timeout to any value less than 1 or false
</p>
<code block>SnackBar({
timeout: 0 // less than or equal to 0
})
// OR
SnackBar({
timeout: false
})</code>
<button type="button" class="button" onclick="demoTimeout();">Timeout Duration</button>
<button type="button" class="button" onclick="demoNoTimeout();">No Timeout</button>
<button type="button" class="button" onclick="demoNoDissmiss();">Undismissible</button>
<script>
var demoTimeout = function () {
SnackBar({
message: "I hang out for a little longer",
timeout: 25000
})
}
var demoNoTimeout = function () {
SnackBar({
message: "You need to manually send me away",
timeout: false
})
}
var demoNoDissmiss = function () {
SnackBar({
message: "You cannot send me away!",
dismissible: false
})
}
</script>
</article>
<article id="speed" class="section">
<h2 class="section-title">Animation Speed</h2>
<p>
You may want the SnackBar to come on screen quicker or slower.
To that end, you can specify the <code>speed</code> property to set the <code>transition-duration</code>
for the element.
</p>
<p>
If you send in a <code>number</code>, then it will be applied as milliseconds (e.g. <code>500</code> will become <code>"500ms"</code>).
If you send in a <code>string</code>, then it will be applied directly to the property with no modifications, making the valid
options any valid CSS property for the <code>transformation-duration</code> property.
Sending in any other type of value will result in no change to the animation duration.
</p>
<code block>
SnackBar({
speed: "0.5s"
});
// OR
SnackBar({
speed: 500
});
</code>
<button class="button" onclick="demoSpeed(1000)">1000ms</button>
<button class="button" onclick="demoSpeed(250)">250ms</button>
<script>
var demoSpeed = function (s) {
SnackBar({
message: "I take " + s + "ms to show and hide",
speed: s
});
}
</script>
</article>
<article id="Positioning" class="section">
<h2 class="section-title">Positioning</h2>
<p>
By default, the Snackbar will appear in the bottom-right corner of the container.
This can be changed by setting the <code>position</code> option to one of the values below
</p>
<table>
<thead>
<tr>
<th>Value</th>
<th>Position</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"tl"</code></td>
<td>Top-Left</td>
</tr>
<tr>
<td><code>"tc"</code> or <code>"tm"</code></td>
<td>Top-Center</td>
</tr>
<tr>
<td><code>"tr"</code></td>
<td>Top-Right</td>
</tr>
<tr>
<td><code>"bl"</code></td>
<td>Bottom-Left</td>
</tr>
<tr>
<td><code>"bc"</code> or <code>"bm"</code></td>
<td>Bottom-Center</td>
</tr>
<tr>
<td><code>"br"</code></td>
<td>Bottom-Right</td>
</tr>
</tbody>
</table>
<p>
SnackBars can appear in multiple positions simultaneously without interfering with one another,
but it is best to avoid changing the position of your SnackBar.
</p>
<code block>SnackBar({
position: "br"
});</code>
<button class="button" onclick="demoPosition('tl');">Top-Left</button>
<button class="button" onclick="demoPosition('tc')">Top-Center</button>
<button class="button" onclick="demoPosition('tr');">Top-Right</button>
<button class="button" onclick="demoPosition('bl');">Bottom-Left</button>
<button class="button" onclick="demoPosition('bc')">Bottom-Center</button>
<button class="button" onclick="demoPosition('br');">Bottom-Right</button>
<script>
var demoPosition = function(pos) {
var snack = SnackBar({
position: pos,
message: "I should be in the '" + pos + "' position!"
});
}
</script>
</article>
<article id="Fixed" class="section">
<h2 class="section-title">Fixed Positioning</h2>
<p>
If your page's body scrolls as the page resizes, it may be necessary to use the <code>fixed</code> option.
By default the SnackBars have absolute positioning and will stay within the container they are created in, but setting <code>fixed: true</code> will keep them in the corner of the screen.
</p>
<code block>SnackBar({
fixed: true
})</code>
<button type=button class="button" onclick="demoFixed();">Fixed Position</button>
<script>
var demoFixed = function() {
var message = SnackBar({
fixed: true
});
}
</script>
</article>
<article id="Actions" class="section">
<h2 class="section-title">Actions</h2>
<p>
Buttons can be added to SnackBars to allow for additional actions.
This can be useful in scenarios where a snackbar may warrant additional user interaction (ie an undo button).
Actions can also be configured to close the snackbar.
</p>
<button type="button" class="button" onclick="demoActions();">Basic Action</button>
<button type="button" class="button" onclick="demoClosing();">Closing Action</button>
<button type="button" class="button" onclick="demoActionsClosing();">Closing Action with Custom
Function</button>
<script>
var demoActions = function () {
var message = SnackBar({
message: "Click the button for an action",
timeout: 30000,
actions: [
{
text: "Click Me!",
function: function () {
alert("A-C-T-I-O-N");
}
}
]
})
}
var demoClosing = function () {
var message = SnackBar({
message: "Click the button to close",
timeout: 30000,
actions: [
{
text: "Close",
dismiss: true
}
]
})
}
var demoActionsClosing = function () {
var message = SnackBar({
message: "Click the button!",
timeout: 30000,
actions: [
{
text: "I close and act!",
dismiss: true,
function: function () {
alert("You've done an action and closed. The snackbar will disappear once you press OK");
}
}
]
})
}
</script>
</article>
<article id="Containers" class="section">
<h2 class="section-title">Containers</h2>
<p>
By default, the SnackBars will appear in the <code>body</code> tag.
However, in some layouts, it may be more desirable for them to appear within an inner container.
</p>
<p>
The <code>container</code> property can accept any string that the <code>document.querySelector</code> method can,
including classes and IDs. See <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector" target="_blank" rel="noreferrer" rel="noopener">MDN</a> for more details.
</p>
<p>
<em>Note: This requires the containing element to have a non-static position (e.g. <code>position: relative;</code>)</em>
</p>
<code block><div id="container"></div>
SnackBar({
message: "I'm inside this box",
container: "#container"
})
</code>
<button type="button" class="button" onclick="demoContainer();">Within the Box</button>
<div id="container" class="box"></div>
<script>
var demoContainer = function () {
SnackBar({
message: "I'm inside this box",
container: "#container"
})
}
</script>
</article>
<article id="tryit" class="section">
<h2 class="section-title">Try it Yourself!</h2>
<p>
Use this form to create your own custom Snackbar using the options above.
</p>
<form>
<div class="field">
<label>Message</label>
<input id=demo_text type=text value="Hello World!" />
</div>
<div class="field">
<label>Status</label>
<select id="demo_status">
<option value="" selected>Default</option>
<option value=error>Error</option>
<option value=success>Success</option>
<option value=warning>Warning</option>
<option value=info>Info</option>
</select>
</div>
<div class="field">
<label>Timeout</label>
<input id=demo_timeout type=number min=0 value=5000 />
</div>
<div class="field">
<label>Position</label>
<select id="demo_pos">
<option value="tl">Top-Left</option>
<option value="tc">Top-Center</option>
<option value="tr">Top-Right</option>
<option value="bl">Bottom-Left</option>
<option value="bc">Bottom-Center</option>
<option selected value="br">Bottom-Right (Default)</option>
</select>
</div>
<div class="field">
<label>Width</label>
<input id="demo_width" type="text" value="500px" />
</div>
<div class="field">
<label>Icon</label>
<select id="demo_icon">
<option value="danger">!</option>
<option value="info">?</option>
<option value="add">+</option>
<option selected value="">None</option>
</select>
<small>Status must be set in order for icon to appear</small>
</div>
<div class="field">
<label>Custom Icon</label>
<input type="text" maxlength="1" id="demo_icon_custom" />
<small>Custom icon will supersede the preset icons above</small>
</div>
<br />
<div class="field">
<label for=demo_dismiss>
<input type=checkbox id=demo_dismiss name=demo_dismiss checked />
Dismissible
</label>
</div>
<button type=button class="button" onclick="return demoCustom();">Snackbar!</button>
</form>
<script>
function demoCustom() {
var icon = document.getElementById("demo_icon_custom").value ?? "";
if (icon == "")
{
icon = document.getElementById("demo_icon").value ?? "";
}
SnackBar({
message: document.getElementById("demo_text").value,
dismissible: document.getElementById("demo_dismiss").checked,
status: document.getElementById("demo_status").value,
timeout: document.getElementById("demo_timeout").value,
position: document.getElementById("demo_pos").value,
width: document.getElementById("demo_width").value,
icon: icon
});
return false;
}
</script>
</article>
</section>
</div>
<script src="dist/js-snackbar.js?v=1.4"></script>
<script src="site.js?v=1.0.0"></script>
</body>
</html>