From 6a83ba997cd1c5706128515569417d48b9b082eb Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Wed, 21 May 2025 13:54:18 +0200 Subject: [PATCH 01/28] setting up my app and creating the first store --- package.json | 3 ++- public/vite.svg | 1 - src/App.jsx | 11 ++++++++--- src/components/ToDoForm.jsx | 19 +++++++++++++++++++ src/stores/useTodoStore.jsx | 8 ++++++++ 5 files changed, 37 insertions(+), 5 deletions(-) delete mode 100644 public/vite.svg create mode 100644 src/components/ToDoForm.jsx create mode 100644 src/stores/useTodoStore.jsx diff --git a/package.json b/package.json index caf6289..669c1e7 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ }, "dependencies": { "react": "^19.0.0", - "react-dom": "^19.0.0" + "react-dom": "^19.0.0", + "zustand": "^5.0.4" }, "devDependencies": { "@eslint/js": "^9.21.0", diff --git a/public/vite.svg b/public/vite.svg deleted file mode 100644 index e7b8dfb..0000000 --- a/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/App.jsx b/src/App.jsx index 5427540..b1455c1 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,5 +1,10 @@ +import ToDoForm from "./components/ToDoForm"; + export const App = () => { return ( -

React Boilerplate

- ) -} + <> +

My To Do List

+ + + ); +}; diff --git a/src/components/ToDoForm.jsx b/src/components/ToDoForm.jsx new file mode 100644 index 0000000..5e5fa74 --- /dev/null +++ b/src/components/ToDoForm.jsx @@ -0,0 +1,19 @@ +import useTodoStore from "../stores/useTodoStore"; + +const ToDoForm = () => { + const { todo, setTodo } = useTodoStore; + + return ( +
+

What do you need to do?

+ setTodo(e.target.value)} + value={todo} + /> + +
+ ); +}; + +export default ToDoForm; diff --git a/src/stores/useTodoStore.jsx b/src/stores/useTodoStore.jsx new file mode 100644 index 0000000..558f2e6 --- /dev/null +++ b/src/stores/useTodoStore.jsx @@ -0,0 +1,8 @@ +import { create } from "zustand"; + +const useTodoStore = create((set) => ({ + todo: "", + setTodo: () => set((state) => ({ todo: state.todo })), +})); + +export default useTodoStore; From 1255d8fda49a0ad5c6b19d4e7fd6bae4466dc2be Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Wed, 21 May 2025 14:33:10 +0200 Subject: [PATCH 02/28] getting the todo store to create and delete todos --- src/App.jsx | 2 ++ src/components/ToDoForm.jsx | 16 ++++++++++++---- src/components/ToDoMessage.jsx | 20 ++++++++++++++++++++ src/components/TodoList.jsx | 20 ++++++++++++++++++++ src/stores/useTodoStore.jsx | 29 +++++++++++++++++++++++++++-- 5 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 src/components/ToDoMessage.jsx create mode 100644 src/components/TodoList.jsx diff --git a/src/App.jsx b/src/App.jsx index b1455c1..e99ea5a 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,10 +1,12 @@ import ToDoForm from "./components/ToDoForm"; +import TodoList from "./components/TodoList"; export const App = () => { return ( <>

My To Do List

+ ); }; diff --git a/src/components/ToDoForm.jsx b/src/components/ToDoForm.jsx index 5e5fa74..1d2b00c 100644 --- a/src/components/ToDoForm.jsx +++ b/src/components/ToDoForm.jsx @@ -1,15 +1,23 @@ +import { useState } from "react"; import useTodoStore from "../stores/useTodoStore"; const ToDoForm = () => { - const { todo, setTodo } = useTodoStore; + const [message, setMessage] = useState(""); + const createTodo = useTodoStore((state) => state.createTodo); + + const handleSubmit = (e) => { + e.preventDefault(); + createTodo(message); + setMessage(""); + }; return ( -
+

What do you need to do?

setTodo(e.target.value)} - value={todo} + onChange={(e) => setMessage(e.target.value)} + value={message} />
diff --git a/src/components/ToDoMessage.jsx b/src/components/ToDoMessage.jsx new file mode 100644 index 0000000..8f59cea --- /dev/null +++ b/src/components/ToDoMessage.jsx @@ -0,0 +1,20 @@ +import useTodoStore from "../stores/useTodoStore"; + +const ToDoMessage = ({ id, message, complete }) => { + const removeTodo = useTodoStore((state) => state.removeTodo); + + return ( +
+

{message}

+ + +

+ {complete + ? "This task has been completed" + : "This task has not been completed"} +

+
+ ); +}; + +export default ToDoMessage; diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx new file mode 100644 index 0000000..89dbec9 --- /dev/null +++ b/src/components/TodoList.jsx @@ -0,0 +1,20 @@ +import useTodoStore from "../stores/useTodoStore"; +import ToDoMessage from "./ToDoMessage"; + +const TodoList = () => { + const todos = useTodoStore((state) => state.todos); + + if (todos.length === 0) { + return

No tasks yet. Be the first!

; + } else { + return ( + <> + {todos.map((todo) => ( + + ))} + + ); + } +}; + +export default TodoList; diff --git a/src/stores/useTodoStore.jsx b/src/stores/useTodoStore.jsx index 558f2e6..9c10347 100644 --- a/src/stores/useTodoStore.jsx +++ b/src/stores/useTodoStore.jsx @@ -1,8 +1,33 @@ import { create } from "zustand"; +const initialState = { + todos: [ + { + id: 1, + message: "", + complete: false, + }, + ], +}; + const useTodoStore = create((set) => ({ - todo: "", - setTodo: () => set((state) => ({ todo: state.todo })), + ...initialState, + + createTodo: (message) => { + const newTodo = { + id: Date.now(), + message, + complete: false, + }; + + set((state) => ({ todos: [newTodo, ...state.todos] })); + }, + + removeTodo: (id) => { + set((state) => ({ + todos: state.todos.filter((todo) => todo.id !== id), + })); + }, })); export default useTodoStore; From 7f76e746d47e9475c7810c26539a940b20afffe8 Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Wed, 21 May 2025 14:51:31 +0200 Subject: [PATCH 03/28] creating the complete / uncomplete task functionality --- src/components/ToDoMessage.jsx | 8 +++++++- src/components/TodoList.jsx | 20 +++++++++----------- src/stores/useTodoStore.jsx | 25 +++++++++++++++++-------- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/components/ToDoMessage.jsx b/src/components/ToDoMessage.jsx index 8f59cea..a2a309d 100644 --- a/src/components/ToDoMessage.jsx +++ b/src/components/ToDoMessage.jsx @@ -2,12 +2,18 @@ import useTodoStore from "../stores/useTodoStore"; const ToDoMessage = ({ id, message, complete }) => { const removeTodo = useTodoStore((state) => state.removeTodo); + const completeTodo = useTodoStore((state) => state.completeTodo); + const uncompleteTodo = useTodoStore((state) => state.uncompleteTodo); return (

{message}

- +

{complete ? "This task has been completed" diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index 89dbec9..0ff46c5 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -4,17 +4,15 @@ import ToDoMessage from "./ToDoMessage"; const TodoList = () => { const todos = useTodoStore((state) => state.todos); - if (todos.length === 0) { - return

No tasks yet. Be the first!

; - } else { - return ( - <> - {todos.map((todo) => ( - - ))} - - ); - } + if (todos.length === 0) return

No tasks yet. Be the first!

; + + return ( + <> + {todos.map((todo) => ( + + ))} + + ); }; export default TodoList; diff --git a/src/stores/useTodoStore.jsx b/src/stores/useTodoStore.jsx index 9c10347..3a22a2c 100644 --- a/src/stores/useTodoStore.jsx +++ b/src/stores/useTodoStore.jsx @@ -1,13 +1,7 @@ import { create } from "zustand"; const initialState = { - todos: [ - { - id: 1, - message: "", - complete: false, - }, - ], + todos: [], }; const useTodoStore = create((set) => ({ @@ -19,7 +13,6 @@ const useTodoStore = create((set) => ({ message, complete: false, }; - set((state) => ({ todos: [newTodo, ...state.todos] })); }, @@ -28,6 +21,22 @@ const useTodoStore = create((set) => ({ todos: state.todos.filter((todo) => todo.id !== id), })); }, + + completeTodo: (id) => { + set((state) => ({ + todos: state.todos.map((todo) => + todo.id === id ? { ...todo, complete: true } : todo + ), + })); + }, + + uncompleteTodo: (id) => { + set((state) => ({ + todos: state.todos.map((todo) => + todo.id === id ? { ...todo, complete: false } : todo + ), + })); + }, })); export default useTodoStore; From 229f78d56dbd66c9bee9710ba804d6e43c8637d3 Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Wed, 21 May 2025 15:10:09 +0200 Subject: [PATCH 04/28] showing a count of all and uncompleted tasks --- src/components/TodoList.jsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index 0ff46c5..98a5adf 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -8,6 +8,11 @@ const TodoList = () => { return ( <> +

All tasks: {todos.length}

+

+ Uncompleted tasks:{" "} + {todos.filter((todo) => todo.complete === false).length} +

{todos.map((todo) => ( ))} From 17cdd571792d1ab88920fb9e51b31fae2a8c853d Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Wed, 21 May 2025 15:13:56 +0200 Subject: [PATCH 05/28] chenging text for emty state, will need styling to look nice later --- src/components/ToDoForm.jsx | 2 +- src/components/TodoList.jsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/ToDoForm.jsx b/src/components/ToDoForm.jsx index 1d2b00c..6e367c5 100644 --- a/src/components/ToDoForm.jsx +++ b/src/components/ToDoForm.jsx @@ -19,7 +19,7 @@ const ToDoForm = () => { onChange={(e) => setMessage(e.target.value)} value={message} /> - + ); }; diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index 98a5adf..5e8cb70 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -4,7 +4,8 @@ import ToDoMessage from "./ToDoMessage"; const TodoList = () => { const todos = useTodoStore((state) => state.todos); - if (todos.length === 0) return

No tasks yet. Be the first!

; + if (todos.length === 0) + return

You have no tasks yet. Add a to-do to get started!

; return ( <> From c77bef72cac6aceb6320b2fb38ca428cc0e5cc44 Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Thu, 22 May 2025 12:39:44 +0200 Subject: [PATCH 06/28] adding a category selection that is then displayed on my to-do --- src/components/ToDoForm.jsx | 50 +++++++++++++++++++++++++++++++++- src/components/ToDoMessage.jsx | 3 +- src/stores/useTodoStore.jsx | 3 +- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/components/ToDoForm.jsx b/src/components/ToDoForm.jsx index 6e367c5..3369ed2 100644 --- a/src/components/ToDoForm.jsx +++ b/src/components/ToDoForm.jsx @@ -3,12 +3,14 @@ import useTodoStore from "../stores/useTodoStore"; const ToDoForm = () => { const [message, setMessage] = useState(""); + const [category, setCategory] = useState(""); const createTodo = useTodoStore((state) => state.createTodo); const handleSubmit = (e) => { e.preventDefault(); - createTodo(message); + createTodo(message, category); setMessage(""); + setCategory(""); }; return ( @@ -17,8 +19,54 @@ const ToDoForm = () => { setMessage(e.target.value)} + required value={message} /> +

Select task category:

+ + + + ); diff --git a/src/components/ToDoMessage.jsx b/src/components/ToDoMessage.jsx index a2a309d..202c461 100644 --- a/src/components/ToDoMessage.jsx +++ b/src/components/ToDoMessage.jsx @@ -1,6 +1,6 @@ import useTodoStore from "../stores/useTodoStore"; -const ToDoMessage = ({ id, message, complete }) => { +const ToDoMessage = ({ id, message, complete, category }) => { const removeTodo = useTodoStore((state) => state.removeTodo); const completeTodo = useTodoStore((state) => state.completeTodo); const uncompleteTodo = useTodoStore((state) => state.uncompleteTodo); @@ -8,6 +8,7 @@ const ToDoMessage = ({ id, message, complete }) => { return (

{message}

+

{category}

+
+ + + + +
+ ); }; diff --git a/src/components/ToDoMessage.jsx b/src/components/ToDoMessage.jsx index 202c461..d477d95 100644 --- a/src/components/ToDoMessage.jsx +++ b/src/components/ToDoMessage.jsx @@ -6,15 +6,25 @@ const ToDoMessage = ({ id, message, complete, category }) => { const uncompleteTodo = useTodoStore((state) => state.uncompleteTodo); return ( -
-

{message}

-

{category}

- - +
+

{message}

+
+

{category}

+
+
+ + +

{complete ? "This task has been completed" diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index 5e8cb70..1d92d39 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -8,16 +8,18 @@ const TodoList = () => { return

You have no tasks yet. Add a to-do to get started!

; return ( - <> -

All tasks: {todos.length}

-

- Uncompleted tasks:{" "} - {todos.filter((todo) => todo.complete === false).length} -

+
+
+

All tasks: {todos.length}

+

+ Uncompleted tasks:{" "} + {todos.filter((todo) => todo.complete === false).length} +

+
{todos.map((todo) => ( ))} - +
); }; diff --git a/src/index.css b/src/index.css index f7c0aef..293c9bc 100644 --- a/src/index.css +++ b/src/index.css @@ -1,3 +1,5 @@ +@import "tailwindcss"; + :root { font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; } diff --git a/vite.config.js b/vite.config.js index ba24244..282fc60 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,7 +1,9 @@ -import react from '@vitejs/plugin-react' -import { defineConfig } from 'vite' +import react from "@vitejs/plugin-react"; +import { defineConfig } from "vite"; + +import tailwindcss from "@tailwindcss/vite"; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react()] -}) + plugins: [react(), tailwindcss()], +}); From faf870822e250f851c79ec1f692f560911edf1b1 Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Thu, 22 May 2025 15:29:38 +0200 Subject: [PATCH 08/28] adding a task filter --- src/components/TodoList.jsx | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index 1d92d39..0b1e3b3 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -1,8 +1,16 @@ +import { useState } from "react"; import useTodoStore from "../stores/useTodoStore"; import ToDoMessage from "./ToDoMessage"; const TodoList = () => { const todos = useTodoStore((state) => state.todos); + const [filter, setFilter] = useState("all"); + + const filteredTodos = todos.filter((todo) => { + if (filter === "completed") return todo.complete; + if (filter === "uncompleted") return !todo.complete; + return true; + }); if (todos.length === 0) return

You have no tasks yet. Add a to-do to get started!

; @@ -16,7 +24,30 @@ const TodoList = () => { {todos.filter((todo) => todo.complete === false).length}

- {todos.map((todo) => ( +
+

Filter tasks by:

+
+ + + +
+
+ {filteredTodos.map((todo) => ( ))}
From 9255a3ed2e148dfe29163d80d936ebfac3d6cd99 Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Thu, 22 May 2025 15:32:39 +0200 Subject: [PATCH 09/28] simple spacing --- 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 0b1e3b3..c350d73 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -17,7 +17,7 @@ const TodoList = () => { return (
-
+

All tasks: {todos.length}

Uncompleted tasks:{" "} From c0d3d810ef6e07efc1d269a8de7e9efcae679141 Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Thu, 22 May 2025 15:45:13 +0200 Subject: [PATCH 10/28] styling complete and uncomplete --- index.html | 8 ++++++++ src/components/ToDoForm.jsx | 2 +- src/components/ToDoMessage.jsx | 14 +++++++++----- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index a3709ae..29f8a09 100644 --- a/index.html +++ b/index.html @@ -10,5 +10,13 @@

+ + diff --git a/src/components/ToDoForm.jsx b/src/components/ToDoForm.jsx index 1fe5aa0..a33a15f 100644 --- a/src/components/ToDoForm.jsx +++ b/src/components/ToDoForm.jsx @@ -26,7 +26,7 @@ const ToDoForm = () => { value={message} className="border border-solid border-gray h-10" /> -

Select task category:

+

Task category:

-

- {complete - ? "This task has been completed" - : "This task has not been completed"} -

+
+

Complete?

+ + {complete ? ( + + ) : ( + + )} +
); }; From eba56829754f8dacabab71e91f0e9fc94bda7a1c Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Thu, 22 May 2025 15:46:50 +0200 Subject: [PATCH 11/28] reorganising the message structure --- src/components/ToDoMessage.jsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/ToDoMessage.jsx b/src/components/ToDoMessage.jsx index 8d44386..aed919e 100644 --- a/src/components/ToDoMessage.jsx +++ b/src/components/ToDoMessage.jsx @@ -11,6 +11,15 @@ const ToDoMessage = ({ id, message, complete, category }) => {

{category}

+
+

Complete?

+ + {complete ? ( + + ) : ( + + )} +
-
-

Complete?

- - {complete ? ( - - ) : ( - - )} -
); }; From 4f70713723d9b3fe219d487ca1566488de18879d Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Fri, 23 May 2025 09:27:10 +0200 Subject: [PATCH 12/28] styling what shows on the page when there are no tasks --- src/components/ToDoMessage.jsx | 2 +- src/components/TodoList.jsx | 36 +++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/components/ToDoMessage.jsx b/src/components/ToDoMessage.jsx index aed919e..6dcaff4 100644 --- a/src/components/ToDoMessage.jsx +++ b/src/components/ToDoMessage.jsx @@ -31,7 +31,7 @@ const ToDoMessage = ({ id, message, complete, category }) => { className="border border-solid border-black rounded-md cursor-pointer p-2" onClick={complete ? () => uncompleteTodo(id) : () => completeTodo(id)} > - {complete ? "Click to uncomplete" : "Click to complete"} + {complete ? "Mark as incomplete" : "Mark as complete"}
diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index c350d73..a486495 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -13,7 +13,41 @@ const TodoList = () => { }); if (todos.length === 0) - return

You have no tasks yet. Add a to-do to get started!

; + return ( +
+
+

All tasks: {todos.length}

+

+ Uncompleted tasks:{" "} + {todos.filter((todo) => todo.complete === false).length} +

+
+
+

Filter tasks by:

+
+ + + +
+
+

You have no tasks yet. Add a to-do to get started!

; +
+ ); return (
From 78dde63531af11359c0409defca7ec6bc5935a5a Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Fri, 23 May 2025 09:28:15 +0200 Subject: [PATCH 13/28] fixing grammar --- src/components/TodoList.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index a486495..fb8a34f 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -35,13 +35,13 @@ const TodoList = () => { className="border border-solid border-black rounded-md cursor-pointer p-2" onClick={() => setFilter("completed")} > - Completed + Complete
@@ -71,13 +71,13 @@ const TodoList = () => { className="border border-solid border-black rounded-md cursor-pointer p-2" onClick={() => setFilter("completed")} > - Completed + Complete From 9b02d74037b2294abc6c4ba5ad70bc4fe4e634d3 Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Fri, 23 May 2025 09:38:36 +0200 Subject: [PATCH 14/28] adding the date posted on the task --- src/components/ToDoMessage.jsx | 1 + src/components/TodoList.jsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/ToDoMessage.jsx b/src/components/ToDoMessage.jsx index 6dcaff4..50210a1 100644 --- a/src/components/ToDoMessage.jsx +++ b/src/components/ToDoMessage.jsx @@ -34,6 +34,7 @@ const ToDoMessage = ({ id, message, complete, category }) => { {complete ? "Mark as incomplete" : "Mark as complete"} +

Task added: {new Date(id).toLocaleString()}

); }; diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index fb8a34f..ed3106f 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -45,7 +45,7 @@ const TodoList = () => { -

You have no tasks yet. Add a to-do to get started!

; +

You have no tasks yet. Add a to-do to get started!

); From 04e2e5183b8d856dfe026f91bc606cb9632c4ae2 Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Fri, 23 May 2025 10:21:38 +0200 Subject: [PATCH 15/28] styling and colouring stuff --- index.html | 4 ++++ src/App.jsx | 2 +- src/components/ToDoForm.jsx | 10 +++++++--- src/components/ToDoMessage.jsx | 8 ++++---- src/components/TodoList.jsx | 16 ++++++++-------- src/index.css | 2 +- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/index.html b/index.html index 29f8a09..d31d805 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,10 @@ + Todo diff --git a/src/App.jsx b/src/App.jsx index e6a5e81..99da9db 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -3,7 +3,7 @@ import TodoList from "./components/TodoList"; export const App = () => { return ( -
+

My To-Do List

diff --git a/src/components/ToDoForm.jsx b/src/components/ToDoForm.jsx index a33a15f..fae1c2d 100644 --- a/src/components/ToDoForm.jsx +++ b/src/components/ToDoForm.jsx @@ -15,7 +15,7 @@ const ToDoForm = () => { return (

What do you need to do?

@@ -24,7 +24,7 @@ const ToDoForm = () => { onChange={(e) => setMessage(e.target.value)} required value={message} - className="border border-solid border-gray h-10" + className="border border-gray-300 h-10 px-3 focus:border-rose-200 focus:ring-rose-300 focus:outline-none focus:ring-2 " />

Task category:

@@ -36,6 +36,7 @@ const ToDoForm = () => { checked={category === "Work"} onChange={(e) => setCategory(e.target.value)} required + className="accent-rose-300 focus:ring-2 focus:ring-rose-300" />{" "} Work @@ -47,6 +48,7 @@ const ToDoForm = () => { checked={category === "Study"} onChange={(e) => setCategory(e.target.value)} required + className="accent-rose-300 focus:ring-2 focus:ring-rose-300" />{" "} Study @@ -58,6 +60,7 @@ const ToDoForm = () => { checked={category === "Chores"} onChange={(e) => setCategory(e.target.value)} required + className="accent-rose-300 focus:ring-2 focus:ring-rose-300" />{" "} Chores @@ -69,12 +72,13 @@ const ToDoForm = () => { checked={category === "Misc"} onChange={(e) => setCategory(e.target.value)} required + className="appearence-none bg-gray-800 accent-rose-300 focus:ring-2 focus:ring-rose-300" />{" "} Misc
-

Task added: {new Date(id).toLocaleString()}

+

Task added: {new Date(id).toLocaleString()}

); }; From acbcbcbed57eb235fdd8983deae5055478fa4846 Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Fri, 23 May 2025 13:04:48 +0200 Subject: [PATCH 17/28] removing repeated code --- src/components/TodoList.jsx | 49 ++++++------------------------------- 1 file changed, 7 insertions(+), 42 deletions(-) diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index 0ebee29..039e175 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -12,43 +12,6 @@ const TodoList = () => { return true; }); - if (todos.length === 0) - return ( -
-
-

All tasks: {todos.length}

-

- Incomplete tasks:{" "} - {todos.filter((todo) => todo.complete === false).length} -

-
-
-

Filter tasks by:

-
- - - -
-
-

You have no tasks yet. Add a to-do to get started!

-
- ); - return (
@@ -62,13 +25,13 @@ const TodoList = () => {

Filter tasks by:

- {filteredTodos.map((todo) => ( - - ))} + {todos.length === 0 ? ( +

You have no tasks yet. Add a to-do to get started!

+ ) : ( + filteredTodos.map((todo) => ) + )}
); }; From 41e2fc2e194f49e98a5a094fa9cd8a6ad5cd572a Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Fri, 23 May 2025 13:08:44 +0200 Subject: [PATCH 18/28] adding indication of which filter we are on --- src/components/TodoList.jsx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index 039e175..4415f40 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -7,8 +7,8 @@ const TodoList = () => { const [filter, setFilter] = useState("all"); const filteredTodos = todos.filter((todo) => { - if (filter === "completed") return todo.complete; - if (filter === "uncompleted") return !todo.complete; + if (filter === "complete") return todo.complete; + if (filter === "incomplete") return !todo.complete; return true; }); @@ -25,20 +25,28 @@ const TodoList = () => {

Filter tasks by:

From 2b931c29db3c522b395a0e693f3064e61acb348e Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Fri, 23 May 2025 13:11:45 +0200 Subject: [PATCH 19/28] heading size change --- src/App.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 99da9db..512e5b2 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -3,8 +3,8 @@ import TodoList from "./components/TodoList"; export const App = () => { return ( -
-

My To-Do List

+
+

My To-Do List

From 2e3b7323c7318d8c722b53f91672cc4ea0b1c31c Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Fri, 23 May 2025 13:15:09 +0200 Subject: [PATCH 20/28] placing the to-d-s side-by side --- src/components/TodoList.jsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index 4415f40..f6281c9 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -52,11 +52,13 @@ const TodoList = () => {
- {todos.length === 0 ? ( -

You have no tasks yet. Add a to-do to get started!

- ) : ( - filteredTodos.map((todo) => ) - )} +
+ {todos.length === 0 ? ( +

You have no tasks yet. Add a to-do to get started!

+ ) : ( + filteredTodos.map((todo) => ) + )} +
); }; From f8d67bea32ae88f24436aa2e91c2ef1de6aa365d Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Fri, 23 May 2025 13:33:52 +0200 Subject: [PATCH 21/28] making it repsonsive --- src/App.jsx | 10 ++++++---- src/components/ToDoForm.jsx | 7 ++++++- src/components/ToDoMessage.jsx | 9 ++++++++- src/components/TodoList.jsx | 8 ++++---- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 512e5b2..0752f0c 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -3,10 +3,12 @@ import TodoList from "./components/TodoList"; export const App = () => { return ( -
-

My To-Do List

- - +
+
+

My To-Do List

+ + +
); }; diff --git a/src/components/ToDoForm.jsx b/src/components/ToDoForm.jsx index fae1c2d..044556f 100644 --- a/src/components/ToDoForm.jsx +++ b/src/components/ToDoForm.jsx @@ -15,7 +15,12 @@ const ToDoForm = () => { return (

What do you need to do?

diff --git a/src/components/ToDoMessage.jsx b/src/components/ToDoMessage.jsx index b88cef2..a20dc37 100644 --- a/src/components/ToDoMessage.jsx +++ b/src/components/ToDoMessage.jsx @@ -6,7 +6,14 @@ const ToDoMessage = ({ id, message, complete, category }) => { const uncompleteTodo = useTodoStore((state) => state.uncompleteTodo); return ( -
+

{category}

diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index f6281c9..5a0b795 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -13,8 +13,8 @@ const TodoList = () => { }); return ( -
-
+
+

All tasks: {todos.length}

Incomplete tasks:{" "} @@ -23,7 +23,7 @@ const TodoList = () => {

Filter tasks by:

-
+
-
+
{todos.length === 0 ? (

You have no tasks yet. Add a to-do to get started!

) : ( From f2e7df51aa4d13a87a82b24397cf654d53f40839 Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Fri, 23 May 2025 13:43:00 +0200 Subject: [PATCH 22/28] resposnive design changes --- 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 5a0b795..d445032 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -52,7 +52,7 @@ const TodoList = () => {
-
+
{todos.length === 0 ? (

You have no tasks yet. Add a to-do to get started!

) : ( From eb260f7daaaf234e6592b1036fa3e9abe585cf2c Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Fri, 23 May 2025 13:47:37 +0200 Subject: [PATCH 23/28] informative text when there's nothing to see --- src/components/TodoList.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index d445032..ca9d2a7 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -53,8 +53,16 @@ const TodoList = () => {
- {todos.length === 0 ? ( -

You have no tasks yet. Add a to-do to get started!

+ {filteredTodos.length === 0 ? ( + filter === "complete" ? ( +

No completed tasks yet. Complete a task to see it here.

+ ) : filter === "incomplete" ? ( +

+ No incomplete tasks yet. Add a task or uncheck a completed one. +

+ ) : ( +

You have no tasks yet. Add a to-do to get started!

+ ) ) : ( filteredTodos.map((todo) => ) )} From 7ec8ad4e72ed5c9edd69b4a2487923d58479922a Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Fri, 23 May 2025 13:56:00 +0200 Subject: [PATCH 24/28] adding an empty ui state --- src/components/TodoList.jsx | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/components/TodoList.jsx b/src/components/TodoList.jsx index ca9d2a7..cf6ccc6 100644 --- a/src/components/TodoList.jsx +++ b/src/components/TodoList.jsx @@ -55,13 +55,31 @@ const TodoList = () => {
{filteredTodos.length === 0 ? ( filter === "complete" ? ( -

No completed tasks yet. Complete a task to see it here.

+
+ +

No completed tasks yet. Complete a task to see it here.

+
) : filter === "incomplete" ? ( -

- No incomplete tasks yet. Add a task or uncheck a completed one. -

+
+ +

+ No incomplete tasks yet. Add a task or uncheck a completed one. +

{" "} +
) : ( -

You have no tasks yet. Add a to-do to get started!

+
+ +

You have no tasks yet. Add a to-do to get started!

{" "} +
) ) : ( filteredTodos.map((todo) => ) From 6eaa56c7357f20b94ecf719d02c5f59f6f68c0b0 Mon Sep 17 00:00:00 2001 From: christina-baldwin Date: Fri, 23 May 2025 14:11:40 +0200 Subject: [PATCH 25/28] accessibility with aria-labels --- src/components/ToDoForm.jsx | 2 ++ src/components/ToDoMessage.jsx | 9 +++++++-- src/components/TodoList.jsx | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/ToDoForm.jsx b/src/components/ToDoForm.jsx index 044556f..ee6a2c0 100644 --- a/src/components/ToDoForm.jsx +++ b/src/components/ToDoForm.jsx @@ -25,6 +25,7 @@ const ToDoForm = () => { >

What do you need to do?

setMessage(e.target.value)} required @@ -83,6 +84,7 @@ const ToDoForm = () => {
+

{message}