Rammohan0504 commited on
Commit
3b22672
·
verified ·
1 Parent(s): 29c8393

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -26
app.py CHANGED
@@ -109,33 +109,34 @@ with gr.Blocks() as demo:
109
  # Update dish display on button click
110
  category_buttons.change(display_dishes, inputs=[category_buttons], outputs=[menu_html])
111
 
112
- gr.HTML(f"""
113
- <div id="popup" style="display: none; position: absolute; left: 50%; transform: translateX(-50%);
114
- background-color: white; padding: 20px; border-radius: 10px;
115
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
116
- <div style="position: absolute; top: 10px; right: 10px; cursor: pointer; font-size: 20px; font-weight: bold;" onclick="closePopup()">&times;</div>
117
- <h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2>
118
- <p id="popup-description" style="margin-top: 10px; font-size: 16px; color: #666;"></p>
119
- <p id="popup-price" style="margin-top: 10px; font-size: 16px; color: #444;"></p>
120
- <button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px;">Close</button>
121
- </div>
122
- <script>
123
- function showPopup(title, description, price) {
124
- const popup = document.getElementById('popup');
125
- document.getElementById('popup-title').textContent = title;
126
- document.getElementById('popup-description').textContent = description;
127
- document.getElementById('popup-price').textContent = price;
 
 
 
 
 
 
128
 
129
- // Get scroll position and adjust popup position
130
- const scrollY = window.scrollY;
131
- popup.style.top = `${scrollY + 100}px`; // Offset for visibility
132
- popup.style.display = 'block';
133
- }
134
 
135
- function closePopup() {
136
- document.getElementById('popup').style.display = 'none';
137
- }
138
- </script>
139
- """)
140
 
141
  demo.launch()
 
109
  # Update dish display on button click
110
  category_buttons.change(display_dishes, inputs=[category_buttons], outputs=[menu_html])
111
 
112
+ gr.HTML(f"""
113
+ <div id="popup" style="display: none; position: absolute; left: 50%; transform: translateX(-50%);
114
+ background-color: white; padding: 20px; border-radius: 10px;
115
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
116
+ <div style="position: absolute; top: 10px; right: 10px; cursor: pointer; font-size: 20px; font-weight: bold;" onclick="closePopup()">&times;</div>
117
+ <h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2>
118
+ <p id="popup-description" style="margin-top: 10px; font-size: 16px; color: #666;"></p>
119
+ <p id="popup-price" style="margin-top: 10px; font-size: 16px; color: #444;"></p>
120
+ <button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px;">Close</button>
121
+ </div>
122
+ <script>
123
+ function showPopup(title, description, price) {{
124
+ const popup = document.getElementById('popup');
125
+ document.getElementById('popup-title').textContent = title;
126
+ document.getElementById('popup-description').textContent = description;
127
+ document.getElementById('popup-price').textContent = price;
128
+
129
+ // Get scroll position and adjust popup position
130
+ const scrollY = window.scrollY;
131
+ popup.style.top = `${{scrollY + 100}}px`; // Offset for visibility
132
+ popup.style.display = 'block';
133
+ }}
134
 
135
+ function closePopup() {{
136
+ document.getElementById('popup').style.display = 'none';
137
+ }}
138
+ </script>
139
+ """)
140
 
 
 
 
 
 
141
 
142
  demo.launch()