Spaces:
Sleeping
Sleeping
Update app.py
Browse files140 unmodified lines1411421431441441451461471481491501511521531541461471481491501511524 unmodified lines15715815916516016116216816316416516616716816917017117217317414 unmodified lines1891901911891901921931941951 unmodified line197198199198200201202203140 unmodified lines popup_js = """<script> document.addEventListener("mousemove", (event) => { function showPopup(image, title, description, price) { const popup = document.getElementById("custom-popup"); if (popup && popup.style.display === "block") { popup.style.left = event.clientX + "px"; popup.style.top = event.clientY + "px"; } });
function showPopup(message) { const popup = document.getElementById("custom-popup"); popup.innerHTML = message; document.getElementById("popup-image").src = image; document.getElementById("popup-title").innerText = title; document.getElementById("popup-description").innerText = description; document.getElementById("popup-price").innerText = price; popup.style.display = "block"; }
4 unmodified lines</script>"""
# HTML for popup container# HTML for the popup containerpopup_html = """<div id="custom-popup" style="position: fixed; display: none; background: white; border: 1px solid black; padding: 10px; z-index: 1000;"> style="position: fixed; display: none; top: 50%; left: 50%; transform: translate(-50%, -50%); background: white; border: 1px solid black; padding: 20px; z-index: 1000; box-shadow: 0 4px 8px rgba(0,0,0,0.2); border-radius: 10px; text-align: center; width: 400px;"> <img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 5px;"> <h2 id="popup-title" style="margin-top: 10px; color: #444;"></h2> <p id="popup-description" style="font-size: 14px; color: #666;"></p> <p id="popup-price" style="font-size: 16px; color: #444;"></p> <button onclick="hidePopup()" style="margin-top: 15px; padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button></div>"""
14 unmodified lines <h3>{dish['name']}</h3> <p>{dish['description']}</p> <p>Price: {dish['price']}</p> <button onmouseover="showPopup('{dish['name']} - {dish['price']}')" onmouseout="hidePopup()" <button onclick="showPopup('{dish['image']}', '{dish['name']}', '{dish['description']}', '{dish['price']}')" style='background-color: #007bff; color: white; border: none; padding: 5px 10px; cursor: pointer;'> Add </button>1 unmodified line """ html_content += "</div>" return html_content
# Main Gradio Appwith gr.Blocks() as demo: gr.HTML(popup_html) # Add the popup containerapp.py+17-15