Skip to content

ejercicio NYTimes - #39

Open
codemcu wants to merge 3 commits into
masterfrom
NYTimes-mau
Open

codemcu wants to merge 3 commits into
masterfrom
NYTimes-mau

Conversation

@codemcu

@codemcu codemcu commented Dec 4, 2018

Copy link
Copy Markdown
Collaborator

ejercicio NYTimes, cuando puedas, échale un vistazo, gracias!

@codemcu
codemcu requested a review from UlisesGascon December 4, 2018 20:18

@UlisesGascon UlisesGascon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Esta claro que estas madurando rápido, así que voy a subir el nivel de exigencia con mis reviews desde ya :trollface:

Gran trabajo 😍

margin: auto;
padding: 0 50px;
display: flex;
/* justify-content: space-between; */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ Si código comentado... sobra :trollface:

}

main > button, main > h1 {
/* position: absolute; */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ Si código comentado... sobra :trollface:

padding: 5px 40px;
background-color: #FF8F00;
color: #F0F0DF;
/* display: flex; */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ Si código comentado... sobra :trollface:

main article {
box-shadow: 2px 2px 5px 2px rgba(189, 189, 189, 0.55);
padding: 20px;
/* max-width: 300px; */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ Si código comentado... sobra :trollface:

@@ -0,0 +1,3 @@
var config = {
API_KEY : '0edf47c3e9e342b2bfd1fb79dce96301'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ recuerda que los tokens no deben estar subidos.. próxima vez los podemos compartir cifrados o similar ;-)
Le damos una vuelta en clase

const res = data.results.books;
header.appendChild(button);

res.forEach(function (item) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ interesante ver el número de modificaciones que haces dentro del DOM. Intenta encolar la modificación haciendo el uso de .join.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Lo he corregido metiendo los elementos nuevos que voy creando en un array para agregarlos todos juntos al final con un append

  function _attachElementsToDOM (array) {
    const article = document.createElement('ARTICLE');
    array.forEach(item => {
      article.appendChild(item);
    });
    articlesContainer.appendChild(article);
  }

Comment thread mauricio/NYTimes/js/main.js Outdated
}
}

function createAndAppendListElement(item) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Objetivo opcional... intenta abstraerlo mucho más. Piensa que pasaría si el elemento del HTMl fuera más complejo aún :trollface:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Me he creado 4 funciones nuevas para esto:
_createElement crea el número de tag que necesito, por ejemplo 2 <articles>, 3 <p> y los mete en un array
_addTextToElement le paso un array con los textos que irán en cada etiqueta del array creado en la función anterior
_setAttributesToTag agrega atributos, id, class
_attachElementsToDOM hace append de todo el array al DOM
Ya me contarás...

const res = data.results;

h1.textContent = 'Best sellers list';
articlesContainer.addEventListener('click', onClickButton, false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bien jugado 🌟

Comment thread mauricio/NYTimes/js/main.js Outdated
});
}

function createAndAppendList(item) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tengo un Déjà vu con createAndAppendListElement, puede ser? Mira como unificar y subir abstracción

Comment thread mauricio/NYTimes/js/main.js Outdated
}

function back() {
header.querySelector('h1').remove();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Esto pide un array a gritos ;-)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

😊👍

@UlisesGascon UlisesGascon mentioned this pull request Jan 9, 2019
24 of 46 tasks
if ($event.target.nodeName === 'A' && $event.target.id !== '' && $event.isTrusted) {
const arrayConditions = [$event.target.nodeName === 'A', $event.target.dataset.id !== '', $event.isTrusted];

const isTagA = arrayConditions.every(item => item === true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

arrayConditions.every(item => item) puedes acortarlo aún más...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants