Skip to content

Commit

Permalink
CORE_Built first version of recipe factory
Browse files Browse the repository at this point in the history
  • Loading branch information
0ddbird committed Dec 25, 2021
1 parent 850946c commit e89928f
Show file tree
Hide file tree
Showing 19 changed files with 4,712 additions and 174 deletions.
20 changes: 20 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"standard"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent":["error", 4]
}
}
8 changes: 8 additions & 0 deletions dist/components/display.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function displayRecipes(recipes) {
const recipesArr = recipes;
// recipesArr.forEach(recipe => console.log('recipe id: ', recipe.id, ', recipe name', recipe.name, ', number of ingredients : ', recipe.ingredients.length))
}
function displayRecipe(recipe) {
const recipe1 = recipe;
}
export { displayRecipes };
1 change: 1 addition & 0 deletions dist/components/query.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"use strict";
1 change: 1 addition & 0 deletions dist/data/data-control.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
12 changes: 1 addition & 11 deletions dist/data/recipes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"use strict";
const recipes = [
{
"id": 1,
Expand Down Expand Up @@ -277,16 +276,6 @@ const recipes = [
"ingredient": "Oeuf",
"quantity": 2
},
{
"ingredient": "Sucre en Poudre",
"quantity": "110",
"unit": "grammes"
},
{
"ingredient": "farine",
"quantity": 90,
"unit": "grammes"
}
],
"time": 60,
"description": "Hachez les noix grossièrement. Faire fondre le chocolat avec le beurre. Mélanger les oeuf et le sucre et mélanger au chocolat. Ajouter la farine. Mélanger afin d'avoir quelque chose d'homogène puis incorporer les noix. Verser la préparation dans un moule de préférence rectangulaire. Cuire 2O à 25 minutes à 180°. Sortez du four et attendez quelques minutes pour démouler. Servir avec une boule de glace pour plus de gourmandise.",
Expand Down Expand Up @@ -1719,3 +1708,4 @@ const recipes = [
"ustensils": ["rouleau à patisserie", "fouet"]
}
];
export { recipes };
36 changes: 35 additions & 1 deletion dist/factory/recipeFactory.js
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
"use strict";
function recipeFactory(recipeContent) {
const { id, name, servings, ingredients, time, description, appliance, ustensils } = recipeContent;
const resultSection = document.getElementById('result-section');
const template = document.getElementById('template_recipe').content;
const templateClone = document.importNode(template, true);
const recipe = templateClone.querySelector('.recipe');
const recipeTitle = templateClone.querySelector('.recipe-title');
const recipeTime = templateClone.querySelector('.recipe-time');
const recipeIngredients = templateClone.querySelector('.recipe-ingredients');
const recipeDescription = templateClone.querySelector('.recipe-description');
recipe.setAttribute('id', `${id}`);
recipe.setAttribute('data-appliance', `${appliance}`);
recipe.setAttribute('data-ustensils', `${ustensils}`);
recipe.setAttribute('data-servings', `${servings}`);
recipeTime.textContent = `${time} min`;
recipeTitle.textContent = name;
ingredients.forEach(ingredient => {
const li = document.createElement('li');
const b = document.createElement('b');
b.textContent = `${ingredient.ingredient}`;
li.appendChild(b);
if (ingredient.quantity !== null && ingredient.quantity !== undefined) {
const span = document.createElement('span');
span.textContent = `: ${ingredient.quantity}`;
if (ingredient.unit !== null && ingredient.unit !== undefined) {
span.textContent = `: ${ingredient.quantity} ${ingredient.unit}`;
}
li.appendChild(span);
}
recipeIngredients.appendChild(li);
});
recipeDescription.textContent = `${description}`;
resultSection.appendChild(templateClone);
}
export { recipeFactory };
15 changes: 14 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
export {};
import { recipes } from './data/recipes.js';
import { recipeFactory } from './factory/recipeFactory.js';
function init() {
recipes.forEach(recipe => recipeFactory(recipe));
}
const searchbar = document.getElementById('searchbar');
searchbar.addEventListener('keyup', handleKeyUp);
function handleKeyUp() {
// Note : prevent other keys than [AZ-az, space] to trigger search
if (searchbar.value.length >= 3) {
console.log('3 or more characters in searchbar:', searchbar.value);
}
}
init();
6 changes: 3 additions & 3 deletions dist/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";
console.log("Hello world");
let myNum = 8;
let myArray = [];
console.log('Hello world');
const myNum = 8;
const myArray = [];
myArray.push(myNum);
myArray.push(10);
console.log(myArray);
Expand Down
145 changes: 9 additions & 136 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,146 +118,19 @@ <h3>Presse citron</h3>
</div>
</div>
</section>
<section id="result-section">
<article class="recipe">
<div class="recipe-thumbnail"></div>
<div class="recipe-details">
<h2 class="recipe-title">Lorem ipsum dolor sit amet.</h2>
<span class="recipe-time">10 min</span>
<ul class="recipe-ingredients">
<li><b>Ingredient 1:</b> quantity unit</li>
<li><b>Ingredient 2:</b> quantity unit</li>
<li><b>Ingredient 3:</b> quantity unit</li>
<li><b>Ingredient 4:</b> quantity unit</li>
<li><b>Ingredient 5:</b> quantity unit</li>
<li><b>Ingredient 6:</b> quantity unit</li>
</ul>
<p class="recipe-description">
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quia vero neque, amet nam impedit, expedita minus laudantium quis quibusdam magni assumenda? Accusantium labore explicabo, veritatis provident repudiandae, commodi, quas iusto tenetur ipsum sequi est. Expedita quas cupiditate, aut ratione odit ducimus tempora voluptas quasi qui ab modi quia neque adipisci!
</p>
</div>
</article>
<article class="recipe">
<div class="recipe-thumbnail"></div>
<div class="recipe-details">
<h2 class="recipe-title">Lorem ipsum dolor sit amet.</h2>
<span class="recipe-time">10 min</span>
<ul class="recipe-ingredients">
<li><b>Ingredient 1:</b> quantity unit</li>
<li><b>Ingredient 2:</b> quantity unit</li>
<li><b>Ingredient 3:</b> quantity unit</li>
<li><b>Ingredient 4:</b> quantity unit</li>
<li><b>Ingredient 5:</b> quantity unit</li>
<li><b>Ingredient 6:</b> quantity unit</li>
</ul>
<p class="recipe-description">
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quia vero neque, amet nam impedit, expedita minus laudantium quis quibusdam magni assumenda? Accusantium labore explicabo, veritatis provident repudiandae, commodi, quas iusto tenetur ipsum sequi est. Expedita quas cupiditate, aut ratione odit ducimus tempora voluptas quasi qui ab modi quia neque adipisci!
</p>
</div>
</article>
<article class="recipe">
<div class="recipe-thumbnail"></div>
<div class="recipe-details">
<h2 class="recipe-title">Lorem ipsum dolor sit amet.</h2>
<span class="recipe-time">10 min</span>
<ul class="recipe-ingredients">
<li><b>Ingredient 1:</b> quantity unit</li>
<li><b>Ingredient 2:</b> quantity unit</li>
<li><b>Ingredient 3:</b> quantity unit</li>
<li><b>Ingredient 4:</b> quantity unit</li>
<li><b>Ingredient 5:</b> quantity unit</li>
<li><b>Ingredient 6:</b> quantity unit</li>
</ul>
<p class="recipe-description">
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quia vero neque, amet nam impedit, expedita minus laudantium quis quibusdam magni assumenda? Accusantium labore explicabo, veritatis provident repudiandae, commodi, quas iusto tenetur ipsum sequi est. Expedita quas cupiditate, aut ratione odit ducimus tempora voluptas quasi qui ab modi quia neque adipisci!
</p>
</div>
</article>
<article class="recipe">
<div class="recipe-thumbnail"></div>
<div class="recipe-details">
<h2 class="recipe-title">Lorem ipsum dolor sit amet.</h2>
<span class="recipe-time">10 min</span>
<ul class="recipe-ingredients">
<li><b>Ingredient 1:</b> quantity unit</li>
<li><b>Ingredient 2:</b> quantity unit</li>
<li><b>Ingredient 3:</b> quantity unit</li>
<li><b>Ingredient 4:</b> quantity unit</li>
<li><b>Ingredient 5:</b> quantity unit</li>
<li><b>Ingredient 6:</b> quantity unit</li>
</ul>
<p class="recipe-description">
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quia vero neque, amet nam impedit, expedita minus laudantium quis quibusdam magni assumenda? Accusantium labore explicabo, veritatis provident repudiandae, commodi, quas iusto tenetur ipsum sequi est. Expedita quas cupiditate, aut ratione odit ducimus tempora voluptas quasi qui ab modi quia neque adipisci!
</p>
</div>
</article>
<article class="recipe">
<div class="recipe-thumbnail"></div>
<div class="recipe-details">
<h2 class="recipe-title">Lorem ipsum dolor sit amet.</h2>
<span class="recipe-time">10 min</span>
<ul class="recipe-ingredients">
<li><b>Ingredient 1:</b> quantity unit</li>
<li><b>Ingredient 2:</b> quantity unit</li>
<li><b>Ingredient 3:</b> quantity unit</li>
<li><b>Ingredient 4:</b> quantity unit</li>
<li><b>Ingredient 5:</b> quantity unit</li>
<li><b>Ingredient 6:</b> quantity unit</li>
</ul>
<p class="recipe-description">
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quia vero neque, amet nam impedit, expedita minus laudantium quis quibusdam magni assumenda? Accusantium labore explicabo, veritatis provident repudiandae, commodi, quas iusto tenetur ipsum sequi est. Expedita quas cupiditate, aut ratione odit ducimus tempora voluptas quasi qui ab modi quia neque adipisci!
</p>
</div>
</article>
<article class="recipe">
<div class="recipe-thumbnail"></div>
<div class="recipe-details">
<h2 class="recipe-title">Lorem ipsum dolor sit amet.</h2>
<span class="recipe-time">10 min</span>
<ul class="recipe-ingredients">
<li><b>Ingredient 1:</b> quantity unit</li>
<li><b>Ingredient 2:</b> quantity unit</li>
<li><b>Ingredient 3:</b> quantity unit</li>
<li><b>Ingredient 4:</b> quantity unit</li>
<li><b>Ingredient 5:</b> quantity unit</li>
<li><b>Ingredient 6:</b> quantity unit</li>
</ul>
<p class="recipe-description">
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quia vero neque, amet nam impedit, expedita minus laudantium quis quibusdam magni assumenda? Accusantium labore explicabo, veritatis provident repudiandae, commodi, quas iusto tenetur ipsum sequi est. Expedita quas cupiditate, aut ratione odit ducimus tempora voluptas quasi qui ab modi quia neque adipisci!
</p>
</div>
</article>
<article class="recipe">
<div class="recipe-thumbnail"></div>
<div class="recipe-details">
<h2 class="recipe-title">Lorem ipsum dolor sit amet.</h2>
<span class="recipe-time">10 min</span>
<ul class="recipe-ingredients">
<li><b>Ingredient 1:</b> quantity unit</li>
<li><b>Ingredient 2:</b> quantity unit</li>
<li><b>Ingredient 3:</b> quantity unit</li>
<li><b>Ingredient 4:</b> quantity unit</li>
<li><b>Ingredient 5:</b> quantity unit</li>
<li><b>Ingredient 6:</b> quantity unit</li>
</ul>
<p class="recipe-description">
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quia vero neque, amet nam impedit, expedita minus laudantium quis quibusdam magni assumenda? Accusantium labore explicabo, veritatis provident repudiandae, commodi, quas iusto tenetur ipsum sequi est. Expedita quas cupiditate, aut ratione odit ducimus tempora voluptas quasi qui ab modi quia neque adipisci!
</p>
</div>
</article>
</section>
<section id="result-section"></section>
</main>
<template id="recipe">
<template id="template_recipe">
<article class="recipe">
<div class="recipe_thumbnail">
<div class="recipe_details">
<h2 class="recipe_name"></h2>
<span class="recipe_time"></span>
<ul class="recipe_ingredients"></ul>
<p class="recipe_description"></p>
<div class="recipe-thumbnail"></div>
<div class="recipe-details">
<h2 class="recipe-title"></h2>
<span class="recipe-time"></span>
<ul class="recipe-ingredients"></ul>
<p class="recipe-description"></p>
</div>
</article>
</template>
<script src="dist/index.js"></script>
<script src="dist/index.js" type="module"></script>
</body>
</html>
Loading

0 comments on commit e89928f

Please sign in to comment.