Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -285,9 +285,8 @@ button {
|
|
| 285 |
}
|
| 286 |
</script>
|
| 287 |
"""
|
| 288 |
-
|
| 289 |
def app():
|
| 290 |
-
with gr.Blocks() as demo:
|
| 291 |
# Login Page
|
| 292 |
with gr.Column(visible=True) as login_section:
|
| 293 |
gr.Markdown("# Login Page")
|
|
@@ -326,7 +325,6 @@ def app():
|
|
| 326 |
# Button to navigate to Cart Page
|
| 327 |
view_cart_button = gr.Button("View Cart")
|
| 328 |
empty_div = gr.HTML('<div style="height: 300px;"></div>')
|
| 329 |
-
|
| 330 |
# Modal window
|
| 331 |
modal_window = gr.HTML("""
|
| 332 |
<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;">
|
|
@@ -367,7 +365,7 @@ def app():
|
|
| 367 |
gr.Row(modal_window)
|
| 368 |
gr.HTML(modal_and_cart_js)
|
| 369 |
|
| 370 |
-
|
| 371 |
with gr.Column(visible=False) as cart_section:
|
| 372 |
gr.Markdown("### Cart & Final Order Page")
|
| 373 |
|
|
@@ -381,14 +379,7 @@ def app():
|
|
| 381 |
back_to_menu_button = gr.Button("Back to Menu")
|
| 382 |
|
| 383 |
gr.Row(cart_output)
|
| 384 |
-
|
| 385 |
-
gr.HTML("""
|
| 386 |
-
<script>
|
| 387 |
-
function scrollToTop() {
|
| 388 |
-
window.scrollTo({ top: 0, behavior: 'smooth' });
|
| 389 |
-
}
|
| 390 |
-
</script>
|
| 391 |
-
""")
|
| 392 |
|
| 393 |
# Button Bindings
|
| 394 |
# Login Button
|
|
@@ -413,28 +404,11 @@ def app():
|
|
| 413 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|
| 414 |
outputs=[login_section, signup_section],
|
| 415 |
)
|
| 416 |
-
# Navigate to Cart Page
|
| 417 |
view_cart_button.click(
|
| 418 |
lambda: (gr.update(visible=False), gr.update(visible=True)),
|
| 419 |
outputs=[menu_section, cart_section],
|
| 420 |
)
|
| 421 |
-
|
| 422 |
-
# JavaScript to Trigger Scroll-to-Top for Cart Page
|
| 423 |
-
gr.HTML("""
|
| 424 |
-
<script>
|
| 425 |
-
document.addEventListener("DOMContentLoaded", function() {
|
| 426 |
-
const viewCartButton = document.querySelector('button:contains("View Cart")');
|
| 427 |
-
if (viewCartButton) {
|
| 428 |
-
viewCartButton.addEventListener("click", function() {
|
| 429 |
-
setTimeout(() => {
|
| 430 |
-
window.scrollTo({ top: 0, behavior: 'smooth' });
|
| 431 |
-
}, 100); // Delay to ensure Cart Page loads
|
| 432 |
-
});
|
| 433 |
-
}
|
| 434 |
-
});
|
| 435 |
-
</script>
|
| 436 |
-
""")
|
| 437 |
-
|
| 438 |
# Navigate Back to Menu Page
|
| 439 |
back_to_menu_button.click(
|
| 440 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|
|
|
|
| 285 |
}
|
| 286 |
</script>
|
| 287 |
"""
|
|
|
|
| 288 |
def app():
|
| 289 |
+
with gr.Blocks(css=".gradio-column { position: absolute; top: 0; width: 100%; }") as demo:
|
| 290 |
# Login Page
|
| 291 |
with gr.Column(visible=True) as login_section:
|
| 292 |
gr.Markdown("# Login Page")
|
|
|
|
| 325 |
# Button to navigate to Cart Page
|
| 326 |
view_cart_button = gr.Button("View Cart")
|
| 327 |
empty_div = gr.HTML('<div style="height: 300px;"></div>')
|
|
|
|
| 328 |
# Modal window
|
| 329 |
modal_window = gr.HTML("""
|
| 330 |
<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;">
|
|
|
|
| 365 |
gr.Row(modal_window)
|
| 366 |
gr.HTML(modal_and_cart_js)
|
| 367 |
|
| 368 |
+
# Cart & Final Order Page
|
| 369 |
with gr.Column(visible=False) as cart_section:
|
| 370 |
gr.Markdown("### Cart & Final Order Page")
|
| 371 |
|
|
|
|
| 379 |
back_to_menu_button = gr.Button("Back to Menu")
|
| 380 |
|
| 381 |
gr.Row(cart_output)
|
| 382 |
+
gr.Row(final_order_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
|
| 384 |
# Button Bindings
|
| 385 |
# Login Button
|
|
|
|
| 404 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|
| 405 |
outputs=[login_section, signup_section],
|
| 406 |
)
|
| 407 |
+
# Navigate to Cart Page
|
| 408 |
view_cart_button.click(
|
| 409 |
lambda: (gr.update(visible=False), gr.update(visible=True)),
|
| 410 |
outputs=[menu_section, cart_section],
|
| 411 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 412 |
# Navigate Back to Menu Page
|
| 413 |
back_to_menu_button.click(
|
| 414 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|