Skip to content

Commit

Permalink
fix bug and add formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
NayanUnni95 committed Mar 14, 2024
1 parent 4a42604 commit 3e34141
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 41 deletions.
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"useTabs": false
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# React ToDo
# React ToDo
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"prettier": "^3.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
8 changes: 4 additions & 4 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import ToDoMain from "./components/ToDoMain";
import React from 'react'
import ToDoMain from './components/ToDoMain'

function App() {
return (
<>
<ToDoMain />
</>
);
)
}

export default App;
export default App
16 changes: 15 additions & 1 deletion src/components/ToDoMain.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
.container .wrapper {
width: 80%;
height: 80%;
background-color: aquamarine;
/* background-color: aquamarine; */
}
.container .wrapper .header {
width: 100%;
height: 25%;
background-color: rgb(65, 197, 214);
border-radius: 1rem 1rem 0 0;
}
.container .wrapper .header h1 {
margin-top: 1rem;
Expand All @@ -50,10 +51,16 @@
.container .wrapper .header .input-div input[type='text'] {
width: 40rem;
padding-left: 1rem;
cursor: pointer;
transition: background-color 0.2s ease-out;
}
.container .wrapper .header .input-div input[type='text']:hover {
background-color: rgb(226, 226, 226);
}
.container .wrapper .header .input-div button {
width: 4rem;
transition: background-color 0.3s ease-out;
cursor: pointer;
}
.container .wrapper .header .input-div button:hover {
background-color: rgb(47, 241, 47);
Expand All @@ -63,6 +70,11 @@
height: 75%;
padding: 1rem;
background-color: rgb(107, 224, 170);
overflow: scroll;
border-radius: 0 0 1rem 1rem;
}
.container .wrapper .footer::-webkit-scrollbar {
display: none;
}
.container .wrapper .footer .content {
width: 96%;
Expand All @@ -86,13 +98,15 @@
border: none;
height: 2.5rem;
transition: background-color 0.5s ease-out;
cursor: pointer;
}
.container .wrapper .footer .content button:hover {
background-color: red;
}
.container .wrapper .footer .content input {
width: 1rem;
height: 1rem;
cursor: pointer;
}
@media (max-width: 1024px) {
.container .wrapper .footer .content .content-data {
Expand Down
64 changes: 35 additions & 29 deletions src/components/ToDoMain.jsx
Original file line number Diff line number Diff line change
@@ -1,74 +1,80 @@
import './ToDoMain.css';
import { useState } from 'react';
import './ToDoMain.css'
import { useState } from 'react'

function ToDoMain() {
const [toDo, setToDo] = useState([]);
const [data, setData] = useState('');
const [toDo, setToDo] = useState([])
const [data, setData] = useState('')
return (
<>
<div className='container flex flex-align flex-content'>
<div className='wrapper flex flex-align flex-content flex-wrap'>
<div className='header flex flex-align flex-content flex-dir'>
<div className="container flex flex-align flex-content">
<div className="wrapper flex flex-align flex-content flex-wrap">
<div className="header flex flex-align flex-content flex-dir">
<h1>React ToDo List...</h1>
<div className='input-div flex'>
<div className="input-div flex">
<input
type='text'
type="text"
onChange={(e) => {
setData(e.target.value);
setData(e.target.value)
}}
placeholder='Enter description'
placeholder="Enter description"
/>
<button
onClick={() => {
setToDo([
...toDo,
{ des: data, id: Date.now(), check: false },
]);
}}>
<i className='fa-solid fa-plus fa-xl'></i>
{
des: data,
id: Date.now(),
check: false,
},
])
}}
>
<i className="fa-solid fa-plus fa-xl"></i>
</button>
</div>
</div>
<div className='footer'>
<div className="footer">
{toDo.map((obj, index) => {
return (
<div key={index} className='content flex flex-align'>
<div key={index} className="content flex flex-align">
<input
onClick={(e) => {
setToDo(
toDo.filter((index) => {
if (obj.id === index.id) {
index.status = e.target.checked;
index.status = e.target.checked
}
return index;
return index
})
);
)
}}
type='checkbox'
type="checkbox"
/>
<div className='content-data flex flex-align flex-content'>
<div className="content-data flex flex-align flex-content">
<h4>{obj.des}</h4>
</div>
<button
onClick={() => {
setToDo(
toDo.filter((index) => {
if (obj.id != index.id) {
return index;
return index
}
})
);
}}>
<i className='fa-solid fa-trash fa-xl'></i>
)
}}
>
<i className="fa-solid fa-trash fa-xl"></i>
</button>
</div>
);
)
})}
</div>
</div>
</div>
</>
);
)
}

export default ToDoMain;
export default ToDoMain
10 changes: 5 additions & 5 deletions src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App'

ReactDOM.createRoot(document.getElementById("root")).render(
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>
);
)

0 comments on commit 3e34141

Please sign in to comment.