Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 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()">×</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()
|