Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules/
/playwright-report/
/playwright/.cache/
.vscode/
package-lock.json
489 changes: 104 additions & 385 deletions README.md

Large diffs are not rendered by default.

Binary file added Screenshot 2024-04-04 122334.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 imagenes/Chemex.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/aeropress.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/afogatto.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/americano.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/cafe-irlandes.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/cafe-turco.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/cappucino.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/espresso tonic.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/espresso.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/flatwhite.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/francesa.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/frappé.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/ice latte.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/kalita wave.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/latte.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/longblack.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/lungo.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/macchiato.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/mocaccino.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/moka italiana.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/origami.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/ristretto.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/syphon.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/v60.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5,922 changes: 5,922 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
"jest": {
"testEnvironment": "jsdom"
}
}
}
440 changes: 225 additions & 215 deletions src/data/dataset.js

Large diffs are not rendered by default.

28 changes: 21 additions & 7 deletions src/dataFunctions.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
// Estas funciones son ejemplos, aquí puedes desarrollar tus propias funciones.

export const example = () => {
return 'example';
//Aquí voy a filtrar de la data un facts que quiero facilitar:
export const filterData = (data, filterBy, value) => {
if (!value) {
return data;
}
//console.log('filtrado por', filterBy);
return data.filter(bebida => bebida.facts[filterBy].toLowerCase() === value.toLowerCase());
};

export const anotherExample = () => {
return [];
};
export const sortData = (data, propertyName, sortOrder) => {
return data.slice().sort((a, b) => {
//const nameA = a[propertyName].toUpperCase();
const nameA = typeof a[propertyName] === 'string' ? a[propertyName].toUpperCase() : '';
const nameB = typeof b[propertyName] === 'string' ? b[propertyName].toUpperCase() : '';
//const nameB = b[propertyName].toUpperCase();
if (sortOrder === "asc") {
return nameA.localeCompare(nameB);
} else if (sortOrder === "desc") {
return nameB.localeCompare(nameA);
}
return 0;
});
};
Binary file added src/fondo/Screenshot 2024-04-04 122334.png
Binary file added src/fondo/Screenshot 2024-05-07 220432.png
Binary file added src/fondo/Screenshot 2024-05-07 220628.png
Binary file added src/fondo/bayas-cafe-1-scaled.jpg
Binary file added src/fondo/prompt.png
Binary file added src/fondo/respuestaPrompt.png
Binary file added src/images/Chemex.jpg
Binary file added src/images/aeropress.jpg
Binary file added src/images/afogatto.jpg
Binary file added src/images/americano.jpg
Binary file added src/images/cafe-irlandes.jpg
Binary file added src/images/cafe-turco.jpg
Binary file added src/images/cappucino.jpg
Binary file added src/images/espresso-tonic.jpg
Binary file added src/images/espresso.jpg
Binary file added src/images/flat-white.jpeg
Binary file added src/images/francesa.jpg
Binary file added src/images/frappé.jpg
Binary file added src/images/ice latte.jpg
Binary file added src/images/kalita-wave.jpg
Binary file added src/images/latte.jpg
Binary file added src/images/longblack.jpg
Binary file added src/images/lungo.jpg
Binary file added src/images/macchiato.jpg
Binary file added src/images/mocaccino.jpg
Binary file added src/images/moka-italiana.jpg
Binary file added src/images/origami.jpg
Binary file added src/images/ristretto.jpg
Binary file added src/images/syphon.jpg
Binary file added src/images/v60.jpg
32 changes: 23 additions & 9 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dataverse</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<script src="main.js" type="module"></script>
</body>
</html>

<head>
<meta charset="utf-8">
<title>Dataverse</title>
<link rel="stylesheet" href="style.css" />
</head>

<body>
<header>
<h1>Visual Coffee</h1>
<main>
<h2> Llegaste al lugar indicado para saber más acerca de tus preparaciones de cafés favoritas</h2>
</main>
<img src="banner/coffee-latte-art-aesthetic-facebook-cover.jpg" alt="banner" class="headerImage">
</header>
<button id="botonLimpiar" data-testid="button-clear">Boton limpiar</button>
<nav id="nav"> </nav> <!-- --> <!-- nav contiene los filtros </div> -->
<div id="root"> </div> <!-- root contiene los li que van dentro de los ul -->

<footer> By Gisela Saavedra </footer>
<script src="main.js" type="module"></script>
</body>
</html>
57 changes: 54 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,57 @@
import { example } from './dataFunctions.js';
import { renderItems } from './view.js';

import { renderItems, createSelect, createSelectSort } from './view.js';
import data from './data/dataset.js';
import { sortData } from './dataFunctions.js';

console.log(example, renderItems(data), data);
const root = document.getElementById("root");
const nav = document.getElementById("nav");
const botonLimpiar = document.getElementById("botonLimpiar"); //Obtener referencia al botón de limpiar
// Crear el select origen y agregarlo al DOM
const selectOrderByOrigen = createSelect(data, 'origen'); //mas descriptivas las constantes
nav.appendChild(selectOrderByOrigen);

// Crear el select molienda y agregarlo al DOM
const selectOrderByMolienda = createSelect(data, 'molienda');
nav.appendChild(selectOrderByMolienda);

//crear el select ordenado y agregarlo al DOM
//const select3 = createSelect(data, 'name');
//root.appendChild(select3);
const selectOrderByPropertyName = createSelectSort(data, 'name');
nav.appendChild(selectOrderByPropertyName);
const propertyName = 'name';

// Agregar un evento de clic al botón
botonLimpiar.addEventListener("click", limpiarFiltros);
// Función para limpiar los filtros
function limpiarFiltros() {
// Limpiar los filtros aplicados
document.getElementById("filtro").innerHTML = "";
}
// Agregar un event listener para el evento change // para el select de ordenar
selectOrderByPropertyName.addEventListener("change", (event) => {
const sortOrder = event.target.value;
// Llamar a la función para ordenar la data y renderizar los elementos
if (sortOrder) {
const sortedData = sortData(data, propertyName, sortOrder);
root.appendChild(renderItems(sortedData));
}
});
// Agregar event listener al select
selectOrderByOrigen.addEventListener("change", (event) => {
const selectedValue = event.target.value;
// Aquí puedes realizar acciones basadas en el valor seleccionado
//console.log("Valor seleccionado:", selectedValue);
// Luego, puedes llamar a renderItems nuevamente con el origen filtrado
root.appendChild(renderItems(data, selectedValue, 'origen'));
});

selectOrderByMolienda.addEventListener("change", (event) => {
const selectedValue = event.target.value;
// Aquí puedes realizar acciones basadas en el valor seleccionado
//console.log("Valor seleccionado:", selectedValue);
// Luego, puedes llamar a renderItems nuevamente con el origen filtrado
root.appendChild(renderItems(data, selectedValue, 'molienda'));
});
// Renderizar los elementos por primera vez sin filtro
root.appendChild(renderItems(data));
95 changes: 95 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
img {
width: 280px;
margin: 25px;
}

ul {
display: flex;
flex-wrap: wrap;
justify-content: center;
padding-right: 5px;
}

li {
border: 11px solid rosybrown;
padding: 15px;
margin: 20px;
border-radius: 10px;
list-style: none;
width: 350px;
display: flex;
flex-wrap: nowrap;
flex-direction: column;
justify-content: space-evenly;
background-color: rgb(229, 190, 93);
align-items: stretch;
font-family: monospace, sans-serif;
font-style: normal;
font-weight: 200;
}

h1 {
font-family: "Avenir Next", sans-serif;
display: flex;
flex-direction: row-reverse;
flex-wrap: nowrap;
justify-content: space-evenly;
color: brown;
}

h2 {
font-family: "Avenir Next", sans-serif;
display: flex;
flex-direction: row-reverse;
flex-wrap: nowrap;
justify-content: space-evenly;
color: brown;
}

.headerImage {
width: 1500px;
height: 450px;
padding: 20px;
border-radius: 50px;
}

body {
background-color: mistyrose;
}

label {
padding: 30px;
font-family: sans-serif;
color: brown;
}

dt,
dd {
color: brown;
}

#nav {
flex-direction: row;
margin-top: 10px;
padding-left: 400px;
border: 5px solid rosybrown;
background-color: rgb(100, 120, 68);
color: antiquewhite
}

.select-style {
margin-right: 50px;
border-radius: 20px;
}

footer {
color: brown;
font-family: sans-serif;
margin: 50px;
padding: 50px;
}

.select-style{
padding: 2px;
}

142 changes: 138 additions & 4 deletions src/view.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,140 @@
export const renderItems = (data) => {
console.log(data)
// Aquí comienza tu código y puedes retornar lo que tu necesites
return 'example';
import { filterData } from "./dataFunctions.js";

// creo el select
export const createSelect = (data, propertyName) => {
// Obtener todos los valores únicos de la propiedad especificada en los datos
const propertyValues = data.map((item) => item.facts[propertyName]);

// Eliminar valores duplicados usando un conjunto (Set)
// eslint-disable-next-line no-undef
const uniqueValues = new Set(propertyValues);
const span = document.createElement("span")
const label = document.createElement("label");
label.setAttribute("for", propertyName)

const select = document.createElement("select");
select.setAttribute("id", propertyName)
select.setAttribute("name", propertyName)
select.setAttribute("class", "select-style")

// Agregar una opción adicional al principio del select que no esté seleccionada
const defaultOption = document.createElement("option");
defaultOption.value = ""; // Valor vacío
defaultOption.textContent = `Seleccione ${propertyName} (sin filtro)`; // Texto descriptivo
//defaultOption.disabled = true; // Deshabilitar la opción para que no se pueda seleccionar
//defaultOption.selected = true; // No seleccionar la opción por defecto
select.appendChild(defaultOption);

// Agregar una clase al select
select.classList.add("select-style");
// Agregar una opción por cada valor único de la propiedad
uniqueValues.forEach((value) => {
const optionElement = document.createElement("option");
optionElement.value = value;
optionElement.textContent = value;
select.appendChild(optionElement);
});
span.append(label, select)
return span;
};
// Crear el selectSort
export const createSelectSort = (data, propertyName) => {
const select = document.createElement("select");

// Agregar una opción adicional al principio del select que no esté seleccionada
const defaultOption = document.createElement("option");
defaultOption.value = ""; // Valor vacío
defaultOption.textContent = `Categoría ${propertyName} (sin filtro)`; // Texto descriptivo
//defaultOption.disabled = true; // Deshabilitar la opción para que no se pueda seleccionar
//defaultOption.selected = true; // No seleccionar la opción por defecto
select.appendChild(defaultOption);

// Agregar opciones para orden ascendente y descendente
const ascendingOption = document.createElement("option");
ascendingOption.value = "asc";
ascendingOption.textContent = "Ordenar ascendente";
select.appendChild(ascendingOption);

const descendingOption = document.createElement("option");
descendingOption.value = "desc";
descendingOption.textContent = "Ordenar descendente";
select.appendChild(descendingOption);

return select;
};

export const renderItems = (data, value = null, filterBy=null) => {
// Eliminar la lista ul existente del DOM si existe
const existingUl = document.querySelector("ul");
if (existingUl) {
existingUl.parentNode.removeChild(existingUl);
}

const newUl = document.createElement("ul");


// Filtrar los datos según el origen especificado si existe
const filteredData = value ? filterData(data,filterBy, value) : data;

filteredData.forEach((element) => {
//console.log(element)
const newLi = document.createElement("li"); //un elemento li por cada elemento en data
newLi.setAttribute("itemscope", "")
newLi.setAttribute("itemType", element.id)

const newImage = document.createElement("img"); //un elemento img para mostrar la imagen
newImage.setAttribute("src", element.imageUrl); //utilizamos la url de la imagen del doc actual

const name = document.createElement("dt");
name.textContent = "Nombre:";
const cafeName = document.createElement("dd");
cafeName.textContent = element.name; //añadimos el nombre al elemento actual

const shortDescription = document.createElement("dt");
shortDescription.textContent = "Descripción:";
const cafeDescription = document.createElement("dd");
cafeDescription.textContent = element.shortDescription;

//Creamos una lista para los hechos de cada café
const origen = document.createElement("dt");
origen.textContent = "Café origen:";
const cafeOrigen = document.createElement("dd");
cafeOrigen.textContent = element.facts.origen;

const tiempoDeExtraccion = document.createElement("dt");
tiempoDeExtraccion.textContent = "Tiempo de extracción:";
const cafeTiempoDeExtraccion = document.createElement("dd");
cafeTiempoDeExtraccion.textContent = element.facts.tiempoDeExtraccion;

const porcentajeDeContenido = document.createElement("dt");
porcentajeDeContenido.textContent = "Porcentaje de contenido:";
const cafePorcentajeDeContenido = document.createElement("dd");
cafePorcentajeDeContenido.textContent = element.facts.porcentajeDeContenido;

const molienda = document.createElement("dt");
molienda.textContent = "Molienda:";
const cafeMolienda = document.createElement("dd");
cafeMolienda.textContent = element.facts.molienda;


newLi.append(
cafeName,
newImage,
shortDescription,
cafeDescription,
origen,
cafeOrigen,
molienda,
cafeMolienda,
porcentajeDeContenido,
cafePorcentajeDeContenido,

);
newUl.appendChild(newLi);
});
// Agregar la nueva lista al body
// Agregar el select al contenedor div

//document.body.appendChild(newUl);
return newUl
};
Loading