nagasurendra commited on
Commit
ed1b5ff
·
verified ·
1 Parent(s): 8d21711

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +26 -11
static/script.js CHANGED
@@ -132,26 +132,46 @@ function displayCustomizationIngredients(ingredients) {
132
  ingredientsList.innerHTML = ''; // Clear previous list
133
  }
134
 
135
- // Apply styles to the ingredients list for horizontal scrolling
136
  ingredientsList.style.display = 'flex';
137
  ingredientsList.style.overflowX = 'auto';
138
  ingredientsList.style.whiteSpace = 'nowrap';
 
139
 
140
  // Display new ingredients
141
  ingredients.forEach(ingredient => {
142
  const item = document.createElement('div');
143
  item.className = 'ingredient-item';
144
-
 
 
 
 
 
 
145
  const img = document.createElement('img');
146
  img.src = ingredient.image_url || 'https://via.placeholder.com/80';
147
  img.alt = ingredient.name;
148
-
 
 
 
 
149
  const name = document.createElement('div');
150
  name.textContent = ingredient.name;
151
  name.style.textAlign = 'center';
152
  name.style.marginTop = '5px';
153
  name.style.fontSize = '12px';
 
 
 
 
 
 
 
 
154
 
 
155
  const button = document.createElement('button');
156
  button.textContent = 'Add';
157
  button.onclick = () => {
@@ -160,20 +180,15 @@ function displayCustomizationIngredients(ingredients) {
160
  displaySelectedCustomizationIngredients();
161
  }
162
  };
163
-
164
- // Set specific styles for each item
165
- item.style.flexShrink = '0'; // Prevent items from shrinking
166
- item.style.marginRight = '10px'; // Space between items
167
- item.style.width = '80px'; // Control the item size
168
-
169
- item.appendChild(img);
170
- item.appendChild(name);
171
  item.appendChild(button);
 
 
172
  ingredientsList.appendChild(item);
173
  });
174
  }
175
 
176
 
 
177
  function displaySelectedCustomizationIngredients() {
178
  const chatMessages = document.getElementById('chatMessages');
179
  if (!chatMessages) {
 
132
  ingredientsList.innerHTML = ''; // Clear previous list
133
  }
134
 
135
+ // Apply styles directly within the script for layout
136
  ingredientsList.style.display = 'flex';
137
  ingredientsList.style.overflowX = 'auto';
138
  ingredientsList.style.whiteSpace = 'nowrap';
139
+ ingredientsList.style.flexWrap = 'wrap'; // Allow wrapping if items overflow
140
 
141
  // Display new ingredients
142
  ingredients.forEach(ingredient => {
143
  const item = document.createElement('div');
144
  item.className = 'ingredient-item';
145
+
146
+ // Styling for each item (flex and width)
147
+ item.style.flexShrink = '0'; // Prevent shrinking
148
+ item.style.marginRight = '10px'; // Space between items
149
+ item.style.width = '20%'; // Adjust width for responsiveness
150
+
151
+ // Create and append image
152
  const img = document.createElement('img');
153
  img.src = ingredient.image_url || 'https://via.placeholder.com/80';
154
  img.alt = ingredient.name;
155
+ img.style.width = '100%'; // Make image fill the container
156
+ img.style.height = 'auto'; // Maintain aspect ratio
157
+ item.appendChild(img);
158
+
159
+ // Create and append name
160
  const name = document.createElement('div');
161
  name.textContent = ingredient.name;
162
  name.style.textAlign = 'center';
163
  name.style.marginTop = '5px';
164
  name.style.fontSize = '12px';
165
+ item.appendChild(name);
166
+
167
+ // Create and append the text box (input)
168
+ const inputBox = document.createElement('input');
169
+ inputBox.type = 'text';
170
+ inputBox.placeholder = 'Enter details';
171
+ inputBox.style.marginTop = '5px';
172
+ item.appendChild(inputBox);
173
 
174
+ // Create and append button
175
  const button = document.createElement('button');
176
  button.textContent = 'Add';
177
  button.onclick = () => {
 
180
  displaySelectedCustomizationIngredients();
181
  }
182
  };
 
 
 
 
 
 
 
 
183
  item.appendChild(button);
184
+
185
+ // Append the item to the list
186
  ingredientsList.appendChild(item);
187
  });
188
  }
189
 
190
 
191
+
192
  function displaySelectedCustomizationIngredients() {
193
  const chatMessages = document.getElementById('chatMessages');
194
  if (!chatMessages) {