Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import gradio as gr
|
2 |
-
from gradio_modal import Modal
|
3 |
from components.cards import create_food_card
|
4 |
from components.data import FOOD_DATA
|
5 |
|
@@ -20,8 +19,8 @@ with gr.Blocks(css="styles.css") as app:
|
|
20 |
"""
|
21 |
)
|
22 |
|
23 |
-
#
|
24 |
-
|
25 |
|
26 |
# Display all items as a vertical list
|
27 |
with gr.Column(elem_id="food-list"):
|
@@ -31,10 +30,17 @@ with gr.Blocks(css="styles.css") as app:
|
|
31 |
elem_id=f"food-{food_name.replace(' ', '-').lower()}",
|
32 |
interactive=True,
|
33 |
).click(
|
34 |
-
|
35 |
-
inputs=
|
36 |
-
outputs=
|
37 |
)
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
# Launch the app
|
40 |
app.launch()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
from components.cards import create_food_card
|
3 |
from components.data import FOOD_DATA
|
4 |
|
|
|
19 |
"""
|
20 |
)
|
21 |
|
22 |
+
# Define the popup area as an HTML component
|
23 |
+
popup_area = gr.HTML(visible=False, elem_id="popup")
|
24 |
|
25 |
# Display all items as a vertical list
|
26 |
with gr.Column(elem_id="food-list"):
|
|
|
30 |
elem_id=f"food-{food_name.replace(' ', '-').lower()}",
|
31 |
interactive=True,
|
32 |
).click(
|
33 |
+
display_card, # Update the popup content
|
34 |
+
inputs=[gr.Textbox(value=food_name, visible=False)],
|
35 |
+
outputs=popup_area # Set the HTML content of the popup
|
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()
|