Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
71cd9cd
data subida
Cris-hr May 12, 2023
3a3b6af
cambio main
Cris-hr May 15, 2023
b6d24c6
background homepage
May 16, 2023
4e98c37
add buttons homepage
May 16, 2023
d930957
buttons homepage stile y JS
May 16, 2023
c090af6
diseñocards
Cris-hr May 16, 2023
644b04e
Merge pull request #1 from Cris-hr/subiendoData-cris1
Cris-hr May 16, 2023
cd2b16e
imagen homepage
May 16, 2023
32d2073
Merge branch 'main' of https://github.com/Cris-hr/DEV007-data-lovers …
May 16, 2023
2d4a079
Merge pull request #2 from Cris-hr/kathy
Cris-hr May 16, 2023
be9d72f
homepage images
May 17, 2023
c2028d0
resumepage
May 17, 2023
b917d63
Merge pull request #3 from Cris-hr/kathy
Cris-hr May 17, 2023
56dea58
cambios-revercard
Cris-hr May 18, 2023
717e506
Merge branch 'main' of https://github.com/Cris-hr/DEV007-data-lovers …
Cris-hr May 18, 2023
c78d2f8
Merge pull request #4 from Cris-hr/subiendoData-cris1
SolEncalada May 18, 2023
112a028
Merge branch 'main' of https://github.com/Cris-hr/DEV007-data-lovers …
Cris-hr May 18, 2023
c82e7d0
cambios-contenedor-cards
Cris-hr May 19, 2023
4720402
Merge pull request #5 from Cris-hr/subiendoData-cris1
SolEncalada May 19, 2023
a7761be
cambios resumePage
May 19, 2023
bf3c81b
bordes css
Cris-hr May 22, 2023
6be19bb
Merge pull request #6 from Cris-hr/subiendoData-cris1
SolEncalada May 22, 2023
818ffa4
boton pokedex en ResumePage
May 22, 2023
80b38ac
Merge pull request #7 from Cris-hr/kathy
Cris-hr May 23, 2023
2801358
boton-buscador
Cris-hr May 23, 2023
7df48e0
Merge pull request #8 from Cris-hr/subiendoData-cris1
SolEncalada May 23, 2023
b759498
cambios al header
Cris-hr May 24, 2023
e45354c
Merge pull request #9 from Cris-hr/subiendoData-cris1
SolEncalada May 24, 2023
01646ff
header pokedexpage selectfilter y homebutton
May 24, 2023
7f56cb5
selectfilter -filtrar por-
May 24, 2023
1383d90
boton ordenador nuevo
Cris-hr May 24, 2023
7792139
Merge pull request #10 from Cris-hr/kathy
Cris-hr May 24, 2023
a332209
resolucion de conflictos
Cris-hr May 24, 2023
9682f25
Merge pull request #11 from Cris-hr/subiendoData-cris1
SolEncalada May 24, 2023
764cb5b
css selects pokedex page
May 24, 2023
45a8f81
Merge pull request #12 from Cris-hr/kathy
SolEncalada May 24, 2023
73b71f2
funcion filtrado
May 26, 2023
8c0ab68
funcion de ordenar
Cris-hr May 26, 2023
8e53935
cambios funcion ordenar
Cris-hr May 26, 2023
c223094
cambios funcion ordenar corregida
Cris-hr May 26, 2023
79d46a1
Merge pull request #13 from Cris-hr/subiendoData-cris1
SolEncalada May 26, 2023
4f03647
test ordenar
Cris-hr May 30, 2023
d78314d
Merge pull request #14 from Cris-hr/subiendoData-cris1
SolEncalada May 30, 2023
50007ed
funcion buscador
May 30, 2023
c7f5cd8
resolucion de conflictos
May 30, 2023
dd3f39d
Merge pull request #15 from Cris-hr/kathy
Cris-hr May 30, 2023
8e9dd18
funcion de busqueda arreglada
May 30, 2023
36e744f
Merge pull request #16 from Cris-hr/kathy
Cris-hr May 30, 2023
0e4a6b6
test terminados
Cris-hr May 30, 2023
e17e7c4
conflictos arreglados3
Cris-hr May 30, 2023
ee6aa4a
Merge pull request #17 from Cris-hr/subiendoData-cris1
SolEncalada May 30, 2023
b09aed0
arreglos responsive
May 31, 2023
d4f9882
Merge pull request #18 from Cris-hr/kathy
Cris-hr May 31, 2023
483c34e
ultimos cambios
Cris-hr May 31, 2023
1c47a4e
Merge branch 'main' of https://github.com/Cris-hr/DEV007-data-lovers …
Cris-hr May 31, 2023
0b4cbc8
Merge pull request #19 from Cris-hr/subiendoData-cris1
SolEncalada May 31, 2023
5307e3b
ultimo cambio
Cris-hr Jun 5, 2023
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
7,522 changes: 7,522 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

27 changes: 20 additions & 7 deletions src/data.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
// estas funciones son de ejemplo

export const example = () => {
return 'example';
};
import data from "./data/pokemon/pokemon.js";

//Función para ordenar el array de objetos de pokémon
export function ordenarPokemones(order) {
if (order === "asc") { // ascendente
return data.pokemon.sort((a, b) => a.name.localeCompare(b.name))
} else if (order === "desc") { // descendente
return data.pokemon.sort((a, b) => -1 * a.name.localeCompare(b.name))
}
}

//Función para filtrar pokémon por tipo
export function filterByType(pokemonData, type) {
return pokemonData.filter(pokemon => pokemon.type.includes(type));
}

//funcion para el buscador
export function findByName(pokemonData, name){
return pokemonData.filter((pokemon) => pokemon.name.toLowerCase().includes(name.toLowerCase()))
}

export const anotherExample = () => {
return 'OMG';
};
Binary file added src/imagenes/image (7).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/imagenes/lupita.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/imagenes/lupita2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/imagenes/picachu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/imagenes/pokebola-remove.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/imagenes/pokebolita.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/imagenes/pokedexx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/imagenes/pokemon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/backgroundhomepage.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/backgroundresumepage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/fondolista.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/homepage1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/homepagelogo.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/homepagepokebola.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/linkresumepage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/pikachu-cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 86 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,95 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<title>Data Lovers</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="root"></div>
<script src="main.js" type="module"></script>
<div class="homePage" id="homePageStart">
<div class="logo-container">
<img src="./img/homepagelogo.PNG" alt="imagenLogoPok">
</div>
<div class="bottom-container">
<div class="contenedorImg">
<img src="./img/homepage1.PNG" alt="imagenPersonajesPok">
</div>
<div class="buttons" id="startButtons">
<button type="button" id="resumeBtn">
POKERESUMEN
</button>
<button type="button" id="pokedexBtn">
POKEDEX
</button>
</div>
</div>
</div>

<div class="resumePage" id="resumePageStart" style="display: none;">
<div class="headerResumePage">
<img src="./imagenes/pokemon.png" alt="logoPokemon">
<button type="button" id="pokedexResumePageBtn">
POKEDEX
</button>
</div>
<div class="bottomResumePage">
<iframe class="video"
width="800"
height="450"
src="https://www.youtube.com/embed/ymFxepbBSvQ"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen>
</iframe>
<img src="./imagenes/picachu.png" alt="imagenPikachu">
</div>
</div>


<div class="pageListaPoke" id="listaPokemon" style="display: none;">
<div class="headerPokedex">
<div class="leftHeader">
<img src="./imagenes/pokedexx.png" alt="logoPokedex" class="loguitoPokedex">
<img src="./imagenes/pokebolita.png" alt="logoPokebolita" class="miniPokebola">
</div>
<div class="rightHeader">
<div class="search-bar">
<input type="text" id="busquedaPokemon" placeholder="Nombre del Pokemon" required autocomplete="off">
<input type="image" src="./imagenes/lupita2.png" class="imagenBuscar">
</div>
<div class="menu-ordenador" id="ordenador">
<select id="select-ordenar">
<option hidden selected>Ordenar por</option>
<option value="asc" class="ordenar">Ascendente</option>
<option value="desc" class="ordenar">Descendente</option>
</select>
</div>

<div class="filterSelect">
<select id="filterSelect">
<option hidden selected>Filtrar por</option>
<option value="water">Agua</option>
<option value="fire">Fuego</option>
<option value="bug">Insecto</option>
<option value="electric">Eléctricos</option>
<option value="grass">Césped</option>
</select>
</div>
<button type="button" id="pokedexHomePageBtn">
INICIO
</button>
</div>
</div>

<div class="bottomPokedex">
<div class="data">
<p id="notFound" style="display: none;"></p>
<div class="adentro"></div>
</div>
</div>
</div>
</body>

<script src="main.js" type="module"></script>

</html>
163 changes: 159 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,161 @@
import { example } from './data.js';
// import data from './data/lol/lol.js';
import data from './data/pokemon/pokemon.js';
// import data from './data/rickandmorty/rickandmorty.js';
import {ordenarPokemones} from './data.js';
import { filterByType} from './data.js';
import { findByName } from './data.js';

console.log(example, data);
const contenidoCard = document.querySelector(".adentro");

document.getElementById("pokedexBtn").onclick = function () { //funcion del botón pokedex//
document.getElementById("homePageStart").style.display = "none";
document.getElementById("listaPokemon").style.display = "flex";
};

document.getElementById("resumeBtn").onclick = function () { //funcion del botón pokeresumen//
document.getElementById("homePageStart").style.display = "none";
document.getElementById("resumePageStart").style.display = "block";
};

document.getElementById("pokedexResumePageBtn").onclick = function () { //funcion del boton pokedex en la resumePage//
document.getElementById("resumePageStart").style.display = "none";
document.getElementById("listaPokemon").style.display = "flex";
};


document.getElementById("pokedexHomePageBtn").onclick = function () { //funcion del boton Inicio en la pokedex//
document.getElementById("listaPokemon").style.display = "none";
document.getElementById("homePageStart").style.display = "flex";
};


data.pokemon.forEach((pokemones) => {
contenidoCard.innerHTML += `
<button class= "mostrar">
<div class= "card__inner">
<div class= "card__side card__side--front">
<div class="card-imag">
<img src="${pokemones.img}" class= "imagen" alt="">
</div>
<div class= "card-contenido">
<p class="numeroPokemon" >${pokemones.num}</p>
<h3>${pokemones.name}</h3>
<div class="poder">
<p>type: ${pokemones.type}</p>
<div class= "generacion">
<p>${pokemones.generation.num} - ${pokemones.generation.name}</p>
</div>
</div>
</div>
</div>
<div class= "card__side card__side--back">
<div class= "card__body">
<p class= "height">ALTURA: ${pokemones.size.height}</p>
<p class= "weight">PESO: ${pokemones.size.weight}</p>
<div class = "resistencia">
<p>RESISTENCIA:</p>
<p class= "parrafo">${pokemones.resistant[0]} , ${pokemones.resistant[1]}</p>
<p class= "parrafo">${pokemones.resistant[2]}</p>
</div>
</div>
</div>
</div>
</button>`;
})

function displayFilteredData(filteredData) {
const contenidoCard = document.querySelector(".adentro");
contenidoCard.innerHTML = ""; // Limpiar contenido existente

filteredData.forEach(pokemones => {
contenidoCard.innerHTML += `
<button class= "mostrar">
<div class= "card__inner">
<div class= "card__side card__side--front">
<div class="card-imag">
<img src="${pokemones.img}" class= "imagen" alt="">
</div>
<div class= "card-contenido">
<p class="numeroPokemon" >${pokemones.num}</p>
<h3>${pokemones.name}</h3>
<div class="poder">
<p>type: ${pokemones.type}</p>
<div class= "generacion">
<p>${pokemones.generation.num} - ${pokemones.generation.name}</p>
</div>
</div>
</div>
</div>
<div class= "card__side card__side--back">
<div class= "card__body">
<p class= "height">ALTURA: ${pokemones.size.height}</p>
<p class= "weight">PESO: ${pokemones.size.weight}</p>
<div class = "resistencia">
<p>RESISTENCIA:</p>
<p class= "parrafo">${pokemones.resistant[0]} , ${pokemones.resistant[1]}</p>
<p class= "parrafo">${pokemones.resistant[2]}</p>
</div>
</div>
</div>
</div>
</button>`;
});
}

// Obtener el elemento select del usuario
const selectElement = document.getElementById("select-ordenar");

// Escuchar el evento change del select
selectElement.addEventListener("change", function() {
const selectedOption = selectElement.value;
const sortedData = ordenarPokemones(selectedOption);

displayFilteredData(sortedData)

});

//funcionalidad del filtrado
document.getElementById("filterSelect").addEventListener("change", function () {
const filterValue = this.value;
let filteredData;

if (filterValue === "water") {

filteredData = filterByType(data.pokemon, "water");
} else if (filterValue === "fire") {

filteredData = filterByType(data.pokemon, "fire");
} else if (filterValue === "bug") {

filteredData = filterByType(data.pokemon, "bug");

}else if (filterValue === "electric") {

filteredData = filterByType(data.pokemon, "electric");

}else if (filterValue === "grass") {

filteredData = filterByType(data.pokemon, "grass");

}else {

filteredData = data.pokemon; // Mostrar todos los pokemon
}
// Lógica para mostrar los resultados filtrados en la interfaz
displayFilteredData(filteredData);
});


//funcionalidad del buscador
document.getElementById("busquedaPokemon").addEventListener ("keyup", function () {
const foundName = this.value;
const foundPokemon = findByName(data.pokemon, foundName);
const errorContainer = document.getElementById("notFound");
//console.log(foundPokemon);
contenidoCard.style.display = "grid"
errorContainer.style.display = "none";
displayFilteredData (foundPokemon);
if(foundPokemon.length === 0){
errorContainer.style.display = "block";
errorContainer.textContent = "Pokémon no encontrado. Inténtalo de nuevo.";
contenidoCard.style.display = "none"
}
})
Loading