Spaces:
Sleeping
Sleeping
Update app.py
Browse files101 unmodified lines1021031041051061071081091101111121131141151161171051061071085 unmodified lines1141151161291301311321331171181198 unmodified lines1281291301481311321331341521531541551561571581591601611351361371381391401411421431441451461471481491504 unmodified lines155156157172158159160161101 unmodified lines <h3 style="margin: 0;">${name}</h3> <p style="margin: 5px 0;">${description}</p> <p style="margin: 5px 0; font-weight: bold;">Price: ${price}</p> <h4 style="margin: 20px 0 10px;">Choose a spice level</h4> <div style="display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px;"> <label><input type="radio" name="spice" value="American Mild"> American Mild</label> <label><input type="radio" name="spice" value="Indian Spicy"> Indian Spicy</label> <label><input type="radio" name="spice" value="American Spicy"> American Spicy</label> </div> <h4 style="margin: 20px 0 10px;">Choose Extras</h4> <div style="display: flex; flex-wrap: wrap; gap: 10px;"> <label><input type="checkbox" name="extras" value="Extra Raitha"> Extra Raitha</label> <label><input type="checkbox" name="extras" value="Extra Onion"> Extra Onion</label> </div> <button onclick="addToCart('${name}')" 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-left: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Close</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> `; popup.style.display = "block"; overlay.style.display = "block";5 unmodified lines popup.style.display = "none"; overlay.style.display = "none"; }
function addToCart(dishName) { alert(`${dishName} has been added to the cart!`); closePopup(); }</script>"""
8 unmodified lines
# Generate dish cardsdef display_dishes(category): html_content = "<div style='display: flex; flex-wrap: wrap; justify-content: space-between;'>" html_content = "<div style='display: flex; flex-direction: column; gap: 20px; width: 80%; margin: 0 auto;'>" for dish in menu_data: if category == "ALL" or dish["category"] == category: html_content += f""" <div style='margin: 10px; width: 30%; border: 1px solid #ddd; border-radius: 10px; padding: 10px;'> <img src='{dish['image']}' alt='{dish['name']}' style='width: 100%; height: auto; border-radius: 5px;'> <h3>{dish['name']}</h3> <p>{dish['description']}</p> <p>Price: {dish['price']}</p> <button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}')" style='background-color: #007bff; color: white; border: none; padding: 5px 10px; cursor: pointer;'> Add </button> <div style='display: flex; align-items: center; justify-content: space-between; padding: 20px; border: 1px solid #ddd; border-radius: 10px; background-color: #f9f9f9;'> <div style='flex: 3; text-align: left;'> <h3 style='margin: 0; font-size: 20px;'>{dish['name']}</h3> <p style='margin: 5px 0; font-size: 14px; color: #555;'>{dish['description']}</p> <p style='margin: 0; font-size: 16px; font-weight: bold;'>Price: {dish['price']}</p> </div> <div style='flex: 1; text-align: center;'> <img src='{dish['image']}' alt='{dish['name']}' style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px;'> <button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}')" style='margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;'> Add </button> </div> </div> """ html_content += "</div>"4 unmodified lines gr.HTML(popup_html) # Add the popup container and overlay gr.HTML(popup_js) # Add the JavaScript
gr.HTML("<h1 style='text-align: center;'>Dynamic Restaurant Menu</h1>") gr.HTML("<h1 style='text-align: center;'>🍛 Biryani Hub Menu 🍛</h1>")
# Buttons for filtering categories with gr.Row():app.py+16-30