Rammohan0504 commited on
Commit
15ad953
·
verified ·
1 Parent(s): 814d325

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -30
app.py CHANGED
@@ -103,19 +103,7 @@ popup_js = """
103
  <h3 style="margin: 0;">${name}</h3>
104
  <p style="margin: 5px 0;">${description}</p>
105
  <p style="margin: 5px 0; font-weight: bold;">Price: ${price}</p>
106
- <h4 style="margin: 20px 0 10px;">Choose a spice level</h4>
107
- <div style="display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px;">
108
- <label><input type="radio" name="spice" value="American Mild"> American Mild</label>
109
- <label><input type="radio" name="spice" value="Indian Spicy"> Indian Spicy</label>
110
- <label><input type="radio" name="spice" value="American Spicy"> American Spicy</label>
111
- </div>
112
- <h4 style="margin: 20px 0 10px;">Choose Extras</h4>
113
- <div style="display: flex; flex-wrap: wrap; gap: 10px;">
114
- <label><input type="checkbox" name="extras" value="Extra Raitha"> Extra Raitha</label>
115
- <label><input type="checkbox" name="extras" value="Extra Onion"> Extra Onion</label>
116
- </div>
117
- <button onclick="addToCart('${name}')" style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer;">Add to Cart</button>
118
- <button onclick="closePopup()" style="margin-left: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button>
119
  `;
120
  popup.style.display = "block";
121
  overlay.style.display = "block";
@@ -127,11 +115,6 @@ popup_js = """
127
  popup.style.display = "none";
128
  overlay.style.display = "none";
129
  }
130
-
131
- function addToCart(dishName) {
132
- alert(`${dishName} has been added to the cart!`);
133
- closePopup();
134
- }
135
  </script>
136
  """
137
 
@@ -146,20 +129,23 @@ popup_html = """
146
 
147
  # Generate dish cards
148
  def display_dishes(category):
149
- html_content = "<div style='display: flex; flex-wrap: wrap; justify-content: space-between;'>"
150
  for dish in menu_data:
151
  if category == "ALL" or dish["category"] == category:
152
  html_content += f"""
153
- <div style='margin: 10px; width: 30%; border: 1px solid #ddd; border-radius: 10px; padding: 10px;'>
154
- <img src='{dish['image']}' alt='{dish['name']}'
155
- style='width: 100%; height: auto; border-radius: 5px;'>
156
- <h3>{dish['name']}</h3>
157
- <p>{dish['description']}</p>
158
- <p>Price: {dish['price']}</p>
159
- <button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}')"
160
- style='background-color: #007bff; color: white; border: none; padding: 5px 10px; cursor: pointer;'>
161
- Add
162
- </button>
 
 
 
163
  </div>
164
  """
165
  html_content += "</div>"
@@ -170,7 +156,7 @@ with gr.Blocks() as demo:
170
  gr.HTML(popup_html) # Add the popup container and overlay
171
  gr.HTML(popup_js) # Add the JavaScript
172
 
173
- gr.HTML("<h1 style='text-align: center;'>Dynamic Restaurant Menu</h1>")
174
 
175
  # Buttons for filtering categories
176
  with gr.Row():
 
103
  <h3 style="margin: 0;">${name}</h3>
104
  <p style="margin: 5px 0;">${description}</p>
105
  <p style="margin: 5px 0; font-weight: bold;">Price: ${price}</p>
106
+ <button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button>
 
 
 
 
 
 
 
 
 
 
 
 
107
  `;
108
  popup.style.display = "block";
109
  overlay.style.display = "block";
 
115
  popup.style.display = "none";
116
  overlay.style.display = "none";
117
  }
 
 
 
 
 
118
  </script>
119
  """
120
 
 
129
 
130
  # Generate dish cards
131
  def display_dishes(category):
132
+ html_content = "<div style='display: flex; flex-direction: column; gap: 20px; width: 80%; margin: 0 auto;'>"
133
  for dish in menu_data:
134
  if category == "ALL" or dish["category"] == category:
135
  html_content += f"""
136
+ <div style='display: flex; align-items: center; justify-content: space-between; padding: 20px; border: 1px solid #ddd; border-radius: 10px; background-color: #f9f9f9;'>
137
+ <div style='flex: 3; text-align: left;'>
138
+ <h3 style='margin: 0; font-size: 20px;'>{dish['name']}</h3>
139
+ <p style='margin: 5px 0; font-size: 14px; color: #555;'>{dish['description']}</p>
140
+ <p style='margin: 0; font-size: 16px; font-weight: bold;'>Price: {dish['price']}</p>
141
+ </div>
142
+ <div style='flex: 1; text-align: center;'>
143
+ <img src='{dish['image']}' alt='{dish['name']}' style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px;'>
144
+ <button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}')"
145
+ style='margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;'>
146
+ Add
147
+ </button>
148
+ </div>
149
  </div>
150
  """
151
  html_content += "</div>"
 
156
  gr.HTML(popup_html) # Add the popup container and overlay
157
  gr.HTML(popup_js) # Add the JavaScript
158
 
159
+ gr.HTML("<h1 style='text-align: center;'>🍛 Biryani Hub Menu 🍛</h1>")
160
 
161
  # Buttons for filtering categories
162
  with gr.Row():