Skip to content

Commit

Permalink
funcionalides de ingreso
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaap2099 committed Aug 10, 2023
1 parent 403d832 commit 4ce4de7
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 9 deletions.
13 changes: 12 additions & 1 deletion src/TodoContext/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function TodoProvider ({ children }) {
loading,
error,} = useLocalStorage('TODOS_V1', []);
const [searchValue, setSearchValue] = React.useState('');
const [openModal, setOpenModal] = React.useState(true);
const [openModal, setOpenModal] = React.useState(false);

const completedTodos = todos.filter(todo => !!todo.completed).length;
const totalTodos=todos.length;
Expand Down Expand Up @@ -43,6 +43,16 @@ function TodoProvider ({ children }) {
saveTodos(newTodos);
}

const addTodo = (text) => {
const newTodos = [...todos];
newTodos.push ({
text, completed: false,
}

)
saveTodos(newTodos);
}

return (
<TodoContext.Provider value={{
loading,
Expand All @@ -56,6 +66,7 @@ function TodoProvider ({ children }) {
deleteTodo,
openModal,
setOpenModal,
addTodo,
}}>
{children}

Expand Down
73 changes: 73 additions & 0 deletions src/TodoForm/TodoForm.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
form {
width: 90%;
max-width: 300px;
background-color: #fff;
padding: 33px 40px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}

label {
text-align: center;
font-weight: bold;
font-size: 20px;
color: #1E1E1F;
margin-bottom: 26px;
}

textarea {
background-color: #F9FBFC;
border: 2px solid #202329;
border-radius: 2px;
box-shadow: 0px 5px 50px rgba(32, 35, 41, 0.25);
color: #1E1E1F;
font-size: 20px;
text-align: center;
padding: 12px;
height: 96px;
width: calc(100% - 25px);
}

textarea::placeholder {
color: #A5A5A5;
font-family: 'Montserrat';
font-weight: 400;
}

textarea:focus {
outline-color: #61DAFA;
}


.TodoForm-buttonContainer {
margin-top: 14px;
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
}

.TodoForm-button {
cursor: pointer;
display: inline-block;
font-size: 20px;
color: 20px;
font-weight: 400;
width: 120px;
height: 48px;
border-radius: 2px;
border: none;
font-family: 'Montserrat';
}

.TodoForm-button--cancel {
background: transparent;
box-shadow: 0px 5px 25px rgba(97, 218, 250, 0.5);
}

.TodoForm-button--add {
background: #61DAFA;
box-shadow: 0px 5px 25px rgba(97, 218, 250, 0.5);
}
52 changes: 44 additions & 8 deletions src/TodoForm/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,52 @@
import React from "react";
import { TodoContext } from '../TodoContext'
import './TodoForm.css'

function TodoForm () {
return (
<form>
<label>Escribe tu nuevo TODO</label>
<textarea placeholder="Cortar cebolla para el almuerzo" />
<button className="TodoForm-button TodoForm-button--cancel">
const {
addTodo,
setOpenModal,
} = React.useContext(TodoContext);

const [newTodoValue, setNewTodoValue] = React.useState('');

const onSubmit = (event) => {
event.preventDefault();
addTodo(newTodoValue);
setOpenModal(false);
}

const onCancel = () => {
setOpenModal(false);
}

</button>
<button className="TodoForm-button TodoForm-button--add">
const onChange = (event) => {
setNewTodoValue(event.target.value);
}

</button>


return (
<form onSubmit={onSubmit}>
<label>Escribe tu nuevo TODO</label>
<textarea
placeholder="Cortar cebolla para el almuerzo"
value={newTodoValue}
onChange={onChange}
/>
<div className="TodoForm-buttonContainer">
<button
type="button"
className="TodoForm-button TodoForm-button--cancel"
onClick={onCancel}>
Cancelar
</button>
<button
type="submit"
className="TodoForm-button TodoForm-button--add">
Añadir
</button>
</div>
</form>
);
}
Expand Down

0 comments on commit 4ce4de7

Please sign in to comment.