Rammohan0504 commited on
Commit
e9c1860
·
verified ·
1 Parent(s): 1657c5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -12
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import gradio as gr
2
 
3
- # Menu data
4
  menu_data = [
5
  {"name": "Veg Burger", "category": "VEGAN",
6
  "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_burger.jpg",
@@ -119,7 +118,7 @@ def display_dishes(category):
119
  style='width: 150px; height: 100px; object-fit: cover; border-radius: 10px;'>
120
  <button onclick="showPopup('{dish['image']}', '{dish['name']}', '{dish['description']}', '{dish['price']}')"
121
  style="margin-top: 15px; padding: 10px 20px; background-color: #28a745; color: white; border: none;
122
- border-radius: 5px; cursor: pointer;">Add</button>
123
  </div>
124
  </div>
125
  """
@@ -141,7 +140,7 @@ with gr.Blocks() as demo:
141
 
142
  # JavaScript for managing the pop-up
143
  gr.HTML(f"""
144
- <div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, 150%);
145
  background-color: white; padding: 20px; border-radius: 10px;
146
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
147
  <img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">
@@ -172,12 +171,6 @@ with gr.Blocks() as demo:
172
  document.getElementById('popup-description').textContent = description;
173
  document.getElementById('popup-price').textContent = "Price: " + price;
174
 
175
- // Set the position of the popup
176
-
177
- popup.style.left = `${event.pageX + 10}px`; // Add a small offset
178
- popup.style.top = `${event.pageY + 10}px`; // Add a small offset
179
-
180
-
181
  // Display the popup
182
  document.getElementById('popup').style.display = 'block';
183
  }
@@ -188,9 +181,6 @@ with gr.Blocks() as demo:
188
  const selectedExtras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(cb => cb.value).join(", ");
189
  alert(dishName + " with " + spiceLevel + " spice level and extras: " + selectedExtras + " has been added to the cart!");
190
  }
191
-
192
-
193
- });
194
  </script>
195
  """)
196
 
 
1
  import gradio as gr
2
 
 
3
  menu_data = [
4
  {"name": "Veg Burger", "category": "VEGAN",
5
  "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_burger.jpg",
 
118
  style='width: 150px; height: 100px; object-fit: cover; border-radius: 10px;'>
119
  <button onclick="showPopup('{dish['image']}', '{dish['name']}', '{dish['description']}', '{dish['price']}')"
120
  style="margin-top: 15px; padding: 10px 20px; background-color: #28a745; color: white; border: none;
121
+ border-radius: 5px; cursor: pointer;">Add</button>
122
  </div>
123
  </div>
124
  """
 
140
 
141
  # JavaScript for managing the pop-up
142
  gr.HTML(f"""
143
+ <div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
144
  background-color: white; padding: 20px; border-radius: 10px;
145
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
146
  <img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">
 
171
  document.getElementById('popup-description').textContent = description;
172
  document.getElementById('popup-price').textContent = "Price: " + price;
173
 
 
 
 
 
 
 
174
  // Display the popup
175
  document.getElementById('popup').style.display = 'block';
176
  }
 
181
  const selectedExtras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(cb => cb.value).join(", ");
182
  alert(dishName + " with " + spiceLevel + " spice level and extras: " + selectedExtras + " has been added to the cart!");
183
  }
 
 
 
184
  </script>
185
  """)
186