Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,10 +14,6 @@ menu_data = [
|
|
| 14 |
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/paneer_butter_masala.jpg",
|
| 15 |
"description": "Cottage cheese cubes in a creamy, mildly spiced tomato gravy.",
|
| 16 |
"price": "$10.99"},
|
| 17 |
-
{"name": "Grilled Chicken Salad", "category": "HALAL",
|
| 18 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/grilled_chicken_salad.jpg",
|
| 19 |
-
"description": "Healthy grilled chicken slices with a bed of fresh greens.",
|
| 20 |
-
"price": "$9.99"},
|
| 21 |
]
|
| 22 |
|
| 23 |
# Filter dishes by category
|
|
@@ -57,8 +53,8 @@ with gr.Blocks() as demo:
|
|
| 57 |
btn_vegan.click(lambda: display_dishes("VEGAN"), outputs=[menu_html])
|
| 58 |
btn_halal.click(lambda: display_dishes("HALAL"), outputs=[menu_html])
|
| 59 |
|
| 60 |
-
gr.HTML(
|
| 61 |
-
<div id="popup" style="display: none; position:
|
| 62 |
background-color: white; padding: 20px; border-radius: 10px;
|
| 63 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
|
| 64 |
<div style="position: absolute; top: 10px; right: 10px; cursor: pointer; font-size: 20px; font-weight: bold;" onclick="closePopup()">×</div>
|
|
@@ -68,21 +64,19 @@ with gr.Blocks() as demo:
|
|
| 68 |
<button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px;">Close</button>
|
| 69 |
</div>
|
| 70 |
<script>
|
| 71 |
-
function showPopup(title, description, price) {
|
| 72 |
const popup = document.getElementById('popup');
|
| 73 |
document.getElementById('popup-title').textContent = title;
|
| 74 |
document.getElementById('popup-description').textContent = description;
|
| 75 |
document.getElementById('popup-price').textContent = price;
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
-
|
| 78 |
-
popup.style.top = `${{scrollY + 100}}px`;
|
| 79 |
-
popup.style.display = 'block';
|
| 80 |
-
}}
|
| 81 |
-
|
| 82 |
-
function closePopup() {{
|
| 83 |
const popup = document.getElementById('popup');
|
| 84 |
-
popup.style.display = 'none';
|
| 85 |
-
}
|
| 86 |
</script>
|
| 87 |
""")
|
| 88 |
|
|
|
|
| 14 |
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/paneer_butter_masala.jpg",
|
| 15 |
"description": "Cottage cheese cubes in a creamy, mildly spiced tomato gravy.",
|
| 16 |
"price": "$10.99"},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
]
|
| 18 |
|
| 19 |
# Filter dishes by category
|
|
|
|
| 53 |
btn_vegan.click(lambda: display_dishes("VEGAN"), outputs=[menu_html])
|
| 54 |
btn_halal.click(lambda: display_dishes("HALAL"), outputs=[menu_html])
|
| 55 |
|
| 56 |
+
gr.HTML("""
|
| 57 |
+
<div id="popup" style="display: none; position: fixed; left: 50%; transform: translateX(-50%);
|
| 58 |
background-color: white; padding: 20px; border-radius: 10px;
|
| 59 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
|
| 60 |
<div style="position: absolute; top: 10px; right: 10px; cursor: pointer; font-size: 20px; font-weight: bold;" onclick="closePopup()">×</div>
|
|
|
|
| 64 |
<button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px;">Close</button>
|
| 65 |
</div>
|
| 66 |
<script>
|
| 67 |
+
function showPopup(title, description, price) {
|
| 68 |
const popup = document.getElementById('popup');
|
| 69 |
document.getElementById('popup-title').textContent = title;
|
| 70 |
document.getElementById('popup-description').textContent = description;
|
| 71 |
document.getElementById('popup-price').textContent = price;
|
| 72 |
+
popup.style.top = `${window.scrollY + 100}px`; // Adjust based on scroll position
|
| 73 |
+
popup.style.display = 'block'; // Make the popup visible
|
| 74 |
+
}
|
| 75 |
|
| 76 |
+
function closePopup() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
const popup = document.getElementById('popup');
|
| 78 |
+
popup.style.display = 'none'; // Hide the popup
|
| 79 |
+
}
|
| 80 |
</script>
|
| 81 |
""")
|
| 82 |
|