Badge / app.py
seawolf2357's picture
Update app.py
5fbecf9 verified
import urllib.parse
import gradio as gr
# ---------------------------
# Badge URL generation
# ---------------------------
def generate_static_badge(label, message, color, label_color, logo, logo_color, style, link):
base = "https://img.shields.io/static/v1"
params = []
if label:
params.append(f"label={urllib.parse.quote(label, safe='')}")
if message:
params.append(f"message={urllib.parse.quote(message, safe='')}")
if color:
params.append(f"color={urllib.parse.quote(color, safe='')}")
if label_color:
params.append(f"labelColor={urllib.parse.quote(label_color, safe='')}")
if logo:
params.append(f"logo={urllib.parse.quote(logo, safe='')}")
if logo_color:
params.append(f"logoColor={urllib.parse.quote(logo_color, safe='')}")
if style:
params.append(f"style={urllib.parse.quote(style, safe='')}")
badge_url = base + ("?" + "&".join(params) if params else "")
if link:
html_code = f'<a href="{link}" target="_blank"><img src="{badge_url}" alt="badge"></a>'
else:
html_code = f'<img src="{badge_url}" alt="badge">'
badge_preview = f"""
<div style='padding:30px; background: #FFFFFF;
border: 4px solid #1F2937; border-radius: 12px;
display: flex; justify-content: center;
box-shadow: 6px 6px 0px #1F2937;'>
{html_code}
</div>
"""
# 정보 둜그 생성
info_log = f"""βœ… BADGE GENERATED!
{'=' * 50}
🏷️ Badge Info:
β€’ Label: {label}
β€’ Message: {message}
β€’ Logo: {logo}
{'=' * 50}
🎨 Style Settings:
β€’ Background: {color}
β€’ Label Color: {label_color}
β€’ Logo Color: {logo_color}
β€’ Style: {style}
{'=' * 50}
πŸ”— Link: {link if link else 'None'}
{'=' * 50}
πŸ’Ύ HTML code ready to copy!"""
return html_code, badge_preview, info_log
# ============================================
# 🎨 Comic Classic Theme - Toon Playground
# ============================================
css = """
/* ===== 🎨 Google Fonts Import ===== */
@import url('https://fonts.googleapis.com/css2?family=Bangers&family=Comic+Neue:wght@400;700&display=swap');
/* ===== 🎨 Comic Classic λ°°κ²½ - λΉˆν‹°μ§€ 페이퍼 + λ„νŠΈ νŒ¨ν„΄ ===== */
.gradio-container {
background-color: #FEF9C3 !important;
background-image:
radial-gradient(#1F2937 1px, transparent 1px) !important;
background-size: 20px 20px !important;
min-height: 100vh !important;
font-family: 'Comic Neue', cursive, sans-serif !important;
}
/* ===== ν—ˆκΉ…νŽ˜μ΄μŠ€ 상단 μš”μ†Œ μˆ¨κΉ€ ===== */
.huggingface-space-header,
#space-header,
.space-header,
[class*="space-header"],
.svelte-1ed2p3z,
.space-header-badge,
.header-badge,
[data-testid="space-header"],
.svelte-kqij2n,
.svelte-1ax1toq,
.embed-container > div:first-child {
display: none !important;
visibility: hidden !important;
height: 0 !important;
width: 0 !important;
overflow: hidden !important;
opacity: 0 !important;
pointer-events: none !important;
}
/* ===== Footer μ™„μ „ μˆ¨κΉ€ ===== */
footer,
.footer,
.gradio-container footer,
.built-with,
[class*="footer"],
.gradio-footer,
.main-footer,
div[class*="footer"],
.show-api,
.built-with-gradio,
a[href*="gradio.app"],
a[href*="huggingface.co/spaces"] {
display: none !important;
visibility: hidden !important;
height: 0 !important;
padding: 0 !important;
margin: 0 !important;
}
/* ===== 메인 μ»¨ν…Œμ΄λ„ˆ ===== */
#col-container {
max-width: 1200px;
margin: 0 auto;
}
/* ===== 🎨 헀더 타이틀 - μ½”λ―Ή μŠ€νƒ€μΌ ===== */
.header-text h1 {
font-family: 'Bangers', cursive !important;
color: #1F2937 !important;
font-size: 3.5rem !important;
font-weight: 400 !important;
text-align: center !important;
margin-bottom: 0.5rem !important;
text-shadow:
4px 4px 0px #FACC15,
6px 6px 0px #1F2937 !important;
letter-spacing: 3px !important;
-webkit-text-stroke: 2px #1F2937 !important;
}
/* ===== 🎨 μ„œλΈŒνƒ€μ΄ν‹€ ===== */
.subtitle {
text-align: center !important;
font-family: 'Comic Neue', cursive !important;
font-size: 1.2rem !important;
color: #1F2937 !important;
margin-bottom: 1.5rem !important;
font-weight: 700 !important;
}
/* ===== 🎨 μΉ΄λ“œ/νŒ¨λ„ - λ§Œν™” ν”„λ ˆμž„ μŠ€νƒ€μΌ ===== */
.gr-panel,
.gr-box,
.gr-form,
.gr-group {
background: #FFFFFF !important;
border: 3px solid #1F2937 !important;
border-radius: 8px !important;
box-shadow: 6px 6px 0px #1F2937 !important;
}
/* block hover 효과 제거 - λ“œλ‘­λ‹€μš΄ 클릭 λ°©ν•΄ λ°©μ§€ */
/* ===== 🎨 μž…λ ₯ ν•„λ“œ (Textbox) ===== */
textarea,
input[type="text"],
input[type="number"] {
background: #FFFFFF !important;
border: 3px solid #1F2937 !important;
border-radius: 8px !important;
color: #1F2937 !important;
font-family: 'Comic Neue', cursive !important;
font-size: 1rem !important;
font-weight: 700 !important;
transition: all 0.2s ease !important;
}
textarea:focus,
input[type="text"]:focus,
input[type="number"]:focus {
border-color: #3B82F6 !important;
box-shadow: 4px 4px 0px #3B82F6 !important;
outline: none !important;
}
textarea::placeholder {
color: #9CA3AF !important;
font-weight: 400 !important;
}
/* ===== 🎨 λ“œλ‘­λ‹€μš΄ μŠ€νƒ€μΌ - κΈ°λ³Έ μœ μ§€, 폰트만 λ³€κ²½ ===== */
/* λ“œλ‘­λ‹€μš΄μ€ Gradio κΈ°λ³Έ μŠ€νƒ€μΌ μ‚¬μš© (클릭 문제 λ°©μ§€) */
/* ===== 🎨 Primary λ²„νŠΌ - μ½”λ―Ή 블루 ===== */
.gr-button-primary,
button.primary,
.gr-button.primary,
.generate-btn {
background: #3B82F6 !important;
border: 3px solid #1F2937 !important;
border-radius: 8px !important;
color: #FFFFFF !important;
font-family: 'Bangers', cursive !important;
font-weight: 400 !important;
font-size: 1.3rem !important;
letter-spacing: 2px !important;
padding: 14px 28px !important;
box-shadow: 5px 5px 0px #1F2937 !important;
transition: all 0.1s ease !important;
text-shadow: 1px 1px 0px #1F2937 !important;
}
.gr-button-primary:hover,
button.primary:hover,
.gr-button.primary:hover,
.generate-btn:hover {
background: #2563EB !important;
transform: translate(-2px, -2px) !important;
box-shadow: 7px 7px 0px #1F2937 !important;
}
.gr-button-primary:active,
button.primary:active,
.gr-button.primary:active,
.generate-btn:active {
transform: translate(3px, 3px) !important;
box-shadow: 2px 2px 0px #1F2937 !important;
}
/* ===== 🎨 Secondary λ²„νŠΌ - μ½”λ―Ή λ ˆλ“œ ===== */
.gr-button-secondary,
button.secondary {
background: #EF4444 !important;
border: 3px solid #1F2937 !important;
border-radius: 8px !important;
color: #FFFFFF !important;
font-family: 'Bangers', cursive !important;
font-weight: 400 !important;
font-size: 1.1rem !important;
letter-spacing: 1px !important;
box-shadow: 4px 4px 0px #1F2937 !important;
transition: all 0.1s ease !important;
text-shadow: 1px 1px 0px #1F2937 !important;
}
.gr-button-secondary:hover,
button.secondary:hover {
background: #DC2626 !important;
transform: translate(-2px, -2px) !important;
box-shadow: 6px 6px 0px #1F2937 !important;
}
/* ===== 🎨 둜그 좜λ ₯ μ˜μ—­ ===== */
.info-log textarea {
background: #1F2937 !important;
color: #10B981 !important;
font-family: 'Courier New', monospace !important;
font-size: 0.9rem !important;
font-weight: 400 !important;
border: 3px solid #10B981 !important;
border-radius: 8px !important;
box-shadow: 4px 4px 0px #10B981 !important;
}
/* ===== 🎨 μ½”λ“œ 블둝 μŠ€νƒ€μΌ ===== */
.gr-code,
pre,
code {
background: #1F2937 !important;
color: #10B981 !important;
font-family: 'Courier New', monospace !important;
border: 3px solid #10B981 !important;
border-radius: 8px !important;
box-shadow: 4px 4px 0px #10B981 !important;
padding: 12px !important;
}
/* ===== 🎨 νƒ­ μŠ€νƒ€μΌ ===== */
.gr-tabs {
background: transparent !important;
}
.gr-tab-item {
background: #FFFFFF !important;
border: 3px solid #1F2937 !important;
border-radius: 8px 8px 0 0 !important;
color: #1F2937 !important;
font-family: 'Bangers', cursive !important;
font-size: 1.1rem !important;
letter-spacing: 1px !important;
padding: 10px 20px !important;
margin-right: 4px !important;
box-shadow: 3px -3px 0px #1F2937 !important;
transition: all 0.2s ease !important;
}
.gr-tab-item:hover {
background: #FEF3C7 !important;
transform: translateY(-2px) !important;
}
.gr-tab-item.selected {
background: #3B82F6 !important;
color: #FFFFFF !important;
box-shadow: 4px -4px 0px #1F2937 !important;
}
/* ===== 🎨 라벨 μŠ€νƒ€μΌ ===== */
label,
.gr-input-label,
.gr-block-label {
color: #1F2937 !important;
font-family: 'Comic Neue', cursive !important;
font-weight: 700 !important;
font-size: 1rem !important;
}
span.gr-label {
color: #1F2937 !important;
}
/* ===== 🎨 Example Grid μŠ€νƒ€μΌ ===== */
.example-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(2, auto);
gap: 16px;
margin-top: 20px;
}
.example-item {
background: #FFFFFF !important;
border: 3px solid #1F2937 !important;
border-radius: 12px !important;
padding: 16px !important;
text-align: center !important;
cursor: pointer !important;
transition: all 0.2s ease !important;
box-shadow: 4px 4px 0px #1F2937 !important;
}
.example-item:hover {
transform: translate(-3px, -3px) !important;
box-shadow: 7px 7px 0px #1F2937 !important;
background: #FEF3C7 !important;
}
.example-item:active {
transform: translate(2px, 2px) !important;
box-shadow: 2px 2px 0px #1F2937 !important;
}
@media (max-width: 768px) {
.example-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 600px) {
.example-grid {
grid-template-columns: 1fr;
}
}
/* ===== 🎨 Badge Section μŠ€νƒ€μΌ ===== */
.badge-section {
background: #FFFFFF !important;
border: 3px solid #1F2937 !important;
border-radius: 12px !important;
padding: 20px !important;
box-shadow: 6px 6px 0px #1F2937 !important;
margin-bottom: 20px !important;
}
.badge-section h3 {
font-family: 'Bangers', cursive !important;
color: #1F2937 !important;
font-size: 1.3rem !important;
letter-spacing: 1px !important;
margin-bottom: 16px !important;
}
/* ===== 🎨 Help Section μŠ€νƒ€μΌ ===== */
.help-section {
background: #FFFFFF !important;
border: 3px solid #1F2937 !important;
border-radius: 12px !important;
padding: 24px !important;
box-shadow: 6px 6px 0px #1F2937 !important;
}
.help-section h3 {
font-family: 'Bangers', cursive !important;
color: #3B82F6 !important;
font-size: 1.5rem !important;
letter-spacing: 1px !important;
margin-bottom: 16px !important;
}
.help-section h4 {
font-family: 'Comic Neue', cursive !important;
color: #1F2937 !important;
font-weight: 700 !important;
font-size: 1.1rem !important;
margin: 16px 0 8px 0 !important;
}
.help-section p,
.help-section li {
font-family: 'Comic Neue', cursive !important;
color: #1F2937 !important;
font-size: 1rem !important;
line-height: 1.6 !important;
}
.help-section ul {
padding-left: 20px !important;
}
.help-section a {
color: #3B82F6 !important;
font-weight: 700 !important;
}
.help-section a:hover {
color: #EF4444 !important;
}
/* ===== 🎨 μŠ€ν¬λ‘€λ°” - μ½”λ―Ή μŠ€νƒ€μΌ ===== */
::-webkit-scrollbar {
width: 12px;
height: 12px;
}
::-webkit-scrollbar-track {
background: #FEF9C3;
border: 2px solid #1F2937;
}
::-webkit-scrollbar-thumb {
background: #3B82F6;
border: 2px solid #1F2937;
border-radius: 0px;
}
::-webkit-scrollbar-thumb:hover {
background: #EF4444;
}
/* ===== 🎨 선택 ν•˜μ΄λΌμ΄νŠΈ ===== */
::selection {
background: #FACC15;
color: #1F2937;
}
/* ===== 🎨 링크 μŠ€νƒ€μΌ ===== */
a {
color: #3B82F6 !important;
text-decoration: none !important;
font-weight: 700 !important;
}
a:hover {
color: #EF4444 !important;
}
/* ===== 🎨 Row/Column 간격 ===== */
.gr-row {
gap: 1.5rem !important;
}
.gr-column {
gap: 1rem !important;
}
/* ===== 🎨 License/Credit 뱃지 ===== */
.license-badge {
display: inline-block;
background: #10B981 !important;
color: #FFFFFF !important;
font-family: 'Comic Neue', cursive !important;
font-weight: 700 !important;
padding: 6px 14px !important;
border: 2px solid #1F2937 !important;
border-radius: 20px !important;
box-shadow: 2px 2px 0px #1F2937 !important;
margin: 4px !important;
}
.credit-badge {
display: inline-block;
background: #3B82F6 !important;
color: #FFFFFF !important;
font-family: 'Comic Neue', cursive !important;
font-weight: 700 !important;
padding: 6px 14px !important;
border: 2px solid #1F2937 !important;
border-radius: 20px !important;
box-shadow: 2px 2px 0px #1F2937 !important;
margin: 4px !important;
}
/* ===== λ°˜μ‘ν˜• μ‘°μ • ===== */
@media (max-width: 768px) {
.header-text h1 {
font-size: 2.2rem !important;
text-shadow:
3px 3px 0px #FACC15,
4px 4px 0px #1F2937 !important;
}
.gr-button-primary,
button.primary {
padding: 12px 20px !important;
font-size: 1.1rem !important;
}
.gr-panel,
.block {
box-shadow: 4px 4px 0px #1F2937 !important;
}
}
/* ===== 🎨 닀크λͺ¨λ“œ λΉ„ν™œμ„±ν™” ===== */
@media (prefers-color-scheme: dark) {
.gradio-container {
background-color: #FEF9C3 !important;
}
}
"""
# ---------------------------
# Gradio UI
# ---------------------------
with gr.Blocks(fill_height=True, css=css, title="BadgeCraft") as demo:
# HOME Badge
gr.HTML("""
<div style="text-align: center; margin: 20px 0 10px 0;">
<a href="https://www.humangen.ai" target="_blank" style="text-decoration: none;">
<img src="https://img.shields.io/static/v1?label=🏠 HOME&message=HUMANGEN.AI&color=0000ff&labelColor=ffcc00&style=for-the-badge" alt="HOME">
</a>
</div>
""")
# Header Title
gr.Markdown(
"""
# 🎨 BADGECRAFT GENERATOR 🏷️
""",
elem_classes="header-text"
)
gr.Markdown(
"""
<p class="subtitle">✨ Create beautiful badges with live preview and HTML snippet! πŸ’»</p>
<div style="text-align: center; margin: 10px 0;">
<span class="license-badge">✨ MIT License</span>
<span class="credit-badge">πŸ‘₯ OpenFreeAI Team</span>
</div>
""",
)
# Define color options
color_options = {
"Red": "#ff0000",
"Blue": "#0000ff",
"Green": "#00ff00",
"Yellow": "#ffff00",
"Purple": "#800080",
"Orange": "#ffa500",
"Pink": "#ffc0cb",
"Teal": "#008080",
"Navy": "#000080",
"Lime": "#00ff00",
"Cyan": "#00ffff",
"Magenta": "#ff00ff",
"Gold": "#ffd700",
"Silver": "#c0c0c0"
}
with gr.Tabs():
with gr.TabItem("🎨 Badge Generator"):
with gr.Row(equal_height=False):
with gr.Column(scale=1, min_width=400):
with gr.Group(elem_classes="badge-section"):
gr.HTML("<h3>✏️ BADGE SETTINGS</h3>")
label = gr.Textbox(
label="🏷️ Label",
value="Discord",
lines=1
)
message = gr.Textbox(
label="πŸ’¬ Message",
value="Join our community",
lines=1
)
logo = gr.Textbox(
label="πŸ–ΌοΈ Logo",
value="discord",
lines=1
)
style = gr.Dropdown(
label="🎭 Style",
choices=["flat", "flat-square", "plastic", "for-the-badge", "social"],
value="for-the-badge"
)
color = gr.Dropdown(
label="🎨 Background Color",
choices=list(color_options.keys()),
value="Blue"
)
label_color = gr.Dropdown(
label="🏷️ Label Background Color",
choices=list(color_options.keys()),
value="Purple"
)
logo_color = gr.Dropdown(
label="✨ Logo Color",
choices=["white", "black"] + list(color_options.keys()),
value="white"
)
link = gr.Textbox(
label="πŸ”— Link (URL)",
value="https://discord.gg/openfreeai",
lines=1
)
with gr.Accordion("πŸ“œ Generation Log", open=True):
info_log = gr.Textbox(
label="",
placeholder="Badge info will appear here...",
lines=14,
max_lines=20,
interactive=False,
elem_classes="info-log"
)
with gr.Column(scale=1, min_width=400):
with gr.Group(elem_classes="badge-section"):
gr.HTML("<h3>πŸ‘οΈ LIVE PREVIEW</h3>")
out_preview = gr.HTML(label="")
with gr.Group(elem_classes="badge-section"):
gr.HTML("<h3>πŸ’» HTML CODE</h3>")
out_code = gr.Code(label="", language="html", lines=3)
gr.Markdown(
"""
<p style="text-align: center; margin-top: 15px; font-weight: 700; color: #1F2937;">
πŸ’‘ Copy the HTML code and paste it into your website or README!
</p>
"""
)
# Example list
examples = [
["Discord", "Openfree AI", "Blue", "Purple", "discord", "white", "for-the-badge", "https://discord.gg/openfreeai"],
["X.com", "Follow us", "Blue", "Cyan", "x", "white", "for-the-badge", "https://x.com/openfree_ai"],
["Collections","Explore", "Orange", "Yellow", "huggingface","black","for-the-badge", "https://huggingface.co/collections/VIDraft/best-open-ai-services-68057e6e312880ea92abaf4c"],
["GitHub", "Star us", "Navy", "Lime", "github", "white", "for-the-badge", "https://github.com/openfreeai"],
["YouTube", "Watch now", "Red", "Orange", "youtube", "white", "for-the-badge", "https://www.youtube.com/@AITechTree"],
["Facebook", "Like us", "Blue", "Cyan", "facebook", "white", "for-the-badge", "https://www.facebook.com/profile.php?id=61575353674679"],
["Instagram", "友情 萬世", "Magenta", "Pink", "instagram", "white", "for-the-badge", "https://www.instagram.com/openfree_ai/"],
["Threads", "ν•¨κ»˜ μ¦κ²¨μš”.", "Navy", "Magenta", "threads", "white", "for-the-badge", "https://www.threads.net/@openfree_ai"],
]
# Example grid preview
gr.Markdown(
"""
<p style="text-align: center; margin: 25px 0 15px 0; font-family: 'Bangers', cursive; font-size: 1.5rem; color: #1F2937;">
🌟 CLICK AN EXAMPLE TO USE! 🌟
</p>
"""
)
html_items = '<div class="example-grid">'
for idx, ex in enumerate(examples):
color_hex = color_options.get(ex[2], ex[2])
label_color_hex = color_options.get(ex[3], ex[3])
logo_color_val = color_options.get(ex[5], ex[5]) if ex[5] in color_options else ex[5]
badge_url = (
"https://img.shields.io/static/v1?" + "&".join([
f"label={urllib.parse.quote(ex[0], safe='')}",
f"message={urllib.parse.quote(ex[1], safe='')}",
f"color={urllib.parse.quote(color_hex, safe='')}",
f"labelColor={urllib.parse.quote(label_color_hex, safe='')}",
f"logo={urllib.parse.quote(ex[4], safe='')}",
f"logoColor={urllib.parse.quote(logo_color_val, safe='')}",
f"style={urllib.parse.quote(ex[6], safe='')}",
])
)
html_items += f'''
<div class="example-item" onclick="applyExample({idx})">
<img src="{badge_url}" alt="{ex[0]} badge" style="margin-bottom:8px;">
<div style="font-size:0.9rem; color:#1F2937; font-family: 'Comic Neue', cursive; font-weight: 700;">{ex[0]}</div>
</div>
'''
html_items += '</div>'
apply_example_js = """
<script>
function updateSelectValue(selectEl, newValue) {
if (!selectEl) return;
selectEl.value = newValue;
selectEl.dispatchEvent(new Event("change", { bubbles: true }));
}
function updateTextValue(el, newValue) {
if (!el) return;
el.value = newValue;
el.dispatchEvent(new Event("input", { bubbles: true }));
el.dispatchEvent(new Event("change", { bubbles: true }));
}
const examples = """ + str(examples).replace("'", '"') + """;
function applyExample(i) {
const ex = examples[i];
const selectors = {
label: "#label-input",
message: "#message-input",
color: "#color-input select",
labelColor: "#label-color-input select",
logo: "#logo-input",
logoColor: "#logo-color-input select",
style: "#style-input select",
link: "#link-input"
};
const labelBox = document.querySelector(`${selectors.label} textarea, ${selectors.label} input`);
if (labelBox) { updateTextValue(labelBox, ex[0]); }
const msgBox = document.querySelector(`${selectors.message} textarea, ${selectors.message} input`);
if (msgBox) { updateTextValue(msgBox, ex[1]); }
const bgColorSelect = document.querySelector(selectors.color);
if (bgColorSelect) { updateSelectValue(bgColorSelect, ex[2]); }
const labelColorSelect = document.querySelector(selectors.labelColor);
if (labelColorSelect) { updateSelectValue(labelColorSelect, ex[3]); }
const logoBox = document.querySelector(`${selectors.logo} textarea, ${selectors.logo} input`);
if (logoBox) { updateTextValue(logoBox, ex[4]); }
const logoColorSelect = document.querySelector(selectors.logoColor);
if (logoColorSelect) { updateSelectValue(logoColorSelect, ex[5]); }
const styleSelect = document.querySelector(selectors.style);
if (styleSelect) { updateSelectValue(styleSelect, ex[6]); }
const linkBox = document.querySelector(`${selectors.link} textarea, ${selectors.link} input`);
if (linkBox) { updateTextValue(linkBox, ex[7]); }
}
</script>
"""
gr.HTML(html_items + apply_example_js)
with gr.TabItem("❓ Help"):
gr.HTML('''
<div class="help-section">
<h3>πŸ“‹ HOW TO USE BADGECRAFT</h3>
<h4>✨ What are Badges?</h4>
<p>Badges are small visual indicators that can be used in README files, websites, and documentation. Shields.io badges are widely used to display project status, social media links, version information, and more.</p>
<h4>πŸ› οΈ Basic Settings</h4>
<ul>
<li><strong>Label</strong>: Text displayed on the left side of the badge (e.g., "Discord", "Version", "Status")</li>
<li><strong>Message</strong>: Text displayed on the right side of the badge</li>
<li><strong>Logo</strong>: Name of a logo provided by Simple Icons (<a href="https://simpleicons.org/" target="_blank">View List</a>)</li>
<li><strong>Style</strong>: Determines the shape of the badge (flat, plastic, for-the-badge, etc.)</li>
</ul>
<h4>🎨 Color Settings</h4>
<ul>
<li><strong>Background Color</strong>: Background color for the right side of the badge</li>
<li><strong>Label Background Color</strong>: Background color for the left side of the badge</li>
<li><strong>Logo Color</strong>: Color of the logo (e.g. white or black)</li>
</ul>
<h4>πŸ”— Using the HTML</h4>
<p>Copy the generated HTML code and paste it into your website, blog, GitHub README, etc.</p>
<p>HTML works in GitHub READMEs, but if you prefer markdown, use <code>![alt text](badge URL)</code>.</p>
<h4>πŸ’‘ Tips</h4>
<ul>
<li>Click on any example in the grid to automatically fill in all settings</li>
<li>The preview updates in real-time as you make changes</li>
<li>You can use over 2000+ logos from Simple Icons - just enter the name</li>
<li>Choose from predefined colors in the dropdown menus for consistent results</li>
</ul>
</div>
''')
def process_badge(label, message, color_name, label_color_name, logo, logo_color_name, style, link):
color_hex = color_options.get(color_name, "#000000")
label_color_hex = color_options.get(label_color_name, "#000000")
logo_color_hex = logo_color_name if logo_color_name in ["white", "black"] else color_options.get(logo_color_name, "#ffffff")
return generate_static_badge(label, message, color_hex, label_color_hex, logo, logo_color_hex, style, link)
demo.load(
fn=process_badge,
inputs=[label, message, color, label_color, logo, logo_color, style, link],
outputs=[out_code, out_preview, info_log],
)
for inp in [label, message, color, label_color, logo, logo_color, style, link]:
inp.change(
fn=process_badge,
inputs=[label, message, color, label_color, logo, logo_color, style, link],
outputs=[out_code, out_preview, info_log],
)
if __name__ == "__main__":
demo.launch()