├── .gitattributes
├── public
├── favicon.ico
└── index.html
├── .gitignore
├── src
├── components
│ ├── TodoList.js
│ └── TodoInput.js
├── index.js
├── App.js
└── App.css
├── README.md
└── package.json
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sachinsaini4278/React-Todo-App/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/src/components/TodoList.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 |
3 | function Todolist(props) {
4 | return (
5 |
6 | {props.item}
7 |
8 | {
10 | props.deleteItem(props.index)
11 | }}>
12 |
13 |
14 | )
15 | }
16 |
17 | export default Todolist
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom/client';
3 | import App from './App';
4 |
5 | const root = ReactDOM.createRoot(document.getElementById('root'));
6 | root.render(
7 |
8 |
9 |
10 | );
11 |
12 | // If you want to start measuring performance in your app, pass a function
13 | // to log results (for example: reportWebVitals(console.log))
14 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React-Todo-App
2 | Todo list app project using react hooks
3 | Here is the screenshot of the project.
4 |
5 |
6 |
7 | Functionalities:
8 |
9 | - Add Todo by clicking add button
10 | - Add Todo by pressing Enter key
11 | - Delete Todo
12 |
13 | Video tutorial for the same in Hindi
14 | Video Tutorial
15 |
--------------------------------------------------------------------------------
/src/components/TodoInput.js:
--------------------------------------------------------------------------------
1 | import React,{useState} from "react";
2 |
3 | function TodoInput(props) {
4 | const [inputText,setInputText] = useState('');
5 | const handleEnterPress = (e)=>{
6 | if(e.keyCode===13){
7 | props.addList(inputText)
8 | setInputText("")
9 | }
10 | }
11 | return (
12 |
13 | {
19 | setInputText(e.target.value)
20 | }}
21 | onKeyDown={handleEnterPress}
22 | />
23 |
28 |
29 | );
30 | }
31 |
32 | export default TodoInput;
33 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "todoapp",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.16.5",
7 | "@testing-library/react": "^13.4.0",
8 | "@testing-library/user-event": "^13.5.0",
9 | "react": "^18.2.0",
10 | "react-dom": "^18.2.0",
11 | "react-scripts": "5.0.1",
12 | "web-vitals": "^2.1.4"
13 | },
14 | "scripts": {
15 | "start": "react-scripts start",
16 | "build": "react-scripts build",
17 | "test": "react-scripts test",
18 | "eject": "react-scripts eject"
19 | },
20 | "eslintConfig": {
21 | "extends": [
22 | "react-app",
23 | "react-app/jest"
24 | ]
25 | },
26 | "browserslist": {
27 | "production": [
28 | ">0.2%",
29 | "not dead",
30 | "not op_mini all"
31 | ],
32 | "development": [
33 | "last 1 chrome version",
34 | "last 1 firefox version",
35 | "last 1 safari version"
36 | ]
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react'
2 | import "./App.css"
3 | import TodoInput from './components/TodoInput'
4 | import Todolist from './components/TodoList';
5 | function App() {
6 | const [listTodo,setListTodo]=useState([]);
7 | let addList = (inputText)=>{
8 | if(inputText!=='')
9 | setListTodo([...listTodo,inputText]);
10 | }
11 | const deleteListItem = (key)=>{
12 | let newListTodo = [...listTodo];
13 | newListTodo.splice(key,1)
14 | setListTodo([...newListTodo])
15 | }
16 | return (
17 |
18 |
19 |
20 | TODO
21 |
22 | {listTodo.map((listItem,i)=>{
23 | return (
24 |
25 | )
26 | })}
27 |
28 |
29 | )
30 | }
31 |
32 | export default App
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | *{
2 | margin: 0;
3 | padding: 0;
4 | }
5 | body{
6 | background-color: #333;
7 | }
8 | .main-container{
9 | display: flex;
10 | justify-content: center;
11 | align-items: center;
12 | height: 100vh;
13 | }
14 | .center-container{
15 | height: 500px;
16 | width: 350px;
17 | }
18 | .app-heading{
19 | padding: 4px;
20 | color: white;
21 | /* text-align: center; */
22 | font-family:Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
23 | text-transform: uppercase;
24 | }
25 | .input-container{
26 | display: flex;
27 | justify-content: center;
28 | margin-bottom: 10px;
29 | }
30 | .input-box-todo{
31 | margin-left: 10px;
32 | width: 70%;
33 | height: 40px;
34 | border-radius: 14px;
35 | border:1px solid black;
36 | padding-left: 10px;
37 | box-shadow: 0px 10px 20px rgba(0,0,0,0.3);
38 | outline: none;
39 | font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
40 | font-size: large;
41 | }
42 | .add-btn{
43 | width:40px;
44 | height:40px;
45 | border-radius: 50%;
46 | border:none;
47 | background-color:#316fc1;
48 | color: white;
49 | font-weight: bolder;
50 | font-size: larger;
51 | margin-left: 10px;
52 | cursor: pointer;
53 | box-shadow: 0px 5px 10px rgba(11, 10, 10, 0.3);
54 | transition: 0.3s;
55 | }
56 | .add-btn:active{
57 | box-shadow: none;
58 | }
59 | .list-container{
60 | display: flex;
61 | align-items: center;
62 | margin-top: 5px;
63 | }
64 | .list-item{
65 | list-style-type: none;
66 | /* background-color: #596e8b; */
67 | border:2px solid rgb(161, 158, 158);
68 | color:white;
69 | padding:3px;
70 | padding-left: 5px;
71 | border-radius: 5px;
72 | width: 100%;
73 | height: 30px;
74 | display: flex;
75 | align-items: center;
76 | position: relative;
77 | margin-top: 10px;
78 | }
79 | .icons{
80 | position: absolute;
81 | right: 10px;
82 | }
83 | .icons i{
84 | margin: 4px;
85 | font-size: large;
86 | cursor: pointer;
87 | transition: 0.1s;
88 | }
89 | .icons i:hover{
90 | transform: scale(1.2);
91 | }
92 | .icon-delete:hover{
93 | color: red;
94 | }
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
19 |
28 | React App
29 |
30 |
31 |
32 |
33 |
43 |
44 |
45 |
--------------------------------------------------------------------------------