Skip to content

Solution: Jon Garcia y Sebastian Burpbacher #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
72801e3
First structural steps
sebastianeliasb May 19, 2021
e4e8baa
Positioning todos
sebastianeliasb May 19, 2021
ae04883
images
jonCroatanUto May 19, 2021
36cf745
trying form
jonCroatanUto May 20, 2021
cda414a
form text input working
jonCroatanUto May 20, 2021
8b0b74a
EnterKey
jonCroatanUto May 20, 2021
415c6f7
placeholder,empty submit
jonCroatanUto May 20, 2021
29e44a5
Trying to print todos
sebastianeliasb May 20, 2021
022e123
todo
jonCroatanUto May 20, 2021
02c3dd0
render
jonCroatanUto May 20, 2021
c026c4e
merged form and todo
jonCroatanUto May 20, 2021
58281db
Footer first-steps
sebastianeliasb May 21, 2021
ac780f7
checkbox, and button
jonCroatanUto May 21, 2021
952931f
merger scrollbar & buttons
jonCroatanUto May 21, 2021
3de2587
details
jonCroatanUto May 21, 2021
252b8fb
bolean
jonCroatanUto May 21, 2021
78f752b
convertido a objeto
jonCroatanUto May 21, 2021
a72cda3
Unique ID's with math.random
sebastianeliasb May 21, 2021
ee0e149
Branch finished
sebastianeliasb May 21, 2021
4297546
fist steps
sebastianeliasb May 21, 2021
34da298
preparing routes
jonCroatanUto May 21, 2021
437546f
trying to find state in handleDelete
sebastianeliasb May 21, 2021
b5900ec
Merge pull request #1 from jonCroatanUto/route
jonCroatanUto May 21, 2021
a527c07
Route finished
sebastianeliasb May 23, 2021
14fb78d
Merge branch 'route'
sebastianeliasb May 23, 2021
0747cab
Merge branch 'main' into edit-delete
sebastianeliasb May 23, 2021
64e9b54
trying delete
jonCroatanUto May 23, 2021
f653c88
delete
jonCroatanUto May 24, 2021
e35c89d
filter active, bolean bugg
jonCroatanUto May 24, 2021
3cfc2da
trying fixing
jonCroatanUto May 24, 2021
ca4e04f
Edit-delete edit progress
sebastianeliasb May 24, 2021
0beb45b
Edit-delete FINISHED!!
sebastianeliasb May 24, 2021
34b13aa
fixed bolean
jonCroatanUto May 24, 2021
665a0ad
merge all in main
jonCroatanUto May 24, 2021
8b6b8e7
filter
jonCroatanUto May 24, 2021
9d697e6
all,completed
jonCroatanUto May 24, 2021
c3a35e4
Local Stroage
sebastianeliasb May 25, 2021
ec822cc
clear
jonCroatanUto May 25, 2021
6990271
Revert "Local Stroage"
sebastianeliasb May 25, 2021
e2a328c
Merge branch 'clear'
sebastianeliasb May 25, 2021
5618e88
last details functionality
sebastianeliasb May 25, 2021
2955859
minor fixes
sebastianeliasb May 25, 2021
8eea1f5
completed clear
jonCroatanUto May 25, 2021
5dab6a7
Merge branch 'main' of https://github.com/jonCroatanUto/reactjs-todo-…
jonCroatanUto May 25, 2021
efc95dc
fixed last problems
jonCroatanUto May 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ module.exports = {
},
],
rules: {
"prettier/prettier": "error",
"prettier/prettier": [
"error",
{
endOfLine: "auto",
},
],
"react/jsx-filename-extension": "off",
"import/prefer-default-export": "off",
"prefer-destructuring": "off",
Expand Down
11 changes: 11 additions & 0 deletions .src/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .src/styles.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20,126 changes: 20,097 additions & 29 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-innertext": "^1.1.5",
"react-redux": "^7.2.3",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
Expand Down Expand Up @@ -56,7 +57,7 @@
"eslint-plugin-react": "^7.23.2",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-testing-library": "^4.1.1",
"jest": "^26.6.0",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"typescript": "^4.2.4"
},
Expand Down
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!-- <link href="%PUBLIC_URL%/styles.css" rel="stylesheet" /> -->
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand Down
163 changes: 151 additions & 12 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,154 @@
import React from "react";

