-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub_dashboard_builder.html
More file actions
1572 lines (1387 loc) · 55.5 KB
/
github_dashboard_builder.html
File metadata and controls
1572 lines (1387 loc) · 55.5 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
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" class="neo-landing-root">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GitHub Dashboard Builder</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600;700&display=swap" rel="stylesheet" />
<style>
html { -webkit-text-size-adjust: 100%; }
img, video, canvas, svg { max-width: 100%; height: auto; }
:root {
--bg: #0b0c10;
--panel: #11131a;
--panel-2: #171923;
--soft: #202433;
--border: #2c3243;
--text: #f4f7ff;
--muted: #aab4cb;
--accent: #ff1493;
--accent-2: #ff4db2;
--danger: #fb7185;
--shadow: 0 16px 40px rgba(0,0,0,.35);
--radius: 16px;
/* Neo-brutalist export controls */
--brutal-ink: #07080d;
--brutal-shadow: 5px 5px 0 var(--brutal-ink);
--brutal-shadow-sm: 3px 3px 0 var(--brutal-ink);
--brutal-lime: #c8f542;
--brutal-cream: #f2efe6;
--brutal-yellow: #ffe14a;
--font-export: "Oswald", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
margin: 0;
font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
background:
radial-gradient(circle at top right, rgba(255,20,147,.18), transparent 26%),
radial-gradient(circle at top left, rgba(86,130,255,.12), transparent 22%),
var(--bg);
color: var(--text);
}
button, input, textarea, select { font: inherit; }
.app {
display: grid;
grid-template-columns: 340px 1fr 1fr;
min-height: 100vh;
}
.sidebar, .builder, .preview {
border-right: 1px solid var(--border);
min-width: 0;
}
.preview { border-right: 0; }
.pane {
padding: 20px;
height: 100vh;
overflow: auto;
}
.hero { margin-bottom: 18px; }
.hero h1 {
margin: 0 0 8px;
font-size: 1.45rem;
line-height: 1.1;
letter-spacing: -0.02em;
}
.hero p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.panel {
background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
padding: 14px;
margin-bottom: 16px;
}
.panel h2, .panel h3 { margin: 0 0 10px; font-size: 1rem; }
.panel p.small, .small { margin: 0; color: var(--muted); font-size: 0.88rem; }
.sidebar-section {
padding: 0;
overflow: hidden;
}
.sidebar-section.is-collapsed .sidebar-section-body,
.preview-markdown-section.is-collapsed .sidebar-section-body {
display: none;
}
.sidebar-section-toggle {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 14px;
margin: 0;
border: none;
border-radius: var(--radius);
background: transparent;
color: inherit;
font: inherit;
text-align: left;
cursor: pointer;
transition: background 0.15s ease;
}
.sidebar-section-toggle:hover {
background: rgba(255, 255, 255, 0.04);
}
.sidebar-section-toggle:focus-visible {
outline: 2px solid var(--accent);
outline-offset: -2px;
}
.sidebar-section-title {
margin: 0;
font-size: 1rem;
font-weight: 600;
letter-spacing: -0.01em;
}
.sidebar-section-chevron {
flex-shrink: 0;
font-size: 0.75rem;
color: var(--muted);
transition: transform 0.2s ease;
}
.sidebar-section.is-collapsed .sidebar-section-chevron,
.preview-markdown-section.is-collapsed .sidebar-section-chevron {
transform: rotate(-90deg);
}
.sidebar-section-body {
padding: 0 14px 14px;
display: grid;
gap: 10px;
}
.button-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
}
/* Neo-brutalist + Oswald: Export (stacked) + Presets (2×2 grid) */
.export-actions {
grid-template-columns: 1fr;
gap: 12px;
}
.preset-actions,
.add-block-actions {
gap: 12px;
}
.export-actions button,
.preset-actions button,
.add-block-actions button {
position: relative;
display: flex;
align-items: center;
justify-content: center;
min-height: 3rem;
padding: 0.75rem 1rem;
font-family: var(--font-export);
font-size: 0.875rem;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
border-radius: 6px;
border: 3px solid var(--brutal-ink);
color: var(--brutal-ink);
background: var(--brutal-cream);
box-shadow: var(--brutal-shadow);
cursor: pointer;
transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.export-actions button:hover,
.preset-actions button:hover,
.add-block-actions button:hover {
transform: translate(-2px, -2px);
box-shadow: 7px 7px 0 var(--brutal-ink);
}
.export-actions button:active,
.preset-actions button:active,
.add-block-actions button:active {
transform: translate(3px, 3px);
box-shadow: var(--brutal-shadow-sm);
}
.export-actions button:focus-visible,
.preset-actions button:focus-visible,
.add-block-actions button:focus-visible {
outline: 3px solid var(--brutal-lime);
outline-offset: 3px;
}
.export-actions #copyMarkdownBtn {
background: var(--accent);
color: #fff;
border-color: var(--brutal-ink);
box-shadow: var(--brutal-shadow);
}
.export-actions #copyMarkdownBtn:hover {
background: #ff4db2;
}
.export-actions #downloadMarkdownBtn,
.export-actions #downloadJsonBtn {
background: var(--brutal-yellow);
color: var(--brutal-ink);
}
.export-actions #downloadMarkdownBtn:hover,
.export-actions #downloadJsonBtn:hover {
background: #fff08a;
}
.export-actions #loadJsonBtn {
background: var(--brutal-lime);
color: var(--brutal-ink);
}
.export-actions #loadJsonBtn:hover {
background: #def65a;
}
.preset-actions [data-preset="readme"] {
background: var(--accent);
color: #fff;
}
.preset-actions [data-preset="readme"]:hover {
background: #ff4db2;
}
.preset-actions [data-preset="profile"] {
background: var(--brutal-yellow);
}
.preset-actions [data-preset="profile"]:hover {
background: #fff08a;
}
.preset-actions [data-preset="faq"] {
background: var(--brutal-lime);
}
.preset-actions [data-preset="faq"]:hover {
background: #def65a;
}
.preset-actions [data-preset="roadmap"] {
background: var(--brutal-cream);
}
.preset-actions [data-preset="roadmap"]:hover {
background: #faf7ef;
}
/* Add block — same brutal frame; label + hint stack; cycle fills */
.block-types.add-block-actions button {
flex-direction: column;
align-items: flex-start;
justify-content: center;
min-height: 4.5rem;
text-transform: none;
letter-spacing: 0.03em;
font-size: 0.8125rem;
line-height: 1.25;
}
.block-types.add-block-actions button span {
font-family: Inter, system-ui, sans-serif;
font-size: 0.6875rem;
font-weight: 500;
letter-spacing: 0.02em;
color: var(--brutal-ink);
opacity: 0.72;
margin-top: 4px;
text-transform: none;
}
.add-block-actions button:nth-child(4n + 1) {
background: var(--accent);
color: #fff;
}
.add-block-actions button:nth-child(4n + 1) span {
color: rgba(255, 255, 255, 0.9);
opacity: 1;
}
.add-block-actions button:nth-child(4n + 1):hover {
background: #ff4db2;
}
.add-block-actions button:nth-child(4n + 2) {
background: var(--brutal-yellow);
}
.add-block-actions button:nth-child(4n + 2):hover {
background: #fff08a;
}
.add-block-actions button:nth-child(4n + 3) {
background: var(--brutal-lime);
}
.add-block-actions button:nth-child(4n + 3):hover {
background: #def65a;
}
.add-block-actions button:nth-child(4n + 4) {
background: var(--brutal-cream);
}
.add-block-actions button:nth-child(4n + 4):hover {
background: #faf7ef;
}
button {
border: 1px solid var(--border);
background: var(--soft);
color: var(--text);
border-radius: 12px;
padding: 10px 12px;
cursor: pointer;
transition: .18s ease;
}
button:hover {
border-color: var(--accent);
transform: translateY(-1px);
}
button.primary {
background: linear-gradient(180deg, var(--accent), var(--accent-2));
border-color: transparent;
color: white;
font-weight: 700;
}
button.ghost { background: transparent; }
button.danger {
background: rgba(251, 113, 133, 0.12);
color: #ffd7df;
border-color: rgba(251, 113, 133, 0.35);
}
.block-types {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.block-types button {
text-align: left;
min-height: 64px;
font-size: 0.92rem;
line-height: 1.2;
}
.block-types span {
display: block;
font-size: 0.75rem;
color: var(--muted);
margin-top: 4px;
}
.block-types.add-block-actions {
gap: 12px;
}
.list { display: grid; gap: 10px; }
.block-card {
border: 1px solid var(--border);
background: var(--panel);
border-radius: 16px;
padding: 12px;
display: grid;
gap: 0;
}
.block-card.is-collapsed .block-card-body {
display: none;
}
.block-card-header {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: space-between;
gap: 10px;
margin-bottom: 12px;
}
.block-card.is-collapsed .block-card-header {
margin-bottom: 0;
}
.block-card-toggle {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 4px 8px;
margin: -4px -8px;
border: none;
border-radius: 10px;
background: transparent;
color: inherit;
font: inherit;
text-align: left;
cursor: pointer;
transition: background 0.15s ease;
}
.block-card-toggle:hover {
background: rgba(255, 255, 255, 0.04);
}
.block-card-toggle:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.block-card-toggle-text {
display: grid;
gap: 4px;
min-width: 0;
}
.block-card-toggle-text strong { font-size: 0.98rem; }
.block-card-chevron {
flex-shrink: 0;
font-size: 0.75rem;
color: var(--muted);
transition: transform 0.2s ease;
}
.block-card.is-collapsed .block-card-chevron {
transform: rotate(-90deg);
}
.block-card-body {
display: grid;
gap: 12px;
}
.meta {
font-size: 0.78rem;
color: var(--muted);
text-transform: uppercase;
letter-spacing: .06em;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar button { padding: 7px 10px; font-size: 0.85rem; }
.field { display: grid; gap: 6px; }
.field label { font-size: 0.84rem; color: var(--muted); font-weight: 600; }
.field input,
.field textarea,
.field select {
width: 100%;
background: var(--panel-2);
color: var(--text);
border: 1px solid var(--border);
border-radius: 12px;
padding: 10px 12px;
outline: none;
}
.field textarea { resize: vertical; min-height: 88px; }
.field input:focus,
.field textarea:focus,
.field select:focus {
border-color: var(--accent);
box-shadow: 0 0 0 4px rgba(255,20,147,.14);
}
pre, .markdown-output {
background: #0a0d14;
border: 1px solid var(--border);
border-radius: 16px;
padding: 14px;
overflow: auto;
white-space: pre-wrap;
word-break: break-word;
line-height: 1.5;
font-size: 0.93rem;
}
.preview-box {
background: #0a0d14;
border: 1px solid var(--border);
border-radius: 16px;
padding: 16px;
line-height: 1.55;
}
.preview-box h1,
.preview-box h2,
.preview-box h3 { margin-top: 1.1em; margin-bottom: 0.45em; }
.preview-box h1:first-child { margin-top: 0; }
.preview-box code {
background: rgba(255,255,255,.06);
padding: 2px 6px;
border-radius: 6px;
}
.preview-box table {
width: 100%;
border-collapse: collapse;
border: 1px solid var(--border);
margin: 12px 0;
border-radius: 12px;
overflow: hidden;
}
.preview-box th,
.preview-box td {
padding: 10px 12px;
border-top: 1px solid var(--border);
vertical-align: top;
text-align: left;
}
.preview-box thead th {
background: rgba(255,255,255,.04);
border-top: 0;
}
.preview-box .md-button-row {
display: flex;
flex-wrap: wrap;
gap: 10px;
align-items: center;
margin: 10px 0;
}
.preview-box .md-button-row a {
display: inline-block;
line-height: 0;
}
.preview-box .md-button-row img {
max-height: 28px;
width: auto;
display: block;
}
.preview-box details {
margin: 14px 0;
padding: 10px 14px;
border: 1px solid var(--border);
border-radius: 12px;
background: rgba(255, 255, 255, 0.04);
white-space: pre-line;
}
.preview-box details > summary {
cursor: pointer;
font-weight: 600;
color: var(--text);
list-style: none;
}
.preview-box details > summary::-webkit-details-marker {
display: none;
}
.preview-box details > summary::before {
content: "▸ ";
display: inline-block;
margin-right: 6px;
transition: transform 0.15s ease;
color: var(--muted);
}
.preview-box details[open] > summary::before {
transform: rotate(90deg);
}
.preview-box a {
color: var(--accent-2);
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 3px;
}
.preview-box a:hover {
color: var(--accent);
}
.pill {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 10px;
border-radius: 999px;
background: rgba(255,255,255,.05);
color: var(--muted);
font-size: 0.76rem;
border: 1px solid var(--border);
margin-bottom: 12px;
}
.empty {
border: 1px dashed var(--border);
border-radius: 16px;
padding: 20px;
color: var(--muted);
text-align: center;
}
.hidden { display: none !important; }
@media (max-width: 1180px) {
.app { grid-template-columns: 320px 1fr; }
.preview {
grid-column: 1 / -1;
border-top: 1px solid var(--border);
}
.preview .pane { height: auto; min-height: 40vh; }
}
@media (max-width: 760px) {
.app { grid-template-columns: 1fr; }
.sidebar, .builder, .preview {
border-right: 0;
border-bottom: 1px solid var(--border);
}
.pane { height: auto; }
.button-grid, .block-types { grid-template-columns: 1fr; }
}
</style>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="./github-tools-neo.css" />
</head>
<body class="neo-landing neo-dash">
<div class="app">
<aside class="sidebar">
<div class="pane">
<div class="hero">
<h1>GitHub Dashboard Builder</h1>
<p>Build GitHub-friendly markdown dashboards, READMEs, profile pages, and project hubs from reusable blocks.</p>
</div>
<section class="panel">
<h2>Project</h2>
<div class="field">
<label for="docName">Output filename</label>
<input id="docName" type="text" value="README.md" />
</div>
<div class="field" style="margin-top:10px;">
<label for="docTitle">Internal project label</label>
<input id="docTitle" type="text" value="GitHub Dashboard" />
</div>
</section>
<section class="panel sidebar-section is-collapsed" data-sidebar-section="presets">
<button type="button" class="sidebar-section-toggle" aria-expanded="false" aria-controls="sidebar-presets-body" id="sidebar-presets-head">
<span class="sidebar-section-title">Presets</span>
<span class="sidebar-section-chevron" aria-hidden="true">▾</span>
</button>
<div class="sidebar-section-body" id="sidebar-presets-body" role="region" aria-labelledby="sidebar-presets-head">
<div class="button-grid preset-actions">
<button data-preset="readme">README</button>
<button data-preset="profile">Profile README</button>
<button data-preset="faq">FAQ</button>
<button data-preset="roadmap">Roadmap</button>
</div>
</div>
</section>
<section class="panel sidebar-section is-collapsed" data-sidebar-section="add">
<button type="button" class="sidebar-section-toggle" aria-expanded="false" aria-controls="sidebar-add-body" id="sidebar-add-head">
<span class="sidebar-section-title">Add block</span>
<span class="sidebar-section-chevron" aria-hidden="true">▾</span>
</button>
<div class="sidebar-section-body" id="sidebar-add-body" role="region" aria-labelledby="sidebar-add-head">
<div class="block-types add-block-actions" id="addBlockButtons"></div>
</div>
</section>
<section class="panel sidebar-section is-collapsed" data-sidebar-section="export">
<button type="button" class="sidebar-section-toggle" aria-expanded="false" aria-controls="sidebar-export-body" id="sidebar-export-head">
<span class="sidebar-section-title">Export</span>
<span class="sidebar-section-chevron" aria-hidden="true">▾</span>
</button>
<div class="sidebar-section-body" id="sidebar-export-body" role="region" aria-labelledby="sidebar-export-head">
<div class="button-grid export-actions">
<button class="primary" id="copyMarkdownBtn">Copy .md</button>
<button id="downloadMarkdownBtn">Download .md</button>
<button id="downloadJsonBtn">Download JSON</button>
<button id="loadJsonBtn">Load JSON</button>
</div>
<input id="jsonInput" class="hidden" type="file" accept="application/json" />
</div>
</section>
</div>
</aside>
<main class="builder">
<div class="pane">
<div class="pill">Builder</div>
<div id="blocksList" class="list"></div>
</div>
</main>
<section class="preview">
<div class="pane">
<div class="panel sidebar-section preview-markdown-section is-collapsed">
<button type="button" class="sidebar-section-toggle" aria-expanded="false" aria-controls="preview-markdown-body" id="preview-markdown-head">
<span class="sidebar-section-title">Generated Markdown</span>
<span class="sidebar-section-chevron" aria-hidden="true">▾</span>
</button>
<div class="sidebar-section-body" id="preview-markdown-body" role="region" aria-labelledby="preview-markdown-head">
<pre id="markdownOutput" class="markdown-output"></pre>
</div>
</div>
<div class="pill">Quick Preview</div>
<div id="renderedPreview" class="preview-box"></div>
</div>
</section>
</div>
<script>
const BLOCK_TYPES = {
heading: { label: 'Heading', hint: 'Title and intro', defaults: () => ({ level: 1, text: 'Project Title', body: 'A short introduction or project summary.' }) },
badges: { label: 'Badges', hint: 'Shields and status', defaults: () => ({ items: '[](#license)\n[](https://example.com)' }) },
links: { label: 'Quick Links', hint: 'Jump links or CTAs', defaults: () => ({ items: 'Live Demo|https://example.com\nOpen Issues|https://github.com/owner/repo/issues\nDocumentation|#documentation' }) },
paragraph: { label: 'Paragraph', hint: 'Freeform text', defaults: () => ({ title: 'Overview', body: 'Write a short paragraph here using plain markdown-friendly text.' }) },
toc: { label: 'Table of Contents', hint: 'Auto-generated links', defaults: () => ({}) },
checklist: { label: 'Checklist', hint: 'Roadmap/tasks', defaults: () => ({ title: 'Roadmap', items: 'true|Launch MVP\nfalse|Add JSON import/export presets\nfalse|Publish demo on GitHub Pages' }) },
table: { label: 'Table', hint: 'Structured info', defaults: () => ({ title: 'Feature Matrix', headers: 'Feature|Status|Notes', rows: 'Markdown export|Done|Downloads a .md file\nJSON config|Done|Export and import layouts\nDrag and drop|Planned|Could be added later' }) },
details: { label: 'Details', hint: 'Collapsible section', defaults: () => ({ summary: 'See more', body: 'Put extra notes, setup instructions, or FAQ content here.' }) },
code: { label: 'Code Block', hint: 'Snippet or shell command', defaults: () => ({ title: 'Install', language: 'bash', body: 'npm install\nnpm run dev' }) },
image: { label: 'Image', hint: 'Screenshot or banner', defaults: () => ({ alt: 'Project screenshot', url: 'https://placehold.co/1200x700/png', title: 'Preview' }) },
quote: { label: 'Quote', hint: 'Callout or note', defaults: () => ({ body: 'Built for people who want GitHub pages that feel useful, clear, and intentional.' }) },
buttons: { label: 'Buttons', hint: 'Badge-style links', defaults: () => ({ items: 'Star Repo|https://github.com/owner/repo|https://img.shields.io/badge/Star-Repo-ff69b4?style=for-the-badge\nLive Demo|https://example.com|https://img.shields.io/badge/Live-Demo-111827?style=for-the-badge' }) },
divider: { label: 'Divider', hint: 'Horizontal rule', defaults: () => ({}) },
custom: { label: 'Custom Markdown', hint: 'Paste your own block', defaults: () => ({ body: '## Custom Section\n\nAdd any markdown here.' }) }
};
const state = {
docName: 'README.md',
docTitle: 'GitHub Dashboard',
blocks: [],
expandedBlockId: null,
sidebarExpandedSection: null,
previewMarkdownExpanded: false
};
const blocksList = document.getElementById('blocksList');
const markdownOutput = document.getElementById('markdownOutput');
const renderedPreview = document.getElementById('renderedPreview');
const addBlockButtons = document.getElementById('addBlockButtons');
const docNameInput = document.getElementById('docName');
const docTitleInput = document.getElementById('docTitle');
const jsonInput = document.getElementById('jsonInput');
function uid() {
return Math.random().toString(36).slice(2, 10);
}
function escapeHtml(value) {
return String(value || '')
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"');
}
/** Only http(s) URLs in preview to avoid javascript: / data: surprises. */
function isSafeHttpUrl(s) {
const u = String(s || '').trim();
if (!/^https?:\/\//i.test(u)) return false;
try {
const parsed = new URL(u);
return parsed.protocol === 'http:' || parsed.protocol === 'https:';
} catch {
return false;
}
}
/** http(s), same-document #fragments, and simple mailto: links for preview. */
function isSafeLinkHref(href) {
const u = String(href || '').trim();
if (!u) return false;
if (isSafeHttpUrl(u)) return true;
if (u.startsWith('#')) {
if (u.length < 2) return false;
if (/javascript:/i.test(u) || /data:/i.test(u)) return false;
return /^#[^\s#"'<>`]+$/i.test(u);
}
if (/^mailto:/i.test(u)) {
const rest = u.slice(7).trim();
return rest.includes('@') && !/[\s"'<>()]/.test(rest);
}
return false;
}
/**
* Turn inline markdown [label](href) into <a>; escapes all other text.
* Skips image syntax  via negative lookbehind.
*/
function renderInlineMarkdownLinks(text) {
const s = String(text || '');
const re = /(?<!!)\[([^\]]+)\]\(([^)]+)\)/g;
let out = '';
let last = 0;
let m;
while ((m = re.exec(s)) !== null) {
out += escapeHtml(s.slice(last, m.index));
const label = m[1];
const href = m[2];
if (isSafeLinkHref(href)) {
const ht = href.trim();
const isFrag = ht.startsWith('#');
const rel = isFrag ? '' : ' rel="noopener noreferrer"';
const tgt = isFrag ? '' : ' target="_blank"';
out += `<a href="${escapeHtml(ht)}"${tgt}${rel}>${escapeHtml(label)}</a>`;
} else {
out += escapeHtml(m[0]);
}
last = m.index + m[0].length;
}
out += escapeHtml(s.slice(last));
return out;
}
/** Light cleanup before injecting HTML preview fragments (details, etc.). */
function stripUnsafeHtmlFragment(html) {
return String(html || '')
.replace(/<script\b[\s\S]*?<\/script>/gi, '')
.replace(/\s(on\w+)\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, ' ');
}
/**
* Our generator emits <details><summary>…</summary> then plain body lines; linkify body for preview.
* Unknown shapes are returned unchanged (after stripUnsafeHtmlFragment).
*/
function processDetailsChunkForPreview(html) {
const stripped = stripUnsafeHtmlFragment(String(html || ''));
const m = stripped.match(/^<details([^>]*)>\s*<summary>([\s\S]*?)<\/summary>\s*([\s\S]*?)<\/details>\s*$/i);
if (!m) return stripped;
const attrs = m[1] || '';
const summaryInner = m[2];
const body = m[3].replace(/\s+$/, '');
const paras = [];
for (const line of body.split('\n')) {
if (!line.trim()) continue;
paras.push('<p>' + renderInlineMarkdownLinks(line) + '</p>');
}
return `<details${attrs}>\n<summary>${summaryInner}</summary>\n${paras.join('\n')}\n</details>`;
}
/**
* Renders list text after "- " for preview: task items, markdown links, or plain text.
*/
function renderListItemBody(raw) {
const t = String(raw || '');
const task = t.match(/^\[([xX ])\]\s*(.+)$/);
if (task) {
const done = String(task[1]).trim().toLowerCase() === 'x';
return `<span class="md-task">${done ? '☑' : '☐'}</span> ${renderInlineMarkdownLinks(task[2])}`;
}
const link = t.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
if (link && isSafeLinkHref(link[2])) {
const ht = link[2].trim();
const isFrag = ht.startsWith('#');
const rel = isFrag ? '' : ' rel="noopener noreferrer"';
const tgt = isFrag ? '' : ' target="_blank"';
return `<a href="${escapeHtml(ht)}"${tgt}${rel}>${escapeHtml(link[1])}</a>`;
}
return renderInlineMarkdownLinks(t);
}
/**
* GitHub-style shield / markdown button: [](href)
*/
function renderLinkedImageLine(trimmed) {
const m = trimmed.match(/^\[!\[([^\]]*)\]\(([^)]+)\)\]\(([^)]+)\)$/);
if (!m || !isSafeHttpUrl(m[2]) || !isSafeHttpUrl(m[3])) return null;
const alt = m[1];
const imgSrc = m[2];
const href = m[3];
return `<div class="md-button-row"><a href="${escapeHtml(href)}" target="_blank" rel="noopener noreferrer"><img src="${escapeHtml(imgSrc)}" alt="${escapeHtml(alt)}" loading="lazy" decoding="async"></a></div>`;
}
function renderStandaloneImageLine(trimmed) {
const m = trimmed.match(/^!\[([^\]]*)\]\(([^)]+)\)$/);
if (!m || !isSafeHttpUrl(m[2])) return null;
return `<p><img src="${escapeHtml(m[2])}" alt="${escapeHtml(m[1])}" loading="lazy" decoding="async" style="max-width:100%;height:auto"></p>`;
}
function slugify(value) {
return String(value || '')
.toLowerCase()
.trim()
.replace(/[^\w\s-]/g, '')
.replace(/\s+/g, '-')
.replace(/-+/g, '-');
}
function splitLines(value) {
return String(value || '').split('\n').map(line => line.trim()).filter(Boolean);
}
function splitPipe(value) {
return String(value || '').split('|').map(part => part.trim());
}
function parsePipeLines(value) {
return splitLines(value).map(splitPipe);
}
function makeBlock(type, overrides = {}) {
return { id: uid(), type, data: { ...BLOCK_TYPES[type].defaults(), ...overrides } };
}
function addBlock(type) {
if (!BLOCK_TYPES[type]) return;
const block = makeBlock(type);
state.blocks.push(block);
state.expandedBlockId = block.id;
render();
}
function removeBlock(id) {
const index = state.blocks.findIndex(block => block.id === id);
state.blocks = state.blocks.filter(block => block.id !== id);
if (state.expandedBlockId === id) {
const next = state.blocks[index] || state.blocks[index - 1];
state.expandedBlockId = next ? next.id : null;
}
render();
}
function moveBlock(id, direction) {
const index = state.blocks.findIndex(block => block.id === id);
if (index === -1) return;
const nextIndex = direction === 'up' ? index - 1 : index + 1;
if (nextIndex < 0 || nextIndex >= state.blocks.length) return;
const copy = state.blocks.slice();
[copy[index], copy[nextIndex]] = [copy[nextIndex], copy[index]];
state.blocks = copy;
render();
}
function updateBlock(id, key, value) {
const block = state.blocks.find(item => item.id === id);
if (!block) return;
block.data[key] = value;
renderMarkdownOnly();
saveState();
}
function saveState() {
localStorage.setItem(
'github-dashboard-builder-state-v2',
JSON.stringify({
docName: state.docName,
docTitle: state.docTitle,
blocks: state.blocks,
expandedBlockId: state.expandedBlockId,
sidebarExpandedSection: state.sidebarExpandedSection,
previewMarkdownExpanded: state.previewMarkdownExpanded
})
);
}