Rammohan0504 commited on
Commit
30db2e0
Β·
verified Β·
1 Parent(s): 6c3c4d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -31
app.py CHANGED
@@ -15,7 +15,49 @@ menu_data = [
15
  "description": "Juicy beef steak served with mashed potatoes and grilled vegetables."},
16
  {"name": "Mushroom Soup", "category": "VEGAN",
17
  "image": "https://upload.wikimedia.org/wikipedia/commons/3/3c/Mushroom_Soup.jpg",
18
- "description": "Creamy mushroom soup with fresh herbs."}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  ]
20
 
21
  # Function to filter dishes by category
@@ -49,38 +91,23 @@ def display_dishes(category):
49
  with gr.Blocks() as demo:
50
  gr.HTML("<h1 style='text-align: center; color: #333;'>πŸ› Biryani Hub Menu πŸ›</h1>")
51
 
 
 
 
 
 
 
52
  # Dish display
53
  dish_display = gr.HTML(value=display_dishes("ALL"))
54
 
55
- # JavaScript for managing the selected button and pop-up
56
  gr.HTML("""
57
- <div style="text-align: center; margin-bottom: 20px;">
58
- <button id="btn-all" class="category-btn" onclick="filterCategory('ALL', this)">ALL</button>
59
- <button id="btn-vegan" class="category-btn" onclick="filterCategory('VEGAN', this)">VEGAN</button>
60
- <button id="btn-halal" class="category-btn" onclick="filterCategory('HALAL', this)">HALAL</button>
61
- </div>
62
  <script>
63
- function filterCategory(category, button) {
64
- const input = document.querySelector('input[aria-label="dish_display"]');
65
- input.value = category;
66
- input.dispatchEvent(new Event('input'));
67
-
68
- // Highlight the selected button
69
- const buttons = document.querySelectorAll('.category-btn');
70
- buttons.forEach(btn => btn.style.backgroundColor = '');
71
- button.style.backgroundColor = 'green';
72
- button.style.color = 'white';
73
- }
74
-
75
  function showPopup(image, title, description) {
76
  document.getElementById('popup-image').src = image;
77
  document.getElementById('popup-title').textContent = title;
78
  document.getElementById('popup-description').textContent = description;
79
-
80
- // Adjust the popup to always appear in the middle
81
- const popup = document.getElementById('popup');
82
- popup.style.top = window.pageYOffset + 'px';
83
- popup.style.display = 'block';
84
  }
85
 
86
  function closePopup() {
@@ -104,12 +131,9 @@ with gr.Blocks() as demo:
104
  </div>
105
  """)
106
 
107
- # Dish display input for Gradio interaction
108
- gr.Textbox(visible=False, label="dish_display", interactive=False)
109
-
110
- # Link button clicks to Gradio logic
111
- btn_all = gr.Button("ALL").click(lambda: gr.update(value=display_dishes("ALL")), outputs=dish_display)
112
- btn_vegan = gr.Button("VEGAN").click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
113
- btn_halal = gr.Button("HALAL").click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
114
 
115
  demo.launch()
 
15
  "description": "Juicy beef steak served with mashed potatoes and grilled vegetables."},
