Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -169,13 +169,16 @@ footer { display: none !important; }
|
|
| 169 |
align-items: center;
|
| 170 |
}
|
| 171 |
|
| 172 |
-
/* 2. LAYOUT COLUMNS */
|
| 173 |
.main-layout { display: flex; justify-content: center; padding-top: 20px; gap: 20px; }
|
| 174 |
|
| 175 |
-
/* Left Sidebar:
|
| 176 |
-
.col-left { width:
|
| 177 |
|
| 178 |
-
|
|
|
|
|
|
|
|
|
|
| 179 |
.col-right { width: 280px; display: none; }
|
| 180 |
|
| 181 |
/* 3. CARD STYLING */
|
|
@@ -189,9 +192,9 @@ footer { display: none !important; }
|
|
| 189 |
border: 1px solid #e4e6eb;
|
| 190 |
}
|
| 191 |
|
| 192 |
-
/* 4. NAVIGATION BUTTONS -
|
| 193 |
.nav-btn {
|
| 194 |
-
width:
|
| 195 |
height: 42.5px !important;
|
| 196 |
text-align: left !important;
|
| 197 |
justify-content: flex-start !important;
|
|
@@ -201,7 +204,7 @@ footer { display: none !important; }
|
|
| 201 |
color: #050505 !important;
|
| 202 |
font-weight: 600 !important;
|
| 203 |
font-size: 15px !important;
|
| 204 |
-
padding: 0 12px !important;
|
| 205 |
border-radius: 8px !important;
|
| 206 |
margin-bottom: 5px !important;
|
| 207 |
display: flex !important;
|
|
@@ -393,92 +396,4 @@ with gr.Blocks(title="CookBook", css=facebook_css, theme=theme) as demo:
|
|
| 393 |
</div>
|
| 394 |
""")
|
| 395 |
gr.Markdown(f"**{row['Title']}**")
|
| 396 |
-
gr.Markdown(f"{str(row['Raw_Output'])[:300]}... <span style='color:#1877F2;
|
| 397 |
-
|
| 398 |
-
with gr.Row(elem_classes=["post-actions"]):
|
| 399 |
-
gr.Button("👍 Like", elem_classes=["action-btn"], size="sm")
|
| 400 |
-
gr.Button("💬 Comment", elem_classes=["action-btn"], size="sm")
|
| 401 |
-
gr.Button("↪ Share", elem_classes=["action-btn"], size="sm")
|
| 402 |
-
else:
|
| 403 |
-
gr.Markdown("⚠️ Database is empty.")
|
| 404 |
-
|
| 405 |
-
# --- VIEW 3: SAVED ---
|
| 406 |
-
with gr.Column(visible=False) as saved_view:
|
| 407 |
-
gr.Markdown("### 🔖 Saved Items")
|
| 408 |
-
if not df_recipes.empty:
|
| 409 |
-
saved_batch = df_recipes.head(20)
|
| 410 |
-
for index, row in saved_batch.iterrows():
|
| 411 |
-
with gr.Group(elem_classes=["fb-card"]):
|
| 412 |
-
with gr.Row():
|
| 413 |
-
gr.HTML("<div style='width:80px; height:80px; background:#eee; border-radius:8px;'></div>")
|
| 414 |
-
with gr.Column():
|
| 415 |
-
gr.Markdown(f"**{row['Title']}**")
|
| 416 |
-
gr.HTML("<span style='color:#65676B; font-size:12px;'>Saved from News Feed</span>")
|
| 417 |
-
gr.Button("View Collection", size="sm", variant="secondary")
|
| 418 |
-
|
| 419 |
-
# --- VIEW 4: ABOUT ---
|
| 420 |
-
with gr.Group(visible=False) as about_view:
|
| 421 |
-
with gr.Group(elem_classes=["fb-card"]):
|
| 422 |
-
gr.Markdown("# About CookBook")
|
| 423 |
-
gr.Markdown("Developed by **Shahar Firshtman** and **Lior Feinstein**.")
|
| 424 |
-
gr.HTML(f"""
|
| 425 |
-
<div style="margin-top: 20px;">
|
| 426 |
-
<img src="data:image/jpeg;base64,{process_b64}" style="width: 100%; border-radius: 8px;">
|
| 427 |
-
</div>
|
| 428 |
-
""")
|
| 429 |
-
|
| 430 |
-
# === RIGHT COLUMN (Contacts) ===
|
| 431 |
-
with gr.Column(elem_classes=["col-right"]):
|
| 432 |
-
gr.Markdown("### Sponsored")
|
| 433 |
-
with gr.Group(elem_classes=["fb-card"]):
|
| 434 |
-
gr.Markdown("**Culinary School**\nJoin 10,000+ students learning to cook today!")
|
| 435 |
-
gr.Image("https://picsum.photos/300/150", show_label=False, interactive=False, height=150)
|
| 436 |
-
|
| 437 |
-
gr.HTML("<hr style='border:0; border-top:1px solid #ced0d4; margin: 10px 0;'>")
|
| 438 |
-
|
| 439 |
-
gr.Markdown("### Contacts")
|
| 440 |
-
contacts = ["Elon Musk", "Gordon Ramsay", "Jamie Oliver", "Martha Stewart"]
|
| 441 |
-
for contact in contacts:
|
| 442 |
-
gr.HTML(f"""
|
| 443 |
-
<div class="contact-row">
|
| 444 |
-
<div style="position:relative;">
|
| 445 |
-
<img src="https://ui-avatars.com/api/?name={contact}&background=random" style="width:36px; height:36px; border-radius:50%;">
|
| 446 |
-
<div style="position:absolute; bottom:0; right:0; width:10px; height:10px; background:#31a24c; border-radius:50%; border:2px solid white;"></div>
|
| 447 |
-
</div>
|
| 448 |
-
<div class="contact-name">{contact}</div>
|
| 449 |
-
</div>
|
| 450 |
-
""")
|
| 451 |
-
|
| 452 |
-
# ==========================================
|
| 453 |
-
# 6. NAVIGATION LOGIC
|
| 454 |
-
# ==========================================
|
| 455 |
-
def go_digi():
|
| 456 |
-
return (
|
| 457 |
-
gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
|
| 458 |
-
gr.update(elem_classes=["nav-btn", "selected"]), gr.update(elem_classes=["nav-btn"]), gr.update(elem_classes=["nav-btn"]), gr.update(elem_classes=["nav-btn"])
|
| 459 |
-
)
|
| 460 |
-
def go_feed():
|
| 461 |
-
return (
|
| 462 |
-
gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False),
|
| 463 |
-
gr.update(elem_classes=["nav-btn"]), gr.update(elem_classes=["nav-btn", "selected"]), gr.update(elem_classes=["nav-btn"]), gr.update(elem_classes=["nav-btn"])
|
| 464 |
-
)
|
| 465 |
-
def go_saved():
|
| 466 |
-
return (
|
| 467 |
-
gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False),
|
| 468 |
-
gr.update(elem_classes=["nav-btn"]), gr.update(elem_classes=["nav-btn"]), gr.update(elem_classes=["nav-btn", "selected"]), gr.update(elem_classes=["nav-btn"])
|
| 469 |
-
)
|
| 470 |
-
def go_about():
|
| 471 |
-
return (
|
| 472 |
-
gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True),
|
| 473 |
-
gr.update(elem_classes=["nav-btn"]), gr.update(elem_classes=["nav-btn"]), gr.update(elem_classes=["nav-btn"]), gr.update(elem_classes=["nav-btn", "selected"])
|
| 474 |
-
)
|
| 475 |
-
|
| 476 |
-
outputs_ui = [digitalizer_view, feed_view, saved_view, about_view, nav_digital, nav_feed, nav_saved, nav_about]
|
| 477 |
-
|
| 478 |
-
nav_digital.click(go_digi, None, outputs_ui)
|
| 479 |
-
nav_feed.click(go_feed, None, outputs_ui)
|
| 480 |
-
nav_saved.click(go_saved, None, outputs_ui)
|
| 481 |
-
nav_about.click(go_about, None, outputs_ui)
|
| 482 |
-
|
| 483 |
-
if __name__ == "__main__":
|
| 484 |
-
demo.launch()
|
|
|
|
| 169 |
align-items: center;
|
| 170 |
}
|
| 171 |
|
| 172 |
+
/* 2. LAYOUT COLUMNS - "FAT CENTER" CONFIGURATION */
|
| 173 |
.main-layout { display: flex; justify-content: center; padding-top: 20px; gap: 20px; }
|
| 174 |
|
| 175 |
+
/* Left Sidebar: Compact (220px) */
|
| 176 |
+
.col-left { width: 220px; display: none; }
|
| 177 |
|
| 178 |
+
/* Center Feed: FAT (900px) */
|
| 179 |
+
.col-feed { width: 900px; max-width: 100%; }
|
| 180 |
+
|
| 181 |
+
/* Right Sidebar: Standard (280px) */
|
| 182 |
.col-right { width: 280px; display: none; }
|
| 183 |
|
| 184 |
/* 3. CARD STYLING */
|
|
|
|
| 192 |
border: 1px solid #e4e6eb;
|
| 193 |
}
|
| 194 |
|
| 195 |
+
/* 4. NAVIGATION BUTTONS - FLUID WIDTH */
|
| 196 |
.nav-btn {
|
| 197 |
+
width: 100% !important; /* Resized to fit the new 220px container */
|
| 198 |
height: 42.5px !important;
|
| 199 |
text-align: left !important;
|
| 200 |
justify-content: flex-start !important;
|
|
|
|
| 204 |
color: #050505 !important;
|
| 205 |
font-weight: 600 !important;
|
| 206 |
font-size: 15px !important;
|
| 207 |
+
padding: 0 12px !important;
|
| 208 |
border-radius: 8px !important;
|
| 209 |
margin-bottom: 5px !important;
|
| 210 |
display: flex !important;
|
|
|
|
| 396 |
</div>
|
| 397 |
""")
|
| 398 |
gr.Markdown(f"**{row['Title']}**")
|
| 399 |
+
gr.Markdown(f"{str(row['Raw_Output'])[:300]}... <span style='color:#1877F2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|