Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
46bcd4c
Creacion de carpeta de imagenes
Natyushk Mar 15, 2024
18432ea
Imagenes de millonarios
Natyushk Mar 15, 2024
97f2c88
Imagenes de millonarios completo
Natyushk Mar 15, 2024
8fc1191
Imagenes de millonarios completo
Natyushk Mar 15, 2024
8194af7
Imagenes de millonarios completo
Natyushk Mar 15, 2024
abdf48c
Añadir urls
Natyushk Mar 15, 2024
6153934
Merge pull request #2 from Natyushk/Backend
Natyushk Mar 15, 2024
8ab0b7e
test de prompting correcto
sandymmora Mar 19, 2024
611a5b8
test de prompting correcto
sandymmora Mar 19, 2024
4d0c7f3
Merge pull request #3 from sandymmora/data
Natyushk Mar 19, 2024
2e0eeda
estructura HTML y view.js renderItems creacion ul y Li
sandymmora Mar 19, 2024
3dd336e
Merge pull request #1 from Natyushk/main
sandymmora Mar 19, 2024
1f86f49
Merge pull request #4 from sandymmora/data
Natyushk Mar 19, 2024
8c24619
Merge pull request #5 from Natyushk/data
Natyushk Mar 19, 2024
e7e4b4d
Cambios en la logica de view.js
Natyushk Mar 19, 2024
1082862
Actualizacion de main js
Natyushk Mar 19, 2024
bf25ee4
Cambios de foto de Bernard Arnault
Natyushk Mar 20, 2024
23910bc
Actualizacion de main js
Natyushk Mar 20, 2024
efb8235
Actualizacion de html y correccion de informacion en dataFunctions.js
Natyushk Mar 20, 2024
2959fb0
Actualizacion de logica de dataFunction y main
Natyushk Mar 20, 2024
7fbe678
correciones en archivos main.js,view.js e index.html para visualizaci…
sandymmora Mar 20, 2024
a03495d
eliminar logica de ul
Natyushk Mar 20, 2024
3c6b267
Se resolvio conflicto para correcciones en main.js view.js e index
sandymmora Mar 20, 2024
39d48fa
Merge branch 'data'
sandymmora Mar 20, 2024
dcdc9a6
Se terminaron los estilos y agregamos mas info en tarjetas
sandymmora Mar 21, 2024
c1ca92c
Estilos, se agrego descripción corta y padding
sandymmora Mar 21, 2024
ea883e6
Merge branch 'main' of https://github.com/Natyushk/DEV014-Dataverse i…
Natyushk Mar 21, 2024
46ae0ac
Merge branch 'main' into visualizarDatos
sandymmora Mar 21, 2024
9500b81
Merge pull request #8 from sandymmora/visualizarDatos
Natyushk Mar 21, 2024
0b00647
Cambios en main
Natyushk Mar 21, 2024
056d77a
cambios en el main
Natyushk Mar 21, 2024
4882e4a
Merge branch 'main' into VisualizarDatos
sandymmora Mar 21, 2024
c053ee8
Merge pull request #9 from Natyushk/VisualizarDatos
sandymmora Mar 21, 2024
2b11aaa
Funciones de filtrar y ordenar
sandymmora Mar 25, 2024
ca174eb
cambios en main.js para funciones
sandymmora Mar 25, 2024
c590b9c
Agregar funcion de calculo y promedio de la fortuna
Natyushk Mar 26, 2024
363c733
Merge pull request #10 from Natyushk/VisualizarDatos
sandymmora Mar 26, 2024
fe62bf3
Modificaciones en style.css para diseño responsive y estilo a element…
sandymmora Mar 26, 2024
bcf3fc1
Modificaciones en style.css para diseño responsive y estilo a element…
sandymmora Mar 26, 2024
eefa506
Merge branch 'main' into estilosResponsive
sandymmora Mar 26, 2024
55dcf07
Merge pull request #11 from Natyushk/estilosResponsive
Natyushk Mar 26, 2024
938f342
Actualizar funcion de calculo y promedio de la fortuna
Natyushk Mar 26, 2024
47f7ed6
Merge pull request #12 from Natyushk/VisualizarDatos
sandymmora Mar 26, 2024
a085926
Se agrego el boton limpiar y su funcionalidad
sandymmora Mar 26, 2024
abb39aa
Merge pull request #13 from Natyushk/resetButton
Natyushk Mar 26, 2024
86aa8cd
Cambios en codigo de archivos, ultima corrección
sandymmora Mar 28, 2024
ebd5a7a
Correcciones para Test OA´s
sandymmora Mar 28, 2024
16f6cce
Modificación de data para test y test prueba unitaria función ordenar
sandymmora Apr 1, 2024
2d6555b
Merge pull request #14 from Natyushk/dataTest
Natyushk Apr 1, 2024
55b28ef
Correcciones para pruebas y se completaron las pruebas unitarias
sandymmora Apr 3, 2024
1a38817
Merge pull request #15 from Natyushk/dataTest
Natyushk Apr 3, 2024
a460b34
Modificacion en el readme
Natyushk Apr 3, 2024
52988b8
Modificacion en el readme
Natyushk Apr 3, 2024
f70bf23
Cambio de ruta de imagen del prompt
Natyushk Apr 3, 2024
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
Binary file added IMAGENES/Alice Walton.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 IMAGENES/Bernard Arnault.jpeg
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 IMAGENES/Bill Gates.jpeg
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 IMAGENES/Carlos Slim.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 IMAGENES/François_Pinault.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 IMAGENES/Giovani Ferrero.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 IMAGENES/Jim_Walton.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 IMAGENES/Larry Page.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 IMAGENES/Lei Jun.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 IMAGENES/Ma-Huateng.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 IMAGENES/Mark Zuckerberg.jpeg
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 IMAGENES/Mike Bloomberg.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 IMAGENES/Mukesh Ambani.jpeg
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 IMAGENES/Sergey Brin.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 IMAGENES/Steve Ballmer.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 IMAGENES/Zhong Shanshan.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 IMAGENES/charles koch.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 IMAGENES/elon-musk.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 IMAGENES/francoise-bettencourt-meyers.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 IMAGENES/jack Ma.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 IMAGENES/jeff-bezos.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 IMAGENES/lakshmi-mittal.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 IMAGENES/larry ellison.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 IMAGENES/warren buffett.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 Prompt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,064 changes: 27 additions & 1,037 deletions README.md

