Repository navigation
Conversation
UlisesGascon
left a comment
There was a problem hiding this comment.
Esta claro que estas madurando rápido, así que voy a subir el nivel de exigencia con mis reviews desde ya ![]()
Gran trabajo 😍
| margin: auto; | ||
| padding: 0 50px; | ||
| display: flex; | ||
| /* justify-content: space-between; */ |
There was a problem hiding this comment.
ℹ️ Si código comentado... sobra ![]()
| } | ||
|
|
||
| main > button, main > h1 { | ||
| /* position: absolute; */ |
There was a problem hiding this comment.
ℹ️ Si código comentado... sobra ![]()
| padding: 5px 40px; | ||
| background-color: #FF8F00; | ||
| color: #F0F0DF; | ||
| /* display: flex; */ |
There was a problem hiding this comment.
ℹ️ Si código comentado... sobra ![]()
| main article { | ||
| box-shadow: 2px 2px 5px 2px rgba(189, 189, 189, 0.55); | ||
| padding: 20px; | ||
| /* max-width: 300px; */ |
There was a problem hiding this comment.
ℹ️ Si código comentado... sobra ![]()
| @@ -0,0 +1,3 @@ | |||
| var config = { | |||
| API_KEY : '0edf47c3e9e342b2bfd1fb79dce96301' | |||
There was a problem hiding this comment.
Le damos una vuelta en clase
| const res = data.results.books; | ||
| header.appendChild(button); | ||
|
|
||
| res.forEach(function (item) { |
There was a problem hiding this comment.
join.
There was a problem hiding this comment.
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);
}| } | ||
| } | ||
|
|
||
| function createAndAppendListElement(item) { |
There was a problem hiding this comment.
Objetivo opcional... intenta abstraerlo mucho más. Piensa que pasaría si el elemento del HTMl fuera más complejo aún ![]()
There was a problem hiding this comment.
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); |
| }); | ||
| } | ||
|
|
||
| function createAndAppendList(item) { |
There was a problem hiding this comment.
Tengo un Déjà vu con createAndAppendListElement, puede ser? Mira como unificar y subir abstracción
| } | ||
|
|
||
| function back() { | ||
| header.querySelector('h1').remove(); |
There was a problem hiding this comment.
Esto pide un array a gritos ;-)
| 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); |
There was a problem hiding this comment.
arrayConditions.every(item => item) puedes acortarlo aún más...
ejercicio NYTimes, cuando puedas, échale un vistazo, gracias!