Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,15 +2,9 @@ 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 |
-
return create_food_card(food_name)
|
| 9 |
-
else:
|
| 10 |
-
return "<p>No data available for the selected item.</p>"
|
| 11 |
-
|
| 12 |
-
# List of food items
|
| 13 |
-
food_items = list(FOOD_DATA.keys())
|
| 14 |
|
| 15 |
# Gradio app interface
|
| 16 |
with gr.Blocks(css="styles.css") as app:
|
|
@@ -18,22 +12,23 @@ with gr.Blocks(css="styles.css") as app:
|
|
| 18 |
gr.Markdown(
|
| 19 |
"""
|
| 20 |
### Explore Popular Dishes π
|
| 21 |
-
|
| 22 |
"""
|
| 23 |
)
|
| 24 |
|
|
|
|
| 25 |
with gr.Row():
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
|
| 35 |
-
#
|
| 36 |
-
|
| 37 |
|
| 38 |
# Launch the app
|
| 39 |
app.launch()
|
|
|
|
| 2 |
from components.cards import create_food_card
|
| 3 |
from components.data import FOOD_DATA
|
| 4 |
|
| 5 |
+
# Function to render the popup card when an item is clicked
|
| 6 |
def display_card(food_name):
|
| 7 |
+
return create_food_card(food_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Gradio app interface
|
| 10 |
with gr.Blocks(css="styles.css") as app:
|
|
|
|
| 12 |
gr.Markdown(
|
| 13 |
"""
|
| 14 |
### Explore Popular Dishes π
|
| 15 |
+
Click on any dish card below to view its image, nutritional facts, and portion size.
|
| 16 |
"""
|
| 17 |
)
|
| 18 |
|
| 19 |
+
# Display all items as clickable cards
|
| 20 |
with gr.Row():
|
| 21 |
+
for food_name in FOOD_DATA.keys():
|
| 22 |
+
with gr.Column():
|
| 23 |
+
# Each item card is a clickable button
|
| 24 |
+
gr.Button(
|
| 25 |
+
value=food_name,
|
| 26 |
+
elem_id=f"food-{food_name.replace(' ', '-').lower()}",
|
| 27 |
+
interactive=True,
|
| 28 |
+
).click(display_card, inputs=None, outputs=gr.HTML())
|
| 29 |
|
| 30 |
+
# Display area for the popup card
|
| 31 |
+
display_area = gr.HTML()
|
| 32 |
|
| 33 |
# Launch the app
|
| 34 |
app.launch()
|