nagasurendra commited on
Commit
c6f513e
·
verified ·
1 Parent(s): 56e9f63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -17
app.py CHANGED
@@ -24,16 +24,12 @@ def filter_menu(preference):
24
  html_content = ""
25
  for _, item in filtered_data.iterrows():
26
  html_content += f"""
27
- <div style="display: flex; align-items: center; border: 1px solid #ddd; border-radius: 8px; padding: 15px; margin-bottom: 10px; box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);">
28
- <div style="flex: 1; margin-right: 15px;">
29
- <h3 style="margin: 0; font-size: 18px;">{item['Dish Name']}</h3>
30
- <p style="margin: 5px 0; font-size: 16px; color: #888;">${item['Price ($)']}</p>
31
- <p style="margin: 5px 0; font-size: 14px; color: #555;">{item['Description']}</p>
32
- </div>
33
- <div style="flex-shrink: 0; text-align: center;">
34
- <img src="{item['Image URL']}" alt="{item['Dish Name']}" style="width: 100px; height: 100px; border-radius: 8px; object-fit: cover; margin-bottom: 10px;">
35
- <button value="{item['Dish Name']}" style="background-color: #28a745; color: white; border: none; padding: 8px 15px; font-size: 14px; border-radius: 5px; cursor: pointer;">View Details</button>
36
- </div>
37
  </div>
38
  """
39
  return html_content
@@ -44,18 +40,18 @@ def render_dish_details(dish_name):
44
  try:
45
  dish = menu_data[menu_data["Dish Name"] == dish_name].iloc[0]
46
  return (
47
- dish["Image URL"], # Image
48
- dish_name, # Dish name
49
- dish["Description"],# Description
50
- f"${dish['Price ($)']}" # Price
51
  )
52
  except IndexError:
53
  raise ValueError(f"Dish '{dish_name}' not found!")
54
 
55
  # Main Gradio app
56
  def app():
57
- with gr.Blocks() as demo:
58
- gr.Markdown("## Menu with Suggestions")
59
 
60
  # Menu page
61
  preference_selector = gr.Radio(
@@ -66,7 +62,7 @@ def app():
66
  menu_output = gr.HTML(value=filter_menu("All"))
67
 
68
  # Modal window (hidden by default)
69
- modal_window = gr.Column(visible=False)
70
  modal_image = gr.Image(label="Dish Image")
71
  modal_name = gr.Markdown()
72
  modal_description = gr.Markdown()
 
24
  html_content = ""
25
  for _, item in filtered_data.iterrows():
26
  html_content += f"""
27
+ <div class="menu-item">
28
+ <img src="{item['Image URL']}" alt="{item['Dish Name']}">
29
+ <h3>{item['Dish Name']}</h3>
30
+ <p>{item['Description']}</p>
31
+ <p><strong>${item['Price ($)']}</strong></p>
32
+ <button value="{item['Dish Name']}" onclick="showModal('{item['Dish Name']}')">Add</button>
 
 
 
 
33
  </div>
34
  """
35
  return html_content
 
40
  try:
41
  dish = menu_data[menu_data["Dish Name"] == dish_name].iloc[0]
42
  return (
43
+ dish["Image URL"],
44
+ dish_name,
45
+ dish["Description"],
46
+ f"${dish['Price ($)']}"
47
  )
48
  except IndexError:
49
  raise ValueError(f"Dish '{dish_name}' not found!")
50
 
51
  # Main Gradio app
52
  def app():
53
+ with gr.Blocks(css="style.css") as demo:
54
+ gr.Markdown("## Dynamic Menu with Modal Window")
55
 
56
  # Menu page
57
  preference_selector = gr.Radio(
 
62
  menu_output = gr.HTML(value=filter_menu("All"))
63
 
64
  # Modal window (hidden by default)
65
+ modal_window = gr.Column(visible=False, elem_classes=["popup"])
66
  modal_image = gr.Image(label="Dish Image")
67
  modal_name = gr.Markdown()
68
  modal_description = gr.Markdown()