Эх сурвалжийг харах

Change color of recipe card when it has no ingredients

Lee Morgan 6 жил өмнө
parent
commit
1527ff0437

+ 0 - 1
controllers/home.js

@@ -134,7 +134,6 @@ module.exports = {
                                 }
                             }
                         }
-                        console.log(result.data.elements);
 
                         let newRecipes = []
                         for(let recipe of result.data.elements){

+ 6 - 0
views/recipesPage/recipes.css

@@ -46,6 +46,12 @@ h2{
                 transform: translateY(-3px);
             }
 
+            .empty-recipe{
+                background: #ff626b;
+                border: 2px solid #001b2d;
+                color: #001b2d;
+            }
+
 #ingredient{
     display: none;
     width: 50%;

+ 6 - 0
views/recipesPage/recipes.js

@@ -20,6 +20,12 @@ let recipesPage = {
             recipeDiv.onclick = ()=>{this.displayOneRecipe(recipe._id)};
             body.appendChild(recipeDiv);
 
+            if(recipe.ingredients.length === 0){
+                recipeDiv.classList = "recipe-card empty-recipe";
+            }else{
+                recipeDiv.classList = "recipe-card";
+            }
+
             let title = document.createElement("h2");
             title.innerText = recipe.name;
             recipeDiv.appendChild(title);