Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1187,6 +1187,152 @@ def render_background_html(bg_id: str, bg_info: dict, primary: str, secondary: s
|
|
| 1187 |
"""
|
| 1188 |
|
| 1189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1190 |
def generate_background_gallery(theme_json: str = ""):
|
| 1191 |
"""
|
| 1192 |
Generate HTML gallery of all 30 backgrounds organized by category
|
|
@@ -1320,6 +1466,158 @@ def generate_background_gallery(theme_json: str = ""):
|
|
| 1320 |
return "".join(html_parts)
|
| 1321 |
|
| 1322 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1323 |
def generate_single_background_preview(bg_id: str):
|
| 1324 |
"""
|
| 1325 |
Generate preview code for a single background
|
|
@@ -1789,6 +2087,52 @@ Snapchat - bright colors, fun filters, youthful design""",
|
|
| 1789 |
outputs=[gallery_html]
|
| 1790 |
)
|
| 1791 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1792 |
|
| 1793 |
# Connect button
|
| 1794 |
generate_flutter_btn.click(
|
|
|
|
| 1187 |
"""
|
| 1188 |
|
| 1189 |
|
| 1190 |
+
def render_header_html(header_id: str, header_info: dict, primary: str, secondary: str, accent: str) -> str:
|
| 1191 |
+
"""
|
| 1192 |
+
Generate HTML/CSS for a single header preview
|
| 1193 |
+
Returns HTML div with the header rendered
|
| 1194 |
+
"""
|
| 1195 |
+
header_name = header_info['name']
|
| 1196 |
+
|
| 1197 |
+
# Common container style
|
| 1198 |
+
base_style = "width: 300px; height: 100px; border-radius: 12px 12px 0 0; position: relative; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: linear-gradient(135deg, {}, {});".format(primary, secondary)
|
| 1199 |
+
|
| 1200 |
+
# Generate header based on type
|
| 1201 |
+
if header_id == "minimal":
|
| 1202 |
+
content = f"""
|
| 1203 |
+
<div style="padding: 20px; text-align: center;">
|
| 1204 |
+
<div style="color: white; font-size: 20px; font-weight: 700;">Dashboard</div>
|
| 1205 |
+
</div>
|
| 1206 |
+
"""
|
| 1207 |
+
elif header_id == "avatar_search":
|
| 1208 |
+
content = f"""
|
| 1209 |
+
<div style="padding: 12px; display: flex; align-items: center; gap: 10px;">
|
| 1210 |
+
<div style="width: 36px; height: 36px; border-radius: 50%; background: {accent}; display: flex; align-items: center; justify-content: center; color: white;">π€</div>
|
| 1211 |
+
<div style="flex: 1; background: rgba(255,255,255,0.2); border-radius: 20px; padding: 8px 12px; font-size: 12px; color: rgba(255,255,255,0.8);">π Search...</div>
|
| 1212 |
+
<div style="color: white; font-size: 20px;">π</div>
|
| 1213 |
+
</div>
|
| 1214 |
+
"""
|
| 1215 |
+
elif header_id == "tabs":
|
| 1216 |
+
content = f"""
|
| 1217 |
+
<div style="padding: 16px 20px 8px;">
|
| 1218 |
+
<div style="color: white; font-size: 18px; font-weight: 700; margin-bottom: 12px;">Dashboard</div>
|
| 1219 |
+
<div style="display: flex; gap: 16px; font-size: 13px;">
|
| 1220 |
+
<span style="color: white; border-bottom: 2px solid white; padding-bottom: 4px;">Home</span>
|
| 1221 |
+
<span style="color: rgba(255,255,255,0.6);">Activity</span>
|
| 1222 |
+
<span style="color: rgba(255,255,255,0.6);">Profile</span>
|
| 1223 |
+
</div>
|
| 1224 |
+
</div>
|
| 1225 |
+
"""
|
| 1226 |
+
elif header_id == "collapsible":
|
| 1227 |
+
content = f"""
|
| 1228 |
+
<div style="padding: 20px;">
|
| 1229 |
+
<div style="color: white; font-size: 22px; font-weight: 700;">Dashboard</div>
|
| 1230 |
+
<div style="color: rgba(255,255,255,0.7); font-size: 12px; margin-top: 4px;">Welcome back</div>
|
| 1231 |
+
</div>
|
| 1232 |
+
"""
|
| 1233 |
+
elif header_id == "stats_header":
|
| 1234 |
+
content = f"""
|
| 1235 |
+
<div style="padding: 20px; display: flex; justify-content: space-around;">
|
| 1236 |
+
<div style="text-align: center;">
|
| 1237 |
+
<div style="color: white; font-size: 18px; font-weight: 700;">24</div>
|
| 1238 |
+
<div style="color: rgba(255,255,255,0.7); font-size: 10px;">Active</div>
|
| 1239 |
+
</div>
|
| 1240 |
+
<div style="text-align: center;">
|
| 1241 |
+
<div style="color: white; font-size: 18px; font-weight: 700;">156</div>
|
| 1242 |
+
<div style="color: rgba(255,255,255,0.7); font-size: 10px;">Total</div>
|
| 1243 |
+
</div>
|
| 1244 |
+
<div style="text-align: center;">
|
| 1245 |
+
<div style="color: white; font-size: 18px; font-weight: 700;">4.8</div>
|
| 1246 |
+
<div style="color: rgba(255,255,255,0.7); font-size: 10px;">Rating</div>
|
| 1247 |
+
</div>
|
| 1248 |
+
</div>
|
| 1249 |
+
"""
|
| 1250 |
+
else:
|
| 1251 |
+
content = "<div style='padding: 20px; color: white;'>Header Preview</div>"
|
| 1252 |
+
|
| 1253 |
+
return f"""
|
| 1254 |
+
<div style="{base_style}">
|
| 1255 |
+
{content}
|
| 1256 |
+
</div>
|
| 1257 |
+
"""
|
| 1258 |
+
|
| 1259 |
+
|
| 1260 |
+
def render_footer_html(footer_id: str, footer_info: dict, primary: str, secondary: str, accent: str) -> str:
|
| 1261 |
+
"""
|
| 1262 |
+
Generate HTML/CSS for a single footer preview
|
| 1263 |
+
Returns HTML div with the footer rendered
|
| 1264 |
+
"""
|
| 1265 |
+
footer_name = footer_info['name']
|
| 1266 |
+
|
| 1267 |
+
# Common container style
|
| 1268 |
+
base_style = "width: 300px; height: 70px; border-radius: 0 0 12px 12px; position: relative; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: white;"
|
| 1269 |
+
|
| 1270 |
+
# Generate footer based on type
|
| 1271 |
+
if footer_id == "minimal_icons":
|
| 1272 |
+
content = f"""
|
| 1273 |
+
<div style="display: flex; justify-content: space-around; align-items: center; height: 100%; padding: 0 20px;">
|
| 1274 |
+
<div style="color: {primary}; font-size: 24px;">π </div>
|
| 1275 |
+
<div style="color: #999; font-size: 24px;">π</div>
|
| 1276 |
+
<div style="color: #999; font-size: 24px;">β€οΈ</div>
|
| 1277 |
+
<div style="color: #999; font-size: 24px;">π€</div>
|
| 1278 |
+
</div>
|
| 1279 |
+
"""
|
| 1280 |
+
elif footer_id == "floating_fab":
|
| 1281 |
+
content = f"""
|
| 1282 |
+
<div style="display: flex; justify-content: space-around; align-items: center; height: 100%; padding: 0 20px; position: relative;">
|
| 1283 |
+
<div style="color: #333; font-size: 24px;">π </div>
|
| 1284 |
+
<div style="color: #333; font-size: 24px;">π</div>
|
| 1285 |
+
<div style="width: 50px; height: 50px; border-radius: 50%; background: {primary}; display: flex; align-items: center; justify-content: center; color: white; font-size: 28px; position: absolute; left: 50%; transform: translateX(-50%) translateY(-50%); box-shadow: 0 4px 8px rgba(0,0,0,0.2);">+</div>
|
| 1286 |
+
<div style="color: #333; font-size: 24px;">β€οΈ</div>
|
| 1287 |
+
<div style="color: #333; font-size: 24px;">π€</div>
|
| 1288 |
+
</div>
|
| 1289 |
+
"""
|
| 1290 |
+
elif footer_id == "animated_pills":
|
| 1291 |
+
content = f"""
|
| 1292 |
+
<div style="display: flex; justify-content: space-around; align-items: center; height: 100%; padding: 0 12px;">
|
| 1293 |
+
<div style="background: {primary}; color: white; padding: 8px 14px; border-radius: 20px; font-size: 11px; font-weight: 600;">π Home</div>
|
| 1294 |
+
<div style="color: #999; font-size: 20px;">π</div>
|
| 1295 |
+
<div style="color: #999; font-size: 20px;">β€οΈ</div>
|
| 1296 |
+
<div style="color: #999; font-size: 20px;">π€</div>
|
| 1297 |
+
</div>
|
| 1298 |
+
"""
|
| 1299 |
+
elif footer_id == "classic_expanded":
|
| 1300 |
+
content = f"""
|
| 1301 |
+
<div style="display: flex; justify-content: space-around; align-items: center; height: 100%; padding: 0 20px; border-top: 1px solid #eee;">
|
| 1302 |
+
<div style="text-align: center;">
|
| 1303 |
+
<div style="color: {primary}; font-size: 20px;">π </div>
|
| 1304 |
+
<div style="color: {primary}; font-size: 9px; margin-top: 2px;">Home</div>
|
| 1305 |
+
</div>
|
| 1306 |
+
<div style="text-align: center;">
|
| 1307 |
+
<div style="color: #999; font-size: 20px;">π</div>
|
| 1308 |
+
<div style="color: #999; font-size: 9px; margin-top: 2px;">Search</div>
|
| 1309 |
+
</div>
|
| 1310 |
+
<div style="text-align: center;">
|
| 1311 |
+
<div style="color: #999; font-size: 20px;">β€οΈ</div>
|
| 1312 |
+
<div style="color: #999; font-size: 9px; margin-top: 2px;">Likes</div>
|
| 1313 |
+
</div>
|
| 1314 |
+
<div style="text-align: center;">
|
| 1315 |
+
<div style="color: #999; font-size: 20px;">π€</div>
|
| 1316 |
+
<div style="color: #999; font-size: 9px; margin-top: 2px;">Profile</div>
|
| 1317 |
+
</div>
|
| 1318 |
+
</div>
|
| 1319 |
+
"""
|
| 1320 |
+
elif footer_id == "gesture_bar":
|
| 1321 |
+
content = f"""
|
| 1322 |
+
<div style="display: flex; justify-content: center; align-items: center; height: 100%; background: rgba(255,255,255,0.95);">
|
| 1323 |
+
<div style="width: 120px; height: 4px; background: #ccc; border-radius: 2px;"></div>
|
| 1324 |
+
</div>
|
| 1325 |
+
"""
|
| 1326 |
+
else:
|
| 1327 |
+
content = "<div style='padding: 20px; color: #333;'>Footer Preview</div>"
|
| 1328 |
+
|
| 1329 |
+
return f"""
|
| 1330 |
+
<div style="{base_style}">
|
| 1331 |
+
{content}
|
| 1332 |
+
</div>
|
| 1333 |
+
"""
|
| 1334 |
+
|
| 1335 |
+
|
| 1336 |
def generate_background_gallery(theme_json: str = ""):
|
| 1337 |
"""
|
| 1338 |
Generate HTML gallery of all 30 backgrounds organized by category
|
|
|
|
| 1466 |
return "".join(html_parts)
|
| 1467 |
|
| 1468 |
|
| 1469 |
+
def generate_header_gallery(theme_json: str = ""):
|
| 1470 |
+
"""
|
| 1471 |
+
Generate HTML gallery of all 5 headers
|
| 1472 |
+
Headers are rendered directly with HTML/CSS using theme colors
|
| 1473 |
+
"""
|
| 1474 |
+
from agents.flutter_screen_generator import FlutterScreenGenerator
|
| 1475 |
+
|
| 1476 |
+
agent = FlutterScreenGenerator()
|
| 1477 |
+
catalog = agent.HEADER_CATALOG
|
| 1478 |
+
|
| 1479 |
+
# Parse theme or use defaults
|
| 1480 |
+
if theme_json and theme_json.strip():
|
| 1481 |
+
try:
|
| 1482 |
+
theme_data = json.loads(theme_json)
|
| 1483 |
+
palette = theme_data.get("palette", {})
|
| 1484 |
+
primary = palette.get("primary", "#2196F3")
|
| 1485 |
+
secondary = palette.get("secondary", "#FF9800")
|
| 1486 |
+
accent = palette.get("accent", "#4CAF50")
|
| 1487 |
+
except:
|
| 1488 |
+
primary = "#2196F3"
|
| 1489 |
+
secondary = "#FF9800"
|
| 1490 |
+
accent = "#4CAF50"
|
| 1491 |
+
else:
|
| 1492 |
+
primary = "#2196F3"
|
| 1493 |
+
secondary = "#FF9800"
|
| 1494 |
+
accent = "#4CAF50"
|
| 1495 |
+
|
| 1496 |
+
# Start HTML
|
| 1497 |
+
html_parts = []
|
| 1498 |
+
html_parts.append("""
|
| 1499 |
+
<div style="background: #f8f9fa; padding: 24px; border-radius: 12px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
| 1500 |
+
<h3 style="margin-top: 0; color: #212529; font-size: 20px;">π― Header Catalog (5 Headers)</h3>
|
| 1501 |
+
<p style="color: #6c757d; font-size: 14px; margin-bottom: 24px;">
|
| 1502 |
+
Tutti gli header renderizzati con i tuoi colori del tema
|
| 1503 |
+
</p>
|
| 1504 |
+
""")
|
| 1505 |
+
|
| 1506 |
+
# Grid container
|
| 1507 |
+
html_parts.append("""
|
| 1508 |
+
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; margin-top: 20px;">
|
| 1509 |
+
""")
|
| 1510 |
+
|
| 1511 |
+
# Render each header
|
| 1512 |
+
for header_id, info in catalog.items():
|
| 1513 |
+
# Render header preview
|
| 1514 |
+
header_preview = render_header_html(header_id, info, primary, secondary, accent)
|
| 1515 |
+
|
| 1516 |
+
# Complexity color
|
| 1517 |
+
complexity = info.get('complexity', 'simple')
|
| 1518 |
+
if complexity == "simple":
|
| 1519 |
+
complexity_color = "#28a745"
|
| 1520 |
+
elif complexity == "medium":
|
| 1521 |
+
complexity_color = "#ffc107"
|
| 1522 |
+
else:
|
| 1523 |
+
complexity_color = "#dc3545"
|
| 1524 |
+
|
| 1525 |
+
html_parts.append(f"""
|
| 1526 |
+
<div style="background: white; padding: 16px; border-radius: 8px; border: 1px solid #dee2e6; display: flex; flex-direction: column; gap: 12px;">
|
| 1527 |
+
{header_preview}
|
| 1528 |
+
<div style="width: 100%; text-align: center;">
|
| 1529 |
+
<div style="font-weight: 600; font-size: 14px; margin-bottom: 4px;">{info['name']}</div>
|
| 1530 |
+
<div style="font-size: 11px; color: #6c757d; margin-bottom: 6px;">
|
| 1531 |
+
<code style="background: #e9ecef; padding: 2px 6px; border-radius: 3px; font-size: 10px;">{header_id}</code>
|
| 1532 |
+
</div>
|
| 1533 |
+
<div style="font-size: 11px; color: #6c757d; margin-bottom: 6px;">{info['description']}</div>
|
| 1534 |
+
<span style="background: {complexity_color}; color: white; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600;">
|
| 1535 |
+
{complexity.upper()}
|
| 1536 |
+
</span>
|
| 1537 |
+
</div>
|
| 1538 |
+
</div>
|
| 1539 |
+
""")
|
| 1540 |
+
|
| 1541 |
+
html_parts.append("</div></div>")
|
| 1542 |
+
return "".join(html_parts)
|
| 1543 |
+
|
| 1544 |
+
|
| 1545 |
+
def generate_footer_gallery(theme_json: str = ""):
|
| 1546 |
+
"""
|
| 1547 |
+
Generate HTML gallery of all 5 footers
|
| 1548 |
+
Footers are rendered directly with HTML/CSS using theme colors
|
| 1549 |
+
"""
|
| 1550 |
+
from agents.flutter_screen_generator import FlutterScreenGenerator
|
| 1551 |
+
|
| 1552 |
+
agent = FlutterScreenGenerator()
|
| 1553 |
+
catalog = agent.FOOTER_CATALOG
|
| 1554 |
+
|
| 1555 |
+
# Parse theme or use defaults
|
| 1556 |
+
if theme_json and theme_json.strip():
|
| 1557 |
+
try:
|
| 1558 |
+
theme_data = json.loads(theme_json)
|
| 1559 |
+
palette = theme_data.get("palette", {})
|
| 1560 |
+
primary = palette.get("primary", "#2196F3")
|
| 1561 |
+
secondary = palette.get("secondary", "#FF9800")
|
| 1562 |
+
accent = palette.get("accent", "#4CAF50")
|
| 1563 |
+
except:
|
| 1564 |
+
primary = "#2196F3"
|
| 1565 |
+
secondary = "#FF9800"
|
| 1566 |
+
accent = "#4CAF50"
|
| 1567 |
+
else:
|
| 1568 |
+
primary = "#2196F3"
|
| 1569 |
+
secondary = "#FF9800"
|
| 1570 |
+
accent = "#4CAF50"
|
| 1571 |
+
|
| 1572 |
+
# Start HTML
|
| 1573 |
+
html_parts = []
|
| 1574 |
+
html_parts.append("""
|
| 1575 |
+
<div style="background: #f8f9fa; padding: 24px; border-radius: 12px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
| 1576 |
+
<h3 style="margin-top: 0; color: #212529; font-size: 20px;">π― Footer Catalog (5 Footers)</h3>
|
| 1577 |
+
<p style="color: #6c757d; font-size: 14px; margin-bottom: 24px;">
|
| 1578 |
+
Tutti i footer/navigation bar renderizzati con i tuoi colori del tema
|
| 1579 |
+
</p>
|
| 1580 |
+
""")
|
| 1581 |
+
|
| 1582 |
+
# Grid container
|
| 1583 |
+
html_parts.append("""
|
| 1584 |
+
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; margin-top: 20px;">
|
| 1585 |
+
""")
|
| 1586 |
+
|
| 1587 |
+
# Render each footer
|
| 1588 |
+
for footer_id, info in catalog.items():
|
| 1589 |
+
# Render footer preview
|
| 1590 |
+
footer_preview = render_footer_html(footer_id, info, primary, secondary, accent)
|
| 1591 |
+
|
| 1592 |
+
# Complexity color
|
| 1593 |
+
complexity = info.get('complexity', 'simple')
|
| 1594 |
+
if complexity == "simple":
|
| 1595 |
+
complexity_color = "#28a745"
|
| 1596 |
+
elif complexity == "medium":
|
| 1597 |
+
complexity_color = "#ffc107"
|
| 1598 |
+
else:
|
| 1599 |
+
complexity_color = "#dc3545"
|
| 1600 |
+
|
| 1601 |
+
html_parts.append(f"""
|
| 1602 |
+
<div style="background: white; padding: 16px; border-radius: 8px; border: 1px solid #dee2e6; display: flex; flex-direction: column; gap: 12px;">
|
| 1603 |
+
{footer_preview}
|
| 1604 |
+
<div style="width: 100%; text-align: center;">
|
| 1605 |
+
<div style="font-weight: 600; font-size: 14px; margin-bottom: 4px;">{info['name']}</div>
|
| 1606 |
+
<div style="font-size: 11px; color: #6c757d; margin-bottom: 6px;">
|
| 1607 |
+
<code style="background: #e9ecef; padding: 2px 6px; border-radius: 3px; font-size: 10px;">{footer_id}</code>
|
| 1608 |
+
</div>
|
| 1609 |
+
<div style="font-size: 11px; color: #6c757d; margin-bottom: 6px;">{info['description']}</div>
|
| 1610 |
+
<span style="background: {complexity_color}; color: white; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600;">
|
| 1611 |
+
{complexity.upper()}
|
| 1612 |
+
</span>
|
| 1613 |
+
</div>
|
| 1614 |
+
</div>
|
| 1615 |
+
""")
|
| 1616 |
+
|
| 1617 |
+
html_parts.append("</div></div>")
|
| 1618 |
+
return "".join(html_parts)
|
| 1619 |
+
|
| 1620 |
+
|
| 1621 |
def generate_single_background_preview(bg_id: str):
|
| 1622 |
"""
|
| 1623 |
Generate preview code for a single background
|
|
|
|
| 2087 |
outputs=[gallery_html]
|
| 2088 |
)
|
| 2089 |
|
| 2090 |
+
# Header Gallery Section
|
| 2091 |
+
gr.Markdown("---")
|
| 2092 |
+
with gr.Accordion("π― Header Catalog (5 Headers)", open=True):
|
| 2093 |
+
gr.Markdown("""
|
| 2094 |
+
Tutti i 5 header disponibili con preview renderizzate in HTML/CSS.
|
| 2095 |
+
Gli header vengono stilizzati automaticamente con i colori del tema.
|
| 2096 |
+
""")
|
| 2097 |
+
|
| 2098 |
+
# Refresh button to update with new theme
|
| 2099 |
+
refresh_headers_btn = gr.Button("π Aggiorna Header con Tema Corrente", variant="secondary", size="sm")
|
| 2100 |
+
|
| 2101 |
+
# Header Gallery HTML - show immediately with default theme
|
| 2102 |
+
header_gallery_html = gr.HTML(
|
| 2103 |
+
value=generate_header_gallery(default_theme_for_gallery)
|
| 2104 |
+
)
|
| 2105 |
+
|
| 2106 |
+
# Connect refresh button
|
| 2107 |
+
refresh_headers_btn.click(
|
| 2108 |
+
fn=generate_header_gallery,
|
| 2109 |
+
inputs=[theme_json_input],
|
| 2110 |
+
outputs=[header_gallery_html]
|
| 2111 |
+
)
|
| 2112 |
+
|
| 2113 |
+
# Footer Gallery Section
|
| 2114 |
+
gr.Markdown("---")
|
| 2115 |
+
with gr.Accordion("π― Footer Catalog (5 Footers)", open=True):
|
| 2116 |
+
gr.Markdown("""
|
| 2117 |
+
Tutti i 5 footer/navigation bar disponibili con preview renderizzate in HTML/CSS.
|
| 2118 |
+
I footer vengono stilizzati automaticamente con i colori del tema.
|
| 2119 |
+
""")
|
| 2120 |
+
|
| 2121 |
+
# Refresh button to update with new theme
|
| 2122 |
+
refresh_footers_btn = gr.Button("π Aggiorna Footer con Tema Corrente", variant="secondary", size="sm")
|
| 2123 |
+
|
| 2124 |
+
# Footer Gallery HTML - show immediately with default theme
|
| 2125 |
+
footer_gallery_html = gr.HTML(
|
| 2126 |
+
value=generate_footer_gallery(default_theme_for_gallery)
|
| 2127 |
+
)
|
| 2128 |
+
|
| 2129 |
+
# Connect refresh button
|
| 2130 |
+
refresh_footers_btn.click(
|
| 2131 |
+
fn=generate_footer_gallery,
|
| 2132 |
+
inputs=[theme_json_input],
|
| 2133 |
+
outputs=[footer_gallery_html]
|
| 2134 |
+
)
|
| 2135 |
+
|
| 2136 |
|
| 2137 |
# Connect button
|
| 2138 |
generate_flutter_btn.click(
|