-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgithub-button-generator.html
More file actions
848 lines (744 loc) · 25.4 KB
/
github-button-generator.html
File metadata and controls
848 lines (744 loc) · 25.4 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GitHub Button Generator</title>
<style>
html { -webkit-text-size-adjust: 100%; }
img, video, canvas, svg { max-width: 100%; height: auto; }
:root {
--bg: #0a0a0f;
--panel: #11111a;
--panel-2: #171723;
--border: #2a2a3a;
--text: #f5f7fb;
--muted: #a4a8b8;
--accent: #ed0d92;
--accent-2: #8a2be2;
--shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
--radius: 22px;
--radius-sm: 14px;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
background:
linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px),
radial-gradient(circle at top, rgba(237, 13, 146, 0.12), transparent 30%),
var(--bg);
background-size: 28px 28px, 28px 28px, auto, auto;
color: var(--text);
min-height: 100vh;
}
.wrap {
max-width: 1300px;
margin: 0 auto;
padding: 32px 20px 48px;
}
.grid {
display: grid;
grid-template-columns: 1.15fr 0.85fr;
gap: 24px;
align-items: start;
}
.card {
background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
overflow: hidden;
backdrop-filter: blur(12px);
}
.card-header {
padding: 24px 24px 0;
}
.card-content {
padding: 24px;
}
.title-row {
display: flex;
justify-content: space-between;
gap: 16px;
align-items: flex-start;
flex-wrap: wrap;
}
h1, h2, h3, p { margin: 0; }
h1 {
font-size: clamp(1.8rem, 3vw, 2.5rem);
line-height: 1.05;
letter-spacing: -0.03em;
margin-bottom: 8px;
}
h2 {
font-size: 1.1rem;
margin-bottom: 8px;
}
.sub {
color: var(--muted);
max-width: 60ch;
line-height: 1.5;
}
.btn,
button,
select,
input,
textarea {
font: inherit;
}
.btn {
border: 1px solid var(--border);
background: var(--panel-2);
color: var(--text);
border-radius: 999px;
padding: 12px 16px;
cursor: pointer;
transition: 0.18s ease;
}
.btn:hover {
transform: translateY(-1px);
border-color: #3b3b52;
background: #1c1c2a;
}
.btn.accent {
background: linear-gradient(135deg, var(--accent), var(--accent-2));
border: none;
}
.layout-stack {
display: grid;
gap: 24px;
}
.form-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
.stack {
display: grid;
gap: 14px;
}
.field {
display: grid;
gap: 8px;
}
.badge-config .field > label {
font-weight: 600;
color: #f1f3fb;
}
label {
font-size: 0.92rem;
color: #ebedf6;
}
.hint {
color: var(--muted);
font-size: 0.83rem;
line-height: 1.45;
}
input, select, textarea {
width: 100%;
border: 1px solid var(--border);
background: #0d0d15;
color: var(--text);
border-radius: var(--radius-sm);
padding: 13px 14px;
outline: none;
transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
input:focus,
select:focus,
textarea:focus {
border-color: rgba(237, 13, 146, 0.8);
box-shadow: 0 0 0 3px rgba(237, 13, 146, 0.15);
}
textarea {
min-height: 130px;
resize: vertical;
font-family: "Cascadia Code", "Consolas", monospace;
font-size: 0.92rem;
line-height: 1.45;
}
.badge-config :is(#style, #color, #logo, #logoColor, #labelColor) {
min-height: 46px;
border-color: #33344a;
background: linear-gradient(180deg, #10101a, #0c0c14);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.badge-config #style {
appearance: none;
-webkit-appearance: none;
background-image:
linear-gradient(45deg, transparent 50%, #c6cad8 50%),
linear-gradient(135deg, #c6cad8 50%, transparent 50%);
background-position:
calc(100% - 20px) calc(50% - 2px),
calc(100% - 14px) calc(50% - 2px);
background-size: 6px 6px, 6px 6px;
background-repeat: no-repeat;
padding-right: 38px;
}
.badge-config :is(#color, #logo, #logoColor, #labelColor) {
font-family: "Cascadia Code", "Consolas", monospace;
font-size: 0.9rem;
}
.badge-config :is(#color, #logoColor, #labelColor)::placeholder {
color: #8c90a5;
letter-spacing: 0.03em;
}
.toggle-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
border: 1px solid var(--border);
background: #0d0d15;
border-radius: var(--radius);
padding: 16px;
}
.toggle {
position: relative;
width: 58px;
height: 34px;
flex: 0 0 auto;
}
.toggle input {
position: absolute;
inset: 0;
opacity: 0;
cursor: pointer;
margin: 0;
}
.slider {
position: absolute;
inset: 0;
background: #2a2a3a;
border-radius: 999px;
transition: 0.18s ease;
}
.slider::before {
content: "";
position: absolute;
width: 26px;
height: 26px;
left: 4px;
top: 4px;
border-radius: 50%;
background: white;
transition: 0.18s ease;
}
.toggle input:checked + .slider {
background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.toggle input:checked + .slider::before {
transform: translateX(24px);
}
.mini-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 14px;
}
.chip-row {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.chip {
border: 1px solid var(--border);
background: #0d0d15;
color: var(--text);
border-radius: 999px;
padding: 10px 14px;
cursor: pointer;
transition: 0.18s ease;
}
.chip:hover {
border-color: #464663;
transform: translateY(-1px);
}
.preview-box,
.code-box {
border: 1px solid var(--border);
background: #0d0d15;
border-radius: var(--radius);
padding: 18px;
}
.preview-box {
min-height: 120px;
display: flex;
align-items: center;
justify-content: center;
overflow-x: auto;
}
.tabs {
display: flex;
gap: 10px;
flex-wrap: wrap;
margin-bottom: 14px;
}
.tab {
border: 1px solid var(--border);
background: #0d0d15;
color: var(--text);
border-radius: 999px;
padding: 10px 14px;
cursor: pointer;
}
.tab.active {
background: linear-gradient(135deg, rgba(237, 13, 146, 0.2), rgba(138, 43, 226, 0.2));
border-color: rgba(237, 13, 146, 0.55);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.copy-row {
display: flex;
gap: 10px;
margin-top: 12px;
flex-wrap: wrap;
}
.example-stack,
.tip-stack {
display: grid;
gap: 14px;
}
.example {
border: 1px solid var(--border);
background: #0d0d15;
border-radius: var(--radius);
padding: 18px;
overflow-x: auto;
}
ul.tips {
margin: 0;
padding-left: 18px;
color: var(--muted);
display: grid;
gap: 10px;
line-height: 1.45;
}
.footer-note {
margin-top: 18px;
color: var(--muted);
font-size: 0.86rem;
}
.hidden {
display: none !important;
}
@media (max-width: 980px) {
.grid,
.form-grid {
grid-template-columns: 1fr;
}
}
@media (max-width: 640px) {
.wrap {
padding: 20px 14px 28px;
}
.card-header,
.card-content {
padding-left: 16px;
padding-right: 16px;
}
.mini-grid {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<div class="wrap">
<div class="grid">
<section class="card">
<div class="card-header">
<div class="title-row">
<div>
<h1>GitHub Button Generator</h1>
<p class="sub">Create clickable Shields.io badge buttons for README files, issue-template links, resource pages, and repo navigation.</p>
</div>
<button class="btn" id="resetBtn" type="button">Reset</button>
</div>
</div>
<div class="card-content layout-stack">
<div class="form-grid">
<div class="stack">
<div class="toggle-row">
<div>
<label for="singleSegment">Single text badge</label>
<p class="hint">Turn this on for one continuous label like “Submit Template”.</p>
</div>
<label class="toggle">
<input id="singleSegment" type="checkbox" checked />
<span class="slider"></span>
</label>
</div>
<div class="field">
<label for="leftText">Badge text</label>
<input id="leftText" type="text" value="📁 Suggest Category" />
</div>
<div class="field hidden" id="rightTextWrap">
<label for="rightText">Right segment text</label>
<input id="rightText" type="text" value="Template" />
</div>
<div class="field">
<label for="altText">Alt text</label>
<input id="altText" type="text" value="📁 Suggest Category" />
</div>
<div class="field">
<label for="targetUrl">Target URL</label>
<input id="targetUrl" type="text" value="https://github.com/monapdx/90s-collage-maker/issues/new?template=suggest-category.yml" />
</div>
<div class="field">
<label>Emoji picker</label>
<div class="chip-row" id="emojiPicker"></div>
<p class="hint">Click an emoji to add it to the badge text field.</p>
</div>
</div>
<div class="stack badge-config">
<div class="mini-grid">
<div class="field">
<label for="style">Style</label>
<select id="style">
<option value="for-the-badge" selected>for-the-badge</option>
<option value="flat">flat</option>
<option value="flat-square">flat-square</option>
<option value="plastic">plastic</option>
<option value="social">social</option>
</select>
</div>
<div class="field">
<label for="color">Color</label>
<input id="color" type="text" value="8a2be2" placeholder="8a2be2 or pink" />
</div>
</div>
<div class="field">
<label>Quick colors</label>
<div class="chip-row" id="colorChips"></div>
</div>
<div class="field">
<label for="logo">Logo slug</label>
<input id="logo" type="text" value="" placeholder="github, markdown, discord" />
</div>
<div class="mini-grid">
<div class="field">
<label for="logoColor">Logo color</label>
<input id="logoColor" type="text" value="" placeholder="ffffff" />
</div>
<div class="field">
<label for="labelColor">Label color</label>
<input id="labelColor" type="text" value="" placeholder="222222" />
</div>
</div>
</div>
</div>
<div class="field">
<label>Preview</label>
<div class="preview-box">
<a id="previewLink" href="#" target="_blank" rel="noreferrer">
<img id="previewImg" alt="Badge preview" src="" />
</a>
</div>
</div>
<div>
<div class="tabs">
<button class="tab active" data-tab="markdown" type="button">Markdown</button>
<button class="tab" data-tab="html" type="button">HTML</button>
<button class="tab" data-tab="url" type="button">Badge URL</button>
<button class="tab" data-tab="plain-link" type="button">Plain Link</button>
</div>
<div class="tab-panel active" id="panel-markdown">
<div class="code-box">
<div class="field">
<label for="markdownOutput">Markdown output</label>
<textarea id="markdownOutput" readonly></textarea>
</div>
<div class="copy-row">
<button class="btn accent" type="button" data-copy="markdownOutput">Copy Markdown</button>
</div>
</div>
</div>
<div class="tab-panel" id="panel-html">
<div class="code-box">
<div class="field">
<label for="htmlOutput">HTML output</label>
<textarea id="htmlOutput" readonly></textarea>
</div>
<div class="copy-row">
<button class="btn accent" type="button" data-copy="htmlOutput">Copy HTML</button>
</div>
</div>
</div>
<div class="tab-panel" id="panel-url">
<div class="code-box">
<div class="field">
<label for="urlOutput">Badge image URL</label>
<textarea id="urlOutput" readonly></textarea>
</div>
<div class="copy-row">
<button class="btn accent" type="button" data-copy="urlOutput">Copy URL</button>
</div>
</div>
</div>
<div class="tab-panel" id="panel-plain-link">
<div class="code-box layout-stack">
<div class="mini-grid">
<div class="field">
<label for="plainLinkText">Link text</label>
<input id="plainLinkText" type="text" value="Suggest Category" />
</div>
<div class="field">
<label for="plainLinkUrl">Link URL</label>
<input id="plainLinkUrl" type="text" value="https://github.com/monapdx/90s-collage-maker/issues/new?template=suggest-category.yml" />
</div>
</div>
<div class="field">
<label for="plainLinkOutput">Plain Markdown link</label>
<textarea id="plainLinkOutput" readonly></textarea>
</div>
<div class="copy-row">
<button class="btn accent" type="button" data-copy="plainLinkOutput">Copy Plain Link</button>
</div>
</div>
</div>
</div>
</div>
</section>
<aside class="layout-stack">
<section class="card">
<div class="card-header">
<h2>Example buttons</h2>
<p class="sub">These match the sort of clickable GitHub badges you showed.</p>
</div>
<div class="card-content example-stack">
<div class="example">
<img alt="Suggest Category" src="https://img.shields.io/badge/%F0%9F%93%81%20Suggest%20Category-8a2be2?style=for-the-badge" />
</div>
<div class="example">
<img alt="Submit Template" src="https://img.shields.io/badge/Submit%20Template-pink?style=for-the-badge" />
</div>
</div>
</section>
<section class="card">
<div class="card-header">
<h2>Tips</h2>
</div>
<div class="card-content tip-stack">
<ul class="tips">
<li>Use a single text badge for one continuous label like “Submit Template”.</li>
<li>Turn single text off if you want a two-part badge with separate left and right segments.</li>
<li>Logo slugs usually come from Simple Icons, like <code>github</code>, <code>discord</code>, or <code>markdown</code>.</li>
<li>The Markdown output is ready to paste straight into a README.</li>
</ul>
<p class="footer-note">This is a standalone HTML file with no frameworks or build tools required.</p>
</div>
</section>
</aside>
</div>
</div>
<script>
const COLORS = [
{ name: "Pink", value: "ff69b4" },
{ name: "Purple", value: "8a2be2" },
{ name: "Hot Pink", value: "ed0d92" },
{ name: "Blue", value: "1f6feb" },
{ name: "Green", value: "2ea44f" },
{ name: "Red", value: "d73a49" },
{ name: "Orange", value: "f59e0b" },
{ name: "Black", value: "111111" },
{ name: "Gray", value: "6b7280" }
];
const EMOJIS = [
"📁","✨","📝","📌","💖","🔥","🎀","🧩","🛠️","📚","🎨","🚀","💡","⭐","🔗","🗂️","📎","💬","✅","🎉",
"💊", /* pill */
"💰","💸","🪙", /* money */
"🩺","🏥","⚕️","💉", /* healthcare */
"✈️","🌍","🧳", /* travel */
"📣","✊","🗳️","⚖️", /* activism/politics */
"📱","☎️", /* phone */
"⚖️","📜","🏛️", /* legal/law */
"📊","📈","📉","🧮", /* data/stats */
"🔒","🛡️","🕶️", /* privacy/safety */
"🎙️","🎧", /* podcasts */
"🎬","🍿" /* films */
];
const els = {
singleSegment: document.getElementById("singleSegment"),
leftText: document.getElementById("leftText"),
rightText: document.getElementById("rightText"),
rightTextWrap: document.getElementById("rightTextWrap"),
altText: document.getElementById("altText"),
targetUrl: document.getElementById("targetUrl"),
style: document.getElementById("style"),
color: document.getElementById("color"),
logo: document.getElementById("logo"),
logoColor: document.getElementById("logoColor"),
labelColor: document.getElementById("labelColor"),
previewLink: document.getElementById("previewLink"),
previewImg: document.getElementById("previewImg"),
markdownOutput: document.getElementById("markdownOutput"),
htmlOutput: document.getElementById("htmlOutput"),
urlOutput: document.getElementById("urlOutput"),
colorChips: document.getElementById("colorChips"),
emojiPicker: document.getElementById("emojiPicker"),
plainLinkText: document.getElementById("plainLinkText"),
plainLinkUrl: document.getElementById("plainLinkUrl"),
plainLinkOutput: document.getElementById("plainLinkOutput"),
resetBtn: document.getElementById("resetBtn")
};
const defaults = {
singleSegment: true,
leftText: "📁 Suggest Category",
rightText: "Template",
altText: "📁 Suggest Category",
targetUrl: "https://github.com/monapdx/90s-collage-maker/issues/new?template=suggest-category.yml",
style: "for-the-badge",
color: "8a2be2",
logo: "",
logoColor: "",
labelColor: "",
plainLinkText: "Suggest Category",
plainLinkUrl: "https://github.com/monapdx/90s-collage-maker/issues/new?template=suggest-category.yml"
};
function encodeSegment(text) {
return encodeURIComponent(text || "").replace(/%20/g, "%20");
}
function cleanColor(value) {
const trimmed = (value || "").trim();
if (!trimmed) return "8a2be2";
return trimmed.replace(/^#/, "");
}
function buildBadgeUrl() {
const single = els.singleSegment.checked;
const left = els.leftText.value.trim() || "Button";
const right = els.rightText.value.trim() || "Label";
const color = cleanColor(els.color.value);
const params = new URLSearchParams();
if (els.style.value) params.set("style", els.style.value);
if (els.logo.value.trim()) params.set("logo", els.logo.value.trim());
if (els.logoColor.value.trim()) params.set("logoColor", cleanColor(els.logoColor.value));
if (els.labelColor.value.trim()) params.set("labelColor", cleanColor(els.labelColor.value));
const query = params.toString();
if (single) {
const segment = encodeSegment(left);
return `https://img.shields.io/badge/${segment}-${color}${query ? `?${query}` : ""}`;
}
return `https://img.shields.io/badge/${encodeSegment(left)}-${encodeSegment(right)}-${color}${query ? `?${query}` : ""}`;
}
function buildMarkdown(badgeUrl) {
const alt = els.altText.value.trim() || els.leftText.value.trim() || "Badge";
const target = els.targetUrl.value.trim() || "https://github.com/";
return `[](${target})`;
}
function buildHtml(badgeUrl) {
const alt = escapeHtml(els.altText.value.trim() || els.leftText.value.trim() || "Badge");
const target = escapeHtml(els.targetUrl.value.trim() || "https://github.com/");
return `<a href="${target}"><img alt="${alt}" src="${badgeUrl}" /></a>`;
}
function buildPlainMarkdownLink() {
const text = (els.plainLinkText.value || "Link").trim();
const url = (els.plainLinkUrl.value || "https://github.com/").trim();
return `[${text}](${url})`;
}
function escapeHtml(str) {
return str
.replaceAll("&", "&")
.replaceAll("\"", """)
.replaceAll("<", "<")
.replaceAll(">", ">");
}
function updateRightField() {
els.rightTextWrap.classList.toggle("hidden", els.singleSegment.checked);
}
function updateOutputs() {
updateRightField();
const badgeUrl = buildBadgeUrl();
const markdown = buildMarkdown(badgeUrl);
const html = buildHtml(badgeUrl);
const target = els.targetUrl.value.trim() || "https://github.com/";
const alt = els.altText.value.trim() || els.leftText.value.trim() || "Badge preview";
els.previewLink.href = target;
els.previewImg.src = badgeUrl;
els.previewImg.alt = alt;
els.markdownOutput.value = markdown;
els.htmlOutput.value = html;
els.urlOutput.value = badgeUrl;
els.plainLinkOutput.value = buildPlainMarkdownLink();
}
function renderColorChips() {
els.colorChips.innerHTML = "";
COLORS.forEach((color) => {
const button = document.createElement("button");
button.type = "button";
button.className = "chip";
button.textContent = color.name;
button.addEventListener("click", () => {
els.color.value = color.value;
updateOutputs();
});
els.colorChips.appendChild(button);
});
}
function renderEmojiPicker() {
els.emojiPicker.innerHTML = "";
EMOJIS.forEach((emoji) => {
const button = document.createElement("button");
button.type = "button";
button.className = "chip";
button.textContent = emoji;
button.addEventListener("click", () => {
const current = els.leftText.value.trim();
els.leftText.value = current ? `${current} ${emoji}` : emoji;
updateOutputs();
});
els.emojiPicker.appendChild(button);
});
}
function resetForm() {
els.singleSegment.checked = defaults.singleSegment;
els.leftText.value = defaults.leftText;
els.rightText.value = defaults.rightText;
els.altText.value = defaults.altText;
els.targetUrl.value = defaults.targetUrl;
els.style.value = defaults.style;
els.color.value = defaults.color;
els.logo.value = defaults.logo;
els.logoColor.value = defaults.logoColor;
els.labelColor.value = defaults.labelColor;
els.plainLinkText.value = defaults.plainLinkText;
els.plainLinkUrl.value = defaults.plainLinkUrl;
updateOutputs();
}
document.querySelectorAll("input, select").forEach((el) => {
el.addEventListener("input", updateOutputs);
el.addEventListener("change", updateOutputs);
});
document.querySelectorAll(".tab").forEach((tab) => {
tab.addEventListener("click", () => {
const target = tab.dataset.tab;
document.querySelectorAll(".tab").forEach((t) => t.classList.remove("active"));
document.querySelectorAll(".tab-panel").forEach((panel) => panel.classList.remove("active"));
tab.classList.add("active");
document.getElementById(`panel-${target}`).classList.add("active");
});
});
document.querySelectorAll("[data-copy]").forEach((btn) => {
btn.addEventListener("click", async () => {
const id = btn.getAttribute("data-copy");
const value = document.getElementById(id).value;
const original = btn.textContent;
try {
await navigator.clipboard.writeText(value);
btn.textContent = "Copied";
setTimeout(() => { btn.textContent = original; }, 1400);
} catch {
btn.textContent = "Copy failed";
setTimeout(() => { btn.textContent = original; }, 1400);
}
});
});
els.resetBtn.addEventListener("click", resetForm);
renderColorChips();
renderEmojiPicker();
updateOutputs();
</script>
</body>
</html>