DSatishchandra commited on
Commit
afb6d97
·
verified ·
1 Parent(s): f148c8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -14
app.py CHANGED
@@ -35,7 +35,7 @@ def filter_menu(preference):
35
  </div>
36
  <div style="flex-shrink: 0; text-align: center;">
37
  <img src="{item['Image URL']}" alt="{item['Dish Name']}" style="width: 100px; height: 100px; border-radius: 8px; object-fit: cover; margin-bottom: 10px;">
38
- <button style="background-color: #28a745; color: white; border: none; padding: 8px 15px; font-size: 14px; border-radius: 5px; cursor: pointer;" onclick="openModal('{item['Dish Name']}', '{item['Image URL']}', '{item['Description']}', '{item['Price ($)']}')">Add</button>
39
  </div>
40
  </div>
41
  """
@@ -76,20 +76,13 @@ def app():
76
  modal_window = gr.HTML("""
77
  <div id="modal" style="
78
  display: none;
79
- position: fixed;
80
- top: 50%;
81
- left: 50%;
82
- transform: translate(-50%, -50%);
83
- width: 90%;
84
- max-width: 500px;
85
- max-height: 90%;
86
  background: white;
 
87
  border-radius: 15px;
88
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
89
- padding: 20px;
90
- z-index: 1000;
91
- overflow-y: auto;
92
  font-family: Arial, sans-serif;
 
93
  ">
94
  <div style="text-align: right;">
95
  <button onclick="closeModal()" style="
@@ -133,9 +126,14 @@ def app():
133
  function openModal(name, image, description, price) {
134
  const modal = document.getElementById('modal');
135
  modal.style.display = 'block';
136
- modal.style.top = '50%';
137
- modal.style.left = '50%';
138
- modal.style.transform = 'translate(-50%, -50%)';
 
 
 
 
 
139
  document.getElementById('modal-image').src = image;
140
  document.getElementById('modal-name').innerText = name;
141
  document.getElementById('modal-description').innerText = description;
 
35
  </div>
36
  <div style="flex-shrink: 0; text-align: center;">
37
  <img src="{item['Image URL']}" alt="{item['Dish Name']}" style="width: 100px; height: 100px; border-radius: 8px; object-fit: cover; margin-bottom: 10px;">
38
+ <button class="add-btn" style="background-color: #28a745; color: white; border: none; padding: 8px 15px; font-size: 14px; border-radius: 5px; cursor: pointer;" onclick="openModal('{item['Dish Name']}', '{item['Image URL']}', '{item['Description']}', '{item['Price ($)']}')">Add</button>
39
  </div>
40
  </div>
41
  """
 
76
  modal_window = gr.HTML("""
77
  <div id="modal" style="
78
  display: none;
79
+ position: absolute;
 
 
 
 
 
 
80
  background: white;
81
+ padding: 20px;
82
  border-radius: 15px;
83
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
 
 
 
84
  font-family: Arial, sans-serif;
85
+ z-index: 1000;
86
  ">
87
  <div style="text-align: right;">
88
  <button onclick="closeModal()" style="
 
126
  function openModal(name, image, description, price) {
127
  const modal = document.getElementById('modal');
128
  modal.style.display = 'block';
129
+
130
+ // Get the clicked button's position
131
+ const rect = event.target.getBoundingClientRect();
132
+
133
+ // Set the popup position based on the clicked element
134
+ modal.style.top = `${rect.top + window.scrollY + rect.height + 10}px`; // 10px below the button
135
+ modal.style.left = `${rect.left + window.scrollX}px`;
136
+
137
  document.getElementById('modal-image').src = image;
138
  document.getElementById('modal-name').innerText = name;
139
  document.getElementById('modal-description').innerText = description;