Rammohan0504 commited on
Commit
a0aab17
·
verified ·
1 Parent(s): 20b9bf1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -63,13 +63,22 @@ with gr.Blocks() as demo:
63
  btn_vegan.click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
64
  btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
65
 
66
- with gr.Row():
67
- gr.HTML("""
 
 
 
 
 
 
 
 
 
68
  <div id='cart-icon' style='position: fixed; top: 10px; right: 10px; cursor: pointer;'>
69
  <img src='https://upload.wikimedia.org/wikipedia/commons/thumb/0/09/Shopping_cart_icon.svg/512px-Shopping_cart_icon.svg.png' alt='Cart' style='width: 40px;' onclick='toggleCartPopup()'>
70
  </div>
71
  <div id='cart-popup' style='display: none; position: fixed; top: 50px; right: 10px; background: white; padding: 20px; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);'>
72
- <div id='cart-content'></div>
73
  <button onclick='toggleCartPopup()' style='margin-top: 10px; padding: 5px 10px; background-color: #007bff; color: white; border: none; border-radius: 3px;'>Close</button>
74
  </div>
75
 
@@ -115,6 +124,6 @@ with gr.Blocks() as demo:
115
  });
116
  }
117
  </script>
118
- """)
119
 
120
  demo.launch()
 
63
  btn_vegan.click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
64
  btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
65
 
66
+ def handle_add_to_cart(cart, dish_name):
67
+ cart.append(dish_name)
68
+ return cart, update_cart(cart)
69
+
70
+ add_to_cart_interface = gr.Interface(
71
+ fn=add_to_cart,
72
+ inputs=[gr.State(cart), gr.Textbox(label="Dish Name")],
73
+ outputs=[gr.State(cart), cart_display]
74
+ )
75
+
76
+ gr.HTML("""
77
  <div id='cart-icon' style='position: fixed; top: 10px; right: 10px; cursor: pointer;'>
78
  <img src='https://upload.wikimedia.org/wikipedia/commons/thumb/0/09/Shopping_cart_icon.svg/512px-Shopping_cart_icon.svg.png' alt='Cart' style='width: 40px;' onclick='toggleCartPopup()'>
79
  </div>
80
  <div id='cart-popup' style='display: none; position: fixed; top: 50px; right: 10px; background: white; padding: 20px; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);'>
81
+ <div id='cart-content'>{cart_display}</div>
82
  <button onclick='toggleCartPopup()' style='margin-top: 10px; padding: 5px 10px; background-color: #007bff; color: white; border: none; border-radius: 3px;'>Close</button>
83
  </div>
84
 
 
124
  });
125
  }
126
  </script>
127
+ """)
128
 
129
  demo.launch()