DSatishchandra commited on
Commit
5bcd1fc
·
verified ·
1 Parent(s): f53e7e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -90
app.py CHANGED
@@ -74,97 +74,47 @@ def app():
74
 
75
  # Modal window
76
  modal_window = gr.HTML("""
77
- <div id="modal" style="
78
- display: none;
79
- position: fixed;
80
- top: 50%;
81
- left: 50%;
82
- transform: translate(-50%, -50%);
83
- width: 90%;
84
- max-width: 500px;
85
- max-height: 90%;
86
- background: white;
87
- border-radius: 15px;
88
- box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
89
- padding: 20px;
90
- z-index: 1000;
91
- overflow-y: auto;
92
- font-family: Arial, sans-serif;
93
- ">
94
- <div style="text-align: right;">
95
- <button onclick="closeModal()" style="
96
- background: none;
97
- border: none;
98
- font-size: 24px;
99
- cursor: pointer;
100
- color: #333;
101
- ">&times;</button>
102
- </div>
103
- <img id="modal-image" style="
104
- width: 100%;
105
- height: auto;
106
- border-radius: 12px;
107
- margin-bottom: 15px;
108
- " />
109
- <h2 id="modal-name" style="margin-bottom: 10px; font-size: 22px; color: #333;"></h2>
110
- <p id="modal-description" style="margin-bottom: 10px; color: #555; font-size: 16px;"></p>
111
- <p id="modal-price" style="margin-bottom: 20px; font-size: 18px; font-weight: bold; color: #222;"></p>
112
- <div style="display: flex; justify-content: space-between; align-items: center;">
113
- <label for="quantity" style="font-weight: bold;">Quantity:</label>
114
- <input type="number" id="quantity" value="1" min="1" style="
115
- width: 60px;
116
- padding: 5px;
117
- border: 1px solid #ccc;
118
- border-radius: 5px;
119
- " />
120
- <button style="
121
- background-color: #28a745;
122
- color: white;
123
- border: none;
124
- padding: 10px 20px;
125
- font-size: 16px;
126
- border-radius: 8px;
127
- cursor: pointer;
128
- " onclick="addToCart()">Add</button>
129
- </div>
130
  </div>
131
-
132
- <script>
133
- let cart = [];
134
- function openModal(name, image, description, price) {
135
- const modal = document.getElementById('modal');
136
- modal.style.display = 'block';
137
- modal.style.top = '50%';
138
- modal.style.left = '50%';
139
- modal.style.transform = 'translate(-50%, -50%)';
140
- document.getElementById('modal-image').src = image;
141
- document.getElementById('modal-name').innerText = name;
142
- document.getElementById('modal-description').innerText = description;
143
- document.getElementById('modal-price').innerText = `$${price}`;
144
- }
145
-
146
- function closeModal() {
147
- const modal = document.getElementById('modal');
148
- modal.style.display = 'none';
149
- }
150
-
151
- function addToCart() {
152
- const name = document.getElementById('modal-name').innerText;
153
- const price = document.getElementById('modal-price').innerText;
154
- const description = document.getElementById('modal-description').innerText;
155
- const quantity = parseInt(document.getElementById('quantity').value) || 1;
156
- const cartItem = { name, description, price, quantity };
157
- cart.push(cartItem);
158
- fetch("/update_cart", {
159
- method: "POST",
160
- headers: { "Content-Type": "application/json" },
161
- body: JSON.stringify(cart)
162
- });
163
- alert(`${name} added to cart!`);
164
- closeModal();
165
- }
166
- </script>
167
- """)
168
 
169
  # Interactivity
170
  selected_preference.change(filter_menu, inputs=[selected_preference], outputs=[menu_output])
 
74
 
75
  # Modal window
