Liori25 commited on
Commit
f2e5ff3
·
verified ·
1 Parent(s): d6104de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +105 -49
app.py CHANGED
@@ -89,12 +89,12 @@ def find_similar_recipes_list(query_text):
89
  row = df_recipes.iloc[idx]
90
  title = row['Title']
91
  desc = str(row['Raw_Output'])
92
- score_display = f"{score:.0%}"
93
 
 
94
  card_content = (
95
- f"<div class='suggested-header'>Suggested for you · {score_display} Match</div>"
96
- f"### 🥘 {title}\n"
97
- f"<div class='sim-scroll'>{desc}</div>"
98
  )
99
  results_list.append(card_content)
100
 
@@ -141,13 +141,12 @@ theme = gr.themes.Default(
141
  )
142
 
143
  facebook_css = """
144
- /* GLOBAL LOCK: This stops the whole page from scrolling */
145
  body, html {
146
  background-color: #f0f2f5;
147
  margin: 0;
148
  padding: 0;
149
- height: 100vh; /* Force height to screen size */
150
- overflow: hidden !important; /* Hide main scrollbar */
151
  }
152
  .gradio-container {
153
  background-color: #f0f2f5 !important;
@@ -166,7 +165,7 @@ footer { display: none !important; }
166
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
167
  display: flex;
168
  align-items: center;
169
- position: fixed; /* Fixed at top */
170
  top: 0;
171
  left: 0;
172
  right: 0;
@@ -174,67 +173,97 @@ footer { display: none !important; }
174
  justify-content: space-between;
175
  }
176
  .fb-logo {
177
- color: #1877F2; font-size: 28px; font-weight: 800; letter-spacing: -0.5px; margin-right: 20px; font-family: Helvetica, Arial, sans-serif;
 
 
 
 
 
178
  }
179
  .fb-search {
180
- background: #f0f2f5; border-radius: 50px; padding: 10px 20px; color: #65676B; width: 250px; display: flex; align-items: center;
 
 
 
 
 
 
181
  }
182
 
183
- /* 2. LAYOUT COLUMNS - INDEPENDENT SCROLLING */
184
- /* This container sits below the navbar and fills the screen */
185
  .main-layout {
186
  display: flex;
187
  justify-content: center;
188
- padding-top: 56px; /* Push down by navbar height */
189
  gap: 20px;
190
- max-width: 100%;
191
  margin: 0 auto;
192
- height: 100vh; /* Fill screen */
193
- box-sizing: border-box;
194
  }
195
 
196
- /* LEFT SIDEBAR: Fixed, no scroll */
197
  .col-left {
198
- width: 280px !important;
199
- min-width: 280px !important;
200
  flex-shrink: 0;
201
- height: 100%;
202
- overflow-y: hidden; /* No scroll */
203
- padding: 20px;
204
- display: none; /* Mobile hidden */
 
 
205
  }
206
 
207
- /* CENTER FEED: THIS IS THE ONLY THING THAT SCROLLS */
208
  .col-feed {
209
  flex-grow: 1;
210
- min-width: 500px;
211
- max-width: 800px;
212
  height: 100%;
213
- overflow-y: auto; /* Scrollable! */
214
- padding: 20px 0 100px 0; /* Padding for bottom spacing */
215
- scrollbar-width: none; /* Hide scrollbar for aesthetics */
216
  }
217
  .col-feed::-webkit-scrollbar { display: none; }
218
 
219
- /* RIGHT SIDEBAR: Fixed, no scroll */
220
  .col-right {
221
- width: 280px !important;
222
- min-width: 280px !important;
223
  flex-shrink: 0;
224
- height: 100%;
225
- overflow-y: hidden; /* No scroll */
226
- padding: 20px;
227
- display: none; /* Mobile hidden */
 
 
228
  }
229
 
230
  /* 3. CARD STYLING */
231
  .fb-card {
232
- background: white; border-radius: 10px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-bottom: 25px; overflow: hidden; padding: 16px; border: 1px solid #e4e6eb;
 
 
 
 
 
 
233
  }
234
 
235
  /* 4. NAVIGATION BUTTONS */
236
  .nav-btn {
237
- width: 100% !important; height: 48px !important; text-align: left !important; justify-content: flex-start !important; background: transparent !important; border: none !important; box-shadow: none !important; color: #050505 !important; font-weight: 600 !important; font-size: 15px !important; padding: 0 12px !important; border-radius: 8px !important; margin-bottom: 5px !important; display: flex !important; align-items: center !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  }
239
  .nav-btn:hover { background-color: #e4e6eb !important; }
240
  .nav-btn.selected { background-color: #e7f3ff !important; color: #1877f2 !important; }
@@ -247,32 +276,60 @@ footer { display: none !important; }
247
  .post-meta { font-size: 13px; color: #65676B; }
248
 
249
  /* 6. POST ACTIONS */
250
- .post-actions { border-top: 1px solid #ced0d4; margin-top: 10px; padding-top: 5px; display: flex; justify-content: space-around; }
 
 
 
 
 
 
251
  .action-btn { background: transparent !important; color: #65676B !important; box-shadow: none !important; }
252
  .action-btn:hover { background: #f2f2f2 !important; }
253
 
254
  /* 7. CONTACTS */
255
- .contact-row { display: flex; align-items: center; padding: 8px; border-radius: 8px; cursor: pointer; }
 
 
256
  .contact-row:hover { background-color: #e4e6eb; }
257
  .contact-name { font-weight: 500; font-size: 14px; margin-left: 10px; color: #050505; }
258
  .profile-row { display: flex; align-items: center; padding: 8px; border-radius: 8px; }
259
 
260
  /* 8. EXAMPLES */
261
  button.gallery-item { border: none !important; background: transparent !important; padding: 4px !important; }
262
- button.gallery-item img { width: 110px !important; height: 110px !important; border-radius: 12px !important; transition: all 0.3s ease !important; object-fit: cover; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
263
- button.gallery-item:hover img { transform: scale(1.15) !important; box-shadow: 0 8px 15px rgba(24, 119, 242, 0.3) !important; z-index: 10; }
 
 
 
 
 
264
 
265
  /* 9. SEE MORE LOGIC */
266
  details[open] > summary { display: none !important; }
267
 
268
  /* 10. MODERN UPLOAD IMAGE */
269
- .modern-image-container button { border-radius: 8px !important; overflow: hidden !important; border: 1px solid #e4e6eb !important; box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important; padding: 0 !important; }
270
- .modern-image-container img { border-radius: 8px !important; width: 100% !important; max-height: 400px !important; object-fit: cover !important; }
271
- .modern-image-container .download-button, .modern-image-container .share-button, .modern-image-container button[title="Download"], .modern-image-container button[title="Share"] { display: none !important; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
 
273
  /* UTILS */
274
  .sim-scroll { height: 200px; overflow-y: auto; font-size: 13px; color: #050505; }
275
- .suggested-header { font-size: 12px; font-weight: bold; color: #65676B; margin-bottom: 5px; }
276
  @media (min-width: 1100px) { .col-left, .col-right { display: block; } }
277
  """
