-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
990 lines (980 loc) · 52.9 KB
/
index.html
File metadata and controls
990 lines (980 loc) · 52.9 KB
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
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
<!DOCTYPE html>
<html class="pui-scroller">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WPUIE</title>
<style>
a {
text-decoration: none;
color: var(--pui-primary-hover);
}
a:hover {
text-decoration: underline;
color: var(--pui-primary-shadow);
}
</style>
<link href="./prism.css" rel="stylesheet">
<script src="./prism.js"></script>
<link href="./release/all.css" rel="stylesheet">
<style>
@font-face { font-family: dot_font; src: url(./fonts/DinkieBitmap-9pxDemo.woff2); }
@font-face { font-family: dot_font_code; src: url(./fonts/DinkieBitmap-9pxCodeDemo.woff2); }
@font-face { font-family: dot_font_italic; src: url(./fonts/DinkieBitmap-9pxItalicDemo.woff2); }
body {
font-family: dot_font_code, dot_font;
font-size: 1pc;
text-rendering: geometricPrecision;
-webkit-font-smoothing: antialiased;
background-color: #fff;
}
i, em { font-family: dot_font_italic; }
</style>
<style>
body {
display: flex;
padding: 0; margin: 0;
}
.sideBar {
position: sticky;
top: 0;
height: 100vh;
background-color: #eee;
padding: 2ex 2ch;
border-right: 1px #ccc solid;
box-sizing: border-box;
min-width: fit-content;
/* Golden ratio! */
width: 38.2%;
overflow: auto;
overflow: overlay;
display: grid;
}
.sideBar > nav {
float: right;
height: auto;
align-self: center;
justify-self: end;
}
.sideBar > nav h1 { font-size: 1.7em; margin: 0 0 1rem; }
.sideBar > nav > ul ul {
--padding-left: calc(4ch - 2px + 1pc);
margin-left: -1pc;
border-left: 2px #ddd dashed;
}
.octocat {
display: block;
text-decoration: none !important;
color: inherit !important;
text-align: end;
}
.octocat > .pui-balloon { display: inline-block; vertical-align: top; text-align: center; }
.octocat > .pui-octocat { --pixel-width: 6px; margin-top: 2em; }
main {
max-width: min(980px, 61.8%);
padding: 2ex 4ch;
}
main > section { margin-top: 2em; }
main > section > fieldset > legend { font-size: 1.2em; font-weight: bold; }
main > section > fieldset.pui { padding-bottom: 2.8em; }
#usage-bottons .items a, #usage-bottons .items button, #usage-bottons .items input {
margin-top: 2ex;
}
.items > table.shelf { margin: auto; }
.items > table.shelf td {
padding: 0;
white-space: nowrap;
}
.items > table.shelf td:first-child {
text-align: end;
}
#usage-radios .items td:not(:first-child) { border-bottom: 1px #ddd solid; }
#usage-checkboxes .items label { display: inline-block; }
#usage-input .items input { margin-top: 1ex; }
#usage-input .items td { word-break: keep-all; }
#usage-textarea .items textarea { margin-top: 1ex; }
#usage-selects .items select { margin-top: 1ex; }
#usage-containers .items fieldset {
display: inline-grid;
}
#usage-containers .items fieldset p {
margin: 0;
}
dialog { overscroll-behavior: contain; }
#usage-dialogs .items > section { margin-top: 1ex; }
#usage-details .items details.pui {
margin: 1ex;
display: inline-block;
}
#usage-tables .items > table {
display: inline-table;
vertical-align: middle;
margin-top: 1ex;
}
#usage-progress .items progress { margin-top: 1ex; }
#usage-balloons .items .pui-balloon { display: inline-block; }
#usage-balloons .items .stripe-bg { display: inline-block; padding: 10px; }
#usage-colored-border .pui-cb {
margin-top: 1ex;
}
#usage-background .items > .pui-bg { color:#fff; }
#usage-image-border .items > .pui-ib { margin-bottom: 1ex; }
#usage-scroll-bar .items > .pui-scroller {
width: 125px; height: 100px;
display: inline-block;
margin: 10px;
background-color: rgba(0, 136, 136, .25);
}
.stripe-bg {
background-image:
repeating-linear-gradient(-45deg, transparent 1.75px, rgba(128, 128, 128, .25) 2.25px 3.75px, transparent 4.25px 6px);
}
[id^=usage-] > fieldset, pre[class*=language-] { margin: 0; }
pre[class*=language-] { padding: 1ex 2ch; }
pre[class*=language-] > * {
font-family: dot_font_code;
}
[id^=usage-] > fieldset + * {
border: 4px #000 solid;
border-top: 0;
display: none;
}
.code-toolbar { position: relative; }
.code-toolbar > .toolbar {
position: absolute;
top: -4px; right: -4px;
}
[id^=usage-] .items {
overflow: auto hidden;
}
/* 微信内置浏览器在这里会抽风 故有此特例 */
#usage-containers .items { overflow: visible; }
[id^=usage-] > fieldset {
position: relative;
}
[id^=usage-] > fieldset > .toolbar {
position: absolute;
bottom: 0; right: 0;
border-bottom: 0; border-right: 0;
}
[id^=usage-] > fieldset > .toolbar > * {
border-bottom: 0;
margin-left: 1ch;
}
[id^=usage-] > fieldset > .toolbar > *:last-child { border-right: 0; }
footer { height: 6em; }
#back2top {
position: fixed;
bottom: 2em;
right: 2em;
width: 1em;
height: 1em;
text-align: center;
padding: .5em;
filter: drop-shadow(0 4px 20px #0007);
transition: all 0.3s ease;
}
#back2top:active { filter: drop-shadow(0 0); }
#showNav { display: none; }
@media (max-width: 768px) {
body {
display: block;
}
.sideBar {
z-index: 9;
width: fit-content;
min-width: 0;
max-width: 68.2%;
position: fixed;
transform: translateX(-100%);
opacity: 0;
transition: all 0.3s ease;
}
#showNav {
display: block;
position: fixed;
bottom: 5em; right: 2em;
width: 2.5em; height: 2.5em;
text-align: center;
line-height: 1em;
transition: all 0.3s ease;
}
#showNav:active { filter: drop-shadow(0 0); }
#showNav > * {
font-family: dot_font;
display: inline-block;
font-size: 1.5em;
transform: translate(-0.1em, -0.05em) rotateZ(-90deg);
}
#sideBarCover {
height: 100vh;
width: 100vw;
background-color: rgba(0, 0, 0, 0.25);
position: fixed;
top: 0;
left: 0;
display: block;
opacity: 0;
transition: all 0.3s ease;
pointer-events: none;
}
main {
max-width: 100vw;
}
}
@media (max-width: 480px) {
.sideBar > nav > ul { --padding-left: 3ch; }
.sideBar > nav > ul ul {
--padding-left: calc(2ch - 2px + 1pc);
margin-left: -1pc;
}
}
@media (max-width: 347px) {
.octocat > .pui-balloon { font-size: .7em; }
.octocat > .pui-octocat { --pixel-width: 4px; }
}
</style>
</head>
<body>
<aside class="sideBar">
<nav>
<ul class="pui disclosure-open">
<li class="nil"><h1><a href="https://github.com/jerrychan7/webPixelUIengine">WPUIE</a></h1></li>
<li><a href="#about">About</a></li>
<li><a href="#installation">Installation</a></li>
<li class="disclosure-closed"><a href="#usage">Usage</a>
<ul id="nav-usage" class="pui circle"></ul>
</li>
</ul>
<a class="octocat" href="https://github.com/jerrychan7/webPixelUIengine" target="_blank">
<b class="pui-balloon from-right">Fork me<br>on GitHub</b><i class="pui-octocat"></i>
</a>
</nav>
</aside>
<main>
<header></header>
<h1><a href="https://github.com/jerrychan7/webPixelUIengine">Web Pixel UI Engine (WPUIE)</a></h1>
<h2 id="about"><a href="#about">#</a> About</h2>
<p>WPUIE 皆在为像素风格网页或像素游戏提供组件。</p>
<h2 id="installation"><a href="#installation">#</a> Installation</h2>
<p>
目前仅有css文件,你可以<a href="./release/all.css" target="_blank" download>点击此处下载</a>。未来会加入js脚本以提供更丰富的操作。当然你可以仅仅使用css。<br/>
如果你没有更丰富的定制需求(例如页面中不同大小和颜色的border),你可以使用<a href="https://nostalgic-css.github.io/NES.css/" target="_blank">NES.css</a>,其对网络更为友好。</p>
<h2 id="usage"><a href="#usage">#</a> Usage</h2>
<p>
下方提供了一些基础示例。详细请参考<a href="https://github.com/jerrychan7/webPixelUIengine/blob/master/documents.md" target="_blank">document</a>。
</p>
<section id="usage-texts">
<fieldset class="pui">
<legend>Texts</legend>
<div class="items">
<span class="pui-text primary">Primary</span>
<span class="pui-text success">Success</span>
<span class="pui-text warning">Warning</span>
<span class="pui-text error">Error</span>
<span class="pui-text disabled">Disabled</span>
</div>
</fieldset>
</section>
<section id="usage-bottons">
<fieldset class="pui">
<legend>Buttons</legend>
<div class="items">
<a href="#" class="pui-btn">Link</a>
<a href="#" class="pui-btn primary" size="1">Link</a>
<a href="#" class="pui-btn success" size="2">Link</a>
<a href="#" class="pui-btn warning" size="2">Warning</a>
<a href="#" class="pui-btn error" size="2">Error</a>
<a href="#" class="pui-btn disabled" size="2">Disabled</a>
<br/>
<button type="button" class="pui">Button</button>
<button type="button" class="pui primary" size="1">Primary</button>
<button type="button" class="pui success" size="2">Success</button>
<button type="button" class="pui warning" size="2">Warning</button>
<button type="button" class="pui error" size="2">Error</button>
<button type="button" class="pui" disabled size="2">Disabled</button>
<br/>
<input type="button" class="pui" value="Input button" />
<input type="button" class="pui primary" size="1" value="Primary" />
<input type="button" class="pui success" size="2" value="Success" />
<input type="button" class="pui warning" size="2" value="Warning" />
<input type="button" class="pui error" size="2" value="Error" />
<input type="button" class="pui" disabled size="2" value="Disabled" />
<br/>
<input type="file" class="pui primary" size="2" />
<input type="file" class="pui warning fill" size="2" />
<br/>
Input type color:
<input class="pui" type="color" value="#008888" />
<input class="pui" type="color" value="#008888" size="1" />
<input class="pui" type="color" value="#008888" size="2" />
<input class="pui" type="color" value="#008888" size="2" disabled />
</div>
</fieldset>
</section>
<section id="usage-radios">
<fieldset class="pui">
<legend>Radios</legend>
<div class="items">
<table class="shelf">
<tr><td>Before text:</td>
<td>
<label><input class="pui" type="radio" name="bie" checked />Yes</label>
<label><input class="pui" type="radio" name="bie" />No</label>
</td>
</tr>
<tr><td>After  text:</td>
<td>
<label>Yes<input class="pui" type="radio" name="bier" at-after checked /></label>
<label>No<input class="pui" type="radio" name="bier" at-after /></label>
</td>
</tr>
<tr><td>Primary:</td>
<td>
<label><input class="pui primary" type="radio" name="biep" checked />Yes</label>
<label><input class="pui primary" type="radio" name="biep" />No</label>
</td>
</tr>
<tr><td>Indeterminate:</td>
<td>
<label><input class="pui triangle" type="radio" name="biei" />Yes</label>
<label><input class="pui triangle" type="radio" name="biei" />No</label>
</td>
</tr>
<tr><td>Triangle:</td>
<td>
<label><input class="pui triangle" type="radio" name="biet" checked />Yes</label>
<label><input class="pui triangle" type="radio" name="biet" />No</label>
</td>
</tr>
<tr><td>Mixed:</td>
<td style="font-size: 2em; color: #00bcd4; --mark-color: #ff9800; --mark-checked-color: #9c27b0; --mark-zoom: .5; --mark: '='; --mark-checked: '->'; --mark-after-checked: '<-';">
<label><input class="pui" type="radio" name="biem" checked />Yes</label>
<label>No<input class="pui" type="radio" name="biem" at-after /></label>
</td>
</tr>
<tr><td>Mixed2:</td>
<td style="font-size: 2em; color: #00bcd4; --mark-color: #ff9800; --mark-checked-color: #9c27b0; --mark-triangle-zoom: 4; --mark: '=';">
<label><input class="pui triangle" type="radio" name="biem2" checked />Yes</label>
<label>No<input class="pui triangle" type="radio" name="biem2" at-after /></label>
</td>
</tr>
</table>
</div>
</fieldset>
</section>
<section id="usage-checkboxes">
<fieldset class="pui">
<legend>Checkboxes</legend>
<div class="items">
<label><input class="pui" type="checkbox" checked />Normal</label>
<label style="color: #2196f3;"><input class="pui" type="checkbox" checked />Colored</label>
<label style="--mark-color: #ff9800;"><input class="pui error" type="checkbox" checked />Colored2</label>
<label style="color: #2196f3; --mark-color: #ff9800; --mark-check-color: #4caf50;"><input class="pui" type="checkbox" checked />Colored3</label>
<label style="color: #9c27b0; --mark-check-color: #4caf50;"><input class="pui" type="checkbox" animation />!CLICK ME! Animation!</label>
<label style="font-size: 2em; --mark-zoom: 3;"><input class="pui" type="checkbox" checked />Big</label>
<br/>
<label>Normal<input class="pui" type="checkbox" at-after checked /></label>
<label style="color: #2196f3;">Colored<input class="pui" type="checkbox" at-after checked /></label>
<label style="--mark-color: #ff9800;">Colored2<input class="pui error" type="checkbox" at-after checked /></label>
<label style="color: #2196f3; --mark-color: #ff9800; --mark-check-color: #4caf50;">Colored3<input class="pui" type="checkbox" at-after checked /></label>
<label style="color: #9c27b0; --mark-check-color: #4caf50;">!CLICK ME! Animation!<input class="pui" type="checkbox" animation at-after /></label>
<label style="font-size: 2em; --mark-zoom: 3;">Big<input class="pui" type="checkbox" at-after checked /></label>
<br/>
Indeterminate:<br/>
<label><input class="pui" type="checkbox" ind />default</label>
<label><input class="pui disc primary" type="checkbox" ind />disc</label>
<label><input class="pui circle" style="--mark-check-color: #9c27b0;" type="checkbox" ind />circle</label>
<label><input class="pui square" style="--mark-color: #ff9800; --mark-check-color: #9c27b0; --mark-indeterminate-color: #4caf50;" type="checkbox" ind />square</label>
<label><input class="pui rect" type="checkbox" ind />rect</label>
<label><input class="pui anti" type="checkbox" ind />anti default</label>
<label><input class="pui pattern" type="checkbox" ind />pattern</label>
<label><input class="pui pattern anti" type="checkbox" ind />anti pattern</label>
<script>
document.querySelectorAll("[ind]").forEach(i => i.indeterminate = true);
</script>
</div>
</fieldset>
</section>
<section id="usage-input">
<fieldset class="pui">
<legend>Inputs</legend>
<div class="items">
<table class="shelf">
<tr><td>email: </td><td><input placeholder="placeholder" type="email" class="pui"></td></tr>
<tr><td>number: </td><td><input placeholder="placeholder" bsize="1" type="number" class="pui primary"></td></tr>
<tr><td>password: </td><td><input placeholder="placeholder" bsize="2" type="password" class="pui success"></td></tr>
<tr><td>search: </td><td><input placeholder="placeholder" bsize="2" type="search" class="pui error"></td></tr>
<tr><td>tel: </td><td><input placeholder="placeholder" bsize="2" type="tel" class="pui warning"></td></tr>
<tr><td>url: </td><td><input placeholder="placeholder" bsize="2" type="url" class="pui" style="--bcolor: #088;"></td></tr>
<tr><td>disabled: </td><td><input placeholder="placeholder" bsize="2" type="text" class="pui" disabled></td></tr>
<tr><td>text: </td><td><input placeholder="placeholder" bsize="2" type="text" class="pui"></td></tr>
</table>
inline: <input placeholder="placeholder" bsize="2" type="text" class="pui inline">
</div>
</fieldset>
</section>
<section id="usage-textarea">
<fieldset class="pui">
<legend>Textarea</legend>
<div class="items">
<textarea cols="23" rows="2" class="pui" placeholder="Normal"></textarea>
<textarea cols="23" rows="2" class="pui primary resizer" bsize="1" placeholder="Radius 1; Primary; resizer"></textarea>
<textarea cols="23" rows="2" class="pui success resizer2" bsize="2" placeholder="Radius 2; Success; resizer2"></textarea>
<textarea cols="23" rows="2" class="pui inline" placeholder="inline" bsize="2"></textarea>
</div>
</fieldset>
</section>
<section id="usage-selects">
<fieldset class="pui">
<legend>Selects</legend>
<div class="items">
<select required class="pui">
<option value="" disabled selected hidden>Normal</option>
<option value="0">To be</option>
<option value="1">Not to be</option>
</select>
<select required class="pui primary" bsize="1">
<option value="" disabled selected hidden>Radius 1; Primary</option>
<option value="0">To be</option>
<option value="1">Not to be</option>
</select>
<select required class="pui success" bsize="2">
<option value="" disabled selected hidden>Radius 2; Success</option>
<option value="0">To be</option>
<option value="1">Not to be</option>
</select>
<select required class="pui warning" size="2" bsize="2">
<option value="" disabled selected hidden>Radius 2; Size 2; Warning</option>
<option value="0">Radius 2</option>
<option value="1">Size 2</option>
<option value="2">Warning</option>
</select>
<select required class="pui error inline" bsize="2">
<option value="" disabled selected hidden>Radius 2; Error; Inline</option>
<option value="0">To be</option>
<option value="1">Not to be</option>
</select>
<select required class="pui" disabled bsize="2">
<option value="" disabled selected hidden>Disabled</option>
<option value="0">To be</option>
<option value="1">Not to be</option>
</select>
</div>
</fieldset>
</section>
<section id="usage-containers">
<fieldset class="pui">
<legend>Containers</legend>
<div class="items">
<fieldset class="pui">no-legend</fieldset>
<fieldset class="pui primary" size="1"><legend>legend</legend>text</fieldset>
<fieldset class="pui success" centered size="2"><legend>centered</legend>centered centered centered</fieldset>
<br/>
<fieldset class="pui centered" size="2" style="--bwidth: 6px; --bcolor: #088; --bg-color: rgba(0, 0, 136, .25);">
<legend>centered</legend>
<span style="white-space: pre-line; display: block; width: 200px">--bwidth: 6px;
--bcolor: #088;
--bg-color: #0084;
</span>
</fieldset>
<fieldset class="pui error" size="2" style="overflow: auto; height: 98px; width: 200px; box-sizing: border-box;">
<legend>scroll</legend>
<p>long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long</p>
<p>longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong</p>
</fieldset>
</div>
</fieldset>
</section>
<section id="usage-dialogs">
<fieldset class="pui">
<legend>Dialogs</legend>
<div class="items">
<!-- Dialog -->
<section>
<button class="pui primary" size="2" onclick="document.getElementById('dialog-default').showModal();">
Open dialog
</button>
<dialog class="pui" size="0" id="dialog-default">
<form method="dialog">
<p class="title">Dialog</p>
<p>Alert: this is a dialog.</p>
<menu class="dialog-menu">
<button class="pui" size=1>Cancel</button>
<button class="pui primary" size=1>Confirm</button>
</menu>
</form>
</dialog>
</section>
<!-- Dark dialog -->
<section>
<button class="pui primary" size="2" onclick="document.getElementById('dialog-dark').showModal();">
Open dark dialog
</button>
<dialog class="pui" style="background-color: black; color: #fff; --bc: #fff;" id="dialog-dark">
<form method="dialog">
<p class="title">Dark dialog</p>
<p>Alert: this is a dialog.</p>
<menu class="dialog-menu">
<button class="pui" size=1 style="color: #000; --bcolor: #fff;">Cancel</button>
<button class="pui primary" size=1 style="--bcolor: #fff;">Confirm</button>
</menu>
</form>
</dialog>
</section>
<!-- Rounded dialog -->
<section>
<button class="pui primary" size="2" onclick="document.getElementById('dialog-rounded').showModal();">
Open rounded dialog
</button>
<dialog class="pui" size="2" id="dialog-rounded">
<form method="dialog">
<p class="title">Rounded dialog</p>
<p>Alert: this is a dialog.</p>
<menu class="dialog-menu">
<button class="pui" size=1>Cancel</button>
<button class="pui primary" size=1>Confirm</button>
</menu>
</form>
</dialog>
</section>
<!-- Dark and Rounded dialog -->
<section>
<button class="pui primary" size="2" onclick="document.getElementById('dialog-dark-rounded').showModal();">
Open dark and rounded dialog
</button>
<dialog class="pui" size="2" style="background-color: black; color: #fff; --bcolor: #fff;" id="dialog-dark-rounded">
<form method="dialog">
<p class="title">Dark and Rounded dialog</p>
<p>Alert: this is a dialog.</p>
<menu class="dialog-menu">
<button class="pui" size=1 style="color: #000; --bcolor: #fff;">Cancel</button>
<button class="pui primary" size=1 style="--bcolor: #fff;">Confirm</button>
</menu>
</form>
</dialog>
</section>
<!-- Dark and Rounded dialog -->
<section>
<button class="pui primary" size="2" onclick="document.getElementById('dialog-dark-rounded-long').showModal();">
Open dark, rounded and long dialog
</button>
<dialog class="pui" size="2" style="background-color: black; color: #fff; --bcolor: #fff;" id="dialog-dark-rounded-long">
<form method="dialog">
<p class="title">Dark and Rounded dialog</p>
<p>Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog.</p>
<p>Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog.</p>
<p>Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog.</p>
<p>Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog.</p>
<p>Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog.</p>
<p>Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog.</p>
<p>Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog.</p>
<p>Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog.</p>
<p>Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog. Alert: this is a dialog.</p>
<menu class="dialog-menu">
<button class="pui" size=1 style="color: #000; --bcolor: #fff;">Cancel</button>
<button class="pui primary" size=1 style="--bcolor: #fff;">Confirm</button>
</menu>
</form>
</dialog>
</section>
</div>
</fieldset>
</section>
<section id="usage-lists">
<fieldset class="pui">
<legend>Lists</legend>
<div class="items">
<ul class="pui disc">
<li>Good morning.</li>
<li>Thou hast had a good night's sleep, I hope.</li>
<li>Thou hast had a good afternoon</li>
<li>a long long long long long long long long long long long long long long long long long long long long long text.</li>
<li>Good night.</li>
</ul>
<ul class="pui circle">
<li>Good morning.</li>
<li>Thou hast had a good night's sleep, I hope.</li>
<li>Thou hast had a good afternoon</li>
<li>a long long long long long long long long long long long long long long long long long long long long long text.</li>
<li>Good night.</li>
</ul>
<ul class="pui">
<li>default</li>
<li class="none">none</li>
<li class="disc">disc</li>
<li class="circle">circle</li>
<li class="square">square</li>
<li class="nil">nil</li>
<li class="rect">rect</li>
<li class="disclosure-open">disclosure-open</li>
<li class="disclosure-closed">disclosure-closed</li>
</ul>
</div>
</fieldset>
</section>
<section id="usage-details">
<fieldset class="pui">
<legend>Details</legend>
<div class="items">
<details class="pui"><summary>Details</summary><p>Content</p></details>
<details class="pui" open><summary>Details</summary><p>Content</p></details>
<details class="pui sideline" open>
<summary>sideline</summary>
<details class="pui sideline dashed" open>
<summary>dashed</summary>
<p>Content</p>
</details>
<details class="pui sideline dotted" open>
<summary>dotted</summary>
<p>Content</p>
</details>
</details>
<details class="pui sideline dashed pui-cb" size="2" open>
<summary>Work with</summary>
<p><a href="#usage-colored-border">Colored border</a></p>
</details>
</div>
</fieldset>
</section>
<section id="usage-tables">
<fieldset class="pui">
<legend>Table</legend>
<div class="items">
<table class="pui" size="0">
<tr><th>Title</th><th>Title</th><th>Title</th></tr>
<tr><td>A</td><td>A long long A</td><td>A</td></tr>
<tr><td>A</td><td>A long long A</td><td>A</td></tr>
</table>
<table class="pui primary" size="1">
<tr><th>Title</th><th>Title</th><th>Title</th></tr>
<tr><td>A</td><td>A long long A</td><td>A</td></tr>
<tr><td>A</td><td>A long long A</td><td>A</td></tr>
</table>
<table class="pui hollow success" size="1">
<tr><th>Title</th><th>Title</th><th>Title</th></tr>
<tr><td>A</td><td>A long long A</td><td>A</td></tr>
<tr><td>A</td><td>A long long A</td><td>A</td></tr>
</table>
<table class="pui hollow warning" size="2">
<tr><th>Title</th><th>Title</th><th>Title</th></tr>
<tr><td>A</td><td>A long long A</td><td>A</td></tr>
<tr><td>A</td><td>A long long A</td><td>A</td></tr>
</table>
<table class="pui unbordered-inside error" size="2">
<tr><th>Title</th><th>Title</th><th>Title</th></tr>
<tr><td>A</td><td>A long long A</td><td>A</td></tr>
<tr><td>A</td><td>A long long A</td><td>A</td></tr>
</table>
<table class="pui hollow unbordered disabled" size="2">
<tr><th>Title</th><th>Title</th><th>Title</th></tr>
<tr><td>A</td><td>A long long A</td><td>A</td></tr>
<tr><td>A</td><td>A long long A</td><td>A</td></tr>
</table>
</div>
</fieldset>
</section>
<section id="usage-progress">
<fieldset class="pui">
<legend>Progress</legend>
<div class="items">
<progress size="0" class="pui" value="90" max="100"></progress>
<progress size="1" class="pui primary" value="80" max="100"></progress>
<progress size="2" class="pui warning" value="30" max="100"></progress>
<progress size="2" class="pui success hollow" value="50" max="100"></progress>
<progress size="2" class="pui error hollow" value="10" max="100"></progress>
<progress size="2" class="pui pattern" value="50" max="100"></progress>
<progress size="2" class="pui hollow pattern primary" value="50" max="100"></progress><br/>
<progress class="pui primary"></progress>
<progress size="2" class="pui warning"></progress>
<progress size="2" class="pui error hollow"></progress>
<progress size="2" class="pui pattern success"></progress>
<progress size="2" class="pui pattern primary hollow"></progress>
</div>
</fieldset>
</section>
<section id="usage-balloons">
<fieldset class="pui">
<legend>Balloons</legend>
<div class="items">
<div class="pui-balloon">Normal balloon</div>
<div class="pui-balloon from-right">from-right</div>
<div class="pui-balloon on-left">on-left<br>foo<br>foo</div>
<div class="pui-balloon on-left from-top">on-left<br>from-top<br>foo</div><br/>
<div class="pui-balloon on-top">on-top</div>
<div class="pui-balloon on-top from-right">on-top from-right</div>
<div class="pui-balloon on-right">on-right<br>foo<br>foo</div>
<div class="pui-balloon on-right from-top">on-right<br>from-top<br>foo</div><br/>
<div class="stripe-bg"><div class="pui-balloon from-right">is transparent background</div></div>
<div class="pui-balloon on-top" id="shark">! Shark !</div>
<style>
#shark {
background-image: linear-gradient(#3ab0ff 15%, #bafaff);
display: inline-block;
width: 150px;
text-align: center;
vertical-align: bottom;
margin-top: 1em;
--toe-bg-color: rgb(55, 66, 75);
}
</style>
<script>
(() => {
let i = 0;
const frame = () => {
const shark = document.getElementById("shark");
if (!shark) return;
if (i % 100 == 0)
if ((i / 50) & 2) shark.classList.add("from-right");
else shark.classList.remove("from-right");
shark.style.setProperty("--start-at", (i++ % 100) + "%");
shark.style.boxShadow = `
inset 0 ${-6 + -8 * (Math.sin(i / 70) + 1) / 2}px #ffdd37,
inset 0 ${-6 + -8 * (Math.sin((i - 60) / 70) + 1) / 2}px #ceebff,
inset 0 ${-6 + -8 * (Math.sin((i + 75) / 70) + 1) / 2}px #d3b72b`;
window.requestAnimationFrame(frame);
};
frame();
})();
</script>
</div>
</fieldset>
</section>
<section id="usage-pixel-arts---octocat">
<fieldset class="pui">
<legend>Pixel-arts</legend>
<div class="items">
<i class="pui-octocat"></i>
</div>
</fieldset>
</section>
<section id="usage-colored-border">
<fieldset class="pui">
<legend>Colored Border</legend>
<div class="items">
<span class="pui-cb">Radius 0; Normal</span>
<span class="pui-cb primary" size="1">Radius 1; Primary</span>
<span class="pui-cb success" size="2">Radius 2; Success</span>
</div>
</fieldset>
</section>
<section id="usage-background">
<fieldset class="pui">
<legend>Pixelated Background</legend>
<div class="items">
<div class="pui-bg" style="--img: url(../test/img-test.png);">content</div>
<div class="pui-bg" style="--img: url(../test/img-test.png); --brightness: 1.3; --size: auto 100%; --color: #888;"><p>brightness="1.3" size="auto 100%"</p></div>
<div class="pui-bg no-repeat" style="--img: url(../test/img-test.png); --size: 25ch 2em; --color: #888;"><p>size="25ch 2em" no-repeat color="#888"</p></div>
</div>
</fieldset>
</section>
<section id="usage-image">
<fieldset class="pui">
<legend>Pixelated Image</legend>
<div class="items">
<img style="width: 100px;" class="pui" src="./test/img-test.png" />
<br/>Original: <img src="./test/img-test.png" />
</div>
</fieldset>
</section>
<section id="usage-image-border">
<fieldset class="pui">
<legend>Image Border</legend>
<div class="items">
<div class="pui-ib" style="--bimg: url(../test/img-test.png); --bw: 4;">
image border
</div>
<div class="pui-ib fill" style="--bimg: url(../test/img-test.png); --bw: 4;">
image border (fill center)
</div>
</div>
</fieldset>
</section>
<section id="usage-scroll-bar">
<fieldset class="pui">
<legend>Scroll Bar</legend>
<div class="items">
<div class="pui-scroller">
<div style="width: 400px; padding: 10px">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi et nisi ut est venenatis viverra. Aenean pede orci, blandit quis, faucibus quis, egestas ut, mi. Pellentesque enim purus, venenatis dignissim, tincidunt a, ullamcorper eget, nibh. Nullam ut sem adipiscing orci vehicula interdum. Proin a enim. Phasellus sollicitudin, magna vitae vestibulum facilisis, tellus nunc iaculis arcu, in molestie sem velit tempus est. In eleifend velit at sem adipiscing sodales. Nunc sapien felis, aliquam et, volutpat rhoncus, condimentum ut, tortor. Integer est. Quisque viverra. Praesent sed arcu. Maecenas id lorem a leo lobortis condimentum.</div>
</div>
<div class="pui-scroller" style="background: #000; color: #fff;">
<div style="width: 400px; padding: 10px">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi et nisi ut est venenatis viverra. Aenean pede orci, blandit quis, faucibus quis, egestas ut, mi. Pellentesque enim purus, venenatis dignissim, tincidunt a, ullamcorper eget, nibh. Nullam ut sem adipiscing orci vehicula interdum. Proin a enim. Phasellus sollicitudin, magna vitae vestibulum facilisis, tellus nunc iaculis arcu, in molestie sem velit tempus est. In eleifend velit at sem adipiscing sodales. Nunc sapien felis, aliquam et, volutpat rhoncus, condimentum ut, tortor. Integer est. Quisque viverra. Praesent sed arcu. Maecenas id lorem a leo lobortis condimentum.</div>
</div>
<div class="pui-scroller has-btn vdouble-start resizer" style="
resize: both;
--track: #800;
--btn-bg: #08f;
--btn: #0f0;
--thumb: #f0f;
--corner: #f88;
--resizer: #8ff;
">
<div style="width: 400px; padding: 10px">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi et nisi ut est venenatis viverra. Aenean pede orci, blandit quis, faucibus quis, egestas ut, mi. Pellentesque enim purus, venenatis dignissim, tincidunt a, ullamcorper eget, nibh. Nullam ut sem adipiscing orci vehicula interdum. Proin a enim. Phasellus sollicitudin, magna vitae vestibulum facilisis, tellus nunc iaculis arcu, in molestie sem velit tempus est. In eleifend velit at sem adipiscing sodales. Nunc sapien felis, aliquam et, volutpat rhoncus, condimentum ut, tortor. Integer est. Quisque viverra. Praesent sed arcu. Maecenas id lorem a leo lobortis condimentum.</div>
</div>
</div>
</fieldset>
</section>
<section id="usage-slider">
<fieldset class="pui stripe-bg">
<legend>Slider</legend>
<div class="items">
<input type="range" class="pui" />
<input type="range" class="pui primary" bsize="1" />
<input type="range" class="pui warning" bsize="2" />
<input type="range" class="pui success hollow" bsize="2" />
<input type="range" class="pui success thin short" bsize="2" />
<input type="range" class="pui success short hollow" bsize="2" style="--track-h: 4px;" />
<input type="range" class="pui primary hollow square" bsize="1" />
</div>
</fieldset>
</section>
<section id="usage-icons">
<fieldset class="pui">
<legend>Icons</legend>
<div class="items">
Triangle:
<i class="pui-icon triangle bg"></i>
<i class="pui-icon triangle sd before down primary"></i>
<i class="pui-icon triangle clip after left success"></i>
<i class="pui-icon triangle clip after up" style="color: #088"></i>
<br />
Disc:
<i class="pui-icon disc bg"></i>
<i class="pui-icon disc sd before primary"></i>
<i class="pui-icon disc clip after success" style="color: #088"></i>
<br />
Circle:
<i class="pui-icon circle bg"></i>
<i class="pui-icon circle sd after primary"></i>
<i class="pui-icon circle clip before success" style="color: #088"></i>
<br />
Square:
<i class="pui-icon square"></i>
<i class="pui-icon square before primary"></i>
<i class="pui-icon square after success" style="color: #088"></i>
<br />
Rect:
<i class="pui-icon rect"></i>
<i class="pui-icon rect after primary"></i>
<i class="pui-icon rect before success" style="color: #088"></i>
</div>
</fieldset>
</section>
<footer>
<p>Font in this page: <a href="https://3type.cn/fonts/dinkie_bitmap/">Dinkie Bitmap</a> (丁卯点阵体) 9px <sub><i>Demo</i></sub></p>
</footer>
</main>
<a id="back2top" class="pui-btn error" size="1">^</a>
<div id="sideBarCover"></div>
<button id="showNav" class="pui primary" size="1"><span>iii</span></button>
<script>
const showcode = function() {
const code = this.parentNode.parentNode.parentNode.querySelectorAll(".code-toolbar")[0];
if (!code) return;
code.style.display = code.style.display? null: "block";
};
const trimStartPreLine = (str) => {
str = str.split("\n");
while (str[0].trimStart() === "") str.shift();
while (str[str.length - 1]?.trimStart() === "") str.pop();
const spNum = str[0]?.search(/\S/) || -1;
if (~spNum) str = str.map(s => s.substring(spNum));
return str.join("\n");
}
document.querySelectorAll("[id^=usage-] > fieldset > .items").forEach(div => {
const fieldset = div.parentElement;
const pre = document.createElement("pre");
let text = "";
if (fieldset.parentNode.id == "usage-radios") {
const tds = div.querySelectorAll("td"), str = [];
for (let i = 0; i < tds.length; i += 2) {
str.push(trimStartPreLine(tds[i].innerHTML), trimStartPreLine(tds[i + 1].innerHTML));
}
text = str.join("\n");
}
else if (fieldset.parentNode.id == "usage-input") {
const tds = div.querySelectorAll("td"), str = [];
for (let i = 0; i < tds.length; i += 2) {
str.push(trimStartPreLine(tds[i].innerHTML) + trimStartPreLine(tds[i + 1].innerHTML));
}
text = str.join("\n") + "\n" + div.innerHTML.replace(/[\s\S]*<\/table>\s*/, "").trim();
}
else {
text = trimStartPreLine(div.innerHTML);
}
pre.innerHTML = `<code class="language-html">${text.replace(/=""/g, "").replace(/</g, "<")}</code>`;
fieldset.parentNode.insertBefore(pre, fieldset.nextSibling);
document.getElementById("nav-usage").innerHTML += `
<li><a href="#${fieldset.parentNode.id}">${fieldset.querySelector("legend").innerHTML}</a></li>
`;
const toolbar = document.createElement("div");
toolbar.className = "toolbar";
fieldset.appendChild(toolbar);
const showCodeBtn = document.createElement("button");
showCodeBtn.type = "button";
showCodeBtn.innerHTML = "< >";
showCodeBtn.className = "pui primary show-code";
showCodeBtn.setAttribute("size", "1");
showCodeBtn.onclick = showcode;
const docBtn = document.createElement("a");
docBtn.innerHTML = "Document";
docBtn.className = "pui-btn success go2document";
docBtn.setAttribute("size", "1");
docBtn.setAttribute("target", "_blank");
docBtn.href = "https://github.com/jerrychan7/webPixelUIengine/blob/master/documents.md#" + ({
"usage-input": "inputs--textarea",
"usage-textarea": "inputs--textarea",
}[fieldset.parentNode.id] || fieldset.parentNode.id.replace("usage-", ""));
toolbar.append(docBtn, showCodeBtn);
});
const mo = new MutationObserver((mrs) => {
mrs.forEach(mr => {
mr.addedNodes[0]?.querySelectorAll(".copy-to-clipboard-button").forEach(btn => {
btn.classList.add("pui");
btn.setAttribute("size", "1");
});
});
});
document.querySelectorAll("[id^=usage-]").forEach(e => mo.observe(e, { childList: true, }));
// 滚动条到页面顶部的水平和垂直距离
const getTopDistance = () => ({
x: Math.max(document.documentElement?.scrollLeft || 0, document.body?.scrollLeft || 0, window.scrollX || 0),
y: Math.max(document.documentElement?.scrollTop || 0, document.body?.scrollTop || 0, window.scrollY || 0)
});
const atTheTop = ({x, y} = getTopDistance()) => x <= 0 && y <= 0;
const goTop = (acceleration = 0.1) => {
let dis = getTopDistance(), {x, y} = dis;
// 如果距离不为零, 继续调用迭代本函数
if (atTheTop(dis)) return;
// 滚动距离 = 目前距离 / 速度, 因为距离原来越小, 速度是大于 1 的数, 所以滚动距离会越来越小
let speed = 1 + acceleration;
if (x / speed <= 10) x = 0;
if (y / speed <= 10) y = 0;
window.scrollTo(~~(x / speed), ~~(y / speed));
window.requestAnimationFrame(() => goTop(acceleration));
};
const back2topBtn = document.getElementById("back2top");
back2topBtn.onclick = () => goTop() && false;
back2topBtn.style.display = atTheTop()? "none": "block";
window.addEventListener("scroll", () => {
const scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
back2topBtn.style.display = null;
back2topBtn.style.bottom = scrollTop > 100? null: "-2.5em";
back2topBtn.style.opacity = scrollTop > 100? null: "0";
});
const sideBarCover = document.getElementById("sideBarCover");
sideBarCover.onclick =
document.getElementById("showNav").onclick = () => {
const sideBar = document.getElementsByClassName("sideBar")[0];
// sideBar.style.display = sideBar.style.display? null: "grid";
// sideBarCover.style.display = sideBarCover.style.display? null: "block";
sideBar.style.transform = sideBarCover.style.opacity? null: "translateX(0)";
sideBar.style.opacity = sideBarCover.style.opacity? null: "1";
sideBarCover.style.pointerEvents = sideBarCover.style.opacity? null: "all";
sideBarCover.style.opacity = sideBarCover.style.opacity? null: "1";
return false;
};
</script>
</body>
</html>