Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sam-singer #274

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintcache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"D:\\lambda_redux_week2\\reducer-todo\\src\\index.js":"1","D:\\lambda_redux_week2\\reducer-todo\\src\\App.js":"2","D:\\lambda_redux_week2\\reducer-todo\\src\\reportWebVitals.js":"3","D:\\lambda_redux_week2\\reducer-todo\\src\\components\\TodoList.js":"4","D:\\lambda_redux_week2\\reducer-todo\\src\\components\\Todo.js":"5","D:\\lambda_redux_week2\\reducer-todo\\src\\actions\\index.js":"6","D:\\lambda_redux_week2\\reducer-todo\\src\\reducers\\index.js":"7","D:\\lambda_redux_week2\\reducer-todo\\src\\components\\TodoForm.js":"8"},{"size":730,"mtime":1611073138000,"results":"9","hashOfConfig":"10"},{"size":661,"mtime":1611116676000,"results":"11","hashOfConfig":"10"},{"size":362,"mtime":499162500000,"results":"12","hashOfConfig":"10"},{"size":416,"mtime":1611116096000,"results":"13","hashOfConfig":"10"},{"size":144,"mtime":1611118210000,"results":"14","hashOfConfig":"10"},{"size":232,"mtime":1611118076000,"results":"15","hashOfConfig":"10"},{"size":920,"mtime":1611117910000,"results":"16","hashOfConfig":"10"},{"size":664,"mtime":1611117282000,"results":"17","hashOfConfig":"10"},{"filePath":"18","messages":"19","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"20"},"jdhpy7",{"filePath":"21","messages":"22","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"20"},{"filePath":"23","messages":"24","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"20"},{"filePath":"25","messages":"26","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"20"},{"filePath":"27","messages":"28","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"20"},{"filePath":"29","messages":"30","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"20"},{"filePath":"31","messages":"32","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"33","usedDeprecatedRules":"20"},{"filePath":"34","messages":"35","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"20"},"D:\\lambda_redux_week2\\reducer-todo\\src\\index.js",[],["36","37"],"D:\\lambda_redux_week2\\reducer-todo\\src\\App.js",[],"D:\\lambda_redux_week2\\reducer-todo\\src\\reportWebVitals.js",[],"D:\\lambda_redux_week2\\reducer-todo\\src\\components\\TodoList.js",[],"D:\\lambda_redux_week2\\reducer-todo\\src\\components\\Todo.js",[],"D:\\lambda_redux_week2\\reducer-todo\\src\\actions\\index.js",[],"D:\\lambda_redux_week2\\reducer-todo\\src\\reducers\\index.js",["38","39"],"export const initialState = {\r\n todos: [{\r\n title: \"todo 1\",\r\n id: 0,\r\n completed: false\r\n },{\r\n title: \"todo 2\",\r\n id: 0,\r\n completed: false\r\n },{\r\n title: \"todo 3\",\r\n id: 0,\r\n completed: false\r\n },\r\n ]\r\n}\r\n \r\n\r\nexport const reducer = (state, action) => {\r\n switch(action.type) {\r\n case(\"ADD_TODO\"):\r\n const newTodo = {\r\n id: state.todos.length,\r\n complete: false,\r\n title:action.payload\r\n }\r\n return({...state, todos:[...state.todos, ]})\r\n default :\r\n return state\r\n }\r\n \r\n}","D:\\lambda_redux_week2\\reducer-todo\\src\\components\\TodoForm.js",[],{"ruleId":"40","replacedBy":"41"},{"ruleId":"42","replacedBy":"43"},{"ruleId":"44","severity":1,"message":"45","line":19,"column":7,"nodeType":"46","messageId":"47","endLine":19,"endColumn":14},{"ruleId":"44","severity":1,"message":"48","line":22,"column":15,"nodeType":"46","messageId":"47","endLine":22,"endColumn":22},"no-native-reassign",["49"],"no-negated-in-lhs",["50"],"no-unused-vars","'reducer' is assigned a value but never used.","Identifier","unusedVar","'newTodo' is assigned a value but never used.","no-global-assign","no-unsafe-negation"]
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,26 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
102 changes: 43 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,86 +1,70 @@
# Module Project: The Reducer Pattern - Reducer Todo
# Getting Started with Create React App

This project allows you to practice the concepts and techniques learned in this module and apply them in a concrete project. This module explored the reducer pattern. During the module, you studied what immutability is, what reducers, actions and dispatch are, and how to use the reducer hook. In your project you will demonstrate proficiency of these subjects and principles by creating an application using each of these.
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

### Commits
## Available Scripts

Commit your code regularly and meaningfully. This helps both you and your team lead in case you ever need to return to old code for any number of reasons.
In the project directory, you can run:

## Introduction
### `npm start`

In this project, you build an app that let's you display a todo list from reducer state, and update todo items as completed and clear completed todos from the list by dispatching different actions.
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

## Instructions
The page will reload if you make edits.\
You will also see any lint errors in the console.

### Task 1: Project Set Up
### `npm test`

