├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt └── src ├── App.css ├── App.js ├── App.test.js ├── components ├── DisplayTodos.js ├── TodoItem.js └── Todos.js ├── css └── main.css ├── index.css ├── index.js ├── logo.svg └── redux ├── reducer.js └── store.js /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Build TODO App with Redux and React JS 2 | 3 | This repository contains code for Todo app with react-redux. 4 | 5 | View Demo: 6 | https://react-redux-todo-app-lac.vercel.app/ 7 | 8 | If you want to learn how to create it please follow below tutorial: 9 | 10 | https://youtu.be/YhgSuUkWlK4 11 | 12 | If you prefer the blog format then checkout this link👇:
13 | Checkout this blog on How to Build a Todo App with Redux and React JS
14 | 15 | 16 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 17 | 18 | ## Available Scripts 19 | 20 | In the project directory, you can run: 21 | 22 | ### `npm start` 23 | 24 | Runs the app in the development mode.\ 25 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 26 | 27 | The page will reload if you make edits.\ 28 | You will also see any lint errors in the console. 29 | 30 | ### `npm test` 31 | 32 | Launches the test runner in the interactive watch mode.\ 33 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 34 | 35 | ### `npm run build` 36 | 37 | Builds the app for production to the `build` folder.\ 38 | It correctly bundles React in production mode and optimizes the build for the best performance. 39 | 40 | The build is minified and the filenames include the hashes.\ 41 | Your app is ready to be deployed! 42 | 43 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 44 | 45 | ### `npm run eject` 46 | 47 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 48 | 49 | 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. 50 | 51 | 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. 52 | 53 | 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. 54 | 55 | ## Learn More 56 | 57 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 58 | 59 | To learn React, check out the [React documentation](https://reactjs.org/). 60 | 61 | ### Code Splitting 62 | 63 | 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) 64 | 65 | ### Analyzing the Bundle Size 66 | 67 | 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) 68 | 69 | ### Making a Progressive Web App 70 | 71 | 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) 72 | 73 | ### Advanced Configuration 74 | 75 | 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) 76 | 77 | ### Deployment 78 | 79 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 80 | 81 | ### `npm run build` fails to minify 82 | 83 | 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) 84 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "redux-todo", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@reduxjs/toolkit": "^1.9.1", 7 | "@testing-library/jest-dom": "^5.11.10", 8 | "@testing-library/react": "^11.2.6", 9 | "@testing-library/user-event": "^12.8.3", 10 | "framer-motion": "^4.1.3", 11 | "react": "^17.0.2", 12 | "react-dom": "^17.0.2", 13 | "react-icons": "^4.2.0", 14 | "react-redux": "^7.2.3", 15 | "react-scripts": "5.0.1", 16 | "redux": "^4.0.5", 17 | "web-vitals": "^1.1.1" 18 | }, 19 | "scripts": { 20 | "start": "react-scripts start", 21 | "build": "react-scripts build", 22 | "test": "react-scripts test", 23 | "eject": "react-scripts eject" 24 | }, 25 | "eslintConfig": { 26 | "extends": [ 27 | "react-app", 28 | "react-app/jest" 29 | ] 30 | }, 31 | "browserslist": { 32 | "production": [ 33 | ">0.2%", 34 | "not dead", 35 | "not op_mini all" 36 | ], 37 | "development": [ 38 | "last 1 chrome version", 39 | "last 1 firefox version", 40 | "last 1 safari version" 41 | ] 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebucks27/React-Redux-Todo-App/8bf5ce388c56a0e7999b0b2f19068d676a90c52d/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebucks27/React-Redux-Todo-App/8bf5ce388c56a0e7999b0b2f19068d676a90c52d/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebucks27/React-Redux-Todo-App/8bf5ce388c56a0e7999b0b2f19068d676a90c52d/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import "./css/main.css"; 2 | import DisplayTodos from "./components/DisplayTodos"; 3 | import Todos from "./components/Todos"; 4 | 5 | import { motion } from "framer-motion"; 6 | function App() { 7 | return ( 8 |
9 | 15 | Todo App 16 | 17 | 22 | 23 | 24 | 25 |
26 | ); 27 | } 28 | 29 | export default App; 30 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /src/components/DisplayTodos.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | import { connect } from "react-redux"; 3 | import { 4 | addTodos, 5 | completeTodos, 6 | removeTodos, 7 | updateTodos, 8 | } from "../redux/reducer"; 9 | import TodoItem from "./TodoItem"; 10 | import { AnimatePresence, motion } from "framer-motion"; 11 | 12 | const mapStateToProps = (state) => { 13 | return { 14 | todos: state, 15 | }; 16 | }; 17 | 18 | const mapDispatchToProps = (dispatch) => { 19 | return { 20 | addTodo: (obj) => dispatch(addTodos(obj)), 21 | removeTodo: (id) => dispatch(removeTodos(id)), 22 | updateTodo: (obj) => dispatch(updateTodos(obj)), 23 | completeTodo: (id) => dispatch(completeTodos(id)), 24 | }; 25 | }; 26 | 27 | const DisplayTodos = (props) => { 28 | const [sort, setSort] = useState("active"); 29 | return ( 30 |
31 |
32 | setSort("active")} 36 | > 37 | Active 38 | 39 | setSort("completed")} 43 | > 44 | Completed 45 | 46 | setSort("all")} 50 | > 51 | All 52 | 53 |
54 | 103 |
104 | ); 105 | }; 106 | 107 | export default connect(mapStateToProps, mapDispatchToProps)(DisplayTodos); 108 | -------------------------------------------------------------------------------- /src/components/TodoItem.js: -------------------------------------------------------------------------------- 1 | import { motion } from "framer-motion"; 2 | import React, { useRef } from "react"; 3 | import { AiFillEdit } from "react-icons/ai"; 4 | import { IoCheckmarkDoneSharp, IoClose } from "react-icons/io5"; 5 | 6 | const TodoItem = (props) => { 7 | const { item, updateTodo, removeTodo, completeTodo } = props; 8 | 9 | const inputRef = useRef(true); 10 | 11 | const changeFocus = () => { 12 | inputRef.current.disabled = false; 13 | inputRef.current.focus(); 14 | }; 15 | 16 | const update = (id, value, e) => { 17 | if (e.which === 13) { 18 | //here 13 is key code for enter key 19 | updateTodo({ id, item: value }); 20 | inputRef.current.disabled = true; 21 | } 22 | }; 23 | return ( 24 | 40 |