在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:ironhack-labs/lab-jquery-pizza-builder开源软件地址:https://github.com/ironhack-labs/lab-jquery-pizza-builder开源编程语言:CSS 69.3%开源软件介绍:JS | Pizza BuilderIntroductionWe've got the munchies for a nice, fresh pie of pizza. Of course, we want to order online. After all, talking to a person will only delay the consumption of pizza. There's only one problem: our local pizzeria's pizza builder isn't working. This time, the local pizzeria is in luck because their customer today is a Web developer. We always hear about how developers should give back to their community. I can't think of a more meaningful contribution than helping the community get pizza more easily. Requirements
Submission
DeliverablesYou should push every file needed to execute the exercise InstructionsWe will work with the Iteration 1: Add and remove toppingsThere are five buttons on the left of the pizza builder. Three of those have to add or remove toppings from the pizza. Write the JavaScript necessary for those three buttons to add and remove pepperonni, mushrooms and green peppers from the pizza. Don't worry about updating the price. We will do it later. Each individual topping has its own HTML element: <section class="green-pepper one"></section>
<section class="green-pepper two"></section> <section class="mushroom one">
<div class="cap">1</div>
<div class="stem"></div>
</section> <section class="pep one">1</section>
<section class="pep two">2</section> Create the code to display those elements when the buttons are clicked. Iteration 2: Sauce and crust optionsWait a minute... this pizza comes with white sauce and gluten-free crust by default! Since that is a ridiculous default setting, we need to fix this as fast as possible. The last two buttons on the left are supposed to handle special options for the sauce and crust of your pizza. Make it so regular sauce and crust are selected by default. Also write the JavaScript code that will let users select white sauce and gluten free crust if they want to choose them. Again, don't worry about updating the price. Both the crust and the sauce have their own HTML elements: <section class="crust crust-gluten-free">
<section class="cheese"></section>
<section class="sauce sauce-white"></section>
</section> As you can see, the sections have two classes Iteration 3: Change the buttons' stateCurrently our pizza builder's buttons look the same, no matter if the option is activateed or not. If you notice, all the buttons have an <button class="btn btn-pepperonni active">Pepperonni</button> Write some JavaScript that will remove and add the buttons' Also make sure that the buttons' initial state matches that of their ingredient. If when you first load the pizza builder there is no pepperonni, the pepperonni button should not be active. Iteration 4: Ingredients and pricesOn the right side of the pizza builder there is a price section. It should show the ingredients we have in the pizza, not all of them. By default, it should show the base price $10, and the price for the pepperonni, mushrooms, and green pepper. <ul>
<li>$1 pepperonni</li>
<li>$1 mushrooms</li>
<li>$1 green peppers</li>
<li>$3 white sauce</li>
<li>$5 gluten-free crust</li>
</ul> Use JavaScript to hide and show the items by default. For now, forget the total price of the pizza. When an ingredient is added or removed, update the list to show/hide the ingredient in the list. By default, the selected ingredients should be pepperonni, mushrooms, and green peppers. Once we remove the pepperonni and we add the white sauce, the list should show:
Don't worry about the total price right now. Hint: How could we select the current ingredients? Remember we have a jQuery Selector that allows us to check if an HTML Node contains a certain string :) Iteration 5: Update priceTo finish this exercise, we should show the correct total price of our pizza. It should show the current price of your pizza, but it's always stuck on $21, which is the price if all the ingredients were on: <aside class="panel price"> <strong>$21</strong> Write the JavaScript that update the current price of the pizza as a user clicks the ingredient buttons to turn ingredients on and off. How can you keep track of the current price? When an ingredient changes, how will you know how much to add or substract? |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论