geethareddy commited on
Commit
6f61a01
·
verified ·
1 Parent(s): b86b48e

Update components/popup_card.py

Browse files
Files changed (1) hide show
  1. components/popup_card.py +10 -26
components/popup_card.py CHANGED
@@ -1,26 +1,10 @@
1
- def generate_popup_card(name, model_path):
2
- """
3
- Generates an HTML popup card dynamically for the selected menu item with proper close functionality.
4
- """
5
- html_content = f"""
6
- <div id="overlay" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.8); z-index: 9999; display: flex; justify-content: center; align-items: center;">
7
- <div style="border: 1px solid #ddd; padding: 20px; border-radius: 10px; background-color: #fff; width: 350px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);">
8
- <h2 style="text-align: center; color: #333; margin-bottom: 10px;">{name}</h2>
9
- <model-viewer src="{model_path}" alt="3D Model of {name}" camera-controls auto-rotate style="width: 100%; margin-bottom: 10px;"></model-viewer>
10
- <label for="instructions" style="display: block; margin-bottom: 5px; font-weight: bold;">Special Instructions:</label>
11
- <textarea id="instructions" placeholder="Add any requests here..." style="width: 100%; margin-bottom: 10px; padding: 5px; border: 1px solid #ccc; border-radius: 5px;"></textarea>
12
- <label for="quantity" style="display: block; font-weight: bold; margin-bottom: 5px;">Quantity:</label>
13
- <input type="number" id="quantity" min="1" max="10" value="1" style="width: 100%; margin-bottom: 10px; padding: 5px; border: 1px solid #ccc; border-radius: 5px;">
14
- <div style="text-align: center;">
15
- <button style="padding: 10px 20px; background-color: #008cba; color: white; border: none; border-radius: 5px; cursor: pointer;">Add to Cart</button>
16
- <button id="closeButton" style="padding: 10px 20px; background-color: #ccc; color: black; border: none; border-radius: 5px; margin-left: 10px; cursor: pointer;">Close</button>
17
- </div>
18
- </div>
19
- </div>
20
- <script>
21
- document.getElementById('closeButton').onclick = function() {{
22
- document.getElementById('overlay').style.display = 'none';
23
- }};
24
- </script>
25
- """
26
- return html_content
 
1
+ import gradio as gr
2
+
3
+ def show_popup_card(dish_name, image_path, portion_size):
4
+ with gr.Modal():
5
+ gr.Markdown(f"### {dish_name}")
6
+ gr.Image(image_path, elem_id="popup_image")
7
+ gr.Markdown(f"#### Portion Size: {portion_size}")
8
+ gr.TextArea(label="Add custom preferences", lines=4, placeholder="E.g., Less Spicy, No Onions")
9
+ gr.Slider(1, 5, step=1, label="Select Portion Size")
10
+ gr.Button("Add to Cart")