Large diffs are not rendered by default.

13,949 changes: 13,949 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

523 changes: 288 additions & 235 deletions src/data/dataset.js

Large diffs are not rendered by default.

84 changes: 79 additions & 5 deletions src/dataFunctions.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,83 @@
// Estas funciones son ejemplos, aquí puedes desarrollar tus propias funciones.
// Función para filtrar los datos por continente
export const filterByContinent = (data, continent) => {
if (continent === 'Todos') {
return data; // No aplicar ningún filtro si se selecciona 'Todos'
} else {
return data.filter(item => item.extraInfo.continent === continent);
}
};

// Función para ordenar los datos por fortuna (mayor a menor o menor a mayor) o por nombre
export const sortBy = (data, sortOrder) => {
if (sortOrder === 'fortune-asc' || sortOrder === 'fortune-desc') {
return data.sort((a, b) => {
const fortuneA = parseFortune(a.facts.fortune);
const fortuneB = parseFortune(b.facts.fortune);
return sortOrder === 'fortune-asc' ? fortuneA - fortuneB : fortuneB - fortuneA;
});
} else if (sortOrder === 'asc' || sortOrder === 'desc') {
return data.sort((a, b) => {
const nameA = a.name.toUpperCase();
const nameB = b.name.toUpperCase();
return sortOrder === 'asc' ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
});
}
};
// export const sortBy = (data, sortOrder) => {
// return data.sort((a, b) => {
// const nameA = a.name.toUpperCase();
// const nameB = b.name.toUpperCase();
// return sortOrder === 'asc' ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
// });
// };

// Función auxiliar para convertir la fortuna a un número
const parseFortune = (fortuneString) => {
return parseFloat(fortuneString.replace(/[^\d.-]/g, ''));
};

