Rammohan0504 commited on
Commit
3ac1af1
·
verified ·
1 Parent(s): 5ce65f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -21,7 +21,7 @@ menu_data = [
21
  # Function to add an item to the cart
22
  def add_to_cart(item_name):
23
  cart.append({"item_name": item_name})
24
- return f"{item_name} added to cart!"
25
 
26
  # Function to display the current cart
27
  def display_cart():
@@ -63,6 +63,7 @@ popup_js = """
63
  const popup = document.getElementById("custom-popup");
64
  const overlay = document.getElementById("overlay");
65
  popup.innerHTML = `
 
66
  <img src="${image}" alt="${name}" style="width: 100%; height: 200px; object-fit: cover; border-radius: 10px; margin-bottom: 10px;">
67
  <h3>${name}</h3>
68
  <p>${description}</p>
@@ -97,7 +98,7 @@ popup_js = """
97
  popup_html = """
98
  <div id="overlay" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; z-index: 999;"></div>
99
  <div id="custom-popup"
100
- style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 400px; max-width: 90%; background: white; padding: 20px; border-radius: 10px; box-shadow: 0px 4px 6px rgba(0,0,0,0.1); display: none; z-index: 1000;">
101
  </div>
102
  """
103
 
@@ -140,7 +141,7 @@ with gr.Blocks() as demo:
140
  outputs=cart_display
141
  )
142
 
143
- # Gradio serves all registered functions automatically
144
  demo.add_to_cart = add_to_cart
145
 
146
  demo.launch()
 
21
  # Function to add an item to the cart
22
  def add_to_cart(item_name):
23
  cart.append({"item_name": item_name})
24
+ return {"data": f"{item_name} added to cart!"}
25
 
26
  # Function to display the current cart
27
  def display_cart():
 
63
  const popup = document.getElementById("custom-popup");
64
  const overlay = document.getElementById("overlay");
65
  popup.innerHTML = `
66
+ <button onclick="closePopup()" style="position: absolute; top: 10px; right: 10px; background: none; border: none; font-size: 20px; cursor: pointer;">&times;</button>
67
  <img src="${image}" alt="${name}" style="width: 100%; height: 200px; object-fit: cover; border-radius: 10px; margin-bottom: 10px;">
68
  <h3>${name}</h3>
69
  <p>${description}</p>
 
98
  popup_html = """
99
  <div id="overlay" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; z-index: 999;"></div>
100
  <div id="custom-popup"
101
+ style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 400px; max-width: 90%; background: white; padding: 20px; border-radius: 10px; box-shadow: 0px 4px 6px rgba(0,0,0,0.1); display: none; z-index: 1000; position: relative;">
102
  </div>
103
  """
104
 
 
141
  outputs=cart_display
142
  )
143
 
144
+ # Register the add_to_cart function
145
  demo.add_to_cart = add_to_cart
146
 
147
  demo.launch()