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
15 changes: 6 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="./styles.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@300;500;700&display=swap" rel="stylesheet">

<link rel="stylesheet" href="./styles.css">

<title>YardSale: tienda online de cositas chidas</title>
<title>YardSale: tienda de cosas chidas</title>
</head>
<body>
<nav>
Expand Down Expand Up @@ -46,7 +43,7 @@
<ul>
<li class="navbar-email">[email protected]</li>
<li class="navbar-shopping-cart">
<img src="./icons/icon_shopping_cart.svg" alt="shopping cart">
<img src="./icons/icon_shopping_cart.svg" alt="shopping-cart" >
<div>2</div>
</li>
</ul>
Expand Down Expand Up @@ -177,7 +174,7 @@
</div>
</aside>

<section class="main-container">
<section class="main-container">
<div class="cards-container">

<!-- <div class="product-card">
Expand All @@ -196,6 +193,6 @@
</div>
</section>

<script src="./main.js"></script>
<script src="main.js"></script>
</body>
</html>
</html>
143 changes: 71 additions & 72 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,117 +1,116 @@
const menuEmail = document.querySelector('.navbar-email');
const menuHamIcon = document.querySelector('.menu');
const menuCarritoIcon = document.querySelector('.navbar-shopping-cart');
const productDetailCloseIcon = document.querySelector('.product-detail-close')
const desktopMenu = document.querySelector('.desktop-menu');
const mobileMenu = document.querySelector('.mobile-menu');
const shoppingCartContainer = document.querySelector('#shoppingCartContainer');
const productDetailContainer = document.querySelector('#productDetail');
const cardsContainer = document.querySelector('.cards-container');

menuEmail.addEventListener('click', toggleDesktopMenu);
menuHamIcon.addEventListener('click', toggleMobileMenu);
menuCarritoIcon.addEventListener('click', toggleCarritoAside);
productDetailCloseIcon.addEventListener('click', closeProductDetailAside);
const menuEmail = document.querySelector(".navbar-email");
const desktopMenu = document.querySelector(".desktop-menu");
const menuHamIcon = document.querySelector(".menu");
const mobileMenu = document.querySelector(".mobile-menu");
const menuCarritoIcon = document.querySelector(".navbar-shopping-cart");
const closeProductDetailIcon = document.querySelector(".product-detail-close");
const shoppingCartContainer = document.querySelector("#shoppingCartContainer");
const productDetailContainer = document.querySelector("#productDetail");
const cardsContainer = document.querySelector(".cards-container");

menuEmail.addEventListener("click", toggleDesktopMenu);
menuHamIcon.addEventListener("click", toggleMobilepMenu);
menuCarritoIcon.addEventListener("click", toggleCarrito);
closeProductDetailIcon.addEventListener("click", closeProductDeatailAside);

function toggleDesktopMenu() {
const isAsideClosed = shoppingCartContainer.classList.contains('inactive');
const isAsideClosed = shoppingCartContainer.classList.contains("inactive");

if (!isAsideClosed) {
shoppingCartContainer.classList.add('inactive');
shoppingCartContainer.classList.add("inactive");
}

desktopMenu.classList.toggle('inactive');
}

function toggleMobileMenu() {
const isAsideClosed = shoppingCartContainer.classList.contains('inactive');
desktopMenu.classList.toggle("inactive");
}

function toggleMobilepMenu() {
const isAsideClosed = shoppingCartContainer.classList.contains("inactive");
if (!isAsideClosed) {
shoppingCartContainer.classList.add('inactive');
shoppingCartContainer.classList.add("inactive");
}

closeProductDetailAside();
mobileMenu.classList.toggle('inactive');
closeProductDeatailAside();

mobileMenu.classList.toggle("inactive");
}

function toggleCarritoAside() {
const isMobileMenuClosed = mobileMenu.classList.contains('inactive');

if (!isMobileMenuClosed) {
mobileMenu.classList.add('inactive');
function toggleCarrito() {
const ismobileMenuClosed = mobileMenu.classList.contains("inactive");
if (!ismobileMenuClosed) {
mobileMenu.classList.add("inactive");
}

const isProductDetailClosed = productDetailContainer.classList.contains('inactive');

const isProductDetailClosed =
productDetailContainer.classList.contains("inactive");
if (!isProductDetailClosed) {
productDetailContainer.classList.add('inactive');
productDetailContainer.classList.add("inactive");
}

shoppingCartContainer.classList.toggle('inactive');
shoppingCartContainer.classList.toggle("inactive");
}

function openProductDetailAside() {
shoppingCartContainer.classList.add('inactive');
productDetailContainer.classList.remove('inactive');
shoppingCartContainer.classList.add("inactive");
productDetailContainer.classList.remove("inactive");
}

function closeProductDetailAside() {
productDetailContainer.classList.add('inactive');
function closeProductDeatailAside() {
productDetailContainer.classList.add("inactive");
}

const productList = [];
productList.push({
name: 'Bike',
name: "Bike",
price: 120,
image: 'https://images.pexels.com/photos/276517/pexels-photo-276517.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940',
image:
"https://images.pexels.com/photos/276517/pexels-photo-276517.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
});
productList.push({
name: 'Pantalla',
name: "Pantalla",
price: 220,
image: 'https://images.pexels.com/photos/276517/pexels-photo-276517.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940',
image:
"https://images.pexels.com/photos/276517/pexels-photo-276517.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
});
productList.push({
name: 'Compu',
price: 620,
image: 'https://images.pexels.com/photos/276517/pexels-photo-276517.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940',
name: "Compu",
price: 320,
image:
"https://images.pexels.com/photos/276517/pexels-photo-276517.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
});

function renderProducts(arr) {
for (product of arr) {
const productCard = document.createElement('div');
productCard.classList.add('product-card');

// product= {name, price, image} -> product.image
const productImg = document.createElement('img');
productImg.setAttribute('src', product.image);
productImg.addEventListener('click', openProductDetailAside);

const productInfo = document.createElement('div');
productInfo.classList.add('product-info');

const productInfoDiv = document.createElement('div');

const productPrice = document.createElement('p');
productPrice.innerText = '$' + product.price;
const productName = document.createElement('p');
const productCard = document.createElement("div");
productCard.classList.add("product-card");

const productImg = document.createElement("img");
productImg.setAttribute("src", product.image);
productImg.addEventListener("click", openProductDetailAside);

const productInfo = document.createElement("div");
productInfo.classList.add("product-info");

const productInfoDiv = document.createElement("div");

const productPrice = document.createElement("p");
productPrice.innerText = "$" + product.price;
const productName = document.createElement("p");
productName.innerText = product.name;

productInfoDiv.appendChild(productPrice);
productInfoDiv.appendChild(productName);
const productInfoFigure = document.createElement('figure');
const productImgCart = document.createElement('img');
productImgCart.setAttribute('src', './icons/bt_add_to_cart.svg');
productInfoFigure.appendChild(productImgCart);

const productInfoFigure = document.createElement("figure");
const productImgCard = document.createElement("img");
productImgCard.setAttribute("src", "./icons/bt_add_to_cart.svg");

productInfoFigure.appendChild(productImgCard);

productInfo.appendChild(productInfoDiv);
productInfo.appendChild(productInfoFigure);

productCard.appendChild(productImg);
productCard.appendChild(productInfo);

cardsContainer.appendChild(productCard);
}
}
Expand Down
Loading