From 614e53c92624b1c3bf2dd4f762a44b5476e254c6 Mon Sep 17 00:00:00 2001 From: dani Date: Mon, 12 Aug 2024 12:45:09 -0500 Subject: [PATCH 01/36] Create Todos component to be reused 4 times branch feat/todo --- src/todo/Todo.jsx | 11 +++++++++++ src/todo/Todos.jsx | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/todo/Todos.jsx diff --git a/src/todo/Todo.jsx b/src/todo/Todo.jsx index 37032b1..2e8aac8 100644 --- a/src/todo/Todo.jsx +++ b/src/todo/Todo.jsx @@ -1,9 +1,20 @@ +import { Todos } from './Todos.jsx' import './Todo.css' export const Todo = () => { return (

Todo

+ + + +
) } \ No newline at end of file diff --git a/src/todo/Todos.jsx b/src/todo/Todos.jsx new file mode 100644 index 0000000..c3a7eb8 --- /dev/null +++ b/src/todo/Todos.jsx @@ -0,0 +1,20 @@ +export const Todos = ({ title, completedText, deleteBtnText, inputText }) => { + return ( +
+
+ {completedText? completedText : "Completed"}:16{completedText? "h" : "%"} +

{title}

+
+ +
+ + +
+ +
+ ) +} \ No newline at end of file From c7a786f5d79f431635ef6858e0f86d1d3d57a7a1 Mon Sep 17 00:00:00 2001 From: dani Date: Mon, 12 Aug 2024 13:05:51 -0500 Subject: [PATCH 02/36] Add minimal style to Todo & Todos components branch feat/todo --- src/App.css | 4 ++++ src/todo/Todo.css | 4 +++- src/todo/Todos.css | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/todo/Todos.jsx | 5 +++-- 4 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 src/todo/Todos.css diff --git a/src/App.css b/src/App.css index 13fd414..10c8f77 100644 --- a/src/App.css +++ b/src/App.css @@ -8,6 +8,10 @@ button { display: none; } +li { + list-style: none; +} + .App { width: 98vw; height: 95vh; diff --git a/src/todo/Todo.css b/src/todo/Todo.css index 384512c..026ef75 100644 --- a/src/todo/Todo.css +++ b/src/todo/Todo.css @@ -1,3 +1,5 @@ .Todo { - color: white; + display: flex; + row-gap: 22px; + overflow-y: auto; } diff --git a/src/todo/Todos.css b/src/todo/Todos.css new file mode 100644 index 0000000..45843d0 --- /dev/null +++ b/src/todo/Todos.css @@ -0,0 +1,44 @@ +.Todos { + width: 100%; + border: 1px solid red; + border-radius: 10px; + padding: 10px; + display: flex; + flex-direction: column; + row-gap: 12px; +} + +.Todos header { + display: flex; + justify-content: space-between; + align-items: center; +} + +.Todos header span span { + font-size: 24px; +} + +.Todos header h1 { + font-size: 22px; +} + +.Todos ul { + width: 95%; + align-self: flex-end; + font-size: 12px; +} + +.Todos footer { + display: flex; + column-gap: 12px; +} + +.Todos footer button { + width: fit-content; + font-size: 16px; + text-wrap: nowrap; +} + +.Todos footer input { + width: 100%; +} \ No newline at end of file diff --git a/src/todo/Todos.jsx b/src/todo/Todos.jsx index c3a7eb8..254682f 100644 --- a/src/todo/Todos.jsx +++ b/src/todo/Todos.jsx @@ -1,8 +1,10 @@ +import './Todos.css' + export const Todos = ({ title, completedText, deleteBtnText, inputText }) => { return (
- {completedText? completedText : "Completed"}:16{completedText? "h" : "%"} + {completedText? completedText : "Completed"}: 16{completedText? "h" : "%"}

{title}

    @@ -14,7 +16,6 @@ export const Todos = ({ title, completedText, deleteBtnText, inputText }) => { -
) } \ No newline at end of file From ae4f5179e03177ea28042ec6dc98ecfb3dd817aa Mon Sep 17 00:00:00 2001 From: dani Date: Mon, 12 Aug 2024 13:24:48 -0500 Subject: [PATCH 03/36] Create todoDailySlice and Render todos array branch feat/todo --- src/store/store.js | 17 +++++++++++++---- src/todo/Todo.jsx | 10 ++++++---- src/todo/Todos.jsx | 20 +++++++++++++------- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/store/store.js b/src/store/store.js index 0882c40..0d06ed8 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -1,18 +1,27 @@ import { create } from "zustand" import { devtools } from "zustand/middleware" -const createBearSlice = set => ({ +const bearSlice = set => ({ amount: 42, add: () => set(state => ({ bears: { ...state.bears, amount: state.bears.amount + 1 } })) }) -const createCowSlice = () => ({ +const cowSlice = () => ({ amount: 21 }) +const todoDailySlice = set => ({ + todos: [1, 2, 3], + dones: [4, 5, 6], + addTodo: ()=>set(state => ({ + todoDaily: {...state.todoDaily, todos: state.todos.push(23)} + })) +}) + export const Store = create(devtools(set => ({ - bears: createBearSlice(set), - cows: createCowSlice() + bears: bearSlice(set), + cows: cowSlice(), + todoDaily: todoDailySlice(), }))) \ No newline at end of file diff --git a/src/todo/Todo.jsx b/src/todo/Todo.jsx index 2e8aac8..f980e19 100644 --- a/src/todo/Todo.jsx +++ b/src/todo/Todo.jsx @@ -1,17 +1,19 @@ +import { Store } from '../store/store.js' import { Todos } from './Todos.jsx' import './Todo.css' export const Todo = () => { + const store = Store() return (

Todo

- - - + + + diff --git a/src/todo/Todos.jsx b/src/todo/Todos.jsx index 254682f..3fda1db 100644 --- a/src/todo/Todos.jsx +++ b/src/todo/Todos.jsx @@ -1,20 +1,26 @@ import './Todos.css' -export const Todos = ({ title, completedText, deleteBtnText, inputText }) => { +export const Todos = ({ title, completedText, todos, dones, deleteBtnText, inputText }) => { + if (!todos) { + todos = [] + } + let todosAndDones = todos.concat(dones) + + return (
- {completedText? completedText : "Completed"}: 16{completedText? "h" : "%"} + {completedText ? completedText : "Completed"}: 16{completedText ? "h" : "%"}

{title}

    -
  • 1
  • -
  • 2
  • -
  • 3
  • + {todosAndDones.map(item => ( +
  • {item}
  • + ))}
- - + +
) From 59bcfaeed2e73b336d13b9bff1aeb90711abbb72 Mon Sep 17 00:00:00 2001 From: dani Date: Mon, 12 Aug 2024 18:38:26 -0500 Subject: [PATCH 04/36] Store all data for each Todo component in the Zustand store branch feat/todo --- src/store/store.js | 25 ++++++++++++++++++++++--- src/todo/Todo.jsx | 12 ++---------- src/todo/Todos.jsx | 23 ++++++++++------------- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/store/store.js b/src/store/store.js index 0d06ed8..bf3cb03 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -13,15 +13,34 @@ const cowSlice = () => ({ }) const todoDailySlice = set => ({ + title: "Daily Goals", + achievedText: "Completed: ", + completed: "23%", + deleteBtnText: "Delete All Completed", + inputText: "Type a new goal and press Enter", todos: [1, 2, 3], dones: [4, 5, 6], - addTodo: ()=>set(state => ({ - todoDaily: {...state.todoDaily, todos: state.todos.push(23)} + addTodo: () => set(state => ({ + daily: { ...state.daily, todos: state.todos.push(23) } + })) +}) + +const taskSlice = set => ({ + title: "Completed Tasks", + achievedText: "Worked Hours: ", + completed: 5.25, + deleteBtnText: "Delete All Tasks", + inputText: "Type a completed task and press Enter", + todos: [], + dones: [4, 5, 6], + addTodo: () => set(state => ({ + completed: { ...state.tasks, todos: state.todos.push(23) } })) }) export const Store = create(devtools(set => ({ bears: bearSlice(set), cows: cowSlice(), - todoDaily: todoDailySlice(), + daily: todoDailySlice(), + tasks: taskSlice() }))) \ No newline at end of file diff --git a/src/todo/Todo.jsx b/src/todo/Todo.jsx index f980e19..a2daeae 100644 --- a/src/todo/Todo.jsx +++ b/src/todo/Todo.jsx @@ -7,16 +7,8 @@ export const Todo = () => { return (

Todo

- - - - + +
) } \ No newline at end of file diff --git a/src/todo/Todos.jsx b/src/todo/Todos.jsx index 3fda1db..fbd97fa 100644 --- a/src/todo/Todos.jsx +++ b/src/todo/Todos.jsx @@ -1,26 +1,23 @@ import './Todos.css' -export const Todos = ({ title, completedText, todos, dones, deleteBtnText, inputText }) => { - if (!todos) { - todos = [] - } - let todosAndDones = todos.concat(dones) +export const Todos = ({ store }) => { + const todosDones = store.todos.concat(store.dones) return (
- {completedText ? completedText : "Completed"}: 16{completedText ? "h" : "%"} -

{title}

+ {store.achievedText}{store.completed} +

{store.title}

-
    - {todosAndDones.map(item => ( -
  • {item}
  • - ))} +
      {todosDones.map(item => ( +
    • {item}
    • + )) + }
    - - + +
) From 9990befe778df6d7e32e7f726d72441d2f334c2c Mon Sep 17 00:00:00 2001 From: dani Date: Mon, 12 Aug 2024 18:47:05 -0500 Subject: [PATCH 05/36] Change names between Todos.jsx and Todo.jsx --- src/App.jsx | 5 ++--- src/todo/Todo.jsx | 22 ++++++++++++++-------- src/todo/Todos.jsx | 26 ++++++++------------------ 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index da03b43..f0a4322 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,5 +1,4 @@ -// import { Store } from './store/store.js' -import {Todo} from './todo/Todo.jsx' +import {Todos} from './todo/Todos.jsx' import {Doing} from './doing/Doing.jsx' import {Done} from './done/Done.jsx' import './App.css' @@ -12,7 +11,7 @@ export const App = () => {
Bears: {store.bears.amount}
Cows: {store.cows.amount}
*/} - +
diff --git a/src/todo/Todo.jsx b/src/todo/Todo.jsx index a2daeae..1ac3695 100644 --- a/src/todo/Todo.jsx +++ b/src/todo/Todo.jsx @@ -1,14 +1,20 @@ -import { Store } from '../store/store.js' -import { Todos } from './Todos.jsx' import './Todo.css' -export const Todo = () => { - const store = Store() +export const Todo = ({ store }) => { + const todosDones = store.todos.concat(store.dones) return ( -
-

Todo

- - +
+
+ {store.achievedText}{store.completed} +

{store.title}

+
+
    + {todosDones.map(item => (
  • {item}
  • ))} +
+
+ + +
) } \ No newline at end of file diff --git a/src/todo/Todos.jsx b/src/todo/Todos.jsx index fbd97fa..3b43211 100644 --- a/src/todo/Todos.jsx +++ b/src/todo/Todos.jsx @@ -1,24 +1,14 @@ +import { Store } from '../store/store.js' +import { Todo } from './Todo.jsx' import './Todos.css' -export const Todos = ({ store }) => { - const todosDones = store.todos.concat(store.dones) - - +export const Todos = () => { + const store = Store() return ( -
-
- {store.achievedText}{store.completed} -

{store.title}

-
-
    {todosDones.map(item => ( -
  • {item}
  • - )) - } -
-
- - -
+
+

Todo

+ +
) } \ No newline at end of file From 3cc7de35ee0d949757dd690efda28c2c8d2e956a Mon Sep 17 00:00:00 2001 From: dani Date: Mon, 12 Aug 2024 19:22:03 -0500 Subject: [PATCH 06/36] Add an item to the todos or dones array in Store branch feat/todo --- src/store/store.js | 12 ++++++------ src/todo/Todo.jsx | 20 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/store/store.js b/src/store/store.js index bf3cb03..494b69b 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -20,8 +20,8 @@ const todoDailySlice = set => ({ inputText: "Type a new goal and press Enter", todos: [1, 2, 3], dones: [4, 5, 6], - addTodo: () => set(state => ({ - daily: { ...state.daily, todos: state.todos.push(23) } + add: (input) => set(state => ({ + daily: { ...state.daily, todos: [...state.daily.todos, input] } })) }) @@ -33,14 +33,14 @@ const taskSlice = set => ({ inputText: "Type a completed task and press Enter", todos: [], dones: [4, 5, 6], - addTodo: () => set(state => ({ - completed: { ...state.tasks, todos: state.todos.push(23) } + add: (input) => set(state => ({ + tasks: { ...state.tasks, dones: [...state.tasks.dones, input] } })) }) export const Store = create(devtools(set => ({ bears: bearSlice(set), cows: cowSlice(), - daily: todoDailySlice(), - tasks: taskSlice() + daily: todoDailySlice(set), + tasks: taskSlice(set) }))) \ No newline at end of file diff --git a/src/todo/Todo.jsx b/src/todo/Todo.jsx index 1ac3695..1dc4be5 100644 --- a/src/todo/Todo.jsx +++ b/src/todo/Todo.jsx @@ -1,7 +1,17 @@ +import { useState } from 'react' import './Todo.css' export const Todo = ({ store }) => { const todosDones = store.todos.concat(store.dones) + const [input, setInput] = useState("") + + const handleInputEnterKey = (k) => { + if (k.key === "Enter") { + store.add(input) + setInput("") + } + } + return (
@@ -9,11 +19,17 @@ export const Todo = ({ store }) => {

{store.title}

    - {todosDones.map(item => (
  • {item}
  • ))} + {todosDones.map(item => (
  • {item}
  • ))}
- + setInput(e.target.value)} + onKeyDown={(k) => handleInputEnterKey(k)} + />
) From 1c44eae5b33d1646838849ae84d9d0e13d22cbe7 Mon Sep 17 00:00:00 2001 From: dani Date: Mon, 12 Aug 2024 19:30:41 -0500 Subject: [PATCH 07/36] Remove commented code branch feat/todo --- src/App.jsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index f0a4322..1f17638 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -4,13 +4,8 @@ import {Done} from './done/Done.jsx' import './App.css' export const App = () => { - // const store = Store() return (
- {/*

App Component

-
Bears: {store.bears.amount}
-
Cows: {store.cows.amount}
- */} From 6fdd521ce276bc07e23d154a1021d9184ea22d02 Mon Sep 17 00:00:00 2001 From: dani Date: Mon, 12 Aug 2024 19:31:02 -0500 Subject: [PATCH 08/36] Remove completed Tasks component from Daily, Weekly, Monthly components group branch feat/todo --- src/store/store.js | 32 +------------------------------- src/todo/Todo.jsx | 6 +++--- src/todo/Todos.jsx | 1 - 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/src/store/store.js b/src/store/store.js index 494b69b..6c8acb4 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -1,23 +1,9 @@ import { create } from "zustand" import { devtools } from "zustand/middleware" -const bearSlice = set => ({ - amount: 42, - add: () => set(state => ({ - bears: { ...state.bears, amount: state.bears.amount + 1 } - })) -}) - -const cowSlice = () => ({ - amount: 21 -}) - const todoDailySlice = set => ({ title: "Daily Goals", - achievedText: "Completed: ", completed: "23%", - deleteBtnText: "Delete All Completed", - inputText: "Type a new goal and press Enter", todos: [1, 2, 3], dones: [4, 5, 6], add: (input) => set(state => ({ @@ -25,22 +11,6 @@ const todoDailySlice = set => ({ })) }) -const taskSlice = set => ({ - title: "Completed Tasks", - achievedText: "Worked Hours: ", - completed: 5.25, - deleteBtnText: "Delete All Tasks", - inputText: "Type a completed task and press Enter", - todos: [], - dones: [4, 5, 6], - add: (input) => set(state => ({ - tasks: { ...state.tasks, dones: [...state.tasks.dones, input] } - })) -}) - export const Store = create(devtools(set => ({ - bears: bearSlice(set), - cows: cowSlice(), - daily: todoDailySlice(set), - tasks: taskSlice(set) + daily: todoDailySlice(set) }))) \ No newline at end of file diff --git a/src/todo/Todo.jsx b/src/todo/Todo.jsx index 1dc4be5..9e5a505 100644 --- a/src/todo/Todo.jsx +++ b/src/todo/Todo.jsx @@ -15,18 +15,18 @@ export const Todo = ({ store }) => { return (
- {store.achievedText}{store.completed} + Completed: {store.completed}

{store.title}

    {todosDones.map(item => (
  • {item}
  • ))}