Spaces:
Sleeping
Sleeping
Update app.py
Browse files123456112 unmodified lines11912012112212312412515 unmodified lines14114214314414514614724 unmodified lines1721731741751761771781791801811821834 unmodified lines188189190191192193194195196import gradio as gr# Menu datamenu_data = [{"name": "Veg Burger", "category": "VEGAN","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_burger.jpg",112 unmodified linesstyle='width: 150px; height: 100px; object-fit: cover; border-radius: 10px;'><button onclick="showPopup('{dish['image']}', '{dish['name']}', '{dish['description']}', '{dish['price']}')"style="margin-top: 15px; padding: 10px 20px; background-color: #28a745; color: white; border: none;border-radius: 5px; cursor: pointer;">Add</button></div></div>"""15 unmodified lines# JavaScript for managing the pop-upgr.HTML(f"""<div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, 150%);background-color: white; padding: 20px; border-radius: 10px;box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;"><img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">24 unmodified linesdocument.getElementById('popup-description').textContent = description;document.getElementById('popup-price').textContent = "Price: " + price;// Set the position of the popuppopup.style.left = `${event.pageX + 10}px`; // Add a small offsetpopup.style.top = `${event.pageY + 10}px`; // Add a small offset// Display the popupdocument.getElementById('popup').style.display = 'block';}4 unmodified linesconst selectedExtras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(cb => cb.value).join(", ");alert(dishName + " with " + spiceLevel + " spice level and extras: " + selectedExtras + " has been added to the cart!");}});</script>""")12345112 unmodified lines11811912012112212312415 unmodified lines14014114214314414514624 unmodified lines1711721731741751764 unmodified lines181182183184185186import gradio as grmenu_data = [{"name": "Veg Burger", "category": "VEGAN","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_burger.jpg",112 unmodified linesstyle='width: 150px; height: 100px; object-fit: cover; border-radius: 10px;'><button onclick="showPopup('{dish['image']}', '{dish['name']}', '{dish['description']}', '{dish['price']}')"style="margin-top: 15px; padding: 10px 20px; background-color: #28a745; color: white; border: none;border-radius: 5px; cursor: pointer;">Add</button></div></div>"""15 unmodified lines# JavaScript for managing the pop-upgr.HTML(f"""<div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);background-color: white; padding: 20px; border-radius: 10px;box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;"><img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">24 unmodified linesdocument.getElementById('popup-description').textContent = description;document.getElementById('popup-price').textContent = "Price: " + price;// Display the popupdocument.getElementById('popup').style.display = 'block';}4 unmodified linesconst selectedExtras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(cb => cb.value).join(", ");alert(dishName + " with " + spiceLevel + " spice level and extras: " + selectedExtras + " has been added to the cart!");}</script>""")
app.py+2-12