= ({
/>
-
- {todo.title}
-
+ {!isRenaming && (
+
- ×
-
+ // onClick={handleEditTodo}
+ >
+ {todo.title}
+
+ )}
+
+ {isRenaming && (
+
+ )}
+
+ {!isRenaming && (
+
+ )}
{
const [errorMessage, setErrorMessage] = useState(null);
const [activeFilter, setActiveFilter] = useState(Filters.All);
const [editingTodos, setEditingTodos] = useState([]);
+ const [renamingTodo, setRenamingTodo] = useState(null);
const isAllCompleted = todos.every(todo => todo.completed);
@@ -132,6 +133,23 @@ export const useTodos = () => {
});
};
+ const handleUpdateTodoTitle = (id: number, title: string) => {
+ const newTodo = todos.find(todo => todo.id === id);
+
+ if (!newTodo) {
+ setErrorMessage('Todo not found');
+
+ return;
+ }
+
+ const updatedTodo: Todo = {
+ ...newTodo,
+ title,
+ };
+
+ updateTodo(updatedTodo);
+ };
+
useEffect(() => {
loadTodos();
}, []);
@@ -159,5 +177,8 @@ export const useTodos = () => {
handleToggleCompleted,
handleToggleAll,
isAllCompleted,
+ renamingTodo,
+ setRenamingTodo,
+ handleUpdateTodoTitle,
};
};
diff --git a/src/styles/todo.scss b/src/styles/todo.scss
index c7f93ff6b9..cdadf964d9 100644
--- a/src/styles/todo.scss
+++ b/src/styles/todo.scss
@@ -15,13 +15,13 @@
&__status-label {
cursor: pointer;
- background-image: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23ededed%22%20stroke-width%3D%223%22/%3E%3C/svg%3E");
+ background-image: url('data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23ededed%22%20stroke-width%3D%223%22/%3E%3C/svg%3E');
background-repeat: no-repeat;
background-position: center left;
}
&.completed &__status-label {
- background-image: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23bddad5%22%20stroke-width%3D%223%22/%3E%3Cpath%20fill%3D%22%235dc2af%22%20d%3D%22M72%2025L42%2071%2027%2056l-4%204%2020%2020%2034-52z%22/%3E%3C/svg%3E");
+ background-image: url('data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23bddad5%22%20stroke-width%3D%223%22/%3E%3Cpath%20fill%3D%22%235dc2af%22%20d%3D%22M72%2025L42%2071%2027%2056l-4%204%2020%2020%2034-52z%22/%3E%3C/svg%3E');
}
&__status {
@@ -72,7 +72,7 @@
&__title-field {
width: 100%;
- padding: 11px 14px;
+ padding: 12px 15px;
font-size: inherit;
line-height: inherit;
@@ -80,8 +80,8 @@
font-weight: inherit;
color: inherit;
- border: 1px solid #999;
- box-shadow: inset 0 -1px 5px 0 rgba(0, 0, 0, 0.2);
+ border: none;
+ box-shadow: inset 0 -2px 1px rgba(0, 0, 0, 0.03);
&::placeholder {
font-style: italic;