Skip to content

Commit

Permalink
Merge pull request #10 from JackDev21/feature/taskForm
Browse files Browse the repository at this point in the history
fix react options, add component Taskfor #5
  • Loading branch information
JackDev21 authored Jun 4, 2024
2 parents 789047a + f134fe6 commit 5948205
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 41 deletions.
21 changes: 5 additions & 16 deletions app/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
// import React, { Component } from 'react';
import React from "react"
import Header from "./component/Header.jsx";
import TaskForm from "./component/TaskForm.jsx";

import Header from './component/Header.jsx'

function App(){
return(<Header />)
function App() {
return [<Header key='header' />, <TaskForm key='taskForm' />];
}

export default App

// class App extends Component{
// constructor(){
// super()
// }
// render(){
// return(<Header />)
// }
// }
export default App;
28 changes: 8 additions & 20 deletions app/src/component/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
// import React, { Component } from 'react';
import React from "react"
import "./Header.css"
import "./Header.css";

function Header(){
return(
<div className="Header">
<h1>TaskFlow</h1>
</div>
)
function Header() {
return (
<div className='Header'>
<h1>TaskFlow</h1>
</div>
);
}

export default Header

// class Header extends Component {
// constructor(){
// super()
// }
// render(){
// return(
// <div className="Header"><h1>To-Do</h1></div>
// )
// }
// }
export default Header;
38 changes: 38 additions & 0 deletions app/src/component/TaskForm.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.TaskForm {
width: 100%;
display: flex;
justify-content: center;
font-size: 40px;
color: dodgerblue;

}

.TaskForm>form {
display: flex;
flex-direction: column;
align-items: center;
gap: 1rem;
}

.TaskForm>form>input {
border-radius: 5px;
text-align: center;
width: 30rem;
height: 2rem;
color: dodgerblue;
font-size: 1.2rem;
}

.TaskForm>form>input::placeholder {
color: dodgerblue;
}

.TaskForm>form>button {
border-radius: 5px;
width: 10rem;
height: 2rem;
font-size: 1.2rem;
background-color: dodgerblue;
color: white;
cursor: pointer;
}
41 changes: 41 additions & 0 deletions app/src/component/TaskForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { useState } from "react";
import "./TaskForm.css";

function TaskForm(props) {
const [inputValue, setInputValue] = useState("");

const handleInputChange = (event) => {
setInputValue(event.target.value);
};

const checkForm = (event) => {
event.preventDefault();

const newTarea = {
id: Date.now(),
description: inputValue,
completed: false,
};

setInputValue("");

props.onSubmit(newTarea);
};

return (
<div className='TaskForm'>
<form onSubmit={checkForm}>
<input
id='newtask'
type='text'
placeholder='Escribe una nueva tarea'
value={inputValue}
onChange={handleInputChange}
></input>
<button type='submit'>Añadir Tarea</button>
</form>
</div>
);
}

export default TaskForm;
9 changes: 4 additions & 5 deletions app/src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './global.css'
import ReactDOM from "react-dom/client";
import App from "./App.jsx";
import "./global.css";

ReactDOM.createRoot(document.getElementById('root')).render([<App />])
ReactDOM.createRoot(document.getElementById("root")).render(<App />);

0 comments on commit 5948205

Please sign in to comment.