Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -80,12 +80,12 @@ def display_dishes(category):
|
|
| 80 |
<div style='flex: 1; margin-right: 20px;'>
|
| 81 |
<h4 style='font-size: 18px; color: #444; margin: 0;'>{dish['name']}</h4>
|
| 82 |
<p style='font-size: 14px; color: #666; margin: 5px 0;'>{dish['description']}</p>
|
| 83 |
-
<button onclick="addToCart('{dish['name']}')"
|
| 84 |
-
style="padding: 5px 10px; background-color: #28a745; color: white; border: none;
|
| 85 |
-
border-radius: 5px; cursor: pointer;">Add</button>
|
| 86 |
</div>
|
| 87 |
<img src='{dish['image']}' alt='{dish['name']}'
|
| 88 |
-
style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px;'>
|
|
|
|
|
|
|
|
|
|
| 89 |
</div>
|
| 90 |
"""
|
| 91 |
html_content += "</div>"
|
|
@@ -104,10 +104,10 @@ with gr.Blocks() as demo:
|
|
| 104 |
# Dish display
|
| 105 |
dish_display = gr.HTML(value=display_dishes("ALL"))
|
| 106 |
|
| 107 |
-
# JavaScript for managing the pop-up
|
| 108 |
gr.HTML("""
|
| 109 |
-
<div id="popup" style="display: none; position: fixed; left: 50%;
|
| 110 |
-
|
| 111 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 300px;">
|
| 112 |
<img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">
|
| 113 |
<h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2>
|
|
@@ -124,10 +124,8 @@ with gr.Blocks() as demo:
|
|
| 124 |
document.getElementById('popup-title').textContent = title;
|
| 125 |
document.getElementById('popup-description').textContent = description;
|
| 126 |
|
| 127 |
-
//
|
| 128 |
-
|
| 129 |
-
popup.style.top = window.pageYOffset + 'px';
|
| 130 |
-
popup.style.display = 'block';
|
| 131 |
}
|
| 132 |
function closePopup() {
|
| 133 |
document.getElementById('popup').style.display = 'none';
|
|
@@ -152,4 +150,4 @@ with gr.Blocks() as demo:
|
|
| 152 |
outputs=dish_display
|
| 153 |
)
|
| 154 |
|
| 155 |
-
demo.launch()
|
|
|
|
| 80 |
<div style='flex: 1; margin-right: 20px;'>
|
| 81 |
<h4 style='font-size: 18px; color: #444; margin: 0;'>{dish['name']}</h4>
|
| 82 |
<p style='font-size: 14px; color: #666; margin: 5px 0;'>{dish['description']}</p>
|
|
|
|
|
|
|
|
|
|
| 83 |
</div>
|
| 84 |
<img src='{dish['image']}' alt='{dish['name']}'
|
| 85 |
+
style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px; margin-right: 10px;'>
|
| 86 |
+
<button onclick="showPopup('{dish['image']}', '{dish['name']}', '{dish['description']}')"
|
| 87 |
+
style="padding: 5px 10px; background-color: #28a745; color: white; border: none;
|
| 88 |
+
border-radius: 5px; cursor: pointer; align-self: flex-end;">Add</button>
|
| 89 |
</div>
|
| 90 |
"""
|
| 91 |
html_content += "</div>"
|
|
|
|
| 104 |
# Dish display
|
| 105 |
dish_display = gr.HTML(value=display_dishes("ALL"))
|
| 106 |
|
| 107 |
+
# JavaScript for managing the pop-up
|
| 108 |
gr.HTML("""
|
| 109 |
+
<div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
|
| 110 |
+
background-color: white; padding: 20px; border-radius: 10px;
|
| 111 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 300px;">
|
| 112 |
<img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">
|
| 113 |
<h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2>
|
|
|
|
| 124 |
document.getElementById('popup-title').textContent = title;
|
| 125 |
document.getElementById('popup-description').textContent = description;
|
| 126 |
|
| 127 |
+
// Display the popup
|
| 128 |
+
document.getElementById('popup').style.display = 'block';
|
|
|
|
|
|
|
| 129 |
}
|
| 130 |
function closePopup() {
|
| 131 |
document.getElementById('popup').style.display = 'none';
|
|
|
|
| 150 |
outputs=dish_display
|
| 151 |
)
|
| 152 |
|
| 153 |
+
demo.launch()
|