16
  {"name": "Mushroom Soup", "category": "VEGAN",
17
  "image": "https://upload.wikimedia.org/wikipedia/commons/3/3c/Mushroom_Soup.jpg",
18
+ "description": "Creamy mushroom soup with fresh herbs."},
19
+ {"name": "Tandoori Chicken", "category": "HALAL",
20
+ "image": "https://upload.wikimedia.org/wikipedia/commons/7/77/Tandoori_Chicken.jpg",
21
+ "description": "Grilled chicken marinated in yogurt and spices, cooked in a tandoor."},
22
+ {"name": "Grilled Veggies", "category": "VEGAN",
23
+ "image": "https://upload.wikimedia.org/wikipedia/commons/6/66/Grilled_Vegetables.jpg",
24
+ "description": "A healthy mix of grilled seasonal vegetables with olive oil."},
25
+ {"name": "Butter Naan", "category": "VEGAN",
26
+ "image": "https://upload.wikimedia.org/wikipedia/commons/8/8a/Naan.jpg",
27
+ "description": "Soft and buttery flatbread, perfect to pair with any curry."},
28
+ {"name": "Fish Curry", "category": "HALAL",
29
+ "image": "https://upload.wikimedia.org/wikipedia/commons/4/44/Fish_Curry.jpg",
30
+ "description": "Fresh fish cooked in a spicy and tangy curry."},
31
+ {"name": "Vegetable Salad", "category": "VEGAN",
32
+ "image": "https://upload.wikimedia.org/wikipedia/commons/8/8c/Vegetable_Salad.jpg",
33
+ "description": "A mix of fresh greens, tomatoes, cucumbers, and a light dressing."},
34
+ {"name": "Veg Spring Rolls", "category": "VEGAN",
35
+ "image": "https://upload.wikimedia.org/wikipedia/commons/3/37/Spring_Rolls.jpg",
36
+ "description": "Crispy spring rolls filled with fresh vegetables."},
37
+ {"name": "Chicken Kebab", "category": "HALAL",
38
+ "image": "https://upload.wikimedia.org/wikipedia/commons/9/9d/Chicken_Kebab.jpg",
39
+ "description": "Juicy chicken kebabs grilled to perfection with a mix of spices."},
40
+ {"name": "Dal Makhani", "category": "VEGAN",
41
+ "image": "https://upload.wikimedia.org/wikipedia/commons/f/f7/Dal_Makhani.jpg",
42
+ "description": "Rich and creamy black lentils slow-cooked with spices."},
43
+ {"name": "Lamb Curry", "category": "HALAL",
44
+ "image": "https://upload.wikimedia.org/wikipedia/commons/2/23/Lamb_Curry.jpg",
45
+ "description": "Tender lamb pieces cooked in a flavorful curry sauce."},
46
+ {"name": "Mixed Veg Curry", "category": "VEGAN",
47
+ "image": "https://upload.wikimedia.org/wikipedia/commons/1/1f/Mixed_Veg_Curry.jpg",
48
+ "description": "A medley of fresh vegetables cooked in a lightly spiced curry."},
49
+ {"name": "Chicken Wings", "category": "HALAL",
50
+ "image": "https://upload.wikimedia.org/wikipedia/commons/7/7e/Chicken_Wings.jpg",
51
+ "description": "Crispy chicken wings tossed in a tangy sauce."},
52
+ {"name": "Aloo Paratha", "category": "VEGAN",
53
+ "image": "https://upload.wikimedia.org/wikipedia/commons/5/54/Aloo_Paratha.jpg",
54
+ "description": "Indian flatbread stuffed with spiced mashed potatoes."},
55
+ {"name": "Egg Curry", "category": "HALAL",
56
+ "image": "https://upload.wikimedia.org/wikipedia/commons/5/54/Egg_Curry.jpg",
57
+ "description": "Boiled eggs cooked in a spiced tomato gravy."},
58
+ {"name": "Chickpea Salad", "category": "VEGAN",
59
+ "image": "https://upload.wikimedia.org/wikipedia/commons/5/53/Chickpea_Salad.jpg",
60
+ "description": "A refreshing salad made with chickpeas, fresh vegetables, and herbs."}
61
  ]
62
 
63
  # Function to filter dishes by category
 
91
  with gr.Blocks() as demo:
92
  gr.HTML("<h1 style='text-align: center; color: #333;'>πŸ› Biryani Hub Menu πŸ›</h1>")
93
 
94
+ # Buttons for category selection
95
+ with gr.Row():
96
+ btn_all = gr.Button("ALL")
97
+ btn_vegan = gr.Button("VEGAN")
98
+ btn_halal = gr.Button("HALAL")
99
+
100
  # Dish display
101
  dish_display = gr.HTML(value=display_dishes("ALL"))
102
 
103
+ # JavaScript for managing the pop-up
104
  gr.HTML("""
 
 
 
 
 
105
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
106
  function showPopup(image, title, description) {
107
  document.getElementById('popup-image').src = image;
108
  document.getElementById('popup-title').textContent = title;
109
  document.getElementById('popup-description').textContent = description;
110
+ document.getElementById('popup').style.display = 'block';
 
 
 
 
111
  }
112
 
113
  function closePopup() {
 
131
  </div>
132
  """)
133
 
134
+ # Button click events
135
+ btn_all.click(lambda: gr.update(value=display_dishes("ALL")), outputs=dish_display)
136
+ btn_vegan.click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
137
+ btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
 
 
 
138
 
139
  demo.launch()