Rammohan0504 commited on
Commit
67c46de
·
verified ·
1 Parent(s): cebd856

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -23
app.py CHANGED
@@ -149,23 +149,21 @@ popup_html = """
149
 
150
  # Generate dish cards
151
  def display_dishes(category):
152
- html_content = "<div style='display: flex; flex-direction: column; gap: 20px; width: 80%; margin: 0 auto;'>"
153
  for dish in menu_data:
154
  if category == "ALL" or dish["category"] == category:
155
  html_content += f"""
156
- <div style='display: flex; align-items: center; justify-content: space-between; padding: 20px; border: 1px solid #ddd; border-radius: 10px; background-color: #f9f9f9;'>
157
- <div style='flex: 3; text-align: left;'>
158
- <h3 style='margin: 0; font-size: 20px;'>{dish['name']}</h3>
159
- <p style='margin: 5px 0; font-size: 14px; color: #555;'>{dish['description']}</p>
160
- <p style='margin: 0; font-size: 16px; font-weight: bold;'>Price: {dish['price']}</p>
161
- </div>
162
- <div style='flex: 1; text-align: center;'>
163
- <img src='{dish['image']}' alt='{dish['name']}' style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px;'>
164
- <button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}', '{dish['image']}')"
165
- style='margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;'>
166
- Add
167
- </button>
168
- </div>
169
  </div>
170
  """
171
  html_content += "</div>"
@@ -190,17 +188,17 @@ with gr.Blocks() as demo:
190
  dish_display = gr.HTML(value=display_dishes("ALL"))
191
 
192
  btn_all.click(
193
- lambda: gr.update(value=display_dishes("ALL")),
194
- outputs=dish_display
195
- )
196
  btn_vegan.click(
197
- lambda: gr.update(value=display_dishes("VEGAN")),
198
- outputs=dish_display
199
- )
200
  btn_halal.click(
201
- lambda: gr.update(value=display_dishes("HALAL")),
202
- outputs=dish_display
203
- )
204
 
205
  with gr.Tab("Cart"):
206
  cart_display = gr.HTML(value=display_cart())
 
149
 
150
  # Generate dish cards
151
  def display_dishes(category):
152
+ html_content = "<div style='display: flex; flex-wrap: wrap; gap: 20px; width: 80%; margin: 0 auto;'>"
153
  for dish in menu_data:
154
  if category == "ALL" or dish["category"] == category:
155
  html_content += f"""
156
+ <div style='flex: 1 1 calc(30% - 20px); display: flex; flex-direction: column; align-items: center;
157
+ justify-content: space-between; padding: 20px; border: 1px solid #ddd; border-radius: 10px;
158
+ background-color: #f9f9f9; box-shadow: 0 4px 8px rgba(0,0,0,0.1);'>
159
+ <img src='{dish['image']}' alt='{dish['name']}' style='width: 100%; height: 150px; object-fit: cover; border-radius: 10px;'>
160
+ <h3 style='margin: 10px 0; font-size: 18px;'>{dish['name']}</h3>
161
+ <p style='margin: 5px 0; font-size: 14px; color: #555;'>{dish['description']}</p>
162
+ <p style='margin: 10px 0; font-size: 16px; font-weight: bold;'>Price: {dish['price']}</p>
163
+ <button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}', '{dish['image']}')"
164
+ style='padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;'>
165
+ Add
166
+ </button>
 
 
167
  </div>
168
  """
169
  html_content += "</div>"
 
188
  dish_display = gr.HTML(value=display_dishes("ALL"))
189
 
190
  btn_all.click(
191
+ lambda: display_dishes("ALL"),
192
+ outputs=dish_display
193
+ )
194
  btn_vegan.click(
195
+ lambda: display_dishes("VEGAN"),
196
+ outputs=dish_display
197
+ )
198
  btn_halal.click(
199
+ lambda: display_dishes("HALAL"),
200
+ outputs=dish_display
201
+ )
202
 
203
  with gr.Tab("Cart"):
204
  cart_display = gr.HTML(value=display_cart())