Spaces:
Sleeping
Sleeping
Update app.py
Browse files12 unmodified lines1314151617181951 unmodified lines71727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251268 unmodified lines13513613713812 unmodified lines{"name": "Paneer Butter Masala", "category": "VEGAN","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/paneer_butter_masala.jpg","description": "Paneer cooked in a rich and creamy tomato-based gravy.","price": "$10.99"}]# Spice levels and extras51 unmodified linesdish_display = gr.HTML(value=display_dishes("ALL"))# JavaScript for managing the pop-upgr.HTML("""<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;"><h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2><p id="popup-description" style="margin-top: 10px; font-size: 16px; color: #666;"></p><p id="popup-price" style="margin-top: 10px; font-size: 16px; color: #444;"></p><h4 style="text-align: left; margin-top: 20px;">Choose a spice level</h4><div style="display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;">""" + "".join([f'<label style="margin-right: 10px; display: block;"><input type="radio" name="spice" value="{spice}" style="margin-right: 5px;">{spice}</label>'for spice in spice_levels]) + """</div><h4 style="text-align: left; margin-top: 20px;">Choose Extras</h4><div style="display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;">""" + "".join([f'<label style="margin-right: 10px; display: block;"><input type="checkbox" name="extras" value="{extra["name"]}" style="margin-right: 5px;">{extra["name"]} + {extra["price"]}</label>'for extra in extras]) + """</div><button onclick="addToCart(document.getElementById('popup-title').textContent, document.querySelector('input[name=spice]:checked').value)"style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none;border-radius: 5px; cursor: pointer;">Add to Cart</button><button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #28a745;color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button></div><script>function showPopup(image, title, description, price) {document.getElementById('popup-image').src = image;document.getElementById('popup-title').textContent = title;document.getElementById('popup-description').textContent = description;document.getElementById('popup-price').textContent = "Price: " + price;// Display the popupdocument.getElementById('popup').style.display = 'block';}function closePopup() {document.getElementById('popup').style.display = 'none';}function addToCart(dishName, spiceLevel) {const 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>""")# Button click eventsbtn_all.click(lambda: gr.update(value=display_dishes("ALL")),8 unmodified linesoutputs=dish_display)demo.launch()12 unmodified lines1314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666751 unmodified lines1191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681698 unmodified lines17817918018112 unmodified lines{"name": "Paneer Butter Masala", "category": "VEGAN","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/paneer_butter_masala.jpg","description": "Paneer cooked in a rich and creamy tomato-based gravy.","price": "$10.99"},{"name": "Mushroom Soup", "category": "VEGAN","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/mushroom_soup.jpg","description": "Creamy mushroom soup with fresh herbs.","price": "$7.99"},{"name": "Butter Naan", "category": "VEGAN","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/butter_naan.jpg","description": "Soft and buttery flatbread, perfect to pair with any curry.","price": "$2.99"},{"name": "Fish Curry", "category": "HALAL","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/fish_curry.jpg","description": "Fresh fish cooked in a spicy and tangy curry.","price": "$13.99"},{"name": "Grilled Veggies", "category": "VEGAN","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/grilled_veggies.jpg","description": "A healthy mix of grilled seasonal vegetables with olive oil.","price": "$9.99"},{"name": "Chicken Kebab", "category": "HALAL","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chicken_kebab.jpg","description": "Juicy chicken kebabs grilled to perfection with a mix of spices.","price": "$9.99"},{"name": "Dal Makhani", "category": "VEGAN","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/dal_makhani.jpg","description": "Rich and creamy black lentils slow-cooked with spices.","price": "$8.99"},{"name": "Lamb Curry", "category": "HALAL","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/lamb_curry.jpg","description": "Tender lamb pieces cooked in a flavorful curry sauce.","price": "$14.99"},{"name": "Mixed Veg Curry", "category": "VEGAN","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/mixed_veg_curry.jpg","description": "A medley of fresh vegetables cooked in a lightly spiced curry.","price": "$9.99"},{"name": "Chicken Wings", "category": "HALAL","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chicken_wings.jpg","description": "Crispy chicken wings tossed in a tangy sauce.","price": "$12.99"},{"name": "Aloo Paratha", "category": "VEGAN","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/aloo_paratha.jpg","description": "Indian flatbread stuffed with spiced mashed potatoes.","price": "$3.99"},{"name": "Egg Curry", "category": "HALAL","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/egg_curry.jpg","description": "Boiled eggs cooked in a spiced tomato gravy.","price": "$9.99"},{"name": "Chickpea Salad", "category": "VEGAN","image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chickpea_salad.jpg","description": "A refreshing salad made with chickpeas, fresh vegetables, and herbs.","price": "$7.99"}]# Spice levels and extras51 unmodified linesdish_display = gr.HTML(value=display_dishes("ALL"))# 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;\"><h2 id=\"popup-title\" style=\"margin-top: 20px; color: #444;\"></h2><p id=\"popup-description\" style=\"margin-top: 10px; font-size: 16px; color: #666;\"></p><p id=\"popup-price\" style=\"margin-top: 10px; font-size: 16px; color: #444;\"></p><h4 style=\"text-align: left; margin-top: 20px;\">Choose a spice level</h4><div style=\"display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;\">""" + """".join([f'<label style=\"margin-right: 10px; display: block;\"><input type=\"radio\" name=\"spice\" value=\"{spice}\" style=\"margin-right: 5px;\">{spice}</label>' for spice in spice_levels]) + """</div><h4 style=\"text-align: left; margin-top: 20px;\">Choose Extras</h4><div style=\"display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;\">""" + """".join([f'<label style=\"margin-right: 10px; display: block;\"><input type=\"checkbox\" name=\"extras\" value=\"{extra["name"]}\" style=\"margin-right: 5px;\">{extra["name"]} + {extra["price"]}</label>' for extra in extras]) + """</div><button onclick=\"addToCart(document.getElementById('popup-title').textContent, document.querySelector('input[name=spice]:checked').value)\"style=\"margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none;border-radius: 5px; cursor: pointer;\">Add to Cart</button><button onclick=\"closePopup()\" style=\"margin-top: 20px; padding: 10px 20px; background-color: #28a745;color: white; border: none; border-radius: 5px; cursor: pointer;\">Close</button></div><script>function showPopup(image, title, description, price) {document.getElementById('popup-image').src = image;document.getElementById('popup-title').textContent = title;document.getElementById('popup-description').textContent = description;document.getElementById('popup-price').textContent = "Price: " + price;// Display the popupdocument.getElementById('popup').style.display = 'block';}function closePopup() {document.getElementById('popup').style.display = 'none';}function addToCart(dishName, spiceLevel) {const 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>""")# Button click eventsbtn_all.click(lambda: gr.update(value=display_dishes("ALL")),8 unmodified linesoutputs=dish_display)demo.launch()
app.py+90-47