Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -155,7 +155,7 @@ button {
|
|
| 155 |
"Veg Manchurian": 12
|
| 156 |
};
|
| 157 |
let finalized = false;
|
| 158 |
-
function openModal(name,
|
| 159 |
if (finalized) {
|
| 160 |
alert("You cannot add more items after finalizing your order.");
|
| 161 |
return;
|
|
@@ -172,7 +172,7 @@ button {
|
|
| 172 |
}
|
| 173 |
modal.style.left = '50%';
|
| 174 |
modal.style.transform = 'translate(-50%, -50%)';
|
| 175 |
-
document.getElementById('modal-image').src =
|
| 176 |
document.getElementById('modal-name').innerText = name;
|
| 177 |
document.getElementById('modal-description').innerText = description;
|
| 178 |
document.getElementById('modal-price').innerText = price;
|
|
@@ -337,40 +337,51 @@ def app():
|
|
| 337 |
value="All",
|
| 338 |
label="Choose a Preference",
|
| 339 |
)
|
|
|
|
|
|
|
| 340 |
|
| 341 |
# Output area for menu items
|
| 342 |
menu_output = gr.HTML(value=filter_menu("All"))
|
| 343 |
|
| 344 |
# Button to navigate to Cart Page
|
| 345 |
-
view_cart_button = gr.Button("View Cart")
|
|
|
|
|
|
|
|
|
|
| 346 |
|
| 347 |
# Modal window
|
| 348 |
modal_window = gr.HTML("""
|
| 349 |
-
<div id="modal" style="display: none; position: fixed; background: white; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); padding:
|
| 350 |
-
<div style="text-align: right;">
|
| 351 |
-
<button onclick="closeModal()" style="background: none; border: none; font-size:
|
| 352 |
</div>
|
| 353 |
-
<img id="modal-image" style="width: 100%; height:
|
| 354 |
-
<h4 id="modal-name"></h4>
|
| 355 |
-
<p id="modal-description"></p>
|
| 356 |
-
<p id="modal-price"></p>
|
| 357 |
-
<!-- Extras -->
|
| 358 |
-
<label for="biryani-extras">Extras :</label>
|
| 359 |
-
<div id="biryani-extras-options" style="display: flex; flex-wrap: wrap; gap:
|
| 360 |
-
<label><input type="checkbox" name="biryani-extra" value="Thums up" /> Thums up + $2.00</label>
|
| 361 |
-
<label><input type="checkbox" name="biryani-extra" value="Sprite" /> Sprite + $2.00</label>
|
| 362 |
-
<label><input type="checkbox" name="biryani-extra" value="Extra Raitha" /> Extra Raitha + $1.00</label>
|
| 363 |
-
<label><input type="checkbox" name="biryani-extra" value="Extra Salan" /> Extra Salan + $2.00</label>
|
| 364 |
-
<label><input type="checkbox" name="biryani-extra" value="Extra Onion & Lemon" /> Extra Onion & Lemon + $2.00</label>
|
| 365 |
-
<label><input type="checkbox" name="biryani-extra" value="Chilli Chicken" /> Chilli Chicken + $14.00</label>
|
| 366 |
-
<label><input type="checkbox" name="biryani-extra" value="Veg Manchurian" /> Veg Manchurian + $12.00</label>
|
| 367 |
</div>
|
| 368 |
<!-- Quantity and Special Instructions -->
|
| 369 |
-
<
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
<
|
| 373 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
</div>
|
| 375 |
""")
|
| 376 |
# Update menu dynamically based on preference
|
|
@@ -431,6 +442,7 @@ def app():
|
|
| 431 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|
| 432 |
outputs=[menu_section, cart_section],
|
| 433 |
)
|
|
|
|
| 434 |
|
| 435 |
return demo
|
| 436 |
|
|
|
|
| 155 |
"Veg Manchurian": 12
|
| 156 |
};
|
| 157 |
let finalized = false;
|
| 158 |
+
function openModal(name, image, description, price) {
|
| 159 |
if (finalized) {
|
| 160 |
alert("You cannot add more items after finalizing your order.");
|
| 161 |
return;
|
|
|
|
| 172 |
}
|
| 173 |
modal.style.left = '50%';
|
| 174 |
modal.style.transform = 'translate(-50%, -50%)';
|
| 175 |
+
document.getElementById('modal-image').src = image;
|
| 176 |
document.getElementById('modal-name').innerText = name;
|
| 177 |
document.getElementById('modal-description').innerText = description;
|
| 178 |
document.getElementById('modal-price').innerText = price;
|
|
|
|
| 337 |
value="All",
|
| 338 |
label="Choose a Preference",
|
| 339 |
)
|
| 340 |
+
# Empty div box with 300px height
|
| 341 |
+
empty_div = gr.HTML('<div style="height: 20px;"></div>')
|
| 342 |
|
| 343 |
# Output area for menu items
|
| 344 |
menu_output = gr.HTML(value=filter_menu("All"))
|
| 345 |
|
| 346 |
# Button to navigate to Cart Page
|
| 347 |
+
view_cart_button = gr.Button("View Cart", elem_id="view-cart-button")
|
| 348 |
+
|
| 349 |
+
# Empty div box with 300px height
|
| 350 |
+
empty_div = gr.HTML('<div style="height: 300px;"></div>')
|
| 351 |
|
| 352 |
# Modal window
|
| 353 |
modal_window = gr.HTML("""
|
| 354 |
+
<div id="modal" style="display: none; position: fixed; background: white; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); padding: 10px; z-index: 1000; width: 90%; max-width: 500px; height: 750px; overflow-y: hidden;">
|
| 355 |
+
<div style="text-align: right; height: 30px;">
|
| 356 |
+
<button onclick="closeModal()" style="background: none; border: none; font-size: 16px; cursor: pointer; height: 30px; width: 30px;">×</button>
|
| 357 |
</div>
|
| 358 |
+
<img id="modal-image" style="width: 100%; height: 250px; border-radius: 8px; margin-bottom: 5px;" />
|
| 359 |
+
<h4 id="modal-name" style="font-size: 18px; height: auto; margin-bottom: 5px;"></h4>
|
| 360 |
+
<p id="modal-description" style="font-size: 14px; height: auto; margin-bottom: 5px;"></p>
|
| 361 |
+
<p id=\"modal-price\" style=\"font-size: 14px; font-weight: bold; height: auto; margin-bottom: 10px;\">$</p>
|
| 362 |
+
<!-- Biryani Extras -->
|
| 363 |
+
<label for=\"biryani-extras\" style=\"display: block; font-size: 12px; margin-bottom: 5px; font-weight: bold;\">Extras :</label>
|
| 364 |
+
<div id="biryani-extras-options" style="display: flex; flex-wrap: wrap; gap: 5px; margin: 5px 0; height: 70px; overflow-y: auto;">
|
| 365 |
+
<label style="font-size: 12px;"><input type="checkbox" name="biryani-extra" value="Thums up" /> Thums up + $2.00</label>
|
| 366 |
+
<label style="font-size: 12px;"><input type="checkbox" name="biryani-extra" value="Sprite" /> Sprite + $2.00</label>
|
| 367 |
+
<label style="font-size: 12px;"><input type="checkbox" name="biryani-extra" value="Extra Raitha" /> Extra Raitha + $1.00</label>
|
| 368 |
+
<label style="font-size: 12px;"><input type="checkbox" name="biryani-extra" value="Extra Salan" /> Extra Salan + $2.00</label>
|
| 369 |
+
<label style="font-size: 12px;"><input type="checkbox" name="biryani-extra" value="Extra Onion & Lemon" /> Extra Onion & Lemon + $2.00</label>
|
| 370 |
+
<label style="font-size: 12px;"><input type="checkbox" name="biryani-extra" value="Chilli Chicken" /> Chilli Chicken + $14.00</label>
|
| 371 |
+
<label style="font-size: 12px;"><input type="checkbox" name="biryani-extra" value="Veg Manchurian" /> Veg Manchurian + $12.00</label>
|
| 372 |
</div>
|
| 373 |
<!-- Quantity and Special Instructions -->
|
| 374 |
+
<div style="margin-bottom: 5px;">
|
| 375 |
+
<label for="quantity" style="display: block; font-size: 12px; margin-bottom: 5px;">Quantity:</label>
|
| 376 |
+
<input type="number" id="quantity" value="1" min="1" style="width: 50px; height: 25px; font-size: 12px;" />
|
| 377 |
+
</div>
|
| 378 |
+
<div style="margin-bottom: 5px;">
|
| 379 |
+
<label for="special-instructions" style="display: block; font-size: 12px; margin-bottom: 5px;">Special Instructions:</label>
|
| 380 |
+
<textarea id="special-instructions" placeholder="Add special instructions here..." style="width: 100%; height: 60px; font-size: 12px;"></textarea>
|
| 381 |
+
</div>
|
| 382 |
+
<div style="text-align: center; margin-top: 10px;">
|
| 383 |
+
<button id="add-to-cart-button" onclick="addToCart()" style="background-color: #28a745; color: white; border: none; padding: 8px 16px; font-size: 12px; border-radius: 5px; cursor: pointer;">Add to Cart</button>
|
| 384 |
+
</div>
|
| 385 |
</div>
|
| 386 |
""")
|
| 387 |
# Update menu dynamically based on preference
|
|
|
|
| 442 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|
| 443 |
outputs=[menu_section, cart_section],
|
| 444 |
)
|
| 445 |
+
|
| 446 |
|
| 447 |
return demo
|
| 448 |
|