-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathnew.html
More file actions
662 lines (582 loc) · 34.2 KB
/
Copy pathnew.html
File metadata and controls
662 lines (582 loc) · 34.2 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>New Contribution Wizard — One File Tools</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=Oxanium:wght@500;600;700;800&family=Nunito:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" />
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; line-height: 1.6; background: #fafafa; color: #1a1a1a; min-height: 100vh; -webkit-font-smoothing: antialiased; }
@media (prefers-color-scheme: dark) { body { background: #0a0a0a; color: #e5e5e5; } }
.container { max-width: 720px; margin: 0 auto; padding: 2rem 1.5rem; }
header { text-align: center; margin-bottom: 2.5rem; }
header h1 { font-family: "Oxanium", sans-serif; font-size: 1.75rem; font-weight: 700; margin-bottom: 0.25rem; }
header p { color: #6b7280; font-size: 0.875rem; }
@media (prefers-color-scheme: dark) { header p { color: #9ca3af; } }
.progress { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-bottom: 2rem; }
.progress-dot { width: 10px; height: 10px; border-radius: 50%; background: #d1d5db; transition: all 0.3s; }
@media (prefers-color-scheme: dark) { .progress-dot { background: #374151; } }
.progress-dot.active { background: #4f46e5; transform: scale(1.3); }
.progress-dot.done { background: #10b981; }
.progress-line { width: 40px; height: 2px; background: #d1d5db; }
@media (prefers-color-scheme: dark) { .progress-line { background: #374151; } }
.progress-line.done { background: #10b981; }
.step { display: none; animation: fadeIn 0.3s ease; }
.step.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.step-title { font-family: "Oxanium", sans-serif; font-size: 1.125rem; font-weight: 600; margin-bottom: 0.5rem; }
.step-desc { color: #6b7280; font-size: 0.875rem; margin-bottom: 1.5rem; }
@media (prefers-color-scheme: dark) { .step-desc { color: #9ca3af; } }
.pillar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.pillar-card { padding: 1rem; border: 2px solid #e5e7eb; border-radius: 12px; cursor: pointer; transition: all 0.2s; background: #fff; text-align: center; }
@media (prefers-color-scheme: dark) { .pillar-card { background: #111; border-color: #1f2937; } }
.pillar-card:hover { border-color: #a5b4fc; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.pillar-card.selected { border-color: #4f46e5; background: #eef2ff; }
@media (prefers-color-scheme: dark) { .pillar-card.selected { background: #1e1b4b; border-color: #6366f1; } }
.pillar-card .icon { font-size: 1.75rem; margin-bottom: 0.5rem; }
.pillar-card .name { font-weight: 600; font-size: 0.875rem; }
.pillar-card .desc { font-size: 0.75rem; color: #6b7280; margin-top: 0.25rem; }
@media (prefers-color-scheme: dark) { .pillar-card .desc { color: #9ca3af; } }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.8125rem; font-weight: 600; margin-bottom: 0.375rem; color: #374151; }
@media (prefers-color-scheme: dark) { .form-group label { color: #d1d5db; } }
.form-group .hint { font-size: 0.75rem; color: #9ca3af; margin-top: 0.25rem; }
input[type="text"], textarea, select {
width: 100%; padding: 0.625rem 0.75rem; border: 1.5px solid #d1d5db; border-radius: 8px;
font-family: "Nunito", sans-serif; font-size: 0.875rem; background: #fff; color: #1a1a1a; transition: border-color 0.2s;
}
@media (prefers-color-scheme: dark) { input[type="text"], textarea, select { background: #111; color: #e5e5e5; border-color: #374151; } }
input[type="text"]:focus, textarea:focus, select:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
textarea { resize: vertical; min-height: 80px; }
.tag-input-wrap { display: flex; flex-wrap: wrap; gap: 0.375rem; padding: 0.5rem; border: 1.5px solid #d1d5db; border-radius: 8px; background: #fff; min-height: 42px; cursor: text; }
@media (prefers-color-scheme: dark) { .tag-input-wrap { background: #111; border-color: #374151; } }
.tag-input-wrap:focus-within { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.tag-input-wrap input { border: none; outline: none; background: transparent; font-size: 0.875rem; flex: 1; min-width: 80px; padding: 0.125rem; color: inherit; font-family: "Nunito", sans-serif; }
.tag { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.125rem 0.5rem; background: #eef2ff; color: #4338ca; border-radius: 999px; font-size: 0.75rem; font-weight: 500; }
@media (prefers-color-scheme: dark) { .tag { background: #1e1b4b; color: #a5b4fc; } }
.tag button { background: none; border: none; cursor: pointer; font-size: 0.875rem; line-height: 1; color: inherit; padding: 0; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.5rem; }
.cat-option { padding: 0.5rem 0.75rem; border: 1.5px solid #e5e7eb; border-radius: 8px; cursor: pointer; text-align: center; font-size: 0.8125rem; font-weight: 500; transition: all 0.2s; background: #fff; }
@media (prefers-color-scheme: dark) { .cat-option { background: #111; border-color: #1f2937; } }
.cat-option:hover { border-color: #a5b4fc; }
.cat-option.selected { border-color: #4f46e5; background: #eef2ff; color: #4338ca; }
@media (prefers-color-scheme: dark) { .cat-option.selected { background: #1e1b4b; border-color: #6366f1; color: #a5b4fc; } }
.diff-options { display: flex; gap: 0.5rem; }
.diff-option { flex: 1; padding: 0.5rem; border: 1.5px solid #e5e7eb; border-radius: 8px; cursor: pointer; text-align: center; font-size: 0.8125rem; font-weight: 500; transition: all 0.2s; background: #fff; }
@media (prefers-color-scheme: dark) { .diff-option { background: #111; border-color: #1f2937; } }
.diff-option.selected { border-color: #4f46e5; background: #eef2ff; color: #4338ca; }
@media (prefers-color-scheme: dark) { .diff-option.selected { background: #1e1b4b; border-color: #6366f1; color: #a5b4fc; } }
.btn-row { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 2rem; }
.btn { padding: 0.625rem 1.5rem; border-radius: 8px; font-family: "Nunito", sans-serif; font-size: 0.875rem; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; }
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-primary:disabled { background: #a5b4fc; cursor: not-allowed; }
.btn-secondary { background: #e5e7eb; color: #374151; }
@media (prefers-color-scheme: dark) { .btn-secondary { background: #1f2937; color: #d1d5db; } }
.btn-secondary:hover { background: #d1d5db; }
@media (prefers-color-scheme: dark) { .btn-secondary:hover { background: #374151; } }
.output-section { margin-bottom: 1.5rem; }
.output-section h3 { font-family: "Oxanium", sans-serif; font-size: 0.9375rem; font-weight: 600; margin-bottom: 0.25rem; display: flex; align-items: center; gap: 0.5rem; }
.output-section h3 .num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: #4f46e5; color: #fff; font-size: 0.75rem; font-weight: 700; }
.output-section .sub { font-size: 0.8125rem; color: #6b7280; margin-bottom: 0.75rem; }
@media (prefers-color-scheme: dark) { .output-section .sub { color: #9ca3af; } }
.code-block { position: relative; background: #1e1b4b; color: #e0e7ff; padding: 1rem; border-radius: 8px; font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8125rem; line-height: 1.7; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.code-block .copy-btn { position: absolute; top: 0.5rem; right: 0.5rem; padding: 0.25rem 0.625rem; border-radius: 6px; border: 1px solid #312e81; background: #312e81; color: #c7d2fe; font-size: 0.6875rem; font-weight: 600; cursor: pointer; font-family: "Nunito", sans-serif; transition: all 0.2s; }
.code-block .copy-btn:hover { background: #3730a3; }
.code-block .copy-btn.copied { background: #065f46; border-color: #065f46; color: #a7f3d0; }
.file-path { display: inline-block; padding: 0.125rem 0.5rem; background: #f3f4f6; border-radius: 4px; font-family: "JetBrains Mono", monospace; font-size: 0.8125rem; }
@media (prefers-color-scheme: dark) { .file-path { background: #1f2937; } }
.checklist { list-style: none; padding: 0; }
.checklist li { padding: 0.375rem 0; font-size: 0.875rem; display: flex; align-items: flex-start; gap: 0.5rem; }
.checklist li::before { content: "☐"; flex-shrink: 0; }
.restart-link { display: inline-block; margin-top: 1.5rem; color: #4f46e5; font-size: 0.875rem; font-weight: 500; cursor: pointer; border: none; background: none; font-family: "Nunito", sans-serif; text-decoration: underline; }
@media (prefers-color-scheme: dark) { .restart-link { color: #818cf8; } }
footer { text-align: center; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid #e5e7eb; font-size: 0.75rem; color: #9ca3af; }
@media (prefers-color-scheme: dark) { footer { border-color: #1f2937; } }
footer a { color: #4f46e5; text-decoration: none; }
@media (prefers-color-scheme: dark) { footer a { color: #818cf8; } }
</style>
</head>
<body>
<div class="container">
<header>
<h1>New Contribution</h1>
<p>Interactive wizard to guide you through contributing to One File Tools</p>
</header>
<div class="progress" id="progress">
<div class="progress-dot active" data-step="1"></div>
<div class="progress-line"></div>
<div class="progress-dot" data-step="2"></div>
<div class="progress-line"></div>
<div class="progress-dot" data-step="3"></div>
</div>
<!-- Step 1: Choose Pillar -->
<div class="step active" id="step1">
<h2 class="step-title">What do you want to contribute?</h2>
<p class="step-desc">Choose the type of contribution you'd like to make.</p>
<div class="pillar-grid" id="pillarGrid">
<div class="pillar-card" data-pillar="tool" onclick="selectPillar('tool')">
<div class="icon">🔧</div>
<div class="name">Tool</div>
<div class="desc">A useful developer utility</div>
</div>
<div class="pillar-card" data-pillar="quest" onclick="selectPillar('quest')">
<div class="icon">⚔️</div>
<div class="name">Quest</div>
<div class="desc">An interactive coding challenge</div>
</div>
<div class="pillar-card" data-pillar="quiz" onclick="selectPillar('quiz')">
<div class="icon">❓</div>
<div class="name">Quiz</div>
<div class="desc">A knowledge quiz</div>
</div>
<div class="pillar-card" data-pillar="design-system" onclick="selectPillar('design-system')">
<div class="icon">🎨</div>
<div class="name">Design System</div>
<div class="desc">A premium UI showcase</div>
</div>
<div class="pillar-card" data-pillar="resume" onclick="selectPillar('resume')">
<div class="icon">📄</div>
<div class="name">Resume Theme</div>
<div class="desc">A Handlebars resume template</div>
</div>
<div class="pillar-card" data-pillar="portfolio" onclick="selectPillar('portfolio')">
<div class="icon">💼</div>
<div class="name">Portfolio Theme</div>
<div class="desc">A Handlebars portfolio template</div>
</div>
</div>
<div class="btn-row">
<button class="btn btn-primary" id="step1Next" disabled onclick="goToStep(2)">Next</button>
</div>
</div>
<!-- Step 2: Fill Details -->
<div class="step" id="step2">
<h2 class="step-title">Fill in your details</h2>
<p class="step-desc" id="step2Desc">Provide information about your contribution.</p>
<div id="formFields"></div>
<div class="btn-row">
<button class="btn btn-secondary" onclick="goToStep(1)">Back</button>
<button class="btn btn-primary" id="step2Next" onclick="goToStep(3)">Generate Instructions</button>
</div>
</div>
<!-- Step 3: Generated Output -->
<div class="step" id="step3">
<h2 class="step-title">Your Contribution Guide</h2>
<p class="step-desc">Follow these steps exactly. Use the copy buttons to grab code snippets.</p>
<div id="outputContent"></div>
<button class="restart-link" onclick="restart()">Start over with a new contribution</button>
</div>
<footer>
Part of <a href="https://github.com/praveenscience/One-File-Tools">One File Tools</a>
</footer>
</div>
<script>
const PILLARS = {
tool: {
label: "Tool",
folder: "tools",
dataFile: "data/tools.json",
arrayKey: "tools",
ext: ".html",
categories: [
{ id: "accessibility", name: "Accessibility" },
{ id: "browser-network", name: "Browser & Network" },
{ id: "color", name: "Color" },
{ id: "css", name: "CSS" },
{ id: "utilities", name: "Utilities" },
{ id: "image", name: "Image" },
{ id: "json-api", name: "JSON & API" },
{ id: "text", name: "Text" },
{ id: "web-seo", name: "Web & SEO" }
],
fields: ["name", "shortDescription", "longDescription", "category", "tags", "techStack", "difficulty"],
branchPrefix: "add"
},
quest: {
label: "Quest",
folder: "quests",
dataFile: "data/quests.json",
arrayKey: "quests",
ext: ".html",
categories: [
{ id: "css-fundamentals", name: "CSS Fundamentals" },
{ id: "general-dev-quests", name: "General Dev Quests" },
{ id: "git", name: "Git" },
{ id: "js-fundamentals", name: "JS Fundamentals" }
],
fields: ["name", "shortDescription", "longDescription", "category", "tags", "techStack", "difficulty"],
branchPrefix: "add"
},
quiz: {
label: "Quiz",
folder: "quizzes",
dataFile: "data/quizzes.json",
arrayKey: "quizzes",
ext: ".html",
categories: [
{ id: "css-fundamentals", name: "CSS Fundamentals" },
{ id: "general-dev-quests", name: "General Dev Quests" },
{ id: "git", name: "Git" },
{ id: "js-fundamentals", name: "JS Fundamentals" }
],
fields: ["name", "shortDescription", "longDescription", "category", "tags", "techStack", "difficulty"],
branchPrefix: "add"
},
"design-system": {
label: "Design System",
folder: "design-system",
dataFile: "data/design-system.json",
arrayKey: "designs",
ext: ".html",
categories: [
{ id: "components", name: "Components" },
{ id: "dashboards", name: "Dashboards" },
{ id: "e-commerce", name: "E-Commerce" },
{ id: "landing-pages", name: "Landing Pages" },
{ id: "portfolios", name: "Portfolios" },
{ id: "social", name: "Social" }
],
fields: ["name", "shortDescription", "longDescription", "category", "tags", "techStack", "frameworks", "difficulty"],
branchPrefix: "add"
},
resume: {
label: "Resume Theme",
folder: "resume",
dataFile: "data/themes.json",
arrayKey: "resume",
ext: ".hbs",
categories: [],
fields: ["name", "description"],
branchPrefix: "add/resume-theme"
},
portfolio: {
label: "Portfolio Theme",
folder: "portfolio",
dataFile: "data/themes.json",
arrayKey: "portfolio",
ext: ".hbs",
categories: [],
fields: ["name", "description"],
branchPrefix: "add/portfolio-theme"
}
};
let selectedPillar = null;
let formData = {};
function selectPillar(pillar) {
selectedPillar = pillar;
document.querySelectorAll(".pillar-card").forEach((c) => c.classList.remove("selected"));
document.querySelector('[data-pillar="' + pillar + '"]').classList.add("selected");
document.getElementById("step1Next").disabled = false;
}
function goToStep(n) {
if (n === 2) buildForm();
if (n === 3) {
collectFormData();
buildOutput();
}
document.querySelectorAll(".step").forEach((s) => s.classList.remove("active"));
document.getElementById("step" + n).classList.add("active");
const dots = document.querySelectorAll(".progress-dot");
const lines = document.querySelectorAll(".progress-line");
dots.forEach((d, i) => {
d.classList.remove("active", "done");
if (i + 1 === n) d.classList.add("active");
else if (i + 1 < n) d.classList.add("done");
});
lines.forEach((l, i) => {
l.classList.remove("done");
if (i + 1 < n) l.classList.add("done");
});
window.scrollTo({ top: 0, behavior: "smooth" });
}
function toKebab(str) {
return str.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
}
function buildForm() {
const p = PILLARS[selectedPillar];
const desc = document.getElementById("step2Desc");
desc.textContent = "Fill in the details for your " + p.label.toLowerCase() + ".";
let html = "";
html += '<div class="form-group"><label>Name *</label>';
html += '<input type="text" id="f_name" placeholder="e.g. JSON Formatter" />';
html += '<div class="hint">Human-readable display name for your ' + p.label.toLowerCase() + '</div></div>';
if (p.fields.includes("shortDescription")) {
html += '<div class="form-group"><label>Short Description *</label>';
html += '<input type="text" id="f_shortDesc" placeholder="One sentence — shown on the card" />';
html += '<div class="hint">Keep it under 100 characters</div></div>';
}
if (p.fields.includes("description")) {
html += '<div class="form-group"><label>Description *</label>';
html += '<input type="text" id="f_themeDesc" placeholder="Brief description of your theme\'s style" /></div>';
}
if (p.fields.includes("longDescription")) {
html += '<div class="form-group"><label>Long Description *</label>';
html += '<textarea id="f_longDesc" placeholder="Detailed description with features. Markdown supported.\n\n## My Tool\n\nA longer description.\n\n### Features\n\n- Feature 1\n- Feature 2"></textarea>';
html += '<div class="hint">Shown in the detail modal. Use Markdown (## headings, - lists).</div></div>';
}
if (p.categories.length > 0) {
html += '<div class="form-group"><label>Category *</label>';
html += '<div class="cat-grid" id="catGrid">';
p.categories.forEach((c) => {
html += '<div class="cat-option" data-cat="' + c.id + '" onclick="selectCategory(\'' + c.id + '\')">' + c.name + "</div>";
});
html += "</div></div>";
}
if (p.fields.includes("tags")) {
html += '<div class="form-group"><label>Tags</label>';
html += '<div class="tag-input-wrap" id="tagWrap" onclick="document.getElementById(\'f_tagInput\').focus()">';
html += '<input type="text" id="f_tagInput" placeholder="Type and press Enter" /></div>';
html += '<div class="hint">Lowercase keywords for search. Press Enter or comma to add.</div></div>';
}
if (p.fields.includes("techStack")) {
html += '<div class="form-group"><label>Tech Stack</label>';
html += '<div class="tag-input-wrap" id="techWrap" onclick="document.getElementById(\'f_techInput\').focus()">';
html += '<input type="text" id="f_techInput" placeholder="e.g. HTML5, CSS3, JavaScript" /></div>';
html += '<div class="hint">Technologies used. Press Enter or comma to add.</div></div>';
}
if (p.fields.includes("frameworks")) {
html += '<div class="form-group"><label>Frameworks (CDN)</label>';
html += '<div class="tag-input-wrap" id="fwWrap" onclick="document.getElementById(\'f_fwInput\').focus()">';
html += '<input type="text" id="f_fwInput" placeholder="e.g. Tailwind CSS, Chart.js" /></div>';
html += '<div class="hint">CSS/JS frameworks loaded via CDN. Displayed as badges.</div></div>';
}
if (p.fields.includes("difficulty")) {
html += '<div class="form-group"><label>Difficulty *</label>';
html += '<div class="diff-options">';
html += '<div class="diff-option" data-diff="Easy" onclick="selectDifficulty(\'Easy\')">Easy</div>';
html += '<div class="diff-option" data-diff="Medium" onclick="selectDifficulty(\'Medium\')">Medium</div>';
html += '<div class="diff-option" data-diff="Hard" onclick="selectDifficulty(\'Hard\')">Hard</div>';
html += "</div></div>";
}
document.getElementById("formFields").innerHTML = html;
if (document.getElementById("f_tagInput")) setupTagInput("f_tagInput", "tagWrap");
if (document.getElementById("f_techInput")) setupTagInput("f_techInput", "techWrap");
if (document.getElementById("f_fwInput")) setupTagInput("f_fwInput", "fwWrap");
}
let tags = [], techStack = [], frameworks = [];
function setupTagInput(inputId, wrapId) {
const input = document.getElementById(inputId);
const wrap = document.getElementById(wrapId);
let arr;
if (inputId === "f_tagInput") arr = tags = [];
else if (inputId === "f_techInput") arr = techStack = [];
else arr = frameworks = [];
input.addEventListener("keydown", function (e) {
if (e.key === "Enter" || e.key === ",") {
e.preventDefault();
const val = input.value.trim().replace(/,/g, "");
if (val && !arr.includes(val.toLowerCase())) {
const display = inputId === "f_tagInput" ? val.toLowerCase() : val;
arr.push(display);
const tag = document.createElement("span");
tag.className = "tag";
tag.innerHTML = display + ' <button onclick="removeTag(this, \'' + inputId + '\')">×</button>';
wrap.insertBefore(tag, input);
}
input.value = "";
}
if (e.key === "Backspace" && !input.value && arr.length) {
arr.pop();
const lastTag = wrap.querySelectorAll(".tag");
if (lastTag.length) lastTag[lastTag.length - 1].remove();
}
});
}
function removeTag(btn, inputId) {
const text = btn.parentElement.textContent.slice(0, -1).trim();
let arr;
if (inputId === "f_tagInput") arr = tags;
else if (inputId === "f_techInput") arr = techStack;
else arr = frameworks;
const idx = arr.indexOf(text);
if (idx > -1) arr.splice(idx, 1);
btn.parentElement.remove();
}
let selectedCategory = null, selectedDifficulty = null;
function selectCategory(cat) {
selectedCategory = cat;
document.querySelectorAll(".cat-option").forEach((c) => c.classList.remove("selected"));
document.querySelector('[data-cat="' + cat + '"]').classList.add("selected");
}
function selectDifficulty(diff) {
selectedDifficulty = diff;
document.querySelectorAll(".diff-option").forEach((d) => d.classList.remove("selected"));
document.querySelector('[data-diff="' + diff + '"]').classList.add("selected");
}
function collectFormData() {
const nameEl = document.getElementById("f_name");
formData.name = nameEl ? nameEl.value.trim() : "";
formData.id = toKebab(formData.name);
const shortEl = document.getElementById("f_shortDesc");
formData.shortDescription = shortEl ? shortEl.value.trim() : "";
const longEl = document.getElementById("f_longDesc");
formData.longDescription = longEl ? longEl.value.trim() : "";
const themeDescEl = document.getElementById("f_themeDesc");
formData.description = themeDescEl ? themeDescEl.value.trim() : "";
formData.category = selectedCategory || "";
formData.tags = [...tags];
formData.techStack = [...techStack];
formData.frameworks = [...frameworks];
formData.difficulty = selectedDifficulty || "Easy";
}
function esc(s) {
const d = document.createElement("div");
d.textContent = s;
return d.innerHTML;
}
function buildOutput() {
const p = PILLARS[selectedPillar];
const id = formData.id;
const folder = p.folder;
const filename = id + p.ext;
const filepath = folder + "/" + filename;
const screenshotPath = folder + "/" + id + ".png";
const isTheme = selectedPillar === "resume" || selectedPillar === "portfolio";
const branchName = isTheme ? p.branchPrefix + "-" + id : p.branchPrefix + "/" + id;
let jsonEntry;
if (isTheme) {
jsonEntry = JSON.stringify({ id: id, name: formData.name, description: formData.description, author: "YOUR NAME" }, null, 2);
} else {
const obj = {
id: id,
name: formData.name,
shortDescription: formData.shortDescription,
longDescription: formData.longDescription.replace(/\n/g, "\\n"),
category: formData.category,
tags: formData.tags.sort(),
techStack: formData.techStack.sort(),
difficulty: formData.difficulty,
status: "live"
};
if (p.fields.includes("frameworks") && formData.frameworks.length) {
obj.frameworks = formData.frameworks.sort();
}
jsonEntry = JSON.stringify(obj, null, 2);
}
const longDescEsc = formData.longDescription.replace(/\n/g, "\\n");
const jsonEntryDisplay = isTheme ? jsonEntry : JSON.stringify(JSON.parse(jsonEntry.replace(/\\n/g, "\n")), null, 2).replace(/\n/g, "\n");
let issueBody = "## Description\\n\\n" + formData.shortDescription + "\\n\\n### Features\\n\\n" + formData.longDescription;
let issueTitle = "Add: " + formData.name + " (" + p.label + ")";
let sortCmd = "node scripts/sort-norm.js " + p.dataFile;
let buildCmd = "node scripts/build.js";
let formatCmd = "npm run format";
let html = "";
html += '<div class="output-section">';
html += '<h3><span class="num">1</span> Create a GitHub Issue</h3>';
html += '<div class="sub">Go to <a href="https://github.com/praveenscience/One-File-Tools/issues/new" target="_blank" style="color:#4f46e5">Issues → New Issue</a> and paste this:</div>';
html += '<div class="code-block"><button class="copy-btn" onclick="copyBlock(this)">Copy</button>';
html += "Title: " + esc(issueTitle) + "\n\n";
html += "## Description\n\n" + esc(formData.shortDescription || formData.description) + "\n\n";
if (!isTheme) {
html += "### Category\n\n`" + esc(formData.category) + "`\n\n";
html += "### Difficulty\n\n" + esc(formData.difficulty) + "\n\n";
if (formData.techStack.length) html += "### Tech Stack\n\n" + formData.techStack.map((t) => "- " + esc(t)).join("\n") + "\n\n";
}
if (formData.longDescription) html += "### Details\n\n" + esc(formData.longDescription);
html += "</div></div>";
html += '<div class="output-section">';
html += '<h3><span class="num">2</span> Fork, Clone & Branch</h3>';
html += '<div class="sub">Fork the repo on GitHub, then run these commands:</div>';
html += '<div class="code-block"><button class="copy-btn" onclick="copyBlock(this)">Copy</button>';
html += "git clone https://github.com/YOUR-USERNAME/One-File-Tools.git\ncd One-File-Tools\nnpm install\ngit checkout -b " + esc(branchName);
html += "</div></div>";
html += '<div class="output-section">';
html += '<h3><span class="num">3</span> Create Your File</h3>';
html += '<div class="sub">Create <span class="file-path">' + esc(filepath) + "</span> and build your " + p.label.toLowerCase() + ".</div>";
html += '<div class="code-block"><button class="copy-btn" onclick="copyBlock(this)">Copy</button>';
html += "touch " + esc(filepath);
html += "</div></div>";
html += '<div class="output-section">';
html += '<h3><span class="num">4</span> Add JSON Entry</h3>';
html += '<div class="sub">Open <span class="file-path">' + esc(p.dataFile) + '</span> and add this inside the <code>"' + p.arrayKey + '"</code> array:</div>';
html += '<div class="code-block"><button class="copy-btn" onclick="copyBlock(this)">Copy</button>';
html += esc(jsonEntryDisplay);
html += "</div></div>";
if (!isTheme) {
html += '<div class="output-section">';
html += '<h3><span class="num">5</span> Add a Screenshot</h3>';
html += '<div class="sub">Take a screenshot (1280×720 recommended) and save as <span class="file-path">' + esc(screenshotPath) + "</span></div>";
html += "</div>";
}
const stepOffset = isTheme ? 4 : 5;
html += '<div class="output-section">';
html += '<h3><span class="num">' + (stepOffset + 1) + "</span> Sort, Build & Format</h3>";
html += '<div class="sub">Run these commands to normalize and verify:</div>';
html += '<div class="code-block"><button class="copy-btn" onclick="copyBlock(this)">Copy</button>';
if (isTheme) {
html += "node scripts/theme-gen.js\n" + formatCmd;
} else {
html += sortCmd + "\n" + buildCmd + "\n" + formatCmd;
}
html += "</div></div>";
html += '<div class="output-section">';
html += '<h3><span class="num">' + (stepOffset + 2) + "</span> Commit & Push</h3>";
html += '<div class="sub">Stage your files and push:</div>';
html += '<div class="code-block"><button class="copy-btn" onclick="copyBlock(this)">Copy</button>';
if (isTheme) {
html += "git add " + esc(filepath) + " " + esc(screenshotPath) + " " + esc(p.dataFile) + '\ngit commit -m "Add: ' + esc(id) + '"\ngit push origin ' + esc(branchName);
} else {
html += "git add " + esc(filepath) + " " + esc(screenshotPath) + " " + esc(p.dataFile) + '\ngit commit -m "Add: ' + esc(id) + '"\ngit push origin ' + esc(branchName);
}
html += "</div></div>";
html += '<div class="output-section">';
html += '<h3><span class="num">' + (stepOffset + 3) + "</span> Open a Pull Request</h3>";
html += "<div class=\"sub\">Go to your fork on GitHub and click <strong>Compare & pull request</strong>.</div>";
html += '<div class="code-block"><button class="copy-btn" onclick="copyBlock(this)">Copy</button>';
html += "PR Title: Add: " + esc(id) + "\n\n";
html += "## What\n\n" + esc(formData.shortDescription || formData.description) + "\n\nCloses #ISSUE_NUMBER\n\n";
html += "## Type of Change\n\n- [x] New " + p.label + "\n\n";
html += "## Checklist\n\n";
if (isTheme) {
html += "- [x] Single `.hbs` template file\n- [x] Screenshot added\n- [x] Registered in data/themes.json\n- [x] Tested with `node scripts/theme-gen.js`";
} else {
html += "- [x] Single `.html` file\n- [x] Works by opening in browser\n- [x] No console errors\n- [x] Responsive design\n- [x] Screenshot added\n- [x] Registered in " + esc(p.dataFile) + "\n- [x] Ran sort-norm and build scripts";
}
html += "</div></div>";
html += '<div class="output-section">';
html += '<h3>Pre-submission Checklist</h3>';
html += '<ul class="checklist">';
html += "<li>File opens correctly in Chrome and Firefox</li>";
html += "<li>Responsive on mobile (use browser DevTools)</li>";
html += "<li>No console errors or warnings</li>";
if (!isTheme) {
html += "<li>Dark mode works (at minimum via prefers-color-scheme)</li>";
html += "<li>Screenshot accurately represents the " + p.label.toLowerCase() + "</li>";
html += "<li>JSON entry has all required fields</li>";
}
html += "<li>Code is formatted with Prettier</li>";
html += "<li>Branch name follows convention: <code>" + esc(branchName) + "</code></li>";
html += "</ul></div>";
document.getElementById("outputContent").innerHTML = html;
}
function copyBlock(btn) {
const block = btn.parentElement;
const text = block.textContent.replace("Copy", "").replace("Copied!", "").trim();
navigator.clipboard.writeText(text).then(() => {
btn.textContent = "Copied!";
btn.classList.add("copied");
setTimeout(() => {
btn.textContent = "Copy";
btn.classList.remove("copied");
}, 2000);
});
}
function restart() {
selectedPillar = null;
selectedCategory = null;
selectedDifficulty = null;
formData = {};
tags = [];
techStack = [];
frameworks = [];
document.querySelectorAll(".pillar-card").forEach((c) => c.classList.remove("selected"));
document.getElementById("step1Next").disabled = true;
goToStep(1);
}
</script>
</body>
</html>