Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +9 -0
static/script.js
CHANGED
@@ -105,9 +105,17 @@ function displayIngredientsList(ingredients) {
|
|
105 |
ingredients.forEach(ingredient => {
|
106 |
const item = document.createElement('div');
|
107 |
item.className = 'ingredient-item';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
const name = document.createElement('div');
|
109 |
name.textContent = ingredient.name;
|
110 |
name.style.textAlign = 'center';
|
|
|
111 |
name.style.fontSize = '12px';
|
112 |
const button = document.createElement('button');
|
113 |
button.textContent = 'Add';
|
@@ -117,6 +125,7 @@ function displayIngredientsList(ingredients) {
|
|
117 |
displaySelectedIngredients();
|
118 |
}
|
119 |
};
|
|
|
120 |
item.appendChild(name);
|
121 |
item.appendChild(button);
|
122 |
ingredientsList.appendChild(item);
|
|
|
105 |
ingredients.forEach(ingredient => {
|
106 |
const item = document.createElement('div');
|
107 |
item.className = 'ingredient-item';
|
108 |
+
const img = document.createElement('img');
|
109 |
+
img.src = ingredient.image_url || '/static/placeholder.png'; // Use local placeholder if no image_url
|
110 |
+
img.alt = ingredient.name;
|
111 |
+
img.style.width = '80px';
|
112 |
+
img.style.height = '80px';
|
113 |
+
img.style.objectFit = 'cover';
|
114 |
+
img.style.borderRadius = '5px';
|
115 |
const name = document.createElement('div');
|
116 |
name.textContent = ingredient.name;
|
117 |
name.style.textAlign = 'center';
|
118 |
+
name.style.marginTop = '5px';
|
119 |
name.style.fontSize = '12px';
|
120 |
const button = document.createElement('button');
|
121 |
button.textContent = 'Add';
|
|
|
125 |
displaySelectedIngredients();
|
126 |
}
|
127 |
};
|
128 |
+
item.appendChild(img);
|
129 |
item.appendChild(name);
|
130 |
item.appendChild(button);
|
131 |
ingredientsList.appendChild(item);
|