Spaces:
Sleeping
Sleeping
Update app.py
Browse files140 unmodified lines1411421431441451461471481491501511521531541551561574 unmodified lines16216316416516616716816917017114 unmodified lines1861871881891901911921931 unmodified line195196197198199200201140 unmodified linespopup_js = """<script>document.addEventListener("mousemove", (event) => {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;popup.style.display = "block";}4 unmodified lines</script>"""# HTML for popup containerpopup_html = """<div id="custom-popup"style="position: fixed; display: none; background: white; border: 1px solid black; padding: 10px; z-index: 1000;"></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()"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 container140 unmodified lines1411421431441451461471481491501511524 unmodified lines15715815916016116216316416516616716816917017117217317414 unmodified lines1891901911921931941951 unmodified line197198199200201202203140 unmodified linespopup_js = """<script>function showPopup(image, title, description, price) {const popup = document.getElementById("custom-popup");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 the popup containerpopup_html = """<div id="custom-popup"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 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 container
app.py+17-15