- [ ] Create a forked copy of this project.
- [ ] Clone your OWN version of the repository in your terminal.
- [ ] CD into the project base directory `cd reducer-todo`.
- [ ] Create a new react app running `npx create-react-app todo --use-npm`.
- [ ] CD into the react app directory `cd todo`.
- [ ] Start up the app using `npm start`.
- [ ] 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>`.
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### Task 2a: Minimum Viable Product
### `npm run build`

1. Set an initial state value through a reducer and render a list of todos from that state
2. Add a form that dispatches an "ADD_TODO" action to be able to add a todo item to your list
3. Build a function that let's you mark todo items as completed when you click on them
4. Build a function that let's you clear completed todos when you click on a "Clear Completed" button
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

#### Build a simple reducer and initial state
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

- In a folder called `reducers` add a reducer file and build out a simple reducer with just a default return for now
- In the same file, build your initial state object that has a list of todos with the following shape:
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

```js
{
item: 'Learn about reducers',
completed: false,
id: 3892987589
}
```
### `npm run eject`

- Export both the reducer and the initial state object
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

#### Set up state in your component
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

You get to choose how you want to set up your components. Please don't just do this all inside App. I know it is a small and simple project, but you will do yourself a great service by setting your app up as if it were going to be a larger application
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

- Using the `reducer` hook, set up state in your component. Think about what you'll need in order to use the reducer hook, and think about what it returns.
- Now render your list of todos from your reducer in your app
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

#### Adding todos
## Learn More

- Build a form to add todos to your list
- Build a function that will dispatch an action to add a new todo
- Write the `case` in your reducer for adding a todo (You can create a unique id with `new Date()`)
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

#### Toggle the completed field
To learn React, check out the [React documentation](https://reactjs.org/).

- Build a function that will dispatch an action to toggle a todo's completed field
- Invoke this new function when you click on a todo
- Style your todo to somehow show that it is completed (be creative here!)
- Write the `case` in your reducer for toggling the completed property
### Code Splitting

#### Clearing completed todos
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

- Build a function that will dispatch an action to filter out any completed todos
- Invoke this new function when you click on a "Clear completed" button
- Write the `case` in your reducer for filtering completed todos
### Analyzing the Bundle Size

### Task 3: Stretch Problems
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

After finishing your required elements, you can push your work further. These goals may or may not be things you have learned in this module but they build on the material you just studied. Time allowing, stretch your limits and see if you can deliver on the following optional goals:
### Making a Progressive Web App

- Add the moment library to show in "human speak" when a todo was completed
- Add a property on the todos for when a todo should be completed by. Then display that a todo is "overdue" if it has not been completed by its due date
- Add "tags" to your todos, and display them with your todo list
- Have fun with the styling. Make this something you'd be proud to show off!
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

## Submission Format
* [ ] Submit a Pull-Request to merge `<firstName-lastName>` Branch into `main` (student's Repo). **Please don't merge your own pull request**
* [ ] Submit the link to your branch to Canvas
### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
86 changes: 86 additions & 0 deletions README.old.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Module Project: The Reducer Pattern - Reducer Todo

This project allows you to practice the concepts and techniques learned in this module and apply them in a concrete project. This module explored the reducer pattern. During the module, you studied what immutability is, what reducers, actions and dispatch are, and how to use the reducer hook. In your project you will demonstrate proficiency of these subjects and principles by creating an application using each of these.

### Commits

Commit your code regularly and meaningfully. This helps both you and your team lead in case you ever need to return to old code for any number of reasons.

## Introduction

In this project, you build an app that let's you display a todo list from reducer state, and update todo items as completed and clear completed todos from the list by dispatching different actions.

## Instructions

### Task 1: Project Set Up

- [ ] Create a forked copy of this project.
- [ ] Clone your OWN version of the repository in your terminal.
- [ ] CD into the project base directory `cd reducer-todo`.
- [ ] Create a new react app running `npx create-react-app todo --use-npm`.
- [ ] CD into the react app directory `cd todo`.
- [ ] Start up the app using `npm start`.
- [ ] 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>`.

### Task 2a: Minimum Viable Product

1. Set an initial state value through a reducer and render a list of todos from that state
2. Add a form that dispatches an "ADD_TODO" action to be able to add a todo item to your list
3. Build a function that let's you mark todo items as completed when you click on them
4. Build a function that let's you clear completed todos when you click on a "Clear Completed" button

#### Build a simple reducer and initial state

- In a folder called `reducers` add a reducer file and build out a simple reducer with just a default return for now
- In the same file, build your initial state object that has a list of todos with the following shape:

```js
{
item: 'Learn about reducers',
completed: false,
id: 3892987589
}
```

- Export both the reducer and the initial state object

#### Set up state in your component

You get to choose how you want to set up your components. Please don't just do this all inside App. I know it is a small and simple project, but you will do yourself a great service by setting your app up as if it were going to be a larger application

- Using the `reducer` hook, set up state in your component. Think about what you'll need in order to use the reducer hook, and think about what it returns.
- Now render your list of todos from your reducer in your app

#### Adding todos

- Build a form to add todos to your list
- Build a function that will dispatch an action to add a new todo
- Write the `case` in your reducer for adding a todo (You can create a unique id with `new Date()`)

#### Toggle the completed field

- Build a function that will dispatch an action to toggle a todo's completed field
- Invoke this new function when you click on a todo
- Style your todo to somehow show that it is completed (be creative here!)
- Write the `case` in your reducer for toggling the completed property

#### Clearing completed todos

- Build a function that will dispatch an action to filter out any completed todos
- Invoke this new function when you click on a "Clear completed" button
- Write the `case` in your reducer for filtering completed todos

### Task 3: Stretch Problems

After finishing your required elements, you can push your work further. These goals may or may not be things you have learned in this module but they build on the material you just studied. Time allowing, stretch your limits and see if you can deliver on the following optional goals:

- Add the moment library to show in "human speak" when a todo was completed
- Add a property on the todos for when a todo should be completed by. Then display that a todo is "overdue" if it has not been completed by its due date
- Add "tags" to your todos, and display them with your todo list
- Have fun with the styling. Make this something you'd be proud to show off!

## Submission Format
* [ ] Submit a Pull-Request to merge `<firstName-lastName>` Branch into `main` (student's Repo). **Please don't merge your own pull request**
* [ ] Submit the link to your branch to Canvas
Loading