76
  modal_window = gr.HTML("""
77
+ <div id="popup" class="popup" style="display:none; position:fixed; top:50%; left:50%; transform:translate(-50%, -50%); max-width:90%; width:600px; max-height:90%; overflow-y:auto; background:rgba(255, 255, 255, 0.95); display:flex; flex-direction: column; justify-content:center; align-items:center; border-radius: 15px; padding: 20px; box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.25); z-index: 1000;">
78
+ <button onclick="closePopup()" style="position:absolute; top:10px; right:10px; background:none; border:none; font-size:20px; cursor:pointer;">&times;</button>
79
+ <div class="popup-content" style="background:#fff; padding:20px; border-radius:15px; width:100%; text-align:center;">
80
+ <img id="popup-image" src="" alt="Food Image" style="width:100%; height:auto; border-radius:10px; margin-bottom:15px;">
81
+ <h2 id="popup-name" style="margin: 15px 0; font-size:24px; color:#333;"></h2>
82
+ <p id="popup-price" style="margin: 5px 0; font-size:18px; color:#555;"></p>
83
+ <p id="popup-description" style="margin: 10px 0; font-size:14px; color:#777; line-height:1.5;"></p>
84
+ <h4 style="margin: 20px 0 10px; font-size:16px; color:#333;">Choose a spice level</h4>
85
+ <p style="font-size:12px; color:#777; margin-bottom:10px;">Required - Choose 1.</p>
86
+ <div style="display:flex; gap:10px; flex-wrap:wrap; justify-content:center;">
87
+ <label><input type="radio" name="spice-level"> American Mild</label>
88
+ <label><input type="radio" name="spice-level"> American Medium</label>
89
+ <label><input type="radio" name="spice-level"> American Spicy</label>
90
+ <label><input type="radio" name="spice-level"> Indian Mild</label>
91
+ <label><input type="radio" name="spice-level"> Indian Medium</label>
92
+ <label><input type="radio" name="spice-level"> Indian Spicy</label>
93
+ <label><input type="radio" name="spice-level"> Indian Very Spicy</label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  </div>
95
+ <h4 style="margin-top:20px; font-size:16px; color:#333;">Biryani Extras</h4>
96
+ <p style="font-size:12px; color:#777; margin-bottom:10px;">Optional - Choose as many as you like.</p>
97
+ <div style="display:flex; gap:10px; flex-wrap:wrap; justify-content:center;">
98
+ <label><input type="checkbox"> Extra Raitha 4oz + $1.00</label>
99
+ <label><input type="checkbox"> Extra Raitha 8oz + $2.00</label>
100
+ <label><input type="checkbox"> Extra Salan 4oz + $1.00</label>
101
+ <label><input type="checkbox"> Extra Salan 8oz + $2.00</label>
102
+ <label><input type="checkbox"> Extra Onion + $1.00</label>
103
+ <label><input type="checkbox"> Extra Onion & Lemon + $2.00</label>
104
+ <label><input type="checkbox"> Extra Fried Onion 4oz + $2.00</label>
105
+ </div>
106
+ <h4 style="margin-top:20px; font-size:16px; color:#333;">Special Instructions</h4>
107
+ <textarea placeholder="Add any requests here." style="width:100%; padding:10px; border-radius:5px; border:1px solid #ddd; margin-bottom:20px;"></textarea>
108
+ <h4 style="margin-top:15px; font-size:16px; color:#333;">Quantity</h4>
109
+ <div style="display:flex; align-items:center; gap:10px; justify-content:center; margin-bottom:20px;">
110
+ <button style="padding:5px 10px; font-size:16px; background:#eee; border:none; border-radius:5px; cursor:pointer;">-</button>
111
+ <input type="number" value="1" min="1" style="width:50px; text-align:center; border:1px solid #ddd; border-radius:5px;">
112
+ <button style="padding:5px 10px; font-size:16px; background:#eee; border:none; border-radius:5px; cursor:pointer;">+</button>
113
+ </div>
114
+ <button style="padding:10px 20px; background:purple; color:#fff; border:none; border-radius:5px; font-size:16px; cursor:pointer;">Add to Bag</button>
115
+ </div>
116
+ </div>
117
+ """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
  # Interactivity
120
  selected_preference.change(filter_menu, inputs=[selected_preference], outputs=[menu_output])