Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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-
|
| 153 |
for dish in menu_data:
|
| 154 |
if category == "ALL" or dish["category"] == category:
|
| 155 |
html_content += f"""
|
| 156 |
-
<div style='
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
</
|
| 162 |
-
<
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 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 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
btn_vegan.click(
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
btn_halal.click(
|
| 201 |
-
|
| 202 |
-
|
| 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())
|