Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,16 +24,12 @@ def filter_menu(preference):
|
|
| 24 |
html_content = ""
|
| 25 |
for _, item in filtered_data.iterrows():
|
| 26 |
html_content += f"""
|
| 27 |
-
<div
|
| 28 |
-
<
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
</
|
| 33 |
-
<div style="flex-shrink: 0; text-align: center;">
|
| 34 |
-
<img src="{item['Image URL']}" alt="{item['Dish Name']}" style="width: 100px; height: 100px; border-radius: 8px; object-fit: cover; margin-bottom: 10px;">
|
| 35 |
-
<button value="{item['Dish Name']}" style="background-color: #28a745; color: white; border: none; padding: 8px 15px; font-size: 14px; border-radius: 5px; cursor: pointer;">View Details</button>
|
| 36 |
-
</div>
|
| 37 |
</div>
|
| 38 |
"""
|
| 39 |
return html_content
|
|
@@ -44,18 +40,18 @@ def render_dish_details(dish_name):
|
|
| 44 |
try:
|
| 45 |
dish = menu_data[menu_data["Dish Name"] == dish_name].iloc[0]
|
| 46 |
return (
|
| 47 |
-
dish["Image URL"],
|
| 48 |
-
dish_name,
|
| 49 |
-
dish["Description"]
|
| 50 |
-
f"${dish['Price ($)']}"
|
| 51 |
)
|
| 52 |
except IndexError:
|
| 53 |
raise ValueError(f"Dish '{dish_name}' not found!")
|
| 54 |
|
| 55 |
# Main Gradio app
|
| 56 |
def app():
|
| 57 |
-
with gr.Blocks() as demo:
|
| 58 |
-
gr.Markdown("## Menu with
|
| 59 |
|
| 60 |
# Menu page
|
| 61 |
preference_selector = gr.Radio(
|
|
@@ -66,7 +62,7 @@ def app():
|
|
| 66 |
menu_output = gr.HTML(value=filter_menu("All"))
|
| 67 |
|
| 68 |
# Modal window (hidden by default)
|
| 69 |
-
modal_window = gr.Column(visible=False)
|
| 70 |
modal_image = gr.Image(label="Dish Image")
|
| 71 |
modal_name = gr.Markdown()
|
| 72 |
modal_description = gr.Markdown()
|
|
|
|
| 24 |
html_content = ""
|
| 25 |
for _, item in filtered_data.iterrows():
|
| 26 |
html_content += f"""
|
| 27 |
+
<div class="menu-item">
|
| 28 |
+
<img src="{item['Image URL']}" alt="{item['Dish Name']}">
|
| 29 |
+
<h3>{item['Dish Name']}</h3>
|
| 30 |
+
<p>{item['Description']}</p>
|
| 31 |
+
<p><strong>${item['Price ($)']}</strong></p>
|
| 32 |
+
<button value="{item['Dish Name']}" onclick="showModal('{item['Dish Name']}')">Add</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
</div>
|
| 34 |
"""
|
| 35 |
return html_content
|
|
|
|
| 40 |
try:
|
| 41 |
dish = menu_data[menu_data["Dish Name"] == dish_name].iloc[0]
|
| 42 |
return (
|
| 43 |
+
dish["Image URL"],
|
| 44 |
+
dish_name,
|
| 45 |
+
dish["Description"],
|
| 46 |
+
f"${dish['Price ($)']}"
|
| 47 |
)
|
| 48 |
except IndexError:
|
| 49 |
raise ValueError(f"Dish '{dish_name}' not found!")
|
| 50 |
|
| 51 |
# Main Gradio app
|
| 52 |
def app():
|
| 53 |
+
with gr.Blocks(css="style.css") as demo:
|
| 54 |
+
gr.Markdown("## Dynamic Menu with Modal Window")
|
| 55 |
|
| 56 |
# Menu page
|
| 57 |
preference_selector = gr.Radio(
|
|
|
|
| 62 |
menu_output = gr.HTML(value=filter_menu("All"))
|
| 63 |
|
| 64 |
# Modal window (hidden by default)
|
| 65 |
+
modal_window = gr.Column(visible=False, elem_classes=["popup"])
|
| 66 |
modal_image = gr.Image(label="Dish Image")
|
| 67 |
modal_name = gr.Markdown()
|
| 68 |
modal_description = gr.Markdown()
|