Update app.py
Browse files
app.py
CHANGED
|
@@ -12,14 +12,17 @@ def generate_static_badge(label, message, color, label_color, logo, logo_color,
|
|
| 12 |
if message:
|
| 13 |
params.append(f"message={urllib.parse.quote(message, safe='')}")
|
| 14 |
if color:
|
| 15 |
-
#
|
| 16 |
-
|
|
|
|
| 17 |
if label_color:
|
| 18 |
-
|
|
|
|
| 19 |
if logo:
|
| 20 |
params.append(f"logo={urllib.parse.quote(logo, safe='')}")
|
| 21 |
if logo_color:
|
| 22 |
-
|
|
|
|
| 23 |
if style:
|
| 24 |
params.append(f"style={urllib.parse.quote(style, safe='')}")
|
| 25 |
|
|
@@ -38,6 +41,25 @@ def generate_static_badge(label, message, color, label_color, logo, logo_color,
|
|
| 38 |
"""
|
| 39 |
return html_code, badge_preview
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 42 |
# ---------------------------
|
| 43 |
# Custom CSS & Header
|
|
@@ -120,7 +142,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 120 |
border-radius: 12px;
|
| 121 |
padding: 16px;
|
| 122 |
text-align: center;
|
| 123 |
-
cursor: pointer;
|
| 124 |
transition: all 0.3s ease;
|
| 125 |
border: 2px solid transparent;
|
| 126 |
}
|
|
@@ -129,6 +150,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 129 |
box-shadow: 0 8px 15px rgba(0,0,0,0.05);
|
| 130 |
border-color: #a8dadc;
|
| 131 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
@media (max-width: 768px) {
|
| 133 |
.example-grid {
|
| 134 |
grid-template-columns: repeat(2, 1fr);
|
|
@@ -158,6 +187,9 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 158 |
</div>
|
| 159 |
""")
|
| 160 |
|
|
|
|
|
|
|
|
|
|
| 161 |
with gr.Tabs():
|
| 162 |
# ---------------------------
|
| 163 |
# 1) Badge Generator Tab
|
|
@@ -173,13 +205,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 173 |
style = gr.Dropdown(
|
| 174 |
label="Style",
|
| 175 |
choices=["flat", "flat-square", "plastic", "for-the-badge", "social"],
|
| 176 |
-
value="for-the-badge"
|
| 177 |
-
elem_id="style-input"
|
| 178 |
)
|
| 179 |
-
color = gr.
|
| 180 |
-
label_color = gr.
|
| 181 |
-
logo_color = gr.
|
| 182 |
-
link = gr.Textbox(label="Link (URL)", value="https://discord.gg/openfreeai",
|
| 183 |
with gr.Column():
|
| 184 |
with gr.Group(elem_classes="badge-section"):
|
| 185 |
gr.HTML("<h3 style='margin-top:0; margin-bottom:16px; font-size:1.3rem;'>๐๏ธ Preview</h3>")
|
|
@@ -189,171 +220,49 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 189 |
out_code = gr.Code(label="", language="html", lines=3)
|
| 190 |
|
| 191 |
# ---------------------------
|
| 192 |
-
#
|
| 193 |
-
# ---------------------------
|
| 194 |
-
examples = [
|
| 195 |
-
["Discord", "Openfree AI", "#5865F2", "#99AAFF", "discord", "white", "for-the-badge", "https://discord.gg/openfreeai"],
|
| 196 |
-
["X.com", "Follow us", "#1DA1F2", "#00CFFF", "x", "white", "for-the-badge", "https://x.com/openfree_ai"],
|
| 197 |
-
["Collections","Explore", "#FFB300", "#FFF176", "huggingface","black","for-the-badge", "https://huggingface.co/collections/VIDraft/best-open-ai-services-68057e6e312880ea92abaf4c"],
|
| 198 |
-
["GitHub", "Star us", "#0A0A0A", "#39FF14", "github", "white", "for-the-badge", "https://github.com/openfreeai"],
|
| 199 |
-
["YouTube", "Watch now", "#E50000", "#FF5E5E", "youtube", "white", "for-the-badge", "https://www.youtube.com/@AITechTree"],
|
| 200 |
-
["Facebook", "Like us", "#1877F2", "#6FAFFF", "facebook", "white", "for-the-badge", "https://www.facebook.com/profile.php?id=61575353674679"],
|
| 201 |
-
["Instagram", "ๅๆ
่ฌไธ", "#E4405F", "#FF77A9", "instagram", "white", "for-the-badge", "https://www.instagram.com/openfree_ai/"],
|
| 202 |
-
["Threads", "ํจ๊ป ์ฆ๊ฒจ์.", "#000000", "#FF00FF", "threads", "white", "for-the-badge", "https://www.threads.net/@openfree_ai"],
|
| 203 |
-
]
|
| 204 |
-
|
| 205 |
-
html_items = '<div class="example-grid">'
|
| 206 |
-
for idx, ex in enumerate(examples):
|
| 207 |
-
# ex = [label, message, bg_color, label_color, logo, logo_color, style, link]
|
| 208 |
-
badge_url = (
|
| 209 |
-
"https://img.shields.io/static/v1?" + "&".join([
|
| 210 |
-
f"label={urllib.parse.quote(ex[0], safe='')}",
|
| 211 |
-
f"message={urllib.parse.quote(ex[1], safe='')}",
|
| 212 |
-
f"color={urllib.parse.quote(ex[2].lstrip('#'), safe='')}",
|
| 213 |
-
f"labelColor={urllib.parse.quote(ex[3].lstrip('#'), safe='')}",
|
| 214 |
-
f"logo={urllib.parse.quote(ex[4], safe='')}",
|
| 215 |
-
f"logoColor={urllib.parse.quote(ex[5], safe='')}",
|
| 216 |
-
f"style={urllib.parse.quote(ex[6], safe='')}"
|
| 217 |
-
])
|
| 218 |
-
)
|
| 219 |
-
html_items += f'''
|
| 220 |
-
<div class="example-item" onclick="applyExample({idx})">
|
| 221 |
-
<img src="{badge_url}" alt="{ex[0]} badge" style="margin-bottom:8px;">
|
| 222 |
-
<div style="font-size:0.9rem; color:#457b9d;">{ex[0]}</div>
|
| 223 |
-
</div>
|
| 224 |
-
'''
|
| 225 |
-
html_items += '</div>'
|
| 226 |
-
|
| 227 |
-
# ---------------------------
|
| 228 |
-
# 3) React Controlled Input Hack
|
| 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 |
-
function setColor(elemId, colorValue) {
|
| 255 |
-
const container = document.getElementById(elemId);
|
| 256 |
-
if (!container) return;
|
| 257 |
-
|
| 258 |
-
// Gradio ColorPicker ์ปดํฌ๋ํธ ๋ด๋ถ ๊ตฌ์กฐ ์ ๊ทผ
|
| 259 |
-
const colorInputs = container.querySelectorAll("input");
|
| 260 |
-
if (colorInputs.length === 0) return;
|
| 261 |
-
|
| 262 |
-
// ์ปฌ๋ฌํผ์ปค ์์ ๋ฐ ํ
์คํธ ์
๋ ฅ ์์ ๋ชจ๋์ ์ ์ฉ
|
| 263 |
-
for (const input of colorInputs) {
|
| 264 |
-
if (input.type === 'color' || input.type === 'text') {
|
| 265 |
-
reactSet(input, colorValue);
|
| 266 |
-
}
|
| 267 |
-
}
|
| 268 |
-
|
| 269 |
-
// ์์ ํ์ ์์ญ ์
๋ฐ์ดํธ (Gradio ๋ฒ์ ์ ๋ฐ๋ผ ์ ํ์ ๋ฌ๋ผ์ง ์ ์์)
|
| 270 |
-
const colorArea = container.querySelector("[data-testid='color-picker'], .color-circle, .color-preview");
|
| 271 |
-
if (colorArea) {
|
| 272 |
-
colorArea.style.background = colorValue;
|
| 273 |
-
}
|
| 274 |
-
|
| 275 |
-
// ์ถ๊ฐ: ๋ณ๊ฒฝ ์ฌํญ ์ค์๊ฐ ๋ฐ์์ ์ํ ์ฒ๋ฆฌ
|
| 276 |
-
setTimeout(() => {
|
| 277 |
-
const anyInput = colorInputs[0];
|
| 278 |
-
if (anyInput) {
|
| 279 |
-
anyInput.dispatchEvent(new Event('change', { bubbles: true }));
|
| 280 |
-
}
|
| 281 |
-
}, 50);
|
| 282 |
-
}
|
| 283 |
-
|
| 284 |
-
const examples = REPLACE_EXAMPLES; // placeholder
|
| 285 |
-
function applyExample(i) {
|
| 286 |
-
const ex = examples[i];
|
| 287 |
-
// ex = [label, message, bg_color, label_bg, logo, logo_color, style, link]
|
| 288 |
-
|
| 289 |
-
// Label
|
| 290 |
-
reactSet(document.querySelector("#label-input input,#label-input textarea"), ex[0]);
|
| 291 |
-
// Message
|
| 292 |
-
reactSet(document.querySelector("#message-input input,#message-input textarea"), ex[1]);
|
| 293 |
-
|
| 294 |
-
// ์์ ์ค์ - ์ ์ฉ ์์์ ์ง์ฐ ์ถ๊ฐ
|
| 295 |
-
setTimeout(() => {
|
| 296 |
-
// Background Color
|
| 297 |
-
setColor("color-input", convertToHexIfNeeded(ex[2]));
|
| 298 |
-
|
| 299 |
-
setTimeout(() => {
|
| 300 |
-
// Label Background
|
| 301 |
-
setColor("label-color-input", convertToHexIfNeeded(ex[3]));
|
| 302 |
-
|
| 303 |
-
setTimeout(() => {
|
| 304 |
-
// Logo Color
|
| 305 |
-
setColor("logo-color-input", convertToHexIfNeeded(ex[5]));
|
| 306 |
-
|
| 307 |
-
// ๋ชจ๋ ์์ ์ค์ ํ ๊ฐ์ ์
๋ฐ์ดํธ ํธ๋ฆฌ๊ฑฐ
|
| 308 |
-
document.querySelector("#label-input input").dispatchEvent(
|
| 309 |
-
new Event('change', { bubbles: true })
|
| 310 |
-
);
|
| 311 |
-
}, 50);
|
| 312 |
-
}, 50);
|
| 313 |
-
}, 50);
|
| 314 |
-
|
| 315 |
-
// Logo
|
| 316 |
-
reactSet(document.querySelector("#logo-input input,#logo-input textarea"), ex[4]);
|
| 317 |
-
|
| 318 |
-
// Style (Dropdown)
|
| 319 |
-
const styleSelect = document.querySelector("#style-input select");
|
| 320 |
-
if (styleSelect) {
|
| 321 |
-
styleSelect.value = ex[6];
|
| 322 |
-
styleSelect.dispatchEvent(new Event("change", { bubbles: true }));
|
| 323 |
-
}
|
| 324 |
-
|
| 325 |
-
// Link
|
| 326 |
-
reactSet(document.querySelector("#link-input input,#link-input textarea"), ex[7]);
|
| 327 |
-
}
|
| 328 |
-
"""
|
| 329 |
-
|
| 330 |
-
# JS ์์ examples ๋ฐฐ์ด์ ๋ฌธ์์ด๋ก ์นํ
|
| 331 |
-
examples_str = str(examples).replace("'", '"')
|
| 332 |
-
hack_js = hack_js.replace("REPLACE_EXAMPLES", examples_str)
|
| 333 |
-
|
| 334 |
-
gr.HTML(html_items + f"<script>{hack_js}</script>")
|
| 335 |
|
| 336 |
# ---------------------------
|
| 337 |
# 4) ์ค์๊ฐ ์
๋ฐ์ดํธ
|
| 338 |
# ---------------------------
|
| 339 |
-
# ์ค์๊ฐ ์
๋ฐ์ดํธ ๋น๋ ์ฆ๊ฐ ๋ฐ ๋ณ๋ ํจ์ ์ถ๊ฐ
|
| 340 |
-
def update_badge(*args):
|
| 341 |
-
return generate_static_badge(*args)
|
| 342 |
-
|
| 343 |
# - ์ด๊ธฐ ๋ก๋
|
| 344 |
demo.load(
|
| 345 |
-
fn=
|
| 346 |
inputs=[label, message, color, label_color, logo, logo_color, style, link],
|
| 347 |
outputs=[out_code, out_preview]
|
| 348 |
)
|
| 349 |
|
| 350 |
-
# - ๋ณ๊ฒฝ
|
| 351 |
for inp in [label, message, color, label_color, logo, logo_color, style, link]:
|
| 352 |
inp.change(
|
| 353 |
-
fn=
|
| 354 |
inputs=[label, message, color, label_color, logo, logo_color, style, link],
|
| 355 |
outputs=[out_code, out_preview],
|
| 356 |
-
queue=False
|
| 357 |
)
|
| 358 |
|
| 359 |
# ---------------------------
|
|
@@ -374,19 +283,19 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 374 |
</ul>
|
| 375 |
<h4 style="color: #457b9d; margin-bottom: 8px;">๐จ Color Settings</h4>
|
| 376 |
<ul>
|
| 377 |
-
<li><strong>Background Color</strong>: Background color for the right side of the badge</li>
|
| 378 |
-
<li><strong>Label Background Color</strong>: Background color for the left side of the badge</li>
|
| 379 |
-
<li><strong>Logo Color</strong>: Color of the logo (
|
| 380 |
</ul>
|
| 381 |
<h4 style="color: #457b9d; margin-bottom: 8px;">๐ Using the HTML</h4>
|
| 382 |
<p>Copy the generated HTML code and paste it into your website, blog, GitHub README, etc.</p>
|
| 383 |
<p>HTML works in GitHub READMEs, but if you prefer markdown, use <code></code>.</p>
|
| 384 |
<h4 style="color: #457b9d; margin-bottom: 8px;">๐ก Tips</h4>
|
| 385 |
<ul>
|
| 386 |
-
<li>Click on any example
|
| 387 |
<li>The preview updates in real-time as you make changes</li>
|
| 388 |
<li>You can use over 2000+ logos from Simple Icons - just enter the name</li>
|
| 389 |
-
<li>
|
| 390 |
</ul>
|
| 391 |
</div>
|
| 392 |
''')
|
|
|
|
| 12 |
if message:
|
| 13 |
params.append(f"message={urllib.parse.quote(message, safe='')}")
|
| 14 |
if color:
|
| 15 |
+
# ์์๊ฐ์์ # ์ ๊ฑฐ
|
| 16 |
+
color = color.lstrip('#')
|
| 17 |
+
params.append(f"color={urllib.parse.quote(color, safe='')}")
|
| 18 |
if label_color:
|
| 19 |
+
label_color = label_color.lstrip('#')
|
| 20 |
+
params.append(f"labelColor={urllib.parse.quote(label_color, safe='')}")
|
| 21 |
if logo:
|
| 22 |
params.append(f"logo={urllib.parse.quote(logo, safe='')}")
|
| 23 |
if logo_color:
|
| 24 |
+
logo_color = logo_color.lstrip('#')
|
| 25 |
+
params.append(f"logoColor={urllib.parse.quote(logo_color, safe='')}")
|
| 26 |
if style:
|
| 27 |
params.append(f"style={urllib.parse.quote(style, safe='')}")
|
| 28 |
|
|
|
|
| 41 |
"""
|
| 42 |
return html_code, badge_preview
|
| 43 |
|
| 44 |
+
# ์์ ์ ์ฉ์ ์ํ ํจ์
|
| 45 |
+
def apply_example(idx):
|
| 46 |
+
examples = [
|
| 47 |
+
["Discord", "Openfree AI", "#5865F2", "#99AAFF", "discord", "#ffffff", "for-the-badge", "https://discord.gg/openfreeai"],
|
| 48 |
+
["X.com", "Follow us", "#1DA1F2", "#00CFFF", "x", "#ffffff", "for-the-badge", "https://x.com/openfree_ai"],
|
| 49 |
+
["Collections","Explore", "#FFB300", "#FFF176", "huggingface","#000000","for-the-badge", "https://huggingface.co/collections/VIDraft/best-open-ai-services-68057e6e312880ea92abaf4c"],
|
| 50 |
+
["GitHub", "Star us", "#0A0A0A", "#39FF14", "github", "#ffffff", "for-the-badge", "https://github.com/openfreeai"],
|
| 51 |
+
["YouTube", "Watch now", "#E50000", "#FF5E5E", "youtube", "#ffffff", "for-the-badge", "https://www.youtube.com/@AITechTree"],
|
| 52 |
+
["Facebook", "Like us", "#1877F2", "#6FAFFF", "facebook", "#ffffff", "for-the-badge", "https://www.facebook.com/profile.php?id=61575353674679"],
|
| 53 |
+
["Instagram", "ๅๆ
่ฌไธ", "#E4405F", "#FF77A9", "instagram", "#ffffff", "for-the-badge", "https://www.instagram.com/openfree_ai/"],
|
| 54 |
+
["Threads", "ํจ๊ป ์ฆ๊ฒจ์.", "#000000", "#FF00FF", "threads", "#ffffff", "for-the-badge", "https://www.threads.net/@openfree_ai"],
|
| 55 |
+
]
|
| 56 |
+
|
| 57 |
+
if idx < 0 or idx >= len(examples):
|
| 58 |
+
return [None] * 8 # ์ธ๋ฑ์ค ๋ฒ์ ์ด๊ณผ ์ ๊ฐ ๋ฐํ ์ํจ
|
| 59 |
+
|
| 60 |
+
# ๊ธฐ์กด ์์ ๊ฐ ๋ฐํ
|
| 61 |
+
return examples[idx]
|
| 62 |
+
|
| 63 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 64 |
# ---------------------------
|
| 65 |
# Custom CSS & Header
|
|
|
|
| 142 |
border-radius: 12px;
|
| 143 |
padding: 16px;
|
| 144 |
text-align: center;
|
|
|
|
| 145 |
transition: all 0.3s ease;
|
| 146 |
border: 2px solid transparent;
|
| 147 |
}
|
|
|
|
| 150 |
box-shadow: 0 8px 15px rgba(0,0,0,0.05);
|
| 151 |
border-color: #a8dadc;
|
| 152 |
}
|
| 153 |
+
.example-btn {
|
| 154 |
+
width: 100%;
|
| 155 |
+
padding: 10px;
|
| 156 |
+
border: none;
|
| 157 |
+
background: transparent;
|
| 158 |
+
cursor: pointer;
|
| 159 |
+
border-radius: 10px;
|
| 160 |
+
}
|
| 161 |
@media (max-width: 768px) {
|
| 162 |
.example-grid {
|
| 163 |
grid-template-columns: repeat(2, 1fr);
|
|
|
|
| 187 |
</div>
|
| 188 |
""")
|
| 189 |
|
| 190 |
+
# ์์ ํด๋ฆญ ์ํ ๊ด๋ฆฌ์ฉ (์ค์ ๋ก๋ ๋ณด์ด์ง ์์)
|
| 191 |
+
example_idx = gr.State(-1)
|
| 192 |
+
|
| 193 |
with gr.Tabs():
|
| 194 |
# ---------------------------
|
| 195 |
# 1) Badge Generator Tab
|
|
|
|
| 205 |
style = gr.Dropdown(
|
| 206 |
label="Style",
|
| 207 |
choices=["flat", "flat-square", "plastic", "for-the-badge", "social"],
|
| 208 |
+
value="for-the-badge"
|
|
|
|
| 209 |
)
|
| 210 |
+
color = gr.Textbox(label="Background Color (hex)", value="#5865F2", lines=1)
|
| 211 |
+
label_color = gr.Textbox(label="Label Background Color (hex)", value="#99AAFF", lines=1)
|
| 212 |
+
logo_color = gr.Textbox(label="Logo Color (hex)", value="#ffffff", lines=1)
|
| 213 |
+
link = gr.Textbox(label="Link (URL)", value="https://discord.gg/openfreeai", lines=1)
|
| 214 |
with gr.Column():
|
| 215 |
with gr.Group(elem_classes="badge-section"):
|
| 216 |
gr.HTML("<h3 style='margin-top:0; margin-bottom:16px; font-size:1.3rem;'>๐๏ธ Preview</h3>")
|
|
|
|
| 220 |
out_code = gr.Code(label="", language="html", lines=3)
|
| 221 |
|
| 222 |
# ---------------------------
|
| 223 |
+
# ์์ ์น์
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
# ---------------------------
|
| 225 |
+
gr.HTML("<h3 style='margin-top:20px; margin-bottom:10px;'>๐ Examples - Click to apply</h3>")
|
| 226 |
+
|
| 227 |
+
with gr.Row(equal_height=True):
|
| 228 |
+
btn0 = gr.Button("Discord", elem_classes="example-item")
|
| 229 |
+
btn1 = gr.Button("X.com", elem_classes="example-item")
|
| 230 |
+
btn2 = gr.Button("Collections", elem_classes="example-item")
|
| 231 |
+
btn3 = gr.Button("GitHub", elem_classes="example-item")
|
| 232 |
+
|
| 233 |
+
with gr.Row(equal_height=True):
|
| 234 |
+
btn4 = gr.Button("YouTube", elem_classes="example-item")
|
| 235 |
+
btn5 = gr.Button("Facebook", elem_classes="example-item")
|
| 236 |
+
btn6 = gr.Button("Instagram", elem_classes="example-item")
|
| 237 |
+
btn7 = gr.Button("Threads", elem_classes="example-item")
|
| 238 |
+
|
| 239 |
+
# ๋ฒํผ ์ด๋ฒคํธ ์ฐ๊ฒฐ
|
| 240 |
+
btn0.click(lambda: 0, outputs=example_idx).then(apply_example, inputs=example_idx, outputs=[label, message, color, label_color, logo, logo_color, style, link])
|
| 241 |
+
btn1.click(lambda: 1, outputs=example_idx).then(apply_example, inputs=example_idx, outputs=[label, message, color, label_color, logo, logo_color, style, link])
|
| 242 |
+
btn2.click(lambda: 2, outputs=example_idx).then(apply_example, inputs=example_idx, outputs=[label, message, color, label_color, logo, logo_color, style, link])
|
| 243 |
+
btn3.click(lambda: 3, outputs=example_idx).then(apply_example, inputs=example_idx, outputs=[label, message, color, label_color, logo, logo_color, style, link])
|
| 244 |
+
btn4.click(lambda: 4, outputs=example_idx).then(apply_example, inputs=example_idx, outputs=[label, message, color, label_color, logo, logo_color, style, link])
|
| 245 |
+
btn5.click(lambda: 5, outputs=example_idx).then(apply_example, inputs=example_idx, outputs=[label, message, color, label_color, logo, logo_color, style, link])
|
| 246 |
+
btn6.click(lambda: 6, outputs=example_idx).then(apply_example, inputs=example_idx, outputs=[label, message, color, label_color, logo, logo_color, style, link])
|
| 247 |
+
btn7.click(lambda: 7, outputs=example_idx).then(apply_example, inputs=example_idx, outputs=[label, message, color, label_color, logo, logo_color, style, link])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
|
| 249 |
# ---------------------------
|
| 250 |
# 4) ์ค์๊ฐ ์
๋ฐ์ดํธ
|
| 251 |
# ---------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
# - ์ด๊ธฐ ๋ก๋
|
| 253 |
demo.load(
|
| 254 |
+
fn=generate_static_badge,
|
| 255 |
inputs=[label, message, color, label_color, logo, logo_color, style, link],
|
| 256 |
outputs=[out_code, out_preview]
|
| 257 |
)
|
| 258 |
|
| 259 |
+
# - ๋ชจ๋ ๋ณ๊ฒฝ ๊ฐ์ง ๋ฐ ์ค์๊ฐ ์
๋ฐ์ดํธ
|
| 260 |
for inp in [label, message, color, label_color, logo, logo_color, style, link]:
|
| 261 |
inp.change(
|
| 262 |
+
fn=generate_static_badge,
|
| 263 |
inputs=[label, message, color, label_color, logo, logo_color, style, link],
|
| 264 |
outputs=[out_code, out_preview],
|
| 265 |
+
queue=False
|
| 266 |
)
|
| 267 |
|
| 268 |
# ---------------------------
|
|
|
|
| 283 |
</ul>
|
| 284 |
<h4 style="color: #457b9d; margin-bottom: 8px;">๐จ Color Settings</h4>
|
| 285 |
<ul>
|
| 286 |
+
<li><strong>Background Color</strong>: Background color for the right side of the badge (hex format, e.g. #5865F2)</li>
|
| 287 |
+
<li><strong>Label Background Color</strong>: Background color for the left side of the badge (hex format)</li>
|
| 288 |
+
<li><strong>Logo Color</strong>: Color of the logo (hex format, #ffffff for white, #000000 for black)</li>
|
| 289 |
</ul>
|
| 290 |
<h4 style="color: #457b9d; margin-bottom: 8px;">๐ Using the HTML</h4>
|
| 291 |
<p>Copy the generated HTML code and paste it into your website, blog, GitHub README, etc.</p>
|
| 292 |
<p>HTML works in GitHub READMEs, but if you prefer markdown, use <code></code>.</p>
|
| 293 |
<h4 style="color: #457b9d; margin-bottom: 8px;">๐ก Tips</h4>
|
| 294 |
<ul>
|
| 295 |
+
<li>Click on any example button to automatically fill in all settings</li>
|
| 296 |
<li>The preview updates in real-time as you make changes</li>
|
| 297 |
<li>You can use over 2000+ logos from Simple Icons - just enter the name</li>
|
| 298 |
+
<li>Enter colors in hex format (e.g. #FF0000 for red)</li>
|
| 299 |
</ul>
|
| 300 |
</div>
|
| 301 |
''')
|