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

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +15 -0
static/script.js CHANGED
@@ -132,18 +132,26 @@ function displayCustomizationIngredients(ingredients) {
132
  ingredientsList.innerHTML = ''; // Clear previous list
133
  }
134
 
 
 
 
 
 
135
  // Display new ingredients
136
  ingredients.forEach(ingredient => {
137
  const item = document.createElement('div');
138
  item.className = 'ingredient-item';
 
139
  const img = document.createElement('img');
140
  img.src = ingredient.image_url || 'https://via.placeholder.com/80';
141
  img.alt = ingredient.name;
 
142
  const name = document.createElement('div');
143
  name.textContent = ingredient.name;
144
  name.style.textAlign = 'center';
145
  name.style.marginTop = '5px';
146
  name.style.fontSize = '12px';
 
147
  const button = document.createElement('button');
148
  button.textContent = 'Add';
149
  button.onclick = () => {
@@ -152,6 +160,12 @@ function displayCustomizationIngredients(ingredients) {
152
  displaySelectedCustomizationIngredients();
153
  }
154
  };
 
 
 
 
 
 
155
  item.appendChild(img);
156
  item.appendChild(name);
157
  item.appendChild(button);
@@ -159,6 +173,7 @@ function displayCustomizationIngredients(ingredients) {
159
  });
160
  }
161
 
 
162
  function displaySelectedCustomizationIngredients() {
163
  const chatMessages = document.getElementById('chatMessages');
164
  if (!chatMessages) {
 
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
  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);
 
173
  });
174
  }
175
 
176
+
177
  function displaySelectedCustomizationIngredients() {
178
  const chatMessages = document.getElementById('chatMessages');
179
  if (!chatMessages) {