Spaces:
Sleeping
Sleeping
Create components/popup.py
Browse files- components/popup.py +50 -0
components/popup.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from components.cart import add_to_cart
|
3 |
+
|
4 |
+
def show_popup(dish_name, menu_data):
|
5 |
+
"""Displays the popup for the selected menu item."""
|
6 |
+
dish = menu_data[menu_data['Dish Name'] == dish_name].iloc[0]
|
7 |
+
popup = gr.Column([
|
8 |
+
gr.Markdown(f"### {dish_name} - ${dish['Price']}"),
|
9 |
+
gr.Image(f"static/images/{dish['Image']}"),
|
10 |
+
gr.Markdown(f"{dish['Description']}"),
|
11 |
+
|
12 |
+
# Spice Level
|
13 |
+
gr.Radio(
|
14 |
+
label="Choose a spice level (Required)",
|
15 |
+
choices=["American Mild", "American Medium", "American Spicy",
|
16 |
+
"Indian Mild", "Indian Medium", "Indian Very Spicy"],
|
17 |
+
value="Indian Medium"
|
18 |
+
),
|
19 |
+
|
20 |
+
# Extras
|
21 |
+
gr.CheckboxGroup(
|
22 |
+
label="Biryani Extras (Optional)",
|
23 |
+
choices=["Extra Raita 4oz + $1.00", "Extra Raita 8oz + $2.00",
|
24 |
+
"Extra Salan 8oz + $2.00", "Extra Onion + $1.00",
|
25 |
+
"Extra Onion & Lemon + $2.00", "Extra Fried Onion 4oz + $2.00"]
|
26 |
+
),
|
27 |
+
|
28 |
+
# Special Instructions
|
29 |
+
gr.Textbox(
|
30 |
+
label="Special Instructions",
|
31 |
+
placeholder="Add any requests here."
|
32 |
+
),
|
33 |
+
|
34 |
+
# Quantity
|
35 |
+
gr.Slider(
|
36 |
+
label="Quantity",
|
37 |
+
minimum=1,
|
38 |
+
maximum=10,
|
39 |
+
step=1,
|
40 |
+
value=1
|
41 |
+
),
|
42 |
+
|
43 |
+
# Add to Cart Button
|
44 |
+
gr.Button("Add to Bag").click(
|
45 |
+
add_to_cart,
|
46 |
+
inputs=[dish_name, gr.Radio, gr.CheckboxGroup, gr.Textbox, gr.Slider],
|
47 |
+
outputs="cart_display"
|
48 |
+
)
|
49 |
+
])
|
50 |
+
return popup
|