|
@@ -18,14 +18,20 @@ window.ingredientsStrandObj = {
|
|
|
headerTitle.innerText = category.name;
|
|
headerTitle.innerText = category.name;
|
|
|
headerDiv.appendChild(headerTitle);
|
|
headerDiv.appendChild(headerTitle);
|
|
|
|
|
|
|
|
|
|
+ let ingredientsDiv = document.createElement("div");
|
|
|
|
|
+ ingredientsDiv.classList = "ingredientsDiv";
|
|
|
|
|
+ ingredientsDiv.style.display = "none";
|
|
|
|
|
+ categoryDiv.appendChild(ingredientsDiv);
|
|
|
|
|
+
|
|
|
let headerButton = document.createElement("button");
|
|
let headerButton = document.createElement("button");
|
|
|
- headerButton.innerText = "^";
|
|
|
|
|
|
|
+ headerButton.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>';
|
|
|
|
|
+ headerButton.onclick = ()=>{this.toggleCategory(ingredientsDiv, headerButton)};
|
|
|
headerDiv.appendChild(headerButton);
|
|
headerDiv.appendChild(headerButton);
|
|
|
|
|
|
|
|
for(let ingredient of category.ingredients){
|
|
for(let ingredient of category.ingredients){
|
|
|
let ingredientDiv = document.createElement("div");
|
|
let ingredientDiv = document.createElement("div");
|
|
|
ingredientDiv.classList = "ingredient";
|
|
ingredientDiv.classList = "ingredient";
|
|
|
- categoryDiv.appendChild(ingredientDiv);
|
|
|
|
|
|
|
+ ingredientsDiv.appendChild(ingredientDiv);
|
|
|
|
|
|
|
|
let ingredientName = document.createElement("p");
|
|
let ingredientName = document.createElement("p");
|
|
|
ingredientName.innerText = ingredient.name;
|
|
ingredientName.innerText = ingredient.name;
|
|
@@ -39,6 +45,8 @@ window.ingredientsStrandObj = {
|
|
|
ingredientData.innerText = `${ingredient.quantity} ${ingredient.unit}`;
|
|
ingredientData.innerText = `${ingredient.quantity} ${ingredient.unit}`;
|
|
|
ingredientDiv.appendChild(ingredientData);
|
|
ingredientDiv.appendChild(ingredientData);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.isPopulated = true;
|
|
this.isPopulated = true;
|
|
@@ -77,8 +85,16 @@ window.ingredientsStrandObj = {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- console.log(ingredientsByCategory);
|
|
|
|
|
-
|
|
|
|
|
return ingredientsByCategory;
|
|
return ingredientsByCategory;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ toggleCategory: function(div, button){
|
|
|
|
|
+ if(div.style.display === "none"){
|
|
|
|
|
+ button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="18 15 12 9 6 15"></polyline></svg>';
|
|
|
|
|
+ div.style.display = "flex";
|
|
|
|
|
+ }else if(div.style.display === "flex"){
|
|
|
|
|
+ button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>';
|
|
|
|
|
+ div.style.display = "none";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|