Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -141,17 +141,12 @@ with gr.Blocks() as demo:
|
|
| 141 |
|
| 142 |
popup_js = """
|
| 143 |
<script>
|
| 144 |
-
|
| 145 |
const popup = document.getElementById("custom-popup");
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
});
|
| 151 |
-
|
| 152 |
-
function showPopup(message) {
|
| 153 |
-
const popup = document.getElementById("custom-popup");
|
| 154 |
-
popup.innerHTML = message;
|
| 155 |
popup.style.display = "block";
|
| 156 |
}
|
| 157 |
|
|
@@ -162,10 +157,18 @@ with gr.Blocks() as demo:
|
|
| 162 |
</script>
|
| 163 |
"""
|
| 164 |
|
| 165 |
-
# HTML for popup container
|
| 166 |
popup_html = """
|
| 167 |
<div id="custom-popup"
|
| 168 |
-
style="position: fixed; display: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
</div>
|
| 170 |
"""
|
| 171 |
|
|
@@ -186,8 +189,7 @@ def display_dishes(category):
|
|
| 186 |
<h3>{dish['name']}</h3>
|
| 187 |
<p>{dish['description']}</p>
|
| 188 |
<p>Price: {dish['price']}</p>
|
| 189 |
-
<button
|
| 190 |
-
onmouseout="hidePopup()"
|
| 191 |
style='background-color: #007bff; color: white; border: none; padding: 5px 10px; cursor: pointer;'>
|
| 192 |
Add
|
| 193 |
</button>
|
|
@@ -195,7 +197,7 @@ def display_dishes(category):
|
|
| 195 |
"""
|
| 196 |
html_content += "</div>"
|
| 197 |
return html_content
|
| 198 |
-
|
| 199 |
# Main Gradio App
|
| 200 |
with gr.Blocks() as demo:
|
| 201 |
gr.HTML(popup_html) # Add the popup container
|
|
|
|
| 141 |
|
| 142 |
popup_js = """
|
| 143 |
<script>
|
| 144 |
+
function showPopup(image, title, description, price) {
|
| 145 |
const popup = document.getElementById("custom-popup");
|
| 146 |
+
document.getElementById("popup-image").src = image;
|
| 147 |
+
document.getElementById("popup-title").innerText = title;
|
| 148 |
+
document.getElementById("popup-description").innerText = description;
|
| 149 |
+
document.getElementById("popup-price").innerText = price;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
popup.style.display = "block";
|
| 151 |
}
|
| 152 |
|
|
|
|
| 157 |
</script>
|
| 158 |
"""
|
| 159 |
|
| 160 |
+
# HTML for the popup container
|
| 161 |
popup_html = """
|
| 162 |
<div id="custom-popup"
|
| 163 |
+
style="position: fixed; display: none; top: 50%; left: 50%; transform: translate(-50%, -50%);
|
| 164 |
+
background: white; border: 1px solid black; padding: 20px; z-index: 1000;
|
| 165 |
+
box-shadow: 0 4px 8px rgba(0,0,0,0.2); border-radius: 10px; text-align: center; width: 400px;">
|
| 166 |
+
<img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 5px;">
|
| 167 |
+
<h2 id="popup-title" style="margin-top: 10px; color: #444;"></h2>
|
| 168 |
+
<p id="popup-description" style="font-size: 14px; color: #666;"></p>
|
| 169 |
+
<p id="popup-price" style="font-size: 16px; color: #444;"></p>
|
| 170 |
+
<button onclick="hidePopup()" style="margin-top: 15px; padding: 10px 20px; background-color: #007bff; color: white;
|
| 171 |
+
border: none; border-radius: 5px; cursor: pointer;">Close</button>
|
| 172 |
</div>
|
| 173 |
"""
|
| 174 |
|
|
|
|
| 189 |
<h3>{dish['name']}</h3>
|
| 190 |
<p>{dish['description']}</p>
|
| 191 |
<p>Price: {dish['price']}</p>
|
| 192 |
+
<button onclick="showPopup('{dish['image']}', '{dish['name']}', '{dish['description']}', '{dish['price']}')"
|
|
|
|
| 193 |
style='background-color: #007bff; color: white; border: none; padding: 5px 10px; cursor: pointer;'>
|
| 194 |
Add
|
| 195 |
</button>
|
|
|
|
| 197 |
"""
|
| 198 |
html_content += "</div>"
|
| 199 |
return html_content
|
| 200 |
+
|
| 201 |
# Main Gradio App
|
| 202 |
with gr.Blocks() as demo:
|
| 203 |
gr.HTML(popup_html) # Add the popup container
|