Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,13 +2,13 @@ import gradio as gr
|
|
| 2 |
from food_data import FOOD_ITEMS
|
| 3 |
|
| 4 |
def get_food_details(name, image, nutrition):
|
| 5 |
-
"""Returns
|
| 6 |
return f"""
|
| 7 |
<div style='text-align: center;'>
|
| 8 |
-
<img src='{image}' alt='{name}' style='width: 100%; border-radius: 10px;'>
|
| 9 |
-
<h3>{name}</h3>
|
| 10 |
-
<p>{nutrition}</p>
|
| 11 |
-
<p style='color: gray;'>Portion Size: Standard</p>
|
| 12 |
</div>
|
| 13 |
"""
|
| 14 |
|
|
@@ -21,19 +21,18 @@ with gr.Blocks(css="templates/style.css") as demo:
|
|
| 21 |
gr.Markdown(f"<h2 style='color:#FF6347;'>{category} Menu</h2>")
|
| 22 |
with gr.Row():
|
| 23 |
for idx, item in enumerate(items):
|
| 24 |
-
# Each block must have a unique variable or unique creation
|
| 25 |
with gr.Column():
|
| 26 |
btn = gr.Button(f"{item['name']}", elem_id=f"menu-item-{idx}")
|
| 27 |
-
|
| 28 |
|
| 29 |
btn.click(
|
| 30 |
fn=get_food_details,
|
| 31 |
inputs=[
|
| 32 |
-
gr.Text(item['name']),
|
| 33 |
-
gr.Text(item['image']),
|
| 34 |
gr.Text(item['nutrition'])
|
| 35 |
],
|
| 36 |
-
outputs=
|
| 37 |
)
|
| 38 |
|
| 39 |
gr.Markdown("<p style='text-align:center; margin-top:20px;'>© 2024 Delicious Restaurant | Built with ❤️</p>")
|
|
|
|
| 2 |
from food_data import FOOD_ITEMS
|
| 3 |
|
| 4 |
def get_food_details(name, image, nutrition):
|
| 5 |
+
"""Returns formatted HTML content for popup with an image and nutrition details."""
|
| 6 |
return f"""
|
| 7 |
<div style='text-align: center;'>
|
| 8 |
+
<img src='{image}' alt='{name}' style='width: 100%; max-height: 200px; border-radius: 10px;'>
|
| 9 |
+
<h3 style="margin: 10px 0; font-size: 1.5em;">{name}</h3>
|
| 10 |
+
<p style="font-size: 1.1em; color: #555;">{nutrition}</p>
|
| 11 |
+
<p style='color: gray; font-size: 0.9em;'>Portion Size: Standard</p>
|
| 12 |
</div>
|
| 13 |
"""
|
| 14 |
|
|
|
|
| 21 |
gr.Markdown(f"<h2 style='color:#FF6347;'>{category} Menu</h2>")
|
| 22 |
with gr.Row():
|
| 23 |
for idx, item in enumerate(items):
|
|
|
|
| 24 |
with gr.Column():
|
| 25 |
btn = gr.Button(f"{item['name']}", elem_id=f"menu-item-{idx}")
|
| 26 |
+
popup_output = gr.HTML("") # Output HTML for image and nutrition
|
| 27 |
|
| 28 |
btn.click(
|
| 29 |
fn=get_food_details,
|
| 30 |
inputs=[
|
| 31 |
+
gr.Text(item['name']),
|
| 32 |
+
gr.Text(item['image']),
|
| 33 |
gr.Text(item['nutrition'])
|
| 34 |
],
|
| 35 |
+
outputs=popup_output
|
| 36 |
)
|
| 37 |
|
| 38 |
gr.Markdown("<p style='text-align:center; margin-top:20px;'>© 2024 Delicious Restaurant | Built with ❤️</p>")
|