Skip to content

Commit

Permalink
add clear function
Browse files Browse the repository at this point in the history
  • Loading branch information
NayanUnni95 committed Mar 17, 2024
1 parent 3e34141 commit 9a6cb79
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ module.exports = {
{ allowConstantExport: true },
],
},
}
};
13 changes: 10 additions & 3 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"semi": true,
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"useTabs": false
"printWidth": 80,
"tabWidth": 2,
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "always",
"requirePragma": false,
"insertPragma": false,
"proseWrap": "preserve",
"endOfLine": "lf"
}
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;
6 changes: 6 additions & 0 deletions src/components/ToDoMain.css
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,10 @@
.container .wrapper .footer .content button {
width: 2rem;
}
.container .wrapper .header {
border-radius: 0;
}
.container .wrapper .footer {
border-radius: 0;
}
}
33 changes: 19 additions & 14 deletions src/components/ToDoMain.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
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('');
const clearInput = () => {
setData('');
};
return (
<>
<div className="container flex flex-align flex-content">
Expand All @@ -14,9 +17,10 @@ function ToDoMain() {
<input
type="text"
onChange={(e) => {
setData(e.target.value)
setData(e.target.value);
}}
placeholder="Enter description"
value={data}
/>
<button
onClick={() => {
Expand All @@ -27,7 +31,8 @@ function ToDoMain() {
id: Date.now(),
check: false,
},
])
]),
clearInput();
}}
>
<i className="fa-solid fa-plus fa-xl"></i>
Expand All @@ -43,11 +48,11 @@ function ToDoMain() {
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"
/>
Expand All @@ -59,22 +64,22 @@ function ToDoMain() {
setToDo(
toDo.filter((index) => {
if (obj.id != index.id) {
return index
return index;
}
})
)
);
}}
>
<i className="fa-solid fa-trash fa-xl"></i>
</button>
</div>
)
);
})}
</div>
</div>
</div>
</>
)
);
}

export default ToDoMain
export default ToDoMain;
8 changes: 4 additions & 4 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(
<React.StrictMode>
<App />
</React.StrictMode>
)
);
6 changes: 3 additions & 3 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
});

0 comments on commit 9a6cb79

Please sign in to comment.