Update app.py
Browse files
app.py
CHANGED
|
@@ -232,6 +232,56 @@ def analyze_business_pdf(pdf_file):
|
|
| 232 |
|
| 233 |
return app_title, screens
|
| 234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
# -----------------------
|
| 236 |
# Generate HTML + Image per Screen
|
| 237 |
# -----------------------
|
|
@@ -241,6 +291,7 @@ def generate_mockups(app_title, screens):
|
|
| 241 |
label = screen.get("screen_name", "Screen")
|
| 242 |
html_content = screen.get("html", "<h2>Empty Screen</h2>")
|
| 243 |
sidebar_html = generate_sidebar(app_title, screens, active_label=label)
|
|
|
|
| 244 |
full_html = BASE_TEMPLATE.replace("{user_sidebar}", sidebar_html)\
|
| 245 |
.replace("{user_content}", html_content)\
|
| 246 |
.replace("{app_title}", app_title)
|
|
|
|
| 232 |
|
| 233 |
return app_title, screens
|
| 234 |
|
| 235 |
+
# -----------------------
|
| 236 |
+
# Dynamic Top Bar Generator
|
| 237 |
+
# -----------------------
|
| 238 |
+
def generate_topbar(screen_name):
|
| 239 |
+
"""Generate a dynamic top bar layout depending on screen name."""
|
| 240 |
+
screen_name_lower = screen_name.lower()
|
| 241 |
+
|
| 242 |
+
# Common SVGs for top bar icons
|
| 243 |
+
ICONS = {
|
| 244 |
+
"back": """<svg viewBox="0 0 24 24" width="18" height="18" fill="#fff"><path d="M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>""",
|
| 245 |
+
"menu": """<svg viewBox="0 0 24 24" width="18" height="18" fill="#fff"><path d="M3 6h18v2H3zM3 12h18v2H3zM3 18h18v2H3z"/></svg>""",
|
| 246 |
+
"share": """<svg viewBox="0 0 24 24" width="18" height="18" fill="#fff"><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7a2.5 2.5 0 000-1.4l7.02-4.11A2.5 2.5 0 0018 7.91a2.5 2.5 0 10-2.5-2.5 2.5 2.5 0 00.1.71L8.59 10.3a2.5 2.5 0 100 3.4l7.02 4.11a2.5 2.5 0 00-.1.71 2.5 2.5 0 102.5-2.44z"/></svg>""",
|
| 247 |
+
"add": """<svg viewBox="0 0 24 24" width="18" height="18" fill="#fff"><path d="M19 11h-6V5h-2v6H5v2h6v6h2v-6h6z"/></svg>""",
|
| 248 |
+
"check": """<svg viewBox="0 0 24 24" width="18" height="18" fill="#fff"><path d="M9 16.17 4.83 12l-1.42 1.41L9 19l12-12-1.41-1.41z"/></svg>""",
|
| 249 |
+
"info": """<svg viewBox="0 0 24 24" width="18" height="18" fill="#fff"><path d="M11 9h2V7h-2v2zm1-7C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6z"/></svg>""",
|
| 250 |
+
"filter": """<svg viewBox="0 0 24 24" width="18" height="18" fill="#fff"><path d="M10 18h4v-2h-4v2zm-7-7v2h18v-2H3zm3-5v2h12V6H6z"/></svg>"""
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
# Default top bar (Dashboard-style)
|
| 254 |
+
left_icon = ICONS["menu"]
|
| 255 |
+
right_icons = ICONS["share"] + ICONS["info"]
|
| 256 |
+
|
| 257 |
+
# Adjust icons dynamically
|
| 258 |
+
if "dashboard" in screen_name_lower:
|
| 259 |
+
left_icon = ICONS["menu"]
|
| 260 |
+
right_icons = ICONS["share"] + ICONS["info"]
|
| 261 |
+
|
| 262 |
+
elif "repository" in screen_name_lower or "library" in screen_name_lower:
|
| 263 |
+
left_icon = ICONS["menu"]
|
| 264 |
+
right_icons = ICONS["filter"] + ICONS["add"]
|
| 265 |
+
|
| 266 |
+
elif "task" in screen_name_lower:
|
| 267 |
+
left_icon = ICONS["menu"]
|
| 268 |
+
right_icons = ICONS["filter"]
|
| 269 |
+
|
| 270 |
+
elif "form" in screen_name_lower or "edit" in screen_name_lower or "add" in screen_name_lower:
|
| 271 |
+
left_icon = ICONS["back"]
|
| 272 |
+
right_icons = ICONS["check"]
|
| 273 |
+
|
| 274 |
+
else:
|
| 275 |
+
left_icon = ICONS["menu"]
|
| 276 |
+
right_icons = ICONS["share"]
|
| 277 |
+
|
| 278 |
+
return f"""
|
| 279 |
+
<div class="topbar">
|
| 280 |
+
<div style='display:flex;align-items:center;gap:8px;'>{left_icon}<span>{screen_name}</span></div>
|
| 281 |
+
<div style='margin-left:auto;display:flex;align-items:center;gap:10px;'>{right_icons}</div>
|
| 282 |
+
</div>
|
| 283 |
+
"""
|
| 284 |
+
|
| 285 |
# -----------------------
|
| 286 |
# Generate HTML + Image per Screen
|
| 287 |
# -----------------------
|
|
|
|
| 291 |
label = screen.get("screen_name", "Screen")
|
| 292 |
html_content = screen.get("html", "<h2>Empty Screen</h2>")
|
| 293 |
sidebar_html = generate_sidebar(app_title, screens, active_label=label)
|
| 294 |
+
topbar_html = generate_topbar(label)
|
| 295 |
full_html = BASE_TEMPLATE.replace("{user_sidebar}", sidebar_html)\
|
| 296 |
.replace("{user_content}", html_content)\
|
| 297 |
.replace("{app_title}", app_title)
|