Rammohan0504 commited on
Commit
e9eb86b
·
verified ·
1 Parent(s): dfea95c

Update app.py

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