278
 
@@ -337,7 +394,6 @@ with gr.Blocks(title="CookBook") as demo:
337
  gr.HTML("<hr style='border:0; border-top:1px solid #e4e6eb; margin: 10px 0;'>")
338
 
339
  with gr.Row():
340
- # FIXED: Image upload without crash
341
  input_img = gr.Image(
342
  type="filepath",
343
  label="Upload Recipe",
@@ -383,10 +439,10 @@ with gr.Blocks(title="CookBook") as demo:
383
  gr.Button("💬 Comment", elem_classes=["action-btn"], size="sm")
384
  gr.Button("📥 Save", elem_classes=["action-btn"], size="sm")
385
 
386
- # SECTION C: SUGGESTIONS
387
  with gr.Group(visible=True):
388
  gr.HTML("<br><hr style='border:0; border-top:1px solid #ced0d4; margin: 15px 0;'><br>")
389
- gr.Markdown("### Suggested Pairings")
390
 
391
  with gr.Group(elem_classes=["fb-card"], visible=False) as c1_box:
392
  sim1 = gr.Markdown("Similar Recipe 1")
 
89
  row = df_recipes.iloc[idx]
90
  title = row['Title']
91
  desc = str(row['Raw_Output'])
 
92
 
93
+ # --- MODIFIED: Show Title, Exact Score (3 decimals), and Description ---
94
  card_content = (
95
+ f"<div style='font-weight: bold; font-size: 16px; margin-bottom: 4px; color: #050505;'>🥘 {title}</div>"
96
+ f"<div style='color: #1877F2; font-size: 13px; font-weight: 600; margin-bottom: 8px;'>Similarity Score: {score:.3f}</div>"
97
+ f"<div class='sim-scroll' style='font-size: 13px; color: #050505;'>{desc}</div>"
98
  )
99
  results_list.append(card_content)
100
 
 
141
  )
