From 405a60a7c621ac78e86d85473c3c0c677266218c Mon Sep 17 00:00:00 2001 From: Mustafa88A Date: Sun, 17 Mar 2024 09:01:10 +0300 Subject: [PATCH 1/3] done with sryle --- package-lock.json | 6 +++ package.json | 1 + public/index.html | 6 +++ src/App.css | 91 +++++++++++++++++++++++++++++++------ src/App.js | 5 ++ src/components/ToDoList.jsx | 54 ++++++++++++++++++++++ src/components/TodoItem.jsx | 55 ++++++++++++++++++++++ src/components/stayl.css | 0 src/index.css | 6 +-- 9 files changed, 206 insertions(+), 18 deletions(-) create mode 100644 src/components/ToDoList.jsx create mode 100644 src/components/TodoItem.jsx create mode 100644 src/components/stayl.css diff --git a/package-lock.json b/package-lock.json index e6a160a..6dc47ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "5.0.1", + "uuid4": "^2.0.3", "web-vitals": "^2.1.4" } }, @@ -17332,6 +17333,11 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/uuid4": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/uuid4/-/uuid4-2.0.3.tgz", + "integrity": "sha512-CTpAkEVXMNJl2ojgtpLXHgz23dh8z81u6/HEPiQFOvBc/c2pde6TVHmH4uwY0d/GLF3tb7+VDAj4+2eJaQSdZQ==" + }, "node_modules/v8-to-istanbul": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-8.1.1.tgz", diff --git a/package.json b/package.json index 88a269e..c84620f 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "5.0.1", + "uuid4": "^2.0.3", "web-vitals": "^2.1.4" }, "scripts": { diff --git a/public/index.html b/public/index.html index aa069f2..e0a6bfd 100644 --- a/public/index.html +++ b/public/index.html @@ -15,6 +15,12 @@ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ --> + + + + React App diff --git a/src/App.css b/src/App.css index 7149fe9..d65f2ff 100644 --- a/src/App.css +++ b/src/App.css @@ -96,15 +96,71 @@ button:active { column-gap: 30px; margin-left: 30px; } - +.items p { + width: 65%; + overflow-wrap: break-word; + text-align: start; + cursor: pointer; +} .detels { width: 20%; display: flex; justify-content: space-evenly; } - +.red { + text-decoration: line-through; +} #delete-img, #edit-img, #save-img { width: 30px; } +.hadar { + width: 90%; + display: flex; + justify-content: space-evenly; +} + +.search { + border-style: none; + height: 50px; + width: 50px; + padding: 10px; + outline: none; + border-radius: 50%; + transition: 0.5s ease-in-out; + background-color: #7e4fd4; + box-shadow: 0px 0px 3px #f3f3f3; + padding-right: 40px; + color: #fff; +} + +.search::placeholder { + color: #8f8f8f; +} + +.icon { + display: flex; + align-items: center; + justify-content: end; + position: absolute; + cursor: pointer; + width: 50px; + height: 50px; + outline: none; + border-style: none; + border-radius: 50%; + pointer-events: painted; + background-color: transparent; + transition: 0.2s linear; +} + +.icon:focus ~ .search, +.search:focus { + box-shadow: none; + width: 250px; + border-radius: 0px; + background-color: transparent; + border-bottom: 3px solid #7e4fd4; + transition: all 500ms cubic-bezier(0, 0.11, 0.35, 2); +} diff --git a/src/App.js b/src/App.js index e61b8ff..70efe55 100644 --- a/src/App.js +++ b/src/App.js @@ -1,5 +1,4 @@ import "./App.css"; - import ToDoList from "./components/ToDoList"; import todoData from "./todoData"; // TODO: Import the todoData and pass it as a prop to the TodoList component @@ -11,7 +10,7 @@ function App() { {/* Call the TodoList Component Here */} - + {" "} ); } diff --git a/src/components/ListTask.jsx b/src/components/ListTask.jsx new file mode 100644 index 0000000..a5076ef --- /dev/null +++ b/src/components/ListTask.jsx @@ -0,0 +1,13 @@ +const ListTask = ({ filterTodo, getToDo }) => { + return ( +
+ +
+ ); +}; + +export default ListTask; diff --git a/src/components/ToDoList.jsx b/src/components/ToDoList.jsx index e1c73d6..26b01b9 100644 --- a/src/components/ToDoList.jsx +++ b/src/components/ToDoList.jsx @@ -1,9 +1,14 @@ -import { useState } from "react"; +import { useState, useRef } from "react"; import uuid4 from "uuid4"; import TodoItem from "./TodoItem"; +import ListTask from "./ListTask"; + function ToDoList({ todoData }) { + const [copyToDo, setcopyToDo] = useState(todoData); const [getToDo, setToDo] = useState(todoData); const [todoTitel, setToDoTitel] = useState(""); + const [search, setSearch] = useState(""); + const inputTitel = useRef(); function handleTextChange(event) { setToDoTitel(event.target.value); @@ -16,7 +21,7 @@ function ToDoList({ todoData }) { done: false, }; setToDo([...getToDo, newToDoObj]); - setToDoTitel(""); + inputTitel.current.value = ""; } function handleDelete(todoId) { @@ -29,25 +34,63 @@ function ToDoList({ todoData }) { ) ); } + + //########################################### + const filterTodo = (text) => { + const filterObjects = (text, todos) => { + if (text == 1) { + return todos.filter((item) => item.done == false); + } else if (text == 2) { + return todos.filter((item) => item.done == true); + } else { + return todos.slice(); // Return a copy of the original array if value is not 1 or 2 + } + }; + + const filteredTodos = filterObjects(text, copyToDo); + setToDo(filteredTodos); + }; + //################################ + return (
- + - {getToDo.map((todo) => ( - - ))} +
+ setSearch(e.target.value)} + > + + +
+ + {getToDo + .filter((todo) => { + return search.toLowerCase() === "" + ? todo + : todo.title.toLowerCase().includes(search); + }) + .map((todo, index) => ( + + ))}
); } diff --git a/src/components/TodoItem.jsx b/src/components/TodoItem.jsx index d94fb95..c82372c 100644 --- a/src/components/TodoItem.jsx +++ b/src/components/TodoItem.jsx @@ -4,6 +4,7 @@ import { useState } from "react"; function TodoItem({ todo, handleDelete, handleEdit }) { const [editText, setEditText] = useState(false); const [newEditText, setNewEditText] = useState(todo.title); + const [done, setDone] = useState(todo.done); // copy text to Edit input function handlEdit(event) { setNewEditText(event.target.value); @@ -13,6 +14,12 @@ function TodoItem({ todo, handleDelete, handleEdit }) { handleEdit(todo.id, newEditText); setEditText(false); } + //############################ not completed + function handleDone() { + console.log("1", done); + setDone(!done); + console.log("2", done); + } return (
@@ -24,7 +31,9 @@ function TodoItem({ todo, handleDelete, handleEdit }) { onChange={handlEdit} /> ) : ( -

{todo.title}

+

+ {todo.title} +

)}
{editText ? ( diff --git a/src/todoData.js b/src/todoData.js index d12d26f..3b819af 100644 --- a/src/todoData.js +++ b/src/todoData.js @@ -17,7 +17,7 @@ const todoData = [ { id: 4, title: "Write a book", - done: false, + done: true, }, { id: 5, From a099e7080630eee3689a5a86ec8ae58d4b5e5fa0 Mon Sep 17 00:00:00 2001 From: Mustafa88A Date: Sat, 27 Apr 2024 06:19:38 +0300 Subject: [PATCH 3/3] its ok --- src/components/ToDoList.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ToDoList.jsx b/src/components/ToDoList.jsx index 26b01b9..6625e80 100644 --- a/src/components/ToDoList.jsx +++ b/src/components/ToDoList.jsx @@ -9,7 +9,7 @@ function ToDoList({ todoData }) { const [todoTitel, setToDoTitel] = useState(""); const [search, setSearch] = useState(""); const inputTitel = useRef(); - + console.log("hi word"); function handleTextChange(event) { setToDoTitel(event.target.value); }