Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -375,11 +375,25 @@ def app():
|
|
| 375 |
|
| 376 |
# Button to navigate to Cart Page
|
| 377 |
|
|
|
|
| 378 |
view_cart_floating_button = gr.HTML(
|
| 379 |
"""
|
| 380 |
<button id="view-cart-btn" onclick="openCart()">View Cart</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
"""
|
| 382 |
)
|
|
|
|
|
|
|
| 383 |
|
| 384 |
# Modal window
|
| 385 |
modal_window = gr.HTML("""
|
|
@@ -461,9 +475,9 @@ def app():
|
|
| 461 |
outputs=[login_section, signup_section],
|
| 462 |
)
|
| 463 |
# Navigate to Cart Page
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
)
|
| 468 |
# Navigate Back to Menu Page
|
| 469 |
back_to_menu_button.click(
|
|
|
|
| 375 |
|
| 376 |
# Button to navigate to Cart Page
|
| 377 |
|
| 378 |
+
# Floating "View Cart" button (HTML for dynamic positioning)
|
| 379 |
view_cart_floating_button = gr.HTML(
|
| 380 |
"""
|
| 381 |
<button id="view-cart-btn" onclick="openCart()">View Cart</button>
|
| 382 |
+
<script>
|
| 383 |
+
function openCart() {
|
| 384 |
+
// Simulate a click event to navigate to the cart
|
| 385 |
+
const cartButton = document.querySelector('[data-testid="view-cart-button"]');
|
| 386 |
+
if (cartButton) {
|
| 387 |
+
cartButton.click();
|
| 388 |
+
} else {
|
| 389 |
+
alert("Cart navigation button not found!");
|
| 390 |
+
}
|
| 391 |
+
}
|
| 392 |
+
</script>
|
| 393 |
"""
|
| 394 |
)
|
| 395 |
+
# Add the "data-testid" attribute to the Gradio Button for proper referencing
|
| 396 |
+
view_cart_navigation_button = gr.Button("View Cart", elem_id="view-cart-button", visible=False)
|
| 397 |
|
| 398 |
# Modal window
|
| 399 |
modal_window = gr.HTML("""
|
|
|
|
| 475 |
outputs=[login_section, signup_section],
|
| 476 |
)
|
| 477 |
# Navigate to Cart Page
|
| 478 |
+
view_cart_navigation_button.click(
|
| 479 |
+
lambda: (gr.update(visible=False), gr.update(visible=True)),
|
| 480 |
+
outputs=[menu_section, cart_section],
|
| 481 |
)
|
| 482 |
# Navigate Back to Menu Page
|
| 483 |
back_to_menu_button.click(
|