142
 
143
  facebook_css = """
 
144
  body, html {
145
  background-color: #f0f2f5;
146
  margin: 0;
147
  padding: 0;
148
+ height: 100vh;
149
+ overflow: hidden !important;
150
  }
151
  .gradio-container {
152
  background-color: #f0f2f5 !important;
 
165
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
166
  display: flex;
167
  align-items: center;
168
+ position: fixed;
169
  top: 0;
170
  left: 0;
171
  right: 0;
 
173
  justify-content: space-between;
174
  }
175
  .fb-logo {
176
+ color: #1877F2;
177
+ font-size: 28px;
178
+ font-weight: 800;
179
+ letter-spacing: -0.5px;
180
+ margin-right: 20px;
181
+ font-family: Helvetica, Arial, sans-serif;
182
  }
183
  .fb-search {
184
+ background: #f0f2f5;
185
+ border-radius: 50px;
186
+ padding: 10px 20px;
187
+ color: #65676B;
188
+ width: 250px;
189
+ display: flex;
190
+ align-items: center;
191
  }
192
 
193
+ /* 2. LAYOUT COLUMNS */
 
194
  .main-layout {
195
  display: flex;
196
  justify-content: center;
197
+ padding-top: 56px;
198
  gap: 20px;
199
+ max-width: 1600px;
200
  margin: 0 auto;
201
+ align-items: flex-start;
 
202
  }
203
 
 
204
  .col-left {
205
+ width: 200px !important;
206
+ min-width: 200px !important;
207
  flex-shrink: 0;
208
+ display: none;
209
+ position: sticky;
210
+ top: 76px;
211
+ height: calc(100vh - 80px);
212
+ overflow-y: auto;
213
+ scrollbar-width: none;
214
  }
215
 
 
216
  .col-feed {
217
  flex-grow: 1;
218
+ min-width: 600px;
219
+ max-width: 1000px;
220
  height: 100%;
221
+ overflow-y: auto;
222
+ padding: 20px 0 100px 0;
223
+ scrollbar-width: none;
224
  }
225
  .col-feed::-webkit-scrollbar { display: none; }
226
 
 
227
  .col-right {
228
+ width: 240px !important;
229
+ min-width: 240px !important;
230
  flex-shrink: 0;
231
+ display: none;
232
+ position: sticky;
233
+ top: 76px;
234
+ height: calc(100vh - 80px);
235
+ overflow-y: auto;
236
+ scrollbar-width: none;
237
  }
238
 
239
  /* 3. CARD STYLING */
240
  .fb-card {
241
+ background: white;
242
+ border-radius: 10px;
243
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
244
+ margin-bottom: 25px;
245
+ overflow: hidden;
246
+ padding: 16px;
247
+ border: 1px solid #e4e6eb;
248
  }
249
 
250
  /* 4. NAVIGATION BUTTONS */
251
  .nav-btn {
252
+ width: 100% !important;
253
+ height: 42.5px !important;
254
+ text-align: left !important;
255
+ justify-content: flex-start !important;
256
+ background: transparent !important;
257
+ border: none !important;
258
+ box-shadow: none !important;
259
+ color: #050505 !important;
260
+ font-weight: 600 !important;
261
+ font-size: 15px !important;
262
+ padding: 0 12px !important;
263
+ border-radius: 8px !important;
264
+ margin-bottom: 5px !important;
265
+ display: flex !important;
266
+ align-items: center !important;
267
  }
268
  .nav-btn:hover { background-color: #e4e6eb !important; }
269
  .nav-btn.selected { background-color: #e7f3ff !important; color: #1877f2 !important; }
 
276
  .post-meta { font-size: 13px; color: #65676B; }
277
 
278
  /* 6. POST ACTIONS */
279
+ .post-actions {
280
+ border-top: 1px solid #ced0d4;
281
+ margin-top: 10px;
282
+ padding-top: 5px;
283
+ display: flex;
284
+ justify-content: space-around;
285
+ }
286
  .action-btn { background: transparent !important; color: #65676B !important; box-shadow: none !important; }
287
  .action-btn:hover { background: #f2f2f2 !important; }
288
 
289
  /* 7. CONTACTS */
290
+ .contact-row {
291
+ display: flex; align-items: center; padding: 8px; border-radius: 8px; cursor: pointer;
292
+ }
293
  .contact-row:hover { background-color: #e4e6eb; }
294
  .contact-name { font-weight: 500; font-size: 14px; margin-left: 10px; color: #050505; }
295
  .profile-row { display: flex; align-items: center; padding: 8px; border-radius: 8px; }
296
 
297
  /* 8. EXAMPLES */
298
  button.gallery-item { border: none !important; background: transparent !important; padding: 4px !important; }
299
+ button.gallery-item img {
300
+ width: 110px !important; height: 110px !important; border-radius: 12px !important;
301
+ transition: all 0.3s ease !important; object-fit: cover; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
302
+ }
303
+ button.gallery-item:hover img {
304
+ transform: scale(1.15) !important; box-shadow: 0 8px 15px rgba(24, 119, 242, 0.3) !important; z-index: 10;
305
+ }
306
 
307
  /* 9. SEE MORE LOGIC */
308
  details[open] > summary { display: none !important; }
309
 
310
  /* 10. MODERN UPLOAD IMAGE */
311
+ .modern-image-container button {
312
+ border-radius: 8px !important;
313
+ overflow: hidden !important;
314
+ border: 1px solid #e4e6eb !important;
315
+ box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
316
+ padding: 0 !important;
317
+ }
318
+ .modern-image-container img {
319
+ border-radius: 8px !important;
320
+ width: 100% !important;
321
+ max-height: 400px !important;
322
+ object-fit: cover !important;
323
+ }
324
+ .modern-image-container .download-button,
325
+ .modern-image-container .share-button,
326
+ .modern-image-container button[title="Download"],
327
+ .modern-image-container button[title="Share"] {
328
+ display: none !important;
329
+ }
330
 
331
  /* UTILS */
332
  .sim-scroll { height: 200px; overflow-y: auto; font-size: 13px; color: #050505; }
 
333
  @media (min-width: 1100px) { .col-left, .col-right { display: block; } }
334
  """
335
 
 
394
  gr.HTML("<hr style='border:0; border-top:1px solid #e4e6eb; margin: 10px 0;'>")
395
 
396
  with gr.Row():
 
397
  input_img = gr.Image(
398
  type="filepath",
399
  label="Upload Recipe",
 
439
  gr.Button("💬 Comment", elem_classes=["action-btn"], size="sm")
440
  gr.Button("📥 Save", elem_classes=["action-btn"], size="sm")
441
 
442
+ # SECTION C: SIMILAR RECIPES
443
  with gr.Group(visible=True):
444
  gr.HTML("<br><hr style='border:0; border-top:1px solid #ced0d4; margin: 15px 0;'><br>")
445
+ gr.Markdown("### 🔍 Similar Recipes")
446
 
447
  with gr.Group(elem_classes=["fb-card"], visible=False) as c1_box:
448
  sim1 = gr.Markdown("Similar Recipe 1")