Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -90,10 +90,11 @@ def find_similar_recipes_list(query_text):
|
|
| 90 |
title = row['Title']
|
| 91 |
desc = str(row['Raw_Output'])
|
| 92 |
|
|
|
|
| 93 |
card_content = (
|
| 94 |
-
f"<div style='font-weight: bold; font-size:
|
| 95 |
-
f"<div style='color: #1877F2; font-size:
|
| 96 |
-
f"<div class='sim-scroll' style='font-size:
|
| 97 |
)
|
| 98 |
results_list.append(card_content)
|
| 99 |
|
|
@@ -144,7 +145,7 @@ body { background-color: #f0f2f5; margin: 0; padding: 0; }
|
|
| 144 |
.gradio-container { background-color: #f0f2f5 !important; max-width: 100% !important; margin: 0 !important; padding: 0 !important; }
|
| 145 |
footer { display: none !important; }
|
| 146 |
|
| 147 |
-
/* 1.
|
| 148 |
.fb-navbar {
|
| 149 |
background: white;
|
| 150 |
height: 56px;
|
|
@@ -152,7 +153,7 @@ footer { display: none !important; }
|
|
| 152 |
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
| 153 |
display: flex;
|
| 154 |
align-items: center;
|
| 155 |
-
position: sticky;
|
| 156 |
top: 0;
|
| 157 |
z-index: 999;
|
| 158 |
justify-content: space-between;
|
|
@@ -175,7 +176,7 @@ footer { display: none !important; }
|
|
| 175 |
align-items: center;
|
| 176 |
}
|
| 177 |
|
| 178 |
-
/* 2. LAYOUT COLUMNS
|
| 179 |
.main-layout {
|
| 180 |
display: flex;
|
| 181 |
justify-content: center;
|
|
@@ -186,29 +187,24 @@ footer { display: none !important; }
|
|
| 186 |
align-items: flex-start;
|
| 187 |
}
|
| 188 |
|
| 189 |
-
/* Left Sidebar */
|
| 190 |
.col-left {
|
| 191 |
width: 280px !important;
|
| 192 |
min-width: 280px !important;
|
| 193 |
flex-shrink: 0;
|
| 194 |
-
display: none;
|
| 195 |
-
/* No position: sticky here anymore */
|
| 196 |
}
|
| 197 |
|
| 198 |
-
/* Center Feed */
|
| 199 |
.col-feed {
|
| 200 |
flex-grow: 1;
|
| 201 |
min-width: 600px;
|
| 202 |
max-width: 1000px;
|
| 203 |
-
/* No overflow-y auto here, let the page scroll */
|
| 204 |
}
|
| 205 |
|
| 206 |
-
/* Right Sidebar */
|
| 207 |
.col-right {
|
| 208 |
width: 280px !important;
|
| 209 |
min-width: 280px !important;
|
| 210 |
flex-shrink: 0;
|
| 211 |
-
display: none;
|
| 212 |
}
|
| 213 |
|
| 214 |
/* 3. CARD STYLING */
|
|
@@ -304,7 +300,7 @@ details[open] > summary { display: none !important; }
|
|
| 304 |
}
|
| 305 |
|
| 306 |
/* UTILS */
|
| 307 |
-
.sim-scroll { height:
|
| 308 |
.suggested-header { font-size: 12px; font-weight: bold; color: #65676B; margin-bottom: 5px; }
|
| 309 |
@media (min-width: 1100px) { .col-left, .col-right { display: block; } }
|
| 310 |
"""
|
|
@@ -393,8 +389,8 @@ with gr.Blocks(title="CookBook") as demo:
|
|
| 393 |
gr.HTML("<div style='height:10px'></div>")
|
| 394 |
magic_btn = gr.Button("β¨ Convert to Text", variant="primary")
|
| 395 |
|
| 396 |
-
# ---
|
| 397 |
-
gr.HTML("<div style='height:
|
| 398 |
|
| 399 |
# SECTION B: TEXT OUTPUT
|
| 400 |
with gr.Group(elem_classes=["fb-card"]):
|
|
@@ -415,27 +411,41 @@ with gr.Blocks(title="CookBook") as demo:
|
|
| 415 |
gr.Button("π¬ Comment", elem_classes=["action-btn"], size="sm")
|
| 416 |
gr.Button("π₯ Save", elem_classes=["action-btn"], size="sm")
|
| 417 |
|
| 418 |
-
# SECTION C: SIMILAR RECIPES
|
| 419 |
with gr.Group(visible=True):
|
| 420 |
-
gr.HTML("<br><hr style='border:0; border-top:1px solid #ced0d4; margin:
|
| 421 |
gr.Markdown("### π Similar Recipes")
|
| 422 |
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
|
| 440 |
# --- VIEW 2: FEED ---
|
| 441 |
with gr.Column(visible=False) as feed_view:
|
|
|
|
| 90 |
title = row['Title']
|
| 91 |
desc = str(row['Raw_Output'])
|
| 92 |
|
| 93 |
+
# HTML Content for Similar Cards
|
| 94 |
card_content = (
|
| 95 |
+
f"<div style='font-weight: bold; font-size: 15px; margin-bottom: 4px; color: #050505; height: 40px; overflow: hidden;'>π₯ {title}</div>"
|
| 96 |
+
f"<div style='color: #1877F2; font-size: 12px; font-weight: 600; margin-bottom: 8px;'>Match: {score:.3f}</div>"
|
| 97 |
+
f"<div class='sim-scroll' style='font-size: 12px; color: #65676B; height: 150px;'>{desc}</div>"
|
| 98 |
)
|
| 99 |
results_list.append(card_content)
|
| 100 |
|
|
|
|
| 145 |
.gradio-container { background-color: #f0f2f5 !important; max-width: 100% !important; margin: 0 !important; padding: 0 !important; }
|
| 146 |
footer { display: none !important; }
|
| 147 |
|
| 148 |
+
/* 1. STICKY NAVBAR */
|
| 149 |
.fb-navbar {
|
| 150 |
background: white;
|
| 151 |
height: 56px;
|
|
|
|
| 153 |
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
| 154 |
display: flex;
|
| 155 |
align-items: center;
|
| 156 |
+
position: sticky;
|
| 157 |
top: 0;
|
| 158 |
z-index: 999;
|
| 159 |
justify-content: space-between;
|
|
|
|
| 176 |
align-items: center;
|
| 177 |
}
|
| 178 |
|
| 179 |
+
/* 2. LAYOUT COLUMNS */
|
| 180 |
.main-layout {
|
| 181 |
display: flex;
|
| 182 |
justify-content: center;
|
|
|
|
| 187 |
align-items: flex-start;
|
| 188 |
}
|
| 189 |
|
|
|
|
| 190 |
.col-left {
|
| 191 |
width: 280px !important;
|
| 192 |
min-width: 280px !important;
|
| 193 |
flex-shrink: 0;
|
| 194 |
+
display: none;
|
|
|
|
| 195 |
}
|
| 196 |
|
|
|
|
| 197 |
.col-feed {
|
| 198 |
flex-grow: 1;
|
| 199 |
min-width: 600px;
|
| 200 |
max-width: 1000px;
|
|
|
|
| 201 |
}
|
| 202 |
|
|
|
|
| 203 |
.col-right {
|
| 204 |
width: 280px !important;
|
| 205 |
min-width: 280px !important;
|
| 206 |
flex-shrink: 0;
|
| 207 |
+
display: none;
|
| 208 |
}
|
| 209 |
|
| 210 |
/* 3. CARD STYLING */
|
|
|
|
| 300 |
}
|
| 301 |
|
| 302 |
/* UTILS */
|
| 303 |
+
.sim-scroll { height: 150px; overflow-y: auto; font-size: 13px; color: #050505; }
|
| 304 |
.suggested-header { font-size: 12px; font-weight: bold; color: #65676B; margin-bottom: 5px; }
|
| 305 |
@media (min-width: 1100px) { .col-left, .col-right { display: block; } }
|
| 306 |
"""
|
|
|
|
| 389 |
gr.HTML("<div style='height:10px'></div>")
|
| 390 |
magic_btn = gr.Button("β¨ Convert to Text", variant="primary")
|
| 391 |
|
| 392 |
+
# --- 30 PIXEL SPACER (INCREASED) ---
|
| 393 |
+
gr.HTML("<div style='height: 30px;'></div>")
|
| 394 |
|
| 395 |
# SECTION B: TEXT OUTPUT
|
| 396 |
with gr.Group(elem_classes=["fb-card"]):
|
|
|
|
| 411 |
gr.Button("π¬ Comment", elem_classes=["action-btn"], size="sm")
|
| 412 |
gr.Button("π₯ Save", elem_classes=["action-btn"], size="sm")
|
| 413 |
|
| 414 |
+
# SECTION C: SIMILAR RECIPES (SEPARATE HORIZONTAL ROW)
|
| 415 |
with gr.Group(visible=True):
|
| 416 |
+
gr.HTML("<br><hr style='border:0; border-top:1px solid #ced0d4; margin: 20px 0;'><br>")
|
| 417 |
gr.Markdown("### π Similar Recipes")
|
| 418 |
|
| 419 |
+
# USE ROW to place cards next to each other
|
| 420 |
+
with gr.Row():
|
| 421 |
+
|
| 422 |
+
# Recipe 1
|
| 423 |
+
with gr.Column(scale=1, min_width=200):
|
| 424 |
+
with gr.Group(elem_classes=["fb-card"]):
|
| 425 |
+
sim1 = gr.HTML("Waiting for results...")
|
| 426 |
+
with gr.Row(elem_classes=["post-actions"], visible=False) as c1_btns:
|
| 427 |
+
gr.Button("Save", elem_classes=["action-btn"], size="sm")
|
| 428 |
+
|
| 429 |
+
# Recipe 2
|
| 430 |
+
with gr.Column(scale=1, min_width=200):
|
| 431 |
+
with gr.Group(elem_classes=["fb-card"]):
|
| 432 |
+
sim2 = gr.HTML("Waiting for results...")
|
| 433 |
+
with gr.Row(elem_classes=["post-actions"], visible=False) as c2_btns:
|
| 434 |
+
gr.Button("Save", elem_classes=["action-btn"], size="sm")
|
| 435 |
+
|
| 436 |
+
# Recipe 3
|
| 437 |
+
with gr.Column(scale=1, min_width=200):
|
| 438 |
+
with gr.Group(elem_classes=["fb-card"]):
|
| 439 |
+
sim3 = gr.HTML("Waiting for results...")
|
| 440 |
+
with gr.Row(elem_classes=["post-actions"], visible=False) as c3_btns:
|
| 441 |
+
gr.Button("Save", elem_classes=["action-btn"], size="sm")
|
| 442 |
+
|
| 443 |
+
# Corrected Output Mapping for the new HTML components
|
| 444 |
+
magic_btn.click(
|
| 445 |
+
ui_update_pipeline,
|
| 446 |
+
input_img,
|
| 447 |
+
[out_text, sim1, c1_btns, sim2, c2_btns, sim3, c3_btns]
|
| 448 |
+
)
|
| 449 |
|
| 450 |
# --- VIEW 2: FEED ---
|
| 451 |
with gr.Column(visible=False) as feed_view:
|