From 7269872b72afdfea697203989cf8739d136af1e4 Mon Sep 17 00:00:00 2001 From: Andrew Szucs Date: Thu, 18 Jan 2018 18:44:11 +0100 Subject: [PATCH 01/45] Refactor DinnerModel to ES6, Implement interface methods --- js/app.js | 4 +- js/model/dinnerModel.js | 608 ++++++++++++++++++++-------------------- 2 files changed, 308 insertions(+), 304 deletions(-) diff --git a/js/app.js b/js/app.js index 296b0bae2..e87dab2c5 100644 --- a/js/app.js +++ b/js/app.js @@ -1,9 +1,9 @@ $(function() { //We instantiate our model - var model = new DinnerModel(); + const model = createDinnerModel(); // And create the instance of ExampleView - var exampleView = new ExampleView($("#exampleView")); + const exampleView = new ExampleView($("#exampleView")); /** * IMPORTANT: app.js is the only place where you are allowed to diff --git a/js/model/dinnerModel.js b/js/model/dinnerModel.js index 47476a61b..a41c06452 100644 --- a/js/model/dinnerModel.js +++ b/js/model/dinnerModel.js @@ -1,330 +1,334 @@ //DinnerModel Object constructor -var DinnerModel = function() { - - //TODO Lab 1 implement the data structure that will hold number of guest - // and selected dishes for the dinner menu - - - this.setNumberOfGuests = function(num) { - //TODO Lab 1 - } +const createDinnerModel = () => { - this.getNumberOfGuests = function() { - //TODO Lab 1 + // the data structure that will hold number of guest + // and selected dishes for the dinner menu + const state = { + numberOfGuests: 1, + menu: [] } - //Returns the dish that is on the menu for selected type - this.getSelectedDish = function(type) { - //TODO Lab 1 + const setNumberOfGuests = num => { + state.numberOfGuests = num } - //Returns all the dishes on the menu. - this.getFullMenu = function() { - //TODO Lab 1 - } + const getNumberOfGuests = () => state.numberOfGuests + + // Returns the dish that is on the menu for selected type + const getSelectedDish = type => state.menu.find(dish => dish.type === type) - //Returns all ingredients for all the dishes on the menu. - this.getAllIngredients = function() { - //TODO Lab 1 - } + // Returns all the dishes on the menu. + const getFullMenu = () => state.menu - //Returns the total price of the menu (all the ingredients multiplied by number of guests). - this.getTotalMenuPrice = function() { - //TODO Lab 1 - } + // Returns all ingredients for all the dishes on the menu. + const getAllIngredients = () => state.menu.map(dish => dish.ingredients) - //Adds the passed dish to the menu. If the dish of that type already exists on the menu - //it is removed from the menu and the new one added. - this.addDishToMenu = function(id) { - //TODO Lab 1 + // Returns the total price of the menu (all the ingredients multiplied by number of guests). + const getTotalMenuPrice = () => getAllIngredients().reduce((acc, curr) => acc = acc + state.numberOfGuests * curr.price, 0) + + // Adds the passed dish to the menu. If the dish of that type already exists on the menu + // it is removed from the menu and the new one added. + const addDishToMenu = id => { + const selectedDish = getDish(id) + const restOfTheMenu = state.menu.filter(dish => dish.type !== selectedDish.type) + state.menu = restOfTheMenu.push(selectedDish) } - //Removes dish from menu - this.removeDishFromMenu = function(id) { - //TODO Lab 1 + // Removes dish from menu + const removeDishFromMenu = id => { + const newMenu = menu.filter(dish => dish.id !== id) + state.menu = newMenu + return newMenu } - //function that returns all dishes of specific type (i.e. "starter", "main dish" or "dessert") - //you can use the filter argument to filter out the dish by name or ingredient (use for search) - //if you don't pass any filter all the dishes will be returned - this.getAllDishes = function (type,filter) { - return dishes.filter(function(dish) { - var found = true; - if(filter){ - found = false; - dish.ingredients.forEach(function(ingredient) { - if(ingredient.name.indexOf(filter)!=-1) { - found = true; - } - }); - if(dish.name.indexOf(filter) != -1) - { - found = true; + // function that returns all dishes of specific type (i.e. "starter", "main dish" or "dessert") + // you can use the filter argument to filter out the dish by name or ingredient (use for search) + // if you don't pass any filter all the dishes will be returned + const getAllDishes = (type, filter) => { + + return dishes.filter(dish => { + + let typeMatch = dish.type === type + if(type === 'all') { + typeMatch = true + } + + let filterMatch = true + if(filter !== undefined) { + const nameMatch = dish.name.includes(filter) + const ingredientMatch = dish.ingredients.some(ingredient => ingredient.name.includes(filter)) + filterMatch = nameMatch || ingredientMatch } - } - return dish.type == type && found; - }); + + return typeMatch && filterMatch + }) } //function that returns a dish of specific ID - this.getDish = function (id) { - for(key in dishes){ - if(dishes[key].id == id) { - return dishes[key]; - } - } - } + const getDish = id => dishes.find(dish => dish.id === id) + return ({ + setNumberOfGuests, + getNumberOfGuests, + getSelectedDish, + getFullMenu, + getAllIngredients, + getTotalMenuPrice, + addDishToMenu, + removeDishFromMenu, + getAllDishes, + getDish + }) - // the dishes variable contains an array of all the - // dishes in the database. each dish has id, name, type, - // image (name of the image file), description and - // array of ingredients. Each ingredient has name, - // quantity (a number), price (a number) and unit (string - // defining the unit i.e. "g", "slices", "ml". Unit - // can sometimes be empty like in the example of eggs where - // you just say "5 eggs" and not "5 pieces of eggs" or anything else. - var dishes = [{ - 'id':1, - 'name':'French toast', - 'type':'starter', - 'image':'toast.jpg', - 'description':"In a large mixing bowl, beat the eggs. Add the milk, brown sugar and nutmeg; stir well to combine. Soak bread slices in the egg mixture until saturated. Heat a lightly oiled griddle or frying pan over medium high heat. Brown slices on both sides, sprinkle with cinnamon and serve hot.", - 'ingredients':[{ - 'name':'eggs', - 'quantity':0.5, - 'unit':'', - 'price':10 - },{ - 'name':'milk', - 'quantity':30, - 'unit':'ml', - 'price':6 - },{ - 'name':'brown sugar', - 'quantity':7, - 'unit':'g', - 'price':1 - },{ - 'name':'ground nutmeg', - 'quantity':0.5, - 'unit':'g', - 'price':12 - },{ - 'name':'white bread', - 'quantity':2, - 'unit':'slices', - 'price':2 - }] +} + +// the dishes variable contains an array of all the +// dishes in the database. each dish has id, name, type, +// image (name of the image file), description and +// array of ingredients. Each ingredient has name, +// quantity (a number), price (a number) and unit (string +// defining the unit i.e. "g", "slices", "ml". Unit +// can sometimes be empty like in the example of eggs where +// you just say "5 eggs" and not "5 pieces of eggs" or anything else. +const dishes = [{ + 'id':1, + 'name':'French toast', + 'type':'starter', + 'image':'toast.jpg', + 'description':"In a large mixing bowl, beat the eggs. Add the milk, brown sugar and nutmeg; stir well to combine. Soak bread slices in the egg mixture until saturated. Heat a lightly oiled griddle or frying pan over medium high heat. Brown slices on both sides, sprinkle with cinnamon and serve hot.", + 'ingredients':[{ + 'name':'eggs', + 'quantity':0.5, + 'unit':'', + 'price':10 },{ - 'id':2, - 'name':'Sourdough Starter', - 'type':'starter', - 'image':'sourdough.jpg', - 'description':"Here is how you make it... Lore ipsum...", - 'ingredients':[{ - 'name':'active dry yeast', - 'quantity':0.5, - 'unit':'g', - 'price':4 - },{ - 'name':'warm water', - 'quantity':30, - 'unit':'ml', - 'price':0 - },{ - 'name':'all-purpose flour', - 'quantity':15, - 'unit':'g', - 'price':2 - }] + 'name':'milk', + 'quantity':30, + 'unit':'ml', + 'price':6 },{ - 'id':3, - 'name':'Baked Brie with Peaches', - 'type':'starter', - 'image':'bakedbrie.jpg', - 'description':"Here is how you make it... Lore ipsum...", - 'ingredients':[{ - 'name':'round Brie cheese', - 'quantity':10, - 'unit':'g', - 'price':8 - },{ - 'name':'raspberry preserves', - 'quantity':15, - 'unit':'g', - 'price':10 - },{ - 'name':'peaches', - 'quantity':1, - 'unit':'', - 'price':4 - }] + 'name':'brown sugar', + 'quantity':7, + 'unit':'g', + 'price':1 },{ - 'id':100, - 'name':'Meat balls', - 'type':'main dish', - 'image':'meatballs.jpg', - 'description':"Preheat an oven to 400 degrees F (200 degrees C). Place the beef into a mixing bowl, and season with salt, onion, garlic salt, Italian seasoning, oregano, red pepper flakes, hot pepper sauce, and Worcestershire sauce; mix well. Add the milk, Parmesan cheese, and bread crumbs. Mix until evenly blended, then form into 1 1/2-inch meatballs, and place onto a baking sheet. Bake in the preheated oven until no longer pink in the center, 20 to 25 minutes.", - 'ingredients':[{ - 'name':'extra lean ground beef', - 'quantity':115, - 'unit':'g', - 'price':20 - },{ - 'name':'sea salt', - 'quantity':0.7, - 'unit':'g', - 'price':3 - },{ - 'name':'small onion, diced', - 'quantity':0.25, - 'unit':'', - 'price':2 - },{ - 'name':'garlic salt', - 'quantity':0.7, - 'unit':'g', - 'price':2 - },{ - 'name':'Italian seasoning', - 'quantity':0.6, - 'unit':'g', - 'price':3 - },{ - 'name':'dried oregano', - 'quantity':0.3, - 'unit':'g', - 'price':3 - },{ - 'name':'crushed red pepper flakes', - 'quantity':0.6, - 'unit':'g', - 'price':3 - },{ - 'name':'Worcestershire sauce', - 'quantity':6, - 'unit':'ml', - 'price':7 - },{ - 'name':'milk', - 'quantity':20, - 'unit':'ml', - 'price':4 - },{ - 'name':'grated Parmesan cheese', - 'quantity':5, - 'unit':'g', - 'price':8 - },{ - 'name':'seasoned bread crumbs', - 'quantity':15, - 'unit':'g', - 'price':4 - }] + 'name':'ground nutmeg', + 'quantity':0.5, + 'unit':'g', + 'price':12 },{ - 'id':101, - 'name':'MD 2', - 'type':'main dish', - 'image':'bakedbrie.jpg', - 'description':"Here is how you make it... Lore ipsum...", - 'ingredients':[{ - 'name':'ingredient 1', - 'quantity':1, - 'unit':'pieces', - 'price':8 - },{ - 'name':'ingredient 2', - 'quantity':15, - 'unit':'g', - 'price':7 - },{ - 'name':'ingredient 3', - 'quantity':10, - 'unit':'ml', - 'price':4 - }] + 'name':'white bread', + 'quantity':2, + 'unit':'slices', + 'price':2 + }] + },{ + 'id':2, + 'name':'Sourdough Starter', + 'type':'starter', + 'image':'sourdough.jpg', + 'description':"Here is how you make it... Lore ipsum...", + 'ingredients':[{ + 'name':'active dry yeast', + 'quantity':0.5, + 'unit':'g', + 'price':4 },{ - 'id':102, - 'name':'MD 3', - 'type':'main dish', - 'image':'meatballs.jpg', - 'description':"Here is how you make it... Lore ipsum...", - 'ingredients':[{ - 'name':'ingredient 1', - 'quantity':2, - 'unit':'pieces', - 'price':8 - },{ - 'name':'ingredient 2', - 'quantity':10, - 'unit':'g', - 'price':7 - },{ - 'name':'ingredient 3', - 'quantity':5, - 'unit':'ml', - 'price':4 - }] + 'name':'warm water', + 'quantity':30, + 'unit':'ml', + 'price':0 },{ - 'id':103, - 'name':'MD 4', - 'type':'main dish', - 'image':'meatballs.jpg', - 'description':"Here is how you make it... Lore ipsum...", - 'ingredients':[{ - 'name':'ingredient 1', - 'quantity':1, - 'unit':'pieces', - 'price':4 - },{ - 'name':'ingredient 2', - 'quantity':12, - 'unit':'g', - 'price':7 - },{ - 'name':'ingredient 3', - 'quantity':6, - 'unit':'ml', - 'price':4 - }] + 'name':'all-purpose flour', + 'quantity':15, + 'unit':'g', + 'price':2 + }] + },{ + 'id':3, + 'name':'Baked Brie with Peaches', + 'type':'starter', + 'image':'bakedbrie.jpg', + 'description':"Here is how you make it... Lore ipsum...", + 'ingredients':[{ + 'name':'round Brie cheese', + 'quantity':10, + 'unit':'g', + 'price':8 },{ - 'id':200, - 'name':'Chocolat Ice cream', - 'type':'dessert', - 'image':'icecream.jpg', - 'description':"Here is how you make it... Lore ipsum...", - 'ingredients':[{ - 'name':'ice cream', - 'quantity':100, - 'unit':'ml', - 'price':6 - }] + 'name':'raspberry preserves', + 'quantity':15, + 'unit':'g', + 'price':10 },{ - 'id':201, - 'name':'Vanilla Ice cream', - 'type':'dessert', - 'image':'icecream.jpg', - 'description':"Here is how you make it... Lore ipsum...", - 'ingredients':[{ - 'name':'ice cream', - 'quantity':100, - 'unit':'ml', - 'price':6 - }] + 'name':'peaches', + 'quantity':1, + 'unit':'', + 'price':4 + }] + },{ + 'id':100, + 'name':'Meat balls', + 'type':'main dish', + 'image':'meatballs.jpg', + 'description':"Preheat an oven to 400 degrees F (200 degrees C). Place the beef into a mixing bowl, and season with salt, onion, garlic salt, Italian seasoning, oregano, red pepper flakes, hot pepper sauce, and Worcestershire sauce; mix well. Add the milk, Parmesan cheese, and bread crumbs. Mix until evenly blended, then form into 1 1/2-inch meatballs, and place onto a baking sheet. Bake in the preheated oven until no longer pink in the center, 20 to 25 minutes.", + 'ingredients':[{ + 'name':'extra lean ground beef', + 'quantity':115, + 'unit':'g', + 'price':20 },{ - 'id':202, - 'name':'Strawberry', - 'type':'dessert', - 'image':'icecream.jpg', - 'description':"Here is how you make it... Lore ipsum...", - 'ingredients':[{ - 'name':'ice cream', - 'quantity':100, - 'unit':'ml', - 'price':6 - }] - } - ]; - -} + 'name':'sea salt', + 'quantity':0.7, + 'unit':'g', + 'price':3 + },{ + 'name':'small onion, diced', + 'quantity':0.25, + 'unit':'', + 'price':2 + },{ + 'name':'garlic salt', + 'quantity':0.7, + 'unit':'g', + 'price':2 + },{ + 'name':'Italian seasoning', + 'quantity':0.6, + 'unit':'g', + 'price':3 + },{ + 'name':'dried oregano', + 'quantity':0.3, + 'unit':'g', + 'price':3 + },{ + 'name':'crushed red pepper flakes', + 'quantity':0.6, + 'unit':'g', + 'price':3 + },{ + 'name':'Worcestershire sauce', + 'quantity':6, + 'unit':'ml', + 'price':7 + },{ + 'name':'milk', + 'quantity':20, + 'unit':'ml', + 'price':4 + },{ + 'name':'grated Parmesan cheese', + 'quantity':5, + 'unit':'g', + 'price':8 + },{ + 'name':'seasoned bread crumbs', + 'quantity':15, + 'unit':'g', + 'price':4 + }] + },{ + 'id':101, + 'name':'MD 2', + 'type':'main dish', + 'image':'bakedbrie.jpg', + 'description':"Here is how you make it... Lore ipsum...", + 'ingredients':[{ + 'name':'ingredient 1', + 'quantity':1, + 'unit':'pieces', + 'price':8 + },{ + 'name':'ingredient 2', + 'quantity':15, + 'unit':'g', + 'price':7 + },{ + 'name':'ingredient 3', + 'quantity':10, + 'unit':'ml', + 'price':4 + }] + },{ + 'id':102, + 'name':'MD 3', + 'type':'main dish', + 'image':'meatballs.jpg', + 'description':"Here is how you make it... Lore ipsum...", + 'ingredients':[{ + 'name':'ingredient 1', + 'quantity':2, + 'unit':'pieces', + 'price':8 + },{ + 'name':'ingredient 2', + 'quantity':10, + 'unit':'g', + 'price':7 + },{ + 'name':'ingredient 3', + 'quantity':5, + 'unit':'ml', + 'price':4 + }] + },{ + 'id':103, + 'name':'MD 4', + 'type':'main dish', + 'image':'meatballs.jpg', + 'description':"Here is how you make it... Lore ipsum...", + 'ingredients':[{ + 'name':'ingredient 1', + 'quantity':1, + 'unit':'pieces', + 'price':4 + },{ + 'name':'ingredient 2', + 'quantity':12, + 'unit':'g', + 'price':7 + },{ + 'name':'ingredient 3', + 'quantity':6, + 'unit':'ml', + 'price':4 + }] + },{ + 'id':200, + 'name':'Chocolat Ice cream', + 'type':'dessert', + 'image':'icecream.jpg', + 'description':"Here is how you make it... Lore ipsum...", + 'ingredients':[{ + 'name':'ice cream', + 'quantity':100, + 'unit':'ml', + 'price':6 + }] + },{ + 'id':201, + 'name':'Vanilla Ice cream', + 'type':'dessert', + 'image':'icecream.jpg', + 'description':"Here is how you make it... Lore ipsum...", + 'ingredients':[{ + 'name':'ice cream', + 'quantity':100, + 'unit':'ml', + 'price':6 + }] + },{ + 'id':202, + 'name':'Strawberry', + 'type':'dessert', + 'image':'icecream.jpg', + 'description':"Here is how you make it... Lore ipsum...", + 'ingredients':[{ + 'name':'ice cream', + 'quantity':100, + 'unit':'ml', + 'price':6 + }] + } +] \ No newline at end of file From 2ab6fbf39840738ec057c78d975797795d04aa1d Mon Sep 17 00:00:00 2001 From: Andrew Szucs Date: Thu, 18 Jan 2018 22:10:36 +0100 Subject: [PATCH 02/45] Create layout for first Home screen --- index.html | 50 ++++++++++++++++++++++++++++++++----------------- styles/main.css | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 styles/main.css diff --git a/index.html b/index.html index 79a6b773b..534540eb5 100644 --- a/index.html +++ b/index.html @@ -6,33 +6,49 @@ Dinner planner - - + + + -
-

Dinner planner

-
-
- Number of guests: -
-
- - -
+
+
+

Dinner Planner

+
+
+
+
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. +
+ +
+
-
- - - - + + + + + + + \ No newline at end of file diff --git a/styles/main.css b/styles/main.css new file mode 100644 index 000000000..d745cb04a --- /dev/null +++ b/styles/main.css @@ -0,0 +1,40 @@ +body { + margin: 0; +} + +.container { + display: grid; + grid-template-rows: 6rem auto; + text-align: center; + height: 100vh; +} + +header { + background-color: rgba(173, 173, 173, 1); + display: flex; + align-items: center; + justify-content: center; +} + +main { + display: flex; + align-items: center; + justify-content: center; +} + +main .content { + max-width: 50%; +} + +main .content .text { + margin-bottom: 3rem; +} + +main .startButton { + color: rgba(0, 0, 0, 1); + background-color: orange; + border: 0.1em solid black; + box-shadow: 0.1em 0.1em 0.1em black; + font-size: 1em; + padding: 0.5em; +} \ No newline at end of file From 947971e5ef623d41edda303c7994f7ab199c1a5d Mon Sep 17 00:00:00 2001 From: Andrew Szucs Date: Fri, 19 Jan 2018 14:01:33 +0100 Subject: [PATCH 03/45] Fixed a typo in a comment --- js/model/dinnerModel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/model/dinnerModel.js b/js/model/dinnerModel.js index a41c06452..7d7b93265 100644 --- a/js/model/dinnerModel.js +++ b/js/model/dinnerModel.js @@ -14,7 +14,7 @@ const createDinnerModel = () => { const getNumberOfGuests = () => state.numberOfGuests - // Returns the dish that is on the menu for selected type + // Returns the dish that is on the menu for the selected type const getSelectedDish = type => state.menu.find(dish => dish.type === type) // Returns all the dishes on the menu. From c2dd3c8a47b49a313261e5e6e84e857cba240632 Mon Sep 17 00:00:00 2001 From: Andrew Szucs Date: Fri, 19 Jan 2018 14:02:15 +0100 Subject: [PATCH 04/45] Add the desktop version of the dish search screen with the sidebar. --- select.html | 120 ++++++++++++++++++++++++++++++++++++++++++++++ styles/select.css | 76 +++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 select.html create mode 100644 styles/select.css diff --git a/select.html b/select.html new file mode 100644 index 000000000..f27c98546 --- /dev/null +++ b/select.html @@ -0,0 +1,120 @@ + + + + + + + Dinner planner + + + + + + + +
+
+

Dinner Planner

+
+
+ +
+
+
+ Add another one +
+
+ + + +
+
+
+
+
+
+ +
+
Baked Brie
+
+
+
+ +
+
Ice Cream
+
+
+
+ +
+
Meatballs
+
+
+
+ +
+
Sourdough
+
+
+
+ +
+
Toast
+
+
+
+
+
+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/styles/select.css b/styles/select.css new file mode 100644 index 000000000..ec4ce6d15 --- /dev/null +++ b/styles/select.css @@ -0,0 +1,76 @@ +body { + margin: 0; +} + +.container { + display: grid; + grid-template-rows: 6rem auto; + text-align: center; + height: 100vh; +} + +header { + background-color: rgba(173, 173, 173, 1); + display: flex; + align-items: center; + justify-content: center; +} + +main { + display: grid; + grid-template-columns: 12rem auto; +} + +.sidebar { + background-color: aquamarine; + display: grid; + grid-template-rows: fit-content(100%) fit-content(100%) auto; +} + +.guestSelector { + display: flex; + +} + +.menu { + display: grid; + grid-template-rows: fit-content(100%) fit-content(100%) fit-content(100%) fit-content(100%); +} + +.menuHeader, .dish { + display: flex; +} + +.menuHeader .dishCostHeader, .dish .dishCost { + margin-left: auto; +} + +.menuCost { + display: flex; + margin-left: auto; +} + +.content { + background-color: blanchedalmond; +} + +.dishResultsContainer { + margin: 0 auto; + width: 80%; +} + +.dishResults { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); +} + +.dishResult { + display: grid; + grid-template-rows: 140px auto; +} + +.dishResultImageContainer { + display: flex; + align-items: center; + justify-content: center; +} \ No newline at end of file From c5cf573e1acb138af42e853a3697f363a491235e Mon Sep 17 00:00:00 2001 From: Andrew Szucs Date: Fri, 19 Jan 2018 21:57:42 +0100 Subject: [PATCH 05/45] Add responsive sidebar to dish search screen --- index.html | 3 +- js/model/dinnerModel.js | 3 ++ js/toggleMenu.js | 20 +++++++++++ select.html | 54 ++++++++++++++++------------ styles/select.css | 79 +++++++++++++++++++++++++++++++++++++++-- 5 files changed, 133 insertions(+), 26 deletions(-) create mode 100644 js/toggleMenu.js diff --git a/index.html b/index.html index 534540eb5..a516875bb 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,8 @@ - + +
diff --git a/js/model/dinnerModel.js b/js/model/dinnerModel.js index 7d7b93265..8bf7009d2 100644 --- a/js/model/dinnerModel.js +++ b/js/model/dinnerModel.js @@ -23,6 +23,9 @@ const createDinnerModel = () => { // Returns all ingredients for all the dishes on the menu. const getAllIngredients = () => state.menu.map(dish => dish.ingredients) + // Return the full price of a given dish (represented by id) + const getPriceForDish = (id) => getDish(id).ingredients.reduce((acc, curr) => acc = acc + curr.price) + // Returns the total price of the menu (all the ingredients multiplied by number of guests). const getTotalMenuPrice = () => getAllIngredients().reduce((acc, curr) => acc = acc + state.numberOfGuests * curr.price, 0) diff --git a/js/toggleMenu.js b/js/toggleMenu.js new file mode 100644 index 000000000..57fe2eb5c --- /dev/null +++ b/js/toggleMenu.js @@ -0,0 +1,20 @@ +const toggleMenu = () => { + const sidebarContent = document.getElementById('sidebarContent') + const collapsedMenuCost = document.getElementById('collapsedMenuCost') + + const sidebarContentDisplay = window.getComputedStyle(sidebarContent).display + + if(sidebarContentDisplay === 'none') { + sidebarContent.classList.remove('hiddenOnMobile') + sidebarContent.classList.add('shownOnMobile') + collapsedMenuCost.classList.remove('shownOnMobile') + collapsedMenuCost.classList.add('hiddenOnMobile') + } + else { + sidebarContent.classList.remove('shownOnMobile') + sidebarContent.classList.add('hiddenOnMobile') + collapsedMenuCost.classList.remove('hiddenOnMobile') + collapsedMenuCost.classList.add('shownOnMobile') + } + +} \ No newline at end of file diff --git a/select.html b/select.html index f27c98546..fa219a8b1 100644 --- a/select.html +++ b/select.html @@ -17,39 +17,46 @@

Dinner Planner

-