diff --git a/components/Cards/index.js b/components/Cards/index.js index 1482e60..ccf14f0 100644 --- a/components/Cards/index.js +++ b/components/Cards/index.js @@ -17,3 +17,74 @@ // // // Create a card for each of the articles and add the card to the DOM. +const cards = document.querySelector('.cards-container'); + function cardCreator(e) { + const card = document.createElement('div'); + card.classList.add('card'); + const headline = document.createElement('div'); + headline.classList.add('headline'); + headline.textContent = e.headline; + card.appendChild(headline); + const author = document.createElement('div'); + author.classList.add('author'); + + card.appendChild(author); + + const imageContainer = document.createElement('div'); + imageContainer.classList.add('img-container'); + author.appendChild(imageContainer); + + const image = document.createElement('img'); + image.src = e.authorPhoto; + imageContainer.appendChild(image); + + const span = document.createElement('span'); + author.appendChild(span); + span.textContent = `By ${e.authorName}` + cards.appendChild(card); + return card; + + + } + + + + +axios.get('https://lambda-times-backend.herokuapp.com/articles') +.then((response) => { + console.log(response.data.articles) + let bootstrap = response.data.articles.bootstrap; + let javascript = response.data.articles.javascript; + let jquery = response.data.articles.jquery; + let node = response.data.articles.node; + let technology = response.data.articles.technology; + + bootstrap.forEach ( i => { + const card = cardCreator(i); + cards.appendChild(card); +}) +javascript.forEach ( i => { + const card = cardCreator(i); + cards.appendChild(card); +}) +jquery.forEach ( i => { + const card = cardCreator(i); + cards.appendChild(card); +}) +node.forEach ( i => { + const card = cardCreator(i); + cards.appendChild(card); +}) + technology.forEach ( i => { + const card = cardCreator(i); + cards.appendChild(card); + }) + + +}) +.catch((err) => { + +console.log(err); +}); + + diff --git a/components/Header/index.js b/components/Header/index.js index c41ba8c..c9b6048 100644 --- a/components/Header/index.js +++ b/components/Header/index.js @@ -1,3 +1,4 @@ + // STEP 1: Create a header component. // ----------------------- // Using a function create the component you see below: @@ -7,6 +8,31 @@ //