File size: 11,566 Bytes
4558d64
059f34f
cf64216
cb3331a
414aab1
cb3331a
414aab1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0507cc4
414aab1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb3331a
 
d2d895b
cf64216
ca14ce4
 
48c87bf
 
 
 
 
 
 
 
 
ca14ce4
 
e49f366
 
 
 
 
1be82e7
cb3331a
0fd1b8b
4161a8c
cb3331a
 
1277bdc
e49f366
57dc350
1277bdc
e49f366
 
ca14ce4
e49f366
1277bdc
 
c40754f
0fd1b8b
 
 
1277bdc
cb3331a
 
 
 
 
0fd1b8b
1be82e7
0fd1b8b
 
 
 
 
 
 
 
1be82e7
 
b45c843
0fd1b8b
cf64216
d2d895b
cf64216
 
0fd1b8b
 
 
 
 
cf64216
d2d895b
cf64216
 
 
 
d2d895b
cf64216
 
0fd1b8b
d2d895b
cf64216
 
 
 
 
11d383d
cf64216
 
 
 
 
 
d2d895b
cf64216
0fd1b8b
 
cf64216
 
d2d895b
 
 
0fd1b8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1be82e7
cb3331a
9b0d3a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import gradio as gr

# Menu data
menu_data = [
    {"name": "Veg Burger", "category": "VEGAN",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_burger.jpg",
     "description": "A delicious vegan burger with plant-based patty, lettuce, and tomato.",
     "price": "$8.99"},
    {"name": "Chicken Biryani", "category": "HALAL",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chicken_biryani.jpg",
     "description": "Spicy chicken biryani with aromatic basmati rice and tender chicken pieces.",
     "price": "$12.99"},
    {"name": "Paneer Butter Masala", "category": "VEGAN",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/paneer_butter_masala.jpg",
     "description": "Paneer cooked in a rich and creamy tomato-based gravy.",
     "price": "$10.99"},
    {"name": "Beef Steak", "category": "HALAL",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/beef_steak.jpg",
     "description": "Juicy beef steak served with mashed potatoes and grilled vegetables.",
     "price": "$15.99"},
    {"name": "Mushroom Soup", "category": "VEGAN",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/mushroom_soup.jpg",
     "description": "Creamy mushroom soup with fresh herbs.",
     "price": "$7.99"},
    {"name": "Tandoori Chicken", "category": "HALAL",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/tandoori_chicken.jpg",
     "description": "Grilled chicken marinated in yogurt and spices, cooked in a tandoor.",
     "price": "$11.99"},
    {"name": "Grilled Veggies", "category": "VEGAN",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/grilled_veggies.jpg",
     "description": "A healthy mix of grilled seasonal vegetables with olive oil.",
     "price": "$9.99"},
    {"name": "Butter Naan", "category": "VEGAN",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/butter_naan.jpg",
     "description": "Soft and buttery flatbread, perfect to pair with any curry.",
     "price": "$2.99"},
    {"name": "Fish Curry", "category": "HALAL",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/fish_curry.jpg",
     "description": "Fresh fish cooked in a spicy and tangy curry.",
     "price": "$13.99"},
    {"name": "Vegetable Salad", "category": "VEGAN",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/vegetable_salad.jpg",
     "description": "A mix of fresh greens, tomatoes, cucumbers, and a light dressing.",
     "price": "$6.99"},
    {"name": "Veg Spring Rolls", "category": "VEGAN",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_spring_rolls.jpg",
     "description": "Crispy spring rolls filled with fresh vegetables.",
     "price": "$5.99"},
    {"name": "Chicken Kebab", "category": "HALAL",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chicken_kebab.jpg",
     "description": "Juicy chicken kebabs grilled to perfection with a mix of spices.",
     "price": "$9.99"},
    {"name": "Dal Makhani", "category": "VEGAN",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/dal_makhani.jpg",
     "description": "Rich and creamy black lentils slow-cooked with spices.",
     "price": "$8.99"},
    {"name": "Lamb Curry", "category": "HALAL",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/lamb_curry.jpg",
     "description": "Tender lamb pieces cooked in a flavorful curry sauce.",
     "price": "$14.99"},
    {"name": "Mixed Veg Curry", "category": "VEGAN",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/mixed_veg_curry.jpg",
     "description": "A medley of fresh vegetables cooked in a lightly spiced curry.",
     "price": "$9.99"},
    {"name": "Chicken Wings", "category": "HALAL",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chicken_wings.jpg",
     "description": "Crispy chicken wings tossed in a tangy sauce.",
     "price": "$12.99"},
    {"name": "Aloo Paratha", "category": "VEGAN",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/aloo_paratha.jpg",
     "description": "Indian flatbread stuffed with spiced mashed potatoes.",
     "price": "$3.99"},
    {"name": "Egg Curry", "category": "HALAL",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/egg_curry.jpg",
     "description": "Boiled eggs cooked in a spiced tomato gravy.",
     "price": "$9.99"},
    {"name": "Chickpea Salad", "category": "VEGAN",
     "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chickpea_salad.jpg",
     "description": "A refreshing salad made with chickpeas, fresh vegetables, and herbs.",
     "price": "$7.99"}
]


# Spice levels and extras
spice_levels = ["American Mild", "American Medium", "American Spicy", 
                "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"]
extras = [
    {"name": "Extra Raitha 4oz", "price": "$1.00"},
    {"name": "Extra Raitha 8oz", "price": "$2.00"},
    {"name": "Extra Salan 4oz", "price": "$1.00"},
    {"name": "Extra Salan 8oz", "price": "$2.00"},
    {"name": "Extra Onion", "price": "$1.00"},
    {"name": "Extra Onion & Lemon", "price": "$2.00"},
    {"name": "Extra Fried Onion 4oz", "price": "$2.00"},
]

# Filter dishes by category
def filter_dishes(category):
    if category == "ALL":
        return menu_data
    return [dish for dish in menu_data if dish["category"] == category]

# Generate dish cards with "Add" button
def display_dishes(category):
    filtered_dishes = filter_dishes(category)
    html_content = "<div style='display: flex; flex-direction: column; align-items: center; width: 100%; height:100%'>"
    for dish in filtered_dishes:
        html_content += f"""
        <div style='margin: 10px; display: flex; align-items: center; justify-content: space-between; 
                    width: 80%; padding: 10px; border: 1px solid #ddd; border-radius: 10px; 
                    background-color: #f9f9f9;'>
            <div style='flex: 1; margin-right: 20px; text-align: left;'>
                <h4 style='font-size: 18px; color: #444; margin: 0;'>{dish['name']}</h4>
                <p style='font-size: 14px; color: #666; margin: 5px 0;'>{dish['description']}</p>
                <p style='font-size: 16px; color: #444; margin: 0;'>Price: {dish['price']}</p>
            </div>
            <div style='text-align: center;'>
                <img src='{dish['image']}' alt='{dish['name']}' 
                     style='width: 150px; height: 100px; object-fit: cover; border-radius: 10px;'>
                <button onclick="showPopup('{dish['image']}', '{dish['name']}', '{dish['description']}', '{dish['price']}')" 
                        style="margin-top: 15px; padding: 10px 20px; background-color: #28a745; color: white; border: none; 
                               border-radius: 5px; cursor: pointer;">Add</button>
            </div>
        </div>
        """
    html_content += "</div>"
    return html_content

# Main Gradio App
with gr.Blocks() as demo:
    gr.HTML("<h1 style='text-align: center; color: #333;'>πŸ› Biryani Hub Menu πŸ›</h1>")

    # Buttons for category selection
    with gr.Row():
        btn_all = gr.Button("ALL")
        btn_vegan = gr.Button("VEGAN")
        btn_halal = gr.Button("HALAL")

    # Dish display
    dish_display = gr.HTML(value=display_dishes("ALL"))

    # JavaScript for managing the pop-up
    gr.HTML(f"""
        <div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); 
                              background-color: white; padding: 20px; border-radius: 10px; 
                              box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
            <img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">
            <h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2>
            <p id="popup-description" style="margin-top: 10px; font-size: 16px; color: #666;"></p>
            <p id="popup-price" style="margin-top: 10px; font-size: 16px; color: #444;"></p>
            
            <h4 style="text-align: left; margin-top: 20px;">Choose a spice level</h4>
            <div style="display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;">
    """ + "".join([f'<label style="margin-right: 10px; display: block;"><input type="radio" name="spice" value="{spice}" style="margin-right: 5px;">{spice}</label>' for spice in spice_levels]) + """
            </div>

            <h4 style="text-align: left; margin-top: 20px;">Choose Extras</h4>
            <div style="display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;">
    """ + "".join([f'<label style="margin-right: 10px; display: block;"><input type="checkbox" name="extras" value="{extra["name"]}" style="margin-right: 5px;">{extra["name"]} + {extra["price"]}</label>' for extra in extras]) + """
            </div>

            <button onclick="addToCart(document.getElementById('popup-title').textContent, document.querySelector('input[name=spice]:checked').value)" 
                    style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none; 
                           border-radius: 5px; cursor: pointer;">Add to Cart</button>
            <button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #28a745; 
                                                  color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button>
        </div>
        <script>
            function showPopup(image, title, description, price) {
                document.getElementById('popup-image').src = image;
                document.getElementById('popup-title').textContent = title;
                document.getElementById('popup-description').textContent = description;
                document.getElementById('popup-price').textContent = "Price: " + price;

                // Display the popup
                document.getElementById('popup').style.display = 'block';
            }
            function closePopup() {
                document.getElementById('popup').style.display = 'none';
            }
            function addToCart(dishName, spiceLevel) {
                const selectedExtras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(cb => cb.value).join(", ");
                alert(dishName + " with " + spiceLevel + " spice level and extras: " + selectedExtras + " has been added to the cart!");
            }
        </script>
    """)

    # Button click events
    btn_all.click(
        lambda: gr.update(value=display_dishes("ALL")),
        outputs=dish_display
    )
    btn_vegan.click(
        lambda: gr.update(value=display_dishes("VEGAN")),
        outputs=dish_display
    )
    btn_halal.click(
        lambda: gr.update(value=display_dishes("HALAL")),
        outputs=dish_display
    )

demo.launch()