This repository is a template for you to follow the course Vue.js Fundamentals.
This Vue.js course Vue School will teach you and get you up and running with the basics concepts of Vue.js.
You can find this free course by Vue School at vueschool.io. The course is suitable for developers who do not yet know about Vue.js or are just getting started with Vue.
See also Annotated Reading of the Essentials Section of the Vue.js Guide
Follow the course and build the Shopping List web app.
- Leave your solution in the file index.html of the
mainbranch, initially empty. - There is a file main.css with the styles used during the course. Use it.
- The file solution.html contains the final solution. Check your progress against it.
- You can check how it has to look at the end here https://crguezl.github.io/vuejs-fundamentals/solution.html
Be sure to follow these steps:
- [ ] Write initial HTML with a shopping-list div
- [ ] Load and Instanciate Vue add data and Vue template syntax to interpolate
- [ ] Add an input an synchronize it with the interpolated text to see it
- [ ] Explore the app in the console
- [ ] Discuss the syntax of JS inside moustaches
- [ ] Learn to read the errors in the console
- [ ] Add items to data and show them using v-for
- [ ] Use Vue Devtools. Configure it to work with file://
- [ ] Add v-on: Start by simulating in the console what we are going to do
- [ ] Add button to add the new item when clicked
- [ ] Add v-on:keyup.enter to the input element
- [ ] Shorthands for v-on
- [ ] Use a method
saveItemto factorice - [ ] Reset the input when finished the insertion
- [ ] Check the method using the debugger
- [ ] v-if and v-else: add a conditional message when the list is empty
-
[ ] Add a
statevariable to the appdatato represent the states of the app.There will be two states: default and edition. The views on each state will be different
State edition corresponds to when the user is adding/editing a new item: there will be an input form to input the item, buttons to cancel the edition, to save the item, etc.
State default corresponds to when the user is the initial state. There will be a button to add a new item
Here is the DFA with the transitions:
-
[ ] Move the
inputandbuttonSave Item elements to adivwith classadd-item-formso that these styles apply.add-item-form, .header { display: flex; align-items: center; justify-content: space-between; } .add-item-form input { width: 70%; border-radius: 3px; box-shadow: 0 2px 4px 0 rgba(0,0,0,0.10); border: 1px solid #F1F5F8; color: #606F7B; padding: .5rem .75rem; box-sizing: border-box; font-size: 1rem; letter-spacing: .5px; margin: .5rem 0; }
-
[ ] Show the
divwith classadd-item-formonly if the state isedition -
[ ] To the div with class
headeradd a buttonAdd Itemthat will make the app transit from thedefaultstate to theeditionstate -
[ ] Show the
add buttononly if the state isdefault -
[ ] To the div with class
headeradd a buttonCancel Adding Itemwith the classbtn-cancelthat will make the app transit from theeditionstate to thedefaultstate -
[ ] Show the
Cancel Adding Itembutton only if the state isedition -
[ ] Add the
changeStatemethod that reflect the transitions between both states
-
Using the dev tools, check that when we click the
save itemwith theinputempty we are adding new empty strings to theitemslist -
Disable the button
save itemwhen theinputis empty by binding thedisabledattribute of the buttonThe
disabledattribute is a boolean attribute. A disabled button is unusable and un-clickable.The disabled attribute can be set to keep a user from clicking on the button until some other condition has been met (like selecting a checkbox, etc.)
-
[ ] Change the list of items from a list of Strings to a list of Objects with
labelandpurchasedattributes. Update thesaveItemmethod and the template accordingly -
[ ] Make use of the class
.strikeoutin the css file:.strikeout { text-decoration: line-through; color: #B8C2CC; } .strikeout:hover { color: #8795A1; }
to style the purchased items. See the Vue.js Guide section on Class and Style Bindings
- [ ] Use first the object syntax
v-bind:class="{myclass: expression}"and - [ ] later the array syntax
v-bind:class=[exp1, exp2]
- [ ] Use first the object syntax
- Introduction to two-way data binding
- Template syntax and expressions
- Vue directives, loops and conditional rendering
- Vue Devtools
- Handling user Inputs
- Handling Events
- Vue.js Methods
- Attribute Bindings and dynamic classes