function App() {
return (
<main className="container mt-5">
<section className="row">
<div className="col col-12">
<h1>Hola mundo</h1>
</div>
</section>
</main>
);
import React, { Component } from "react";
import { BrowserRouter, Route } from "react-router-dom";
import Home from "./components/pages/Home";
import Active from "./components/pages/Active";
import Completed from "./components/pages/Complete";
// import Todo from "./components/Todo";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

es recomendable eliminar todo el código comentado que no se utiliza


import "./_App.scss";

const LOCAL_STORAGE_KEY = "react-sc-state";

function loadLocalStorage() {
const json = localStorage.getItem(LOCAL_STORAGE_KEY);

const state = JSON.parse(json);

if (!state) {
return {
todos: [],
};
}

return state;
}
class App extends Component {
constructor(props) {
super(props);
this.state = {
todos: [],
};
this.newTodo = this.newTodo.bind(this);
this.handleDelete = this.handleDelete.bind(this);
this.handleSelected = this.handleSelected.bind(this);
this.clear = this.clear.bind(this);
}

componentDidMount() {
const prevState = loadLocalStorage();

this.setState({
todos: prevState.todos,
});
}

componentDidUpdate() {
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(this.state));
}

handleSelected(itemId) {
const { todos } = this.state;
const bolTodo = todos.map((todo) => {
if (todo.id === itemId) {
// eslint-disable-next-line no-param-reassign
return { ...todo, selected: !todo.selected };
}
return todo;
});
this.setState({
todos: bolTodo,
});
}

handleDelete(itemId) {
const { todos } = this.state;
const notDelete = todos.filter((el) => el.id !== itemId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Muy bien implementado!

Es recomendable nombrar las variables con un nombre descriptivo para que se entienda exactamente qué es la variable. En este caso como mejora se podría llamar el argument el como todo

this.setState({
todos: notDelete,
});
}

submitNewTitle = (newTitle, id) => {
const { todos } = this.state;

this.setState({
todos: todos.map((todo) => {
if (todo.id === id) {
// eslint-disable-next-line no-param-reassign
todo.title = newTitle;
}
return todo;
}),
});
};

newTodo(item) {
const { todos } = this.state;

this.setState({
todos: [...todos, item],
});
}

clear() {
const { todos } = this.state;
const cleared = todos.filter((item) => item.selected !== true);
this.setState({
todos: cleared,
});
}

render() {
const { todos } = this.state;

return (
<BrowserRouter>
<Route
exact
path="/"
render={(routeProps) => (
<Home
clear={this.clear}
submitNewTitle={this.submitNewTitle}
todos={todos}
newTodo={this.newTodo}
handleDelete={this.handleDelete}
handleSelected={this.handleSelected}
{...routeProps}
/>
)}
/>
<Route
exact
path="/active"
render={(routeProps) => (
<Active
submitNewTitle={this.submitNewTitle}
handleDelete={this.handleDelete}
handleSelected={this.handleSelected}
newTodo={this.newTodo}
todos={todos.filter((item) => item.selected === false)}
{...routeProps}
/>
)}
/>
<Route
exact
path="/completed"
render={(routeProps) => (
<Completed
clear={this.clear}
submitNewTitle={this.submitNewTitle}
handleDelete={this.handleDelete}
handleSelected={this.handleSelected}
newTodo={this.newTodo}
todos={todos.filter((item) => item.selected === true)}
{...routeProps}
/>
)}
/>
</BrowserRouter>
);
}
}
export default App;
40 changes: 40 additions & 0 deletions src/_App.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// @use "./global.scss" as global;

.background_container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
width: 100%;
}
.parent_container {
display: flex;
position: fixed;
background-image: linear-gradient(
20deg,
rgb(13, 13, 14),
rgb(38, 44, 70),
rgb(42, 79, 134),
rgb(144, 174, 207),
rgba(175, 194, 207, 0.8),
rgba(238, 242, 247, 0.3)
);
top: 5%;
flex-direction: column;
justify-content: center;
align-items: center;
height: 70%;
width: 40%;
flex-wrap: wrap;
gap: 25px;
border-radius: 10px;
}
h1 {
height: 80px;
width: 100%;
letter-spacing: 10px;
}

Link:hover {
color: red;
}
15 changes: 15 additions & 0 deletions src/components/Button/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import "./_Button.scss";
// import { Link } from "react-router-dom";

const Checkbox = ({ ...newers }) => {
return <input className="check" type="checkbox" {...newers} />;
};

function Button({ ...newers }) {
return <input className="but" type="button" {...newers} />;
}
function ClearBut({ ...newers }) {
return <input className="butClear" type="button" {...newers} />;
}
export { Button, Checkbox, ClearBut };
Comment on lines +1 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Este fichero se debería extraer a varios componentes ya que el fichero se llama Button pero incluye componentes que no son botón como el checkbox.

18 changes: 18 additions & 0 deletions src/components/Button/_Button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@use "../../global.scss" as global;

.check {
max-width: 20px;
margin-right: 20px;
}

.but {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Los nombres de clases deberían ser más descriptivos para evitar palabras que puedan significar otra cosas en inglés como but. Un nombre más adecuado podría ser directamente .button

position: absolute;
max-width: 20px;
max-height: 20px;
right: 100px;
}

.butClear {
height: 20px;
width: 20px;
}
1 change: 1 addition & 0 deletions src/components/Button/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./Button";
24 changes: 24 additions & 0 deletions src/components/Footer/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from "react";
import "./footer.scss";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Es recomendable ordenar los imports para tener los imports de librerías primero y luego los imports de dependencias propias.

En este caso sería:

import React from "react";
import { Link } from "react-router-dom";

import "./footer.scss";
import { ClearBut } from "../Button/Button";

import { Link } from "react-router-dom";
import { ClearBut } from "../Button/Button";

function Footer({ clear }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se entiende que el prop clear es una función que se ejecuta en el botón, por tanto un nombre mejor sería clearTodos por ejemplo para saber qué hace exactamente.

return (
<footer className="todo_footer">
<h6>5 items left</h6>
<Link to="/" className="nav_links">
<h6>All</h6>
</Link>
<Link to="/active" className="nav_links">
<h6>Active</h6>
</Link>
<Link to="/completed" className="nav_links">
<h6>Completed</h6>
</Link>
<ClearBut onClick={clear} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sería recomendable renombrar este componente a <ClearButton /> en vez de <ClearBut /> para ser más descriptivo.

</footer>
);
}

export default Footer;
16 changes: 16 additions & 0 deletions src/components/Footer/footer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.todo_footer {
display: flex;
flex-direction: row;
color: white;
}

h6 {
margin: 0 25px 0 25px;
}

.nav_links {
color: white;
}
.nav_links:hover {
text-decoration: none;
}
1 change: 1 addition & 0 deletions src/components/Footer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./Footer";
Loading