-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from David-Kasilia/add-content
Add content to home page
- Loading branch information
Showing
10 changed files
with
295 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
import './index.css'; | ||
import getPokemon from './modules/pokeapi.js'; | ||
|
||
// function to fetch pokemon | ||
|
||
const pokemonNumber = 20; | ||
const fetchPokemons = async () => { | ||
// eslint-disable-next-line no-plusplus | ||
for (let i = 1; i <= pokemonNumber; i++) { | ||
getPokemon(i); | ||
} | ||
}; | ||
|
||
fetchPokemons(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// populating the html container for the pokemon | ||
|
||
const createPokemonCard = (pokemon) => { | ||
const pokeContainer = document.getElementById('poke-container'); | ||
const pokemonEl = document.createElement('div'); | ||
pokemonEl.classList.add('pokemon'); | ||
|
||
const name = pokemon.name[0].toUpperCase() + pokemon.name.slice(1); | ||
|
||
const pokeInnerHTML = ` | ||
<div class="img-container"> | ||
<img class="poke-img" src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/${pokemon.id}.png"> | ||
</div> | ||
<div class="info"> | ||
<h3 class="poke-name">${name} <span class="material-symbols-outlined"> | ||
favorite | ||
</span> </h3> | ||
<button id="comments" class="comments-btn">Comments</buttons> | ||
</div> | ||
`; | ||
|
||
pokemonEl.innerHTML = pokeInnerHTML; | ||
|
||
pokeContainer.appendChild(pokemonEl); | ||
}; | ||
|
||
export default createPokemonCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// function to get pokemon | ||
import createPokemonCard from './content.js'; | ||
|
||
const getPokemon = async (id) => { | ||
// base for the api to get the pokemon | ||
const url = `https://pokeapi.co/api/v2/pokemon/${id}`; | ||
|
||
// fetch data | ||
const res = await fetch(url); | ||
const pokemon = await res.json(); | ||
createPokemonCard(pokemon); | ||
}; | ||
|
||
export default getPokemon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters