Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

also added an new ui/ux for the website#45

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
aerinpatel wants to merge1 commit intosolygambas:mainfromaerinpatel:main
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
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
30 changes: 30 additions & 0 deletions037-pokedex/index.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,10 +5,40 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Pokedex</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-SgOJa3DmI69IUzQ2PVdRZhwQ+dy64/BUtbMJw1MZ8t5HZApcHrRKUc4W0kG879m7" crossorigin="anonymous">
</head>
<body>
<h1>Pokedex</h1>
<div class="user-input">
<div class="choose-type-of-pokemon">
<label for="type-of-pokemon">Choose a type of pokemon:</label>
<select name="type-of-pokemon" class="form-select" id="type-of-pokemon">
<option value="all" disabled selected>type</option>
<option value="fire">fire</option>
<option value="grass">grass</option>
<option value="electric">electric</option>
<option value="water">water</option>
<option value="ground">ground</option>
<option value="rock">rock</option>
<option value="fairy">fairy</option>
<option value="poison">poison</option>
<option value="bug">bug</option>
<option value="dragon">dragon</option>
<option value="psychic">psychic</option>
<option value="flying">flying</option>
<option value="fighting">fighting</option>
<option value="normal">normal</option>

</select>
</div>
<div class="choose-number-of-pokemon">
<label for="number-of-pokemon">Choose number of pokemon:</label>
<input type="number" id="number-of-pokemon" min="1" max="300" />
</div>
<button onclick="fetchPokemons()">Catch it!!</button>
</div>
<div class="poke-container" id="poke-container"></div>
<script src="script.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/js/bootstrap.bundle.min.js" integrity="sha384-k6d4wzSIapyDyv1kpU366/PK5hCdSbCRGRCMv+eplOQJWyd1fbcAu9OCUj5zNLiq" crossorigin="anonymous"></script>
</body>
</html>
48 changes: 34 additions & 14 deletions037-pokedex/script.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
const pokeContainer = document.getElementById("poke-container");
const pokemonCount = 150;

// console.log(pokemonCount, pokemonType);
const colors = {
fire: "#FDDFDF",
grass: "#DEFDE0",
Expand All@@ -19,42 +20,61 @@ const colors = {
const mainTypes = Object.keys(colors);

const createPokemonCard = (pokemon) => {
const pokemonType = document.getElementById("type-of-pokemon").value || "all";
const pokemonElement = document.createElement("div");
pokemonElement.classList.add("pokemon");
const name = pokemon.name[0].toUpperCase() + pokemon.name.slice(1);
const id = pokemon.id.toString().padStart(3, "0");
const pokeTypes = pokemon.types.map((type) => type.type.name);
const type = mainTypes.find((type) => pokeTypes.indexOf(type) > -1);
const color = colors[type];
//const name = pokemon.name[0].toUpperCase() + pokemon.name.slice(1);
//const id = pokemon.id.toString().padStart(3, "0");
//const pokeTypes = pokemon.types.map((type) => type.type.name);
//const type = mainTypes.find((type) => pokeTypes.indexOf(type) > -1);
const color = colors[pokemonType];
pokemonElement.style.backgroundColor = color;

const pokemonInnerHTML = `
<div class="img-container">
<img
src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/${pokemon.id}.png"
src="${pokemon.image}"
alt="${pokemon.name}"
alt=""
/>
</div>
<div class="info">
<span class="number">#${id}</span>
<h3 class="name">${name}</h3>
<small class="type">Type: <span>${type}</span></small>
<span class="number">#${pokemon.id}</span>
<h3 class="name">${pokemon.name}</h3>
<small class="type">Type: <span>${pokemonType}</span></small>
</div>
`;
pokemonElement.innerHTML = pokemonInnerHTML;
pokeContainer.appendChild(pokemonElement);
};

const getPokemon = async (id) => {
const url = `https://pokeapi.co/api/v2/pokemon/${id}`;
//fetch data
const pokemonType = document.getElementById("type-of-pokemon").value || "all";
const url = `https://pokeapi.co/api/v2/type/${pokemonType}`;
const res = await fetch(url);
const data = await res.json();
createPokemonCard(data);
console.log(data);
// send data to createPokemonCard
const pokemonName = data.pokemon[id].pokemon.name;
const pokemonId = data.pokemon[id].pokemon.url.split("/")[6];
// const pokemonTypes = data.pokemon.pokemon.types.map((type) => type.type.name);
const image = `https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${pokemonId}.png`;
const next = {
id: id,
name: pokemonName,
// types: pokemonTypes,
image: image,
};
createPokemonCard(next);
};

const fetchPokemons = async () => {
for (let i = 1; i < pokemonCount; i++) {
const pokemonCount = document.getElementById("number-of-pokemon").value || 20;

for (let i = 1; i <= pokemonCount; i++) {
await getPokemon(i);
}
};

fetchPokemons();
//fetchPokemons();
123 changes: 98 additions & 25 deletions037-pokedex/style.css
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,140 @@
@import url("https://fonts.googleapis.com/css?family=Lato:wght@300;400&display=swap");
@import url("https://fonts.googleapis.com/css?family=Roboto:300,400,700&display=swap");

* {
box-sizing: border-box;
}

body {
background: #efefbb;
background: linear-gradient(to right, #d4d3dd, #efefbb);
font-family: "Lato", sans-serif;
background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
font-family: "Roboto", sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 0;
padding: 20px;
}

h1 {
letter-spacing: 3px;
margin: 20px 0;
font-size: 3rem;
color: #374785;
text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.poke-container {
.user-input {
display: flex;
flex-wrap: wrap;
align-items: space-between;
justify-content: center;
margin: 0 auto;
align-items: center;
margin-bottom: 30px;
background-color: rgba(255, 255, 255, 0.8);
padding: 20px 30px;
border-radius: 10px;
box-shadow: 0px 4px 8px rgba(0,0,0,0.1);
}

.user-input > div {
margin: 10px 20px;
}

.choose-number-of-pokemon label {
font-size: 1.2rem;
margin-right: 10px;
color: #374785;
}

select, input {
font-size: 1rem;
padding: 0.5rem 1rem;
border: 1px solid #ccc;
border-radius: 5px;
outline: none;
transition: border-color 0.3s ease;
}

select:focus, input:focus {
border-color: #374785;
}

.user-input button {
font-size: 1.1rem;
padding: 0.6rem 1.2rem;
border: none;
background-color: #374785;
color: #fff;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
margin-top: 10px;
}

.user-input button:hover {
background-color: #2c3e50;
}

.poke-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
gap: 20px;
width: 100%;
max-width: 1200px;
}

.pokemon {
background-color: #eee;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 3px 15px rgba(100, 100, 100, 0.5);
margin: 10px;
padding: 20px;
box-shadow: 0 8px 15px rgba(0,0,0,0.1);
padding: 15px;
text-align: center;
transition: transform 0.2s ease;
}

.pokemon:hover {
transform: scale(1.05);
}

.pokemon .img-container {
background-color:rgba(255, 255, 255, 0.6);
background-color:#f7f7f7;
border-radius: 50%;
height: 120px;
width: 120px;
text-align: center;
height: 130px;
width: 130px;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}

.pokemon .img-container img {
max-width:90%;
margin-top: 20px;
width:100%;
height: auto;
}

.pokemon .info {
margin-top:20px;
margin-top:15px;
}

.pokemon .info .number {
background-color:rgba(0, 0, 0, 0.1);
background-color:#f1f1f1;
padding: 5px 10px;
border-radius: 10px;
font-size: 0.8em;
border-radius: 20px;
font-size: 0.9em;
display: inline-block;
margin-bottom: 10px;
}

.pokemon .info .name {
margin: 15px 0 7px;
letter-spacing: 1px;
font-size: 1.3rem;
color: #333;
margin-bottom: 8px;
}

.pokemon .info .type {
font-size: 1rem;
margin: 0;
}

.pokemon .info .type span {
font-weight: bold;
color: #374785;
}

[8]ページ先頭

©2009-2025 Movatter.jp