Skip to content

Commit

Permalink
fim agora de verdade
Browse files Browse the repository at this point in the history
  • Loading branch information
l-ricardo committed Mar 19, 2023
1 parent 5803d33 commit 30c9c48
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/components/TaskForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function TaskForm({ addTask, inputText }) {
addTask(task)
}

// Checks if the input has valid text and creates a new task
const submitHandler = () => {
if (text.trim() !== "") {
newTask(text)
Expand Down
6 changes: 3 additions & 3 deletions src/components/TaskList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import TaskForm from "./TaskForm"

import styles from "../styles/TaskList.module.css"


export default function TaskList() {
const [tasks, setTasks] = useState([])
const [notDoneCount, setNotDoneCount] = useState(0)
const [doneCount, setDoneCount] = useState(0)
const [inputText, setInputText] = useState("")

// Find the task position in the tasks array using its id
Expand All @@ -21,6 +21,7 @@ export default function TaskList() {
const doneTasks = messyTasks.filter((task) => task.isDone)
const notDoneTasks = messyTasks.filter((task) => !task.isDone)
setNotDoneCount(notDoneTasks.length)
setDoneCount(doneTasks.length)
const sortedTasks = [...notDoneTasks, ...doneTasks]
return sortedTasks
}
Expand All @@ -46,12 +47,11 @@ export default function TaskList() {
const index = getIndexById(id)
setInputText(tasks[index].text)
deleteTask(id)
// TODO: Colocar uma href para focar no input e rolar a tela ate ele ao editar
}

return (
<div className={styles.task_list_box}>
<h2>Pendentes ({notDoneCount})</h2>
<h2>Pendentes ({notDoneCount}) / Concluídas ({doneCount})</h2>

<TaskForm
addTask={addTask}
Expand Down
2 changes: 1 addition & 1 deletion src/styles/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
--contrast-color: #bb86fc;

--h1-font: 6.25rem;
--h2-font: 2.5rem;
--h2-font: 2.25rem;
--p-font: 1.25rem;
}

Expand Down
1 change: 1 addition & 0 deletions src/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ input {
line-height: 1.5rem;
padding: 0 0.5rem;
border: none;
background-color: transparent;
}

input:focus {
Expand Down

0 comments on commit 30c9c48

Please sign in to comment.