React-Todo
We're going to practice building a stateful class component with this project. Even though hooks are gaining popularity among react developers, class components are going to be around for a long time. It's imperative that you get use to class components, and feel comfortable working with class components since you'll most likely need to work with them if you are hired to work on a React app.
Introduction
- Your job is to write the components to complete the Todo List application.
- Your todo list should be fully functional and you should design it however you'd like. Feel free to get creative here. I have supplied a gif for you to see what the MVP functionality is.
- Your todo data should be an array of objects that look a lot like this:
[
{
task: 'Organize Garage',
id: 1528817077286,
completed: false
},
{
task: 'Bake Cookies',
id: 1528817084358,
completed: false
}
];
- The
task
field is the todo title that will be shown to the user. - The
completed
field should default tofalse
and will be the field that we toggle when we complete a todo. - The
id
field is a uniqueTime Stamp
that will be assigned byDate.now()
.
Instructions
Task 1: Project Set Up
- Create a forked copy of this project.
- Clone your OWN version of the repository in your terminal
- Create a new branch: git checkout -b
<firstName-lastName>
. - Implement the project on your newly created
<firstName-lastName>
branch, committing changes regularly. - Push commits: git push origin
<firstName-lastName>
.
Follow these steps for completing your project.
- Submit a Pull-Request to merge Branch into main (student's Repository). Please don't merge your own pull request
- From the home page of your repo, make sure you have your branch selected
- Copy the URL and paste it into Canvas
Task 2: MVP
- Don't focus on styling yet. We want you to worry about function over form today.
- Your todo list should display a list of todos, an input field, a submit button, and a clear all button.
- Be sure to use the given files for building out these components.
<App />
will hold all the data needed for this project. It will also be the container for your Todo Components.- All of your application data will be stored here on
<App />
. - All of your
handler
functions should live here on<App />
.
- All of your application data will be stored here on
<TodoList />
receives your Todos array and iterates over the list generating a new<Todo />
for each element in the array.<Todo />
is a component that takes in thetodo
data and displays the task to the screen.<TodoForm>
will hold your input field and yourAdd Todo
andClear Completed
buttons.- Your input field should take in user input, and allow a user to press
Enter
or click on theSubmit Button
to add a todo to your list. - Once a todo is submitted, the Todo List should re-render and show the added todo.
- Your input field should take in user input, and allow a user to press
- Add the functionality to toggle your todo's completed flag from
false
totrue
.- Once a todo is completed, be sure to demonstrate to the user that the todo is completed by adding a line-through style property if the completed flag is true.
- Add the ability to remove any todos that you have completed.
.filter
will be your best friend here. When a user clicks on theClear Completed
button call your handler function that will filter out any todos that have the completed flag toggled totrue
. - Now is the time to style Take your time to make this an app that you can be proud of.
Task 3: Stretch Problems
-
Persist your data in
window.localStorage()
hint: you may have to pass your data to a stringifier to get it to live inside thelocalStorage()
of the browser. This will cause it to persist past the page refresh. -
Search Functionality Add a input bar that allows you to search through your tasks and only show the ones that match the search input.
-
Hosting Create a Netlify Account and follow the tutorial on how to host your shiny new todo app on the world wide web.
Submission Format
- Submit a Pull-Request to merge
<firstName-lastName>
Branch intomain
(student's Repo). Please don't merge your own pull request - From the home page of your repo, make sure you have your branch selected
- Copy the URL and paste it into Canvas to submit your assignment