-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f8d760
commit b985eea
Showing
14 changed files
with
253 additions
and
67 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,81 @@ | ||
@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap'); | ||
|
||
* { | ||
font-family: 'Poppins', sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
|
||
body { | ||
background: #8758ff; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.App { | ||
text-align: center; | ||
} | ||
|
||
.App-logo { | ||
height: 40vmin; | ||
pointer-events: none; | ||
h1 { | ||
color: #fff; | ||
margin-bottom: 0.5rem; | ||
font-size: 1.75rem; | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
} | ||
.TodoWrapper { | ||
background: #1A1A40; | ||
margin-top: 5rem; | ||
padding: 2rem; | ||
border-radius: 5px; | ||
} | ||
|
||
.App-header { | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
.TodoForm { | ||
width: 100%; | ||
} | ||
|
||
.todo-input { | ||
outline: none; | ||
background: none; | ||
border: 1px solid #8758ff; | ||
padding: 0.5rem 1rem; | ||
margin-top: 1rem; | ||
margin-bottom: 2rem; | ||
width: 300px; | ||
color: #fff; | ||
} | ||
|
||
.todo-input::placeholder { | ||
color: #ffffff4d; | ||
} | ||
|
||
.todo-btn { | ||
background: #8758ff; | ||
color: #fff; | ||
border: none; | ||
padding: 0.55rem; | ||
cursor: pointer; | ||
|
||
} | ||
|
||
.Todo { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
color: white; | ||
background: #8758ff; | ||
color: #fff; | ||
padding: 0.75rem 1rem; | ||
border-radius: 5px; | ||
margin-bottom: 1rem; | ||
cursor: pointer; | ||
} | ||
|
||
.App-link { | ||
color: #61dafb; | ||
.fa-trash { | ||
margin-left: 0.75rem; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
.completed { | ||
color: #c5aeff; | ||
text-decoration: line-through; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, {useState} from "react"; | ||
|
||
export const EditTodoForm = ({editTodo, task}) => { | ||
const [value, setValue] = useState(task.task) | ||
|
||
const handleSubmit = e => { | ||
e.preventDefault(); | ||
|
||
editTodo(value, task.id); | ||
|
||
setValue("") | ||
} | ||
return( | ||
<form className='TodoForm' onSubmit={handleSubmit}> | ||
<input type="text" className='todo-input' value={value} placeholder='Editar Tarefa' onChange={(e) => setValue(e.target.value)}/> | ||
<button type='submit' className='todo-btn'>Editar</button> | ||
</form> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from "react"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faPenToSquare } from "@fortawesome/free-regular-svg-icons"; | ||
import { faTrash } from "@fortawesome/free-solid-svg-icons"; | ||
|
||
export const Todo = ({task, toggleComplete, deleteTodo, editTodo}) => { | ||
return( | ||
<div className="Todo"> | ||
<p onClick={() => toggleComplete(task.id)} className={`${task.completed ? 'completed': ""}`}>{task.task}</p> | ||
<div> | ||
<FontAwesomeIcon icon={faPenToSquare} onClick={() => editTodo(task.id)}/> | ||
<FontAwesomeIcon icon={faTrash} onClick={() => deleteTodo(task.id)}/> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, {useState} from "react"; | ||
|
||
export const TodoForm = ({addTodo}) => { | ||
const [value, setValue] = useState("") | ||
|
||
const handleSubmit = e => { | ||
e.preventDefault(); | ||
|
||
addTodo(value); | ||
|
||
setValue("") | ||
} | ||
return( | ||
<form className='TodoForm' onSubmit={handleSubmit}> | ||
<input type="text" className='todo-input' value={value} placeholder='Tarefa' onChange={(e) => setValue(e.target.value)}/> | ||
<button type='submit' className='todo-btn'>Add</button> | ||
</form> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, {useState} from "react"; | ||
import { TodoForm } from "./TodoFoms"; | ||
import { EditTodoForm } from "./EditTodoForm"; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
import { Todo } from "./Todo"; | ||
uuidv4(); | ||
|
||
export const TodoWrapper = () => { | ||
const [todos, setTodos] = useState([]) | ||
|
||
const addTodo = todo => { | ||
setTodos([...todos, {id: uuidv4(), task: todo, completed: false, isEditing: false}]) | ||
console.log(todos) | ||
} | ||
|
||
const toggleComplete = id => { | ||
setTodos(todos.map(todo => todo.id === id ? {... todo, completed: !todo.completed} : todo)) | ||
} | ||
|
||
const deleteTodo = id => { | ||
setTodos(todos.filter(todo => todo.id !== id)) | ||
} | ||
|
||
const editTodo = id => { | ||
setTodos(todos.map(todo => todo.id === id ? {... todo, isEditing: !todo.isEditing} : todo)) | ||
} | ||
|
||
const editTask = (task, id) => { | ||
setTodos(todos.map(todo => todo.id === id ? {... todo, task, isEditing: !todo.isEditing} : todo)) | ||
} | ||
|
||
return( | ||
<div className='TodoWrapper'> | ||
<h1>To-Do List</h1> | ||
<TodoForm addTodo={addTodo}/> | ||
{todos.map((todo, index) => ( | ||
todo.isEditing ? ( | ||
<EditTodoForm editTodo={editTask} task={todo}/> | ||
) : ( | ||
<Todo task={todo} key={index} toggleComplete={toggleComplete} deleteTodo={deleteTodo} editTodo={editTodo} /> | ||
) | ||
|
||
))} | ||
|
||
</div> | ||
) | ||
} |
Oops, something went wrong.