Rammohan0504 commited on
Commit
669ebb6
·
verified ·
1 Parent(s): 15ad953

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -14
app.py CHANGED
@@ -80,30 +80,49 @@ menu_data = [
80
  ]
81
 
82
 
 
83
  # Spice levels and extras
84
  spice_levels = ["American Mild", "American Medium", "American Spicy",
85
  "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"]
86
  extras = [
87
  {"name": "Extra Raitha 4oz", "price": "$1.00"},
88
  {"name": "Extra Raitha 8oz", "price": "$2.00"},
89
- {"name": "Extra Salan 4oz", "price": "$1.00"},
90
- {"name": "Extra Salan 8oz", "price": "$2.00"},
91
  {"name": "Extra Onion", "price": "$1.00"},
92
- {"name": "Extra Onion & Lemon", "price": "$2.00"},
93
- {"name": "Extra Fried Onion 4oz", "price": "$2.00"},
94
  ]
95
 
96
  # JavaScript for popup modal
97
  popup_js = """
98
  <script>
99
- function showPopup(name, description, price) {
100
  const popup = document.getElementById("custom-popup");
101
  const overlay = document.getElementById("overlay");
102
  popup.innerHTML = `
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";
@@ -120,10 +139,9 @@ popup_js = """
120
 
121
  # HTML for popup modal
122
  popup_html = """
123
- <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;">
124
- </div>
125
  <div id="custom-popup"
126
- style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 50%; background: white; padding: 20px; border-radius: 10px; box-shadow: 0px 4px 6px rgba(0,0,0,0.1); display: none; z-index: 1000; text-align: center;">
127
  </div>
128
  """
129
 
@@ -141,7 +159,7 @@ def display_dishes(category):
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>
@@ -181,4 +199,4 @@ with gr.Blocks() as demo:
181
  outputs=dish_display
182
  )
183
 
184
- demo.launch()
 
80
  ]
81
 
82
 
83
+
84
  # Spice levels and extras
85
  spice_levels = ["American Mild", "American Medium", "American Spicy",
86
  "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"]
87
  extras = [
88
  {"name": "Extra Raitha 4oz", "price": "$1.00"},
89
  {"name": "Extra Raitha 8oz", "price": "$2.00"},
 
 
90
  {"name": "Extra Onion", "price": "$1.00"},
91
+ {"name": "Extra Onion & Lemon", "price": "$2.00"}
 
92
  ]
93
 
94
  # JavaScript for popup modal
95
  popup_js = """
96
  <script>
97
+ function showPopup(name, description, price, image) {
98
  const popup = document.getElementById("custom-popup");
99
  const overlay = document.getElementById("overlay");
100
  popup.innerHTML = `
101
+ <img src="${image}" alt="${name}" style="width: 100%; height: auto; border-radius: 10px;">
102
+ <h3 style="margin-top: 10px;">${name}</h3>
103
+ <p>${description}</p>
104
+ <p style="font-weight: bold;">Price: ${price}</p>
105
+
106
+ <h4 style="margin-top: 20px;">Choose a Spice Level</h4>
107
+ <div style="display: flex; flex-wrap: wrap; gap: 10px;">
108
+ ${["American Mild", "American Medium", "American Spicy", "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"].map(spice => `
109
+ <label style="margin-right: 10px;">
110
+ <input type="radio" name="spice" value="${spice}"> ${spice}
111
+ </label>
112
+ `).join("")}
113
+ </div>
114
+
115
+ <h4 style="margin-top: 20px;">Choose Extras</h4>
116
+ <div style="display: flex; flex-wrap: wrap; gap: 10px;">
117
+ ${["Extra Raitha 4oz + $1.00", "Extra Raitha 8oz + $2.00", "Extra Onion + $1.00", "Extra Onion & Lemon + $2.00"].map(extra => `
118
+ <label style="margin-right: 10px;">
119
+ <input type="checkbox" name="extras" value="${extra}"> ${extra}
120
+ </label>
121
+ `).join("")}
122
+ </div>
123
+
124
+ <button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer;">Add to Cart</button>
125
+ <button onclick="closePopup()" style="margin-top: 20px; margin-left: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button>
126
  `;
127
  popup.style.display = "block";
128
  overlay.style.display = "block";
 
139
 
140
  # HTML for popup modal
141
  popup_html = """
142
+ <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>
 
143
  <div id="custom-popup"
144
+ style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 50%; max-width: 400px; background: white; padding: 20px; border-radius: 10px; box-shadow: 0px 4px 6px rgba(0,0,0,0.1); display: none; z-index: 1000; text-align: center;">
145
  </div>
146
  """
147
 
 
159
  </div>
160
  <div style='flex: 1; text-align: center;'>
161
  <img src='{dish['image']}' alt='{dish['name']}' style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px;'>
162
+ <button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}', '{dish['image']}')"
163
  style='margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;'>
164
  Add
165
  </button>
 
199
  outputs=dish_display
200
  )
201
 
202
+ demo.launch()