// Función para calcular la suma total y el promedio de las fortunas
export const calculateFortuneStats = (data) => {
const filteredFortunes = data.map(item => parseFortune(item.facts.fortune));
const totalFortune = filteredFortunes.reduce((total, fortune) => total + fortune, 0);
<<<<<<< Updated upstream
const averageFortune = (totalFortune / filteredFortunes.length).toFixed(2);

return [ totalFortune, averageFortune ];
=======
const averageFortune = totalFortune / filteredFortunes.length;

export const example = () => {
return 'example';
//Formatear la suma total y el promedio
const formattedTotalFortune = formatFortune(totalFortune);
const formattedAverageFortune = formatFortune(averageFortune);

return { totalFortune: formattedTotalFortune, averageFortune: formattedAverageFortune };
};

// Función auxiliar para formatear la fortuna en el formato deseado
const formatFortune = (fortune) => {
// Convertir la fortuna a cadena y agregar 'B' al final
return `$${fortune.toFixed(2)}B`;
};

export const anotherExample = () => {
return [];
// Función auxiliar para convertir la fortuna a un número
const parseFortune = (fortuneString) => {
// Verificar si la cadena de fortuna es nula, indefinida o no es una cadena
if (fortuneString === null || fortuneString === undefined || typeof fortuneString !== 'string') {
return 0; // Devolver 0 si la cadena de fortuna no es válida
}

// Eliminar caracteres no numéricos excepto "." y "-"
const sanitizedString = fortuneString.replace(/[^0-9.-]/g, '');

// Intentar convertir la cadena a un número de punto flotante
const parsedFortune = parseFloat(sanitizedString);

// Verificar si el resultado es NaN o infinito
if (isNaN(parsedFortune) || !isFinite(parsedFortune)) {
return 0; // Devolver 0 si el resultado no es un número finito
}

return parsedFortune; // Devolver la fortuna convertida si es válida
>>>>>>> Stashed changes
};
36 changes: 35 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,44 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dataverse</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<header>
<h1>Personas mas ricas del mundo</h1>
</header>
<main id="root">
<h2></h2>
<section>
<label for="continent-filter">Filtrar por continente:</label>
<select name="continente" id="continent-filter" data-testid="select-filter" >
<option value="Todos">Todos</option>
<option value="Oceanía">Oceanía</option>
<option value="América">América</option>
<option value="Asia">Asia</option>
<option value="Africa">África</option>
<option value="Europa">Europa</option>
<option value="Antartida">Antártida</option>
</select>
<label for="sort-by">Ordenar por:</label>
<select name="name" id="sort-by" data-testid="select-sort">
<option value="asc">Nombre (A-Z)</option>
<option value="desc">Nombre (Z-A)</option>
<option value="fortune-asc">Fortuna (Ascendente)</option>
<option value="fortune-desc">Fortuna (Descendente)</option>
</select>
<button data-testid="button-clear" id="reset-button">Limpiar</button>
</section>
<div id="fortune-stats">
<p id="total-fortune">Suma total de fortunas:</p>
<p id="average-fortune">Promedio de fortunas:</p>
</div>
</main>
<footer>
<p>Nataly Molano y Sandra Morales</p>
</footer>
<script src="main.js" type="module"></script>
</body>
</html>
</html>
95 changes: 92 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,95 @@
import { example } from './dataFunctions.js';
import data from './data/dataset.js';

import { renderItems } from './view.js';

import data from './data/dataset.js';
// Importar funciones
import { filterByContinent, sortBy, calculateFortuneStats } from './dataFunctions.js';

// Referencias a elementos del DOM
const continentFilterSelect = document.querySelector('#continent-filter');
const sortBySelect = document.querySelector('#sort-by');
const totalFortuneElement = document.querySelector('#total-fortune');
const averageFortuneElement = document.querySelector('#average-fortune');
const resetButton = document.querySelector('#reset-button');

// Renderizar los elementos inicilmente
<<<<<<< Updated upstream
let richPeopleList = document.querySelector("main").appendChild(renderItems(sortBy(data, 'asc')));
=======
richPeopleList.appendChild(renderItems(data));

// Manejador de evento para cambio en select
continentFilterSelect.addEventListener('change', () => {
const continent = continentFilterSelect.value;
const filteredData = filterByContinent(data, continent);
richPeopleList.innerHTML = '';
richPeopleList.appendChild(renderItems(filteredData));
updateFortuneStats(filteredData);
});

// Manejador de evento para el botón de ordenar
sortBySelect.addEventListener('change', () => {
const [field, order] = sortBySelect.value.split('-');
const sortedData = sortBy(filterByContinent(data,continentFilterSelect.value), field, order);
richPeopleList.innerHTML = '';
richPeopleList.appendChild(renderItems(sortedData));
updateTotalFortune(sortedData);
});

//Función para actualizar y mostrar la fortuna total
const updateTotalFortune = (data) => {
const totalFortune = calculateTotalFortune(data);
totalFortuneElement.textContent = `Fortuna total: ${formatFortune(totalFortune)}`;


/*const sortedData = sortBy(data, field, order);
richPeopleList.innerHTML = '';
richPeopleList.appendChild(renderItems(sortedData));*/
};
>>>>>>> Stashed changes

// Función para actualizar y mostrar la fortuna total y el promedio
const updateFortuneStats = (data) => {
const [formattedTotalFortune, formattedAverageFortune] = calculateFortuneStats(data)
totalFortuneElement.textContent = `Suma total de fortunas: $${formattedTotalFortune.toLocaleString('en')} B`;
averageFortuneElement.textContent = `Promedio de fortunas: $${isNaN(formattedAverageFortune) ? 0 : formattedAverageFortune} B`;
};

// Actualizar las estadísticas de fortuna inicialmente
updateFortuneStats(data);

// Manejador de evento para cambio en select para filtrar por continente
continentFilterSelect.addEventListener('change', () => {
const continent = continentFilterSelect.value;
const filteredData = filterByContinent(data, continent);
sortBySelect.value = 'asc';
richPeopleList.remove();
richPeopleList = document.querySelector("main").appendChild(renderItems(filteredData));
updateFortuneStats(filteredData);
});

// Manejador de evento para cambio en select para ordenar
// sortBySelect.addEventListener('change', () => {
// const [field, order] = sortBySelect.value.split('-');
// const sortedData = sortBy(filterByContinent(data,continentFilterSelect.value), field, order);
// richPeopleList.remove();
// richPeopleList = document.querySelector("main").appendChild(renderItems(sortedData));
// updateFortuneStats(sortedData);
// });
sortBySelect.addEventListener('change', () => {
const order = sortBySelect.value;
const sortedData = sortBy(filterByContinent(data,continentFilterSelect.value), order);
richPeopleList.remove();
richPeopleList = document.querySelector("main").appendChild(renderItems(sortedData));
updateFortuneStats(sortedData);
});

console.log(example, renderItems(data), data);
//Función para boton limpiar
resetButton.addEventListener('click', (event) => {
continentFilterSelect.value = 'Todos';
sortBySelect.value = 'asc';
richPeopleList.remove();
richPeopleList = document.querySelector("main").appendChild(renderItems(sortBy(data, 'asc')));
updateFortuneStats(data);
console.log('Evento', event.type);
});
160 changes: 160 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
:root {
--main-color: #FFAC46;
--orange: #C96C34;
--red: #922B21;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body{
background-color: #333333;
font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif;
color: white;
min-height: 100vh;
position: relative;
}
header{
height: 200px;
padding-top: 64px;
text-align: center;
background-color: var(--main-color);
color: var(--red);
}
h1{
align-self: center;
font-size: 50px;
}
main {
text-align: center;
}
section {
padding: 28px;
width: 100%;
font-size: 28px;
display: flex;
justify-content: center;
border-bottom: 8px solid var(--main-color);
}
div{
padding: 24px;
display: flex;
flex-direction: column;
justify-content: center;
}
div p {
font-size: 28px;
}
label {
margin-left: 24px;
}
select {
border-radius: 8px;
font-size: 28px;
margin-left: 24px;
outline: none;
}
select:focus{
border:4px solid var(--main-color);
}
select:hover{
box-shadow: 3px 3px var(--main-color);
}
button{
width: 150px;
border-radius: 8px;
margin-left: 24px;
font-size: 28px;
box-shadow: 5px 5px;
}
button:hover {
background-color: var(--main-color);
}
ul{
padding: 24px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.card {
width: 380px;
height: 550px;
margin: 12px;
padding: 0 12px 0 12px;
border-radius: 8px ;
background-color: var(--main-color);
display: flex;
flex-direction: column;
align-items: center;
list-style: none;
flex-grow: 1;
color: var(--red);
}
li p:nth-child(2){
font-size: 32px;
}
li p:nth-child(4), p:nth-child(5) {
margin-top: 12px;
}
img {
width: 300px;
height: 300px;
margin: 24px;
border-radius: 100%;
}
footer{
width: 100%;
height: 32px;
background-color:var(--red);
position: absolute;
bottom: 0;
text-align: center;
}
footer p {
padding: 8px;
}
@media (max-width: 1000px) {
header {
height: 250px;
padding: 24px;
}
body{
width: 100%;
}
section {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
}
label {
margin-top: 24px;
}
button {
margin-top: 28px;
}
}

@media (max-width: 400px) {
.card {
width: 220px;
height: px;
margin: 8px;
padding: 0 8px 0 8px;
border-radius: 8px ;
background-color: var(--main-color);
display: flex;
flex-direction: column;
align-items: center;
list-style: none;
color: var(--red);
}
img {
width: 200px;
height: 200px;
margin: 24px;
border-radius: 100%;
}

}
Loading