Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,34 +107,12 @@ with gr.Blocks() as demo:
|
|
| 107 |
|
| 108 |
# JavaScript for managing the pop-up
|
| 109 |
gr.HTML("""
|
| 110 |
-
<div id="popup" style="
|
| 111 |
-
display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
|
| 112 |
-
background-color: white; padding: 20px; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
| 113 |
-
z-index: 1000; text-align: center; width: 300px;">
|
| 114 |
-
<img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">
|
| 115 |
-
<h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2>
|
| 116 |
-
<p id="popup-description" style="margin-top: 10px; font-size: 16px; color: #666;"></p>
|
| 117 |
-
<button onclick="closePopup()" style="
|
| 118 |
-
margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none;
|
| 119 |
-
border-radius: 5px; cursor: pointer;">Close</button>
|
| 120 |
-
</div>
|
| 121 |
-
""")
|
| 122 |
-
|
| 123 |
<script>
|
| 124 |
-
function showPopup(image, title, description
|
| 125 |
-
// Get the item's position
|
| 126 |
-
const rect = element.getBoundingClientRect();
|
| 127 |
-
|
| 128 |
-
// Set pop-up content
|
| 129 |
-
const popup = document.getElementById('popup');
|
| 130 |
document.getElementById('popup-image').src = image;
|
| 131 |
document.getElementById('popup-title').textContent = title;
|
| 132 |
document.getElementById('popup-description').textContent = description;
|
| 133 |
-
|
| 134 |
-
// Position the pop-up near the item
|
| 135 |
-
popup.style.top = window.scrollY + rect.top + rect.height + 'px';
|
| 136 |
-
popup.style.left = rect.left + 'px';
|
| 137 |
-
popup.style.display = 'block';
|
| 138 |
}
|
| 139 |
|
| 140 |
function closePopup() {
|
|
@@ -143,9 +121,24 @@ with gr.Blocks() as demo:
|
|
| 143 |
</script>
|
| 144 |
""")
|
| 145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
# Button click events
|
| 147 |
btn_all.click(lambda: gr.update(value=display_dishes("ALL")), outputs=dish_display)
|
| 148 |
btn_vegan.click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
|
| 149 |
btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
|
| 150 |
|
| 151 |
-
demo.launch()
|
|
|
|
| 107 |
|
| 108 |
# JavaScript for managing the pop-up
|
| 109 |
gr.HTML("""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
<script>
|
| 111 |
+
function showPopup(image, title, description) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
document.getElementById('popup-image').src = image;
|
| 113 |
document.getElementById('popup-title').textContent = title;
|
| 114 |
document.getElementById('popup-description').textContent = description;
|
| 115 |
+
document.getElementById('popup').style.display = 'block';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
}
|
| 117 |
|
| 118 |
function closePopup() {
|
|
|
|
| 121 |
</script>
|
| 122 |
""")
|
| 123 |
|
| 124 |
+
# Pop-up for dish details
|
| 125 |
+
gr.HTML("""
|
| 126 |
+
<div id="popup" style="
|
| 127 |
+
display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, 150%);
|
| 128 |
+
background-color: white; padding: 20px; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
| 129 |
+
z-index: 1000; text-align: center; width: 300px;">
|
| 130 |
+
<img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">
|
| 131 |
+
<h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2>
|
| 132 |
+
<p id="popup-description" style="margin-top: 10px; font-size: 16px; color: #666;"></p>
|
| 133 |
+
<button onclick="closePopup()" style="
|
| 134 |
+
margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none;
|
| 135 |
+
border-radius: 5px; cursor: pointer;">Close</button>
|
| 136 |
+
</div>
|
| 137 |
+
""")
|
| 138 |
+
|
| 139 |
# Button click events
|
| 140 |
btn_all.click(lambda: gr.update(value=display_dishes("ALL")), outputs=dish_display)
|
| 141 |
btn_vegan.click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
|
| 142 |
btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
|
| 143 |
|
| 144 |
+
demo.launch()
|