Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -72,7 +72,7 @@ def filter_menu(preference):
|
|
| 72 |
</div>
|
| 73 |
<div style="flex-shrink: 0; text-align: center;">
|
| 74 |
<img src="{item['Image URL']}" alt="{item['Dish Name']}" style="width: 100px; height: 100px; border-radius: 8px; object-fit: cover; margin-bottom: 10px;">
|
| 75 |
-
<button style="background-color: #28a745; color: white; border: none; padding: 8px 15px; font-size: 14px; border-radius: 5px; cursor: pointer;" onclick="openModal('{item['Dish Name']}', '{item['Image
|
| 76 |
</div>
|
| 77 |
</div>
|
| 78 |
"""
|
|
@@ -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;
|
|
@@ -346,17 +346,16 @@ def app():
|
|
| 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: 20px; z-index: 1000;">
|
| 350 |
-
<div style="text-align: right;">
|
| 351 |
-
<button onclick="closeModal()" style="background: none; border: none; font-size: 18px; cursor: pointer;">×</button>
|
| 352 |
</div>
|
| 353 |
-
<img id="modal-image" style="width: 100%; height:
|
| 354 |
-
<h2 id="modal-name"></h2>
|
| 355 |
-
<p id="modal-description"></p>
|
| 356 |
-
<p id="modal-price"></p>
|
| 357 |
-
<!-- Biryani Extras -->
|
| 358 |
<label for="biryani-extras">Extras :</label>
|
| 359 |
-
<div id="biryani-extras-options" style="display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0;">
|
| 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>
|
|
@@ -364,16 +363,14 @@ def app():
|
|
| 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 |
<label for="quantity">Quantity:</label>
|
| 370 |
-
<input type="number" id="quantity" value="1" min="1" style="width: 50px;" />
|
| 371 |
-
<
|
| 372 |
-
<
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
<button style="background-color: #28a745; color: white; border: none; padding: 10px 20px; font-size: 14px; border-radius: 5px; cursor: pointer;" onclick="addToCart()">Add to Cart</button>
|
| 376 |
-
</div>
|
| 377 |
""")
|
| 378 |
# Update menu dynamically based on preference
|
| 379 |
selected_preference.change(filter_menu, inputs=[selected_preference], outputs=[menu_output])
|
|
|
|
| 72 |
</div>
|
| 73 |
<div style="flex-shrink: 0; text-align: center;">
|
| 74 |
<img src="{item['Image URL']}" alt="{item['Dish Name']}" style="width: 100px; height: 100px; border-radius: 8px; object-fit: cover; margin-bottom: 10px;">
|
| 75 |
+
<button style="background-color: #28a745; color: white; border: none; padding: 8px 15px; font-size: 14px; border-radius: 5px; cursor: pointer;" onclick="openModal('{item['Dish Name']}', '{item['Image URL']}', '{item['Description']}', '{item['Price ($)']}')">Add</button>
|
| 76 |
</div>
|
| 77 |
</div>
|
| 78 |
"""
|
|
|
|
| 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;
|
|
|
|
| 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: 20px; z-index: 1000; width: 90%; max-width: 500px; height: 400px; overflow-y: auto;">
|
| 350 |
+
<div style="text-align: right; height: 30px;">
|
| 351 |
+
<button onclick="closeModal()" style="background: none; border: none; font-size: 18px; cursor: pointer; height: 30px; width: 30px;">×</button>
|
| 352 |
</div>
|
| 353 |
+
<img id="modal-image" style="width: 100%; height: 200px; border-radius: 8px; margin-bottom: 20px;" />
|
| 354 |
+
<h2 id="modal-name" style="height: 50px; overflow: hidden; text-overflow: ellipsis;">Modal Title</h2>
|
| 355 |
+
<p id="modal-description" style="height: 70px; overflow: hidden;">Description goes here...</p>
|
| 356 |
+
<p id="modal-price" style="height: 30px;">Price: $10</p>
|
|
|
|
| 357 |
<label for="biryani-extras">Extras :</label>
|
| 358 |
+
<div id="biryani-extras-options" style="max-height: 150px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0;">
|
| 359 |
<label><input type="checkbox" name="biryani-extra" value="Thums up" /> Thums up + $2.00</label>
|
| 360 |
<label><input type="checkbox" name="biryani-extra" value="Sprite" /> Sprite + $2.00</label>
|
| 361 |
<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 Onion & Lemon" /> Extra Onion & Lemon + $2.00</label>
|
| 364 |
<label><input type="checkbox" name="biryani-extra" value="Chilli Chicken" /> Chilli Chicken + $14.00</label>
|
| 365 |
<label><input type="checkbox" name="biryani-extra" value="Veg Manchurian" /> Veg Manchurian + $12.00</label>
|
| 366 |
+
|
| 367 |
</div>
|
|
|
|
| 368 |
<label for="quantity">Quantity:</label>
|
| 369 |
+
<input type="number" id="quantity" value="1" min="1" style="width: 50px; height: 30px;" />
|
| 370 |
+
<textarea id="special-instructions" style="width: 100%; height: 100px;">Special instructions...</textarea>
|
| 371 |
+
<button style="background-color: #28a745; color: white; border: none; padding: 10px 20px; font-size: 14px; border-radiu s: 5px; cursor: pointer; height: 40px;">Add to Cart</button>
|
| 372 |
+
</div>
|
| 373 |
+
|
|
|
|
|
|
|
| 374 |
""")
|
| 375 |
# Update menu dynamically based on preference
|
| 376 |
selected_preference.change(filter_menu, inputs=[selected_preference], outputs=[menu_output])
|