Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,27 @@ import gradio as gr
|
|
2 |
from components.cards import create_food_card
|
3 |
from components.data import FOOD_DATA
|
4 |
|
5 |
-
# Function to
|
6 |
def display_card(food_name):
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# Gradio app interface
|
13 |
with gr.Blocks(css="styles.css") as app:
|
@@ -30,17 +45,10 @@ with gr.Blocks(css="styles.css") as app:
|
|
30 |
elem_id=f"food-{food_name.replace(' ', '-').lower()}",
|
31 |
interactive=True,
|
32 |
).click(
|
33 |
-
display_card,
|
34 |
-
inputs=
|
35 |
-
outputs=popup_area
|
36 |
)
|
37 |
|
38 |
-
# Close popup button
|
39 |
-
gr.Button("Close Popup", elem_id="close-popup").click(
|
40 |
-
lambda: "", # Clear the popup content
|
41 |
-
inputs=None,
|
42 |
-
outputs=popup_area,
|
43 |
-
)
|
44 |
-
|
45 |
# Launch the app
|
46 |
app.launch()
|
|
|
2 |
from components.cards import create_food_card
|
3 |
from components.data import FOOD_DATA
|
4 |
|
5 |
+
# Function to generate popup card content
|
6 |
def display_card(food_name):
|
7 |
+
food_info = FOOD_DATA[food_name]
|
8 |
+
image_src = f"assets/images/{food_info['image']}"
|
9 |
+
description = food_info["description"]
|
10 |
+
price = food_info["price"]
|
11 |
+
|
12 |
+
# HTML for the popup
|
13 |
+
card_html = f"""
|
14 |
+
<div class="popup-card">
|
15 |
+
<img src="{image_src}" alt="{food_name}" class="popup-image" />
|
16 |
+
<div class="popup-content">
|
17 |
+
<h3>{food_name}</h3>
|
18 |
+
<p class="price">₹{price}</p>
|
19 |
+
<button class="add-btn">ADD</button>
|
20 |
+
<p class="customizable">Customizable</p>
|
21 |
+
<p class="description">{description}</p>
|
22 |
+
</div>
|
23 |
+
</div>
|
24 |
+
"""
|
25 |
+
return card_html
|
26 |
|
27 |
# Gradio app interface
|
28 |
with gr.Blocks(css="styles.css") as app:
|
|
|
45 |
elem_id=f"food-{food_name.replace(' ', '-').lower()}",
|
46 |
interactive=True,
|
47 |
).click(
|
48 |
+
lambda x=food_name: display_card(x),
|
49 |
+
inputs=None,
|
50 |
+
outputs=popup_area
|
51 |
)
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
# Launch the app
|
54 |
app.launch()
|