Please read the instructions carefully and submit your project files to in the directory Unit4/Unit4-Project
.
Be creative when completing this project and add your own style. However, remember to stay focused on the main bullet points.
-
Create an
html
,css
, andjs
file linking them together. -
Add an input field for users to add a todo item.
-
Create an empty list element in the
<body>
. -
Create an event listener on the input field. On
ENTER
, it should append an item to the list with the user's text. -
For each item created in the list:
- Add a checkbox to mark the item as complete. If checked, apply the
strikethroughstyle to the item's text. - Add a button that will delete the item from the list.
- Add a checkbox to mark the item as complete. If checked, apply the
-
Create an empty state view for the list if there are no items in the list.
- Just an element with some text saying something like "Add your first todo" is fine. Here is an example:
-
Make sure everything works. Add, delete, and check an item.
We are going to use a local mock server to save and persist your data.
NOTE: To clear the database of items, reset the db.json
file to look like this:
{ "item": [] }
-
First lets design the data structure for our ToDo items. This will be an object that will hold properties to describe each item.
- When we are ready to create these items, they will populate the array property
item
as described above.
{ "id": 1, "text": "Finish the Unit 4 Project", "completed": false }
- When we are ready to create these items, they will populate the array property
-
Lets run our mock server:
- Open terminal
- Navigate to the project folder:
cd Unit4/Unit4-Project
- Start the mock server script:
./start_mock_server.sh
- The server will run at the endpoint:
http://localhost:3000
- Navigate to
http://localhost:3000/item
in your browser to see the empty list of our ToDo items.
-
Update your
js
file to fetch all the items from the API once the document is ready.- Fetch the data using a
GET
request to/item
- Read the response from the request and render the todo items with the corresponding
id
so that we can uniquely reference this item later on.
- Fetch the data using a
-
When adding an item, submit a
POST
request to/item
withtext={user input}
andcompleted=false
- Be sure to read the response data and grab the item
id
- Be sure to read the response data and grab the item
-
When clicking the checkbox, submit a
PATCH
request to/item/{item id}
withcompleted={value of the checkbox}
-
When deleting an item, submit a
DELETE
request to/item/{item id}
-
Make sure the data is correctly persisted when you reload the page.
-
When finished, be sure to stop the server script.
-
As usual, create a new branch and then new Pull Request and assign it to your coach for review.