diff --git a/index.html b/index.html new file mode 100644 index 000000000..2036104fe --- /dev/null +++ b/index.html @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + YardSale: tienda online de cositas chidas + + + + + + + + + + + + + + +
+
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/main.js b/main.js new file mode 100644 index 000000000..9a1a8694f --- /dev/null +++ b/main.js @@ -0,0 +1,205 @@ + + + +// selecionamos el elemento que contiene el mail de l usuario +const navbar_email_element = document.querySelector('.navbar-email'); + +// Seleccionamos el elemento que contiene el menu en la version escritorio +const desktopMenuElement = document.querySelector('.desktop-menu'); + +//Seleccionamos el icono hamburuqesa +const hamburguerIconElement = document.querySelector('#hamIcon'); + +// Seleccionamos el menu en su version mobile +const mobileMenuElement = document.querySelector('.mobile-menu'); + +//icono del carrito de compras +const menuCarritoIcon = document.querySelector('.navbar-shopping-cart') + +// aside que aparece con al descripcion del carrito de compras cuando hacemos click en el carrito +const asideComprasDetail = document.querySelector('#shoppingCartContainer') + +// aside que contiene los detalles y descripcion del producto que es seleccionado de la lista de productos. +const asideProductDetail = document.querySelector('#productDetail'); + +//boton que cierra el aside de la descripcion del producto +const btn_clouse_product_detail = document.querySelector('#btn_clouse_productDetail'); + + +// Esconde o muestra el menu cuando hacemos click en el mail del uduario en la vercion de escritorio +const togleDesktopMenu = () => { + const isCarritoMenuClouse = asideComprasDetail.classList.contains('inactive'); + + if (!isCarritoMenuClouse) { + asideComprasDetail.classList.add('inactive'); + } + desktopMenuElement.classList.toggle('inactive'); + + // cerramos el aside con la descripcion del producto + cerrarProductDetail(); +} +// creamos la misma funcion para poner la clase incative pero ahora para cuando hagomos clik en el menu hamburguesas +const toggleMobileMenu = () => { + const isCarritoMenuClouse = asideComprasDetail.classList.contains('inactive'); + + if (!isCarritoMenuClouse) { + asideComprasDetail.classList.add('inactive'); + } + + mobileMenuElement.classList.toggle('inactive') + // cerramos el aside con la descripcion del producto + cerrarProductDetail(); +} + +// funcion para poner la clase inactive al icono del carrito +const toggleCarritoIcon = () => { + + const isMobileMenuElementCLouse = mobileMenuElement.classList.contains('inactive'); + const isDesktopMenuClose = desktopMenuElement.classList.contains('inactive'); + if (!isMobileMenuElementCLouse) { + mobileMenuElement.classList.add('inactive'); + } + if (!isDesktopMenuClose) { + desktopMenuElement.classList.add('inactive') + } + + asideComprasDetail.classList.toggle('inactive'); + + // cerramos el aside con la descripcion del producto + cerrarProductDetail(); +} + + +//creamos una funcion mas generica para agregar la clase inactive y poder usarla con otros elementos +// const tooggleInactiveClass = (element)=>{ +// element.classList.tooggle('inactive'); +// } + +// escuchamos si el usuario hace click en el mail de l usaurio en la barra de navegacion +navbar_email_element.addEventListener('click', togleDesktopMenu); + +// escuchamos si el usuario hace click en ICONO HAMBURGUEZA en la barra de navegacion +hamburguerIconElement.addEventListener('click', toggleMobileMenu); + +// escuchamos si el usuario hace click en EL CARRITO DE COMPRAS en la barra de navegacion +menuCarritoIcon.addEventListener('click', toggleCarritoIcon); + +//array de la lista de producto cuando se hiciera una consulta al servidor pidiendo la lista de productos, que luego cargaremos en el html +const productList = []; + +productList.push({ + 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", +}) +productList.push({ + name: 'Escritorio', + price: 180, + image: "https://images.pexels.com/photos/265129/pexels-photo-265129.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1", +}) +productList.push({ + name: 'Computador', + price: 200, + image: "https://media.istockphoto.com/id/1394988455/es/foto/port%C3%A1til-con-pantalla-en-blanco-sobre-fondo-blanco.jpg?s=2048x2048&w=is&k=20&c=Mw1-pF7aAe5Y4KK4VdlVoLehx5y-0gQAMNfNlwoJ6Qc=", +}) + +// CONTENEDOR DE LAS TARJETAS DE LOS PRODUCTOS +const cardProducContainerElement = document.querySelector('.cards-container'); + + + +// for in para los indices del arreglo +// for (indice in productList) { +// console.log(indice) +// } + +// FUNCION PARA CARGAR LA LISTA DE PRODUCTOS A LA PAGINA A PARTIR DE UN ARRAY DE PRODUCTOS +function renderProductList(arr){ + // for of para los elementos + for (product of arr) { + + // const card = document.createRange().createContextualFragment(` + //
+ // + //
+ //
+ //

${product.price}

+ //

${product.name}

+ //
+ //
+ // + //
+ //
+ //
+ // `) + + const cardElement = document.createElement('div'); + const imgProductElement = document.createElement('img'); + const priceProductElement = document.createElement('p'); + const nameProductElement = document.createElement('p'); + const productInfoContainElement = document.createElement('div'); + const figureBtAddToCartContainerElement = document.createElement('figure'); + const imgIconAddToCartElement = document.createElement('img'); + + + + cardElement.classList.add('product-card');//
+ imgProductElement.src = product.image;// + imgProductElement.addEventListener('click', openProductDetail) + productInfoContainElement.classList.add('product-info');//
+ priceProductElement.innerText = `$ ${product.price}`; + nameProductElement.innerText = `$ ${product.name}`; + imgIconAddToCartElement.src = "./icons/bt_add_to_cart.svg"; // + + figureBtAddToCartContainerElement.append(imgIconAddToCartElement);// agregamos el icon bt add cart al contenedor figure + productInfoContainElement.append(priceProductElement, nameProductElement,figureBtAddToCartContainerElement) //agregamos el precio y el nombre dentro del contenedor produc-info + + cardElement.append(imgProductElement,productInfoContainElement); + + + cardProducContainerElement.append(cardElement) + } + +} + +// CARGAMOS LOS PRODUCTOS A LA PAGINA +renderProductList(productList); + + +// FUNCION PARA ABRIR EL ASIDE DE DETALELS DE CADA PRODUCTO CUANDO LE HACEMOS CLICK EN LA IMAGEN DEL PRODUCTO +function openProductDetail (event){ + + asideProductDetail.classList.remove('inactive'); + + // cerramos todos los menus + cerrarTodosLosMenus(); + + + + const parent = event.target.parentNode; + const lista = parent.childNodes + console.log(event) + console.log(parent) + console.log(lista) + // const productDetail = document.querySelector("#productDetail"); + // parent.append(productDetail) + + + + +} +// FUNCION PARA CERRAR EL ASIDE CON LA DESCRIPCION DEL PRUDUCTO CUANDO HACEN CLICK EN CEL BOTON DE CERRAR +const cerrarProductDetail = () =>{ + asideProductDetail.classList.add('inactive'); +} + +// FUNCION PARA CERRAR TODOS LOS MENUS +function cerrarTodosLosMenus (){ + desktopMenuElement.classList.add('inactive'); + mobileMenuElement.classList.add('inactive'); + asideComprasDetail.classList.add('inactive'); +} +// PARA CERRAR EL ASIDE DE DESCRIPCION DE CADA PRODUCTO +btn_clouse_product_detail.addEventListener('click',cerrarProductDetail); + +// HACER UNA FUNCION QUE CARGUE EL PRODUCTO QUE SE SELECCIONE EN EL ASIDE DE DESCRIPCION DE PRODUCTO \ No newline at end of file diff --git a/styles.css b/styles.css new file mode 100644 index 000000000..a61f219f9 --- /dev/null +++ b/styles.css @@ -0,0 +1,414 @@ +:root { + --white: #FFFFFF; + --black: #000000; + --very-light-pink: #C7C7C7; + --text-input-field: #F7F7F7; + --hospital-green: #ACD9B2; + --sm: 14px; + --md: 16px; + --lg: 18px; + } + body { + margin: 0; + font-family: 'Quicksand', sans-serif; + } + + + /* estilo para activar o desacticar un menu */ + + .inactive{ + display: none; + } + + + /* ESTILOS DEL MENU PRINCIPAL GRANDE */ + nav { + display: flex; + justify-content: space-between; + padding: 0 24px; + border-bottom: 1px solid var(--very-light-pink); + } + .menu { + display: none; + } + .logo { + width: 100px; + } + .navbar-left ul, + .navbar-right ul { + list-style: none; + padding: 0; + margin: 0; + display: flex; + align-items: center; + height: 60px; + } + .navbar-left { + display: flex; + } + .navbar-left ul { + margin-left: 12px; + } + .navbar-left ul li a, + .navbar-right ul li a { + text-decoration: none; + color: var(--very-light-pink); + border: 1px solid var(--white); + padding: 8px; + border-radius: 8px; + } + .navbar-left ul li a:hover, + .navbar-right ul li a:hover { + border: 1px solid var(--hospital-green); + color: var(--hospital-green); + } + .navbar-email { + color: var(--very-light-pink); + font-size: var(--sm); + margin-right: 12px; + } + .navbar-shopping-cart { + position: relative; + } + .navbar-shopping-cart div { + width: 16px; + height: 16px; + background-color: var(--hospital-green); + border-radius: 50%; + font-size: var(--sm); + font-weight: bold; + position: absolute; + top: -6px; + right: -3px; + display: flex; + justify-content: center; + align-items: center; + } + +/* ESTILOS PARA EL MENU CHICO CUANDO HACEMOS CLINK EN EL MAIL DEL USUARIO O LOGO DEL USUARIO */ +.desktop-menu { + + background-color: var(--white); + + position: absolute; + top: 60px; /* tamaƱo del menu principal */ + right: 50px; + + width: 100px; + height: auto; + border: 1px solid var(--very-light-pink); + border-radius: 6px; + padding: 20px 20px 0 20px; +} +.desktop-menu ul { + list-style: none; + padding: 0; + margin: 0; +} +.desktop-menu ul li { + text-align: end; +} +.desktop-menu ul li:nth-child(1), +.desktop-menu ul li:nth-child(2) { + font-weight: bold; +} +.desktop-menu ul li:last-child { + padding-top: 20px; + border-top: 1px solid var(--very-light-pink); +} +.desktop-menu ul li:last-child a { + color: var(--hospital-green); + font-size: var(--sm); +} +.desktop-menu ul li a { + color: var(--back); + text-decoration: none; + margin-bottom: 20px; + display: inline-block; +} + +/* ESTILOS PARA EL MENU DESPLEGABLE EN LA VERSION MOBILE + */ + + .mobile-menu { + background-color: var(--white); + + position: absolute; + top: 60px; + left: 0; + width: 100%; + padding: 24px; + +} +.mobile-menu a { + text-decoration: none; + color: var(--black); + font-weight: bold; + /* margin-bottom: 24px; */ +} +.mobile-menu ul { + padding: 0; + margin: 24px 0 0; + list-style: none; +} +.mobile-menu ul:nth-child(1) { + border-bottom: 1px solid var(--very-light-pink); +} +.mobile-menu ul li { + margin-bottom: 24px; +} +.email { + font-size: var(--sm); + font-weight: 300 !important; +} +.sign-out { + font-size: var(--sm); + color: var(--hospital-green) !important; +} + +/* ESTILOS GENERALES PARA TODOS LOS ASIDE */ +.aside { + width: 360px; + box-sizing: border-box; + position: absolute; + right: 0; + } + + +/* ESTILOS para el ASIDE DEL CARRITO DE COMPRAS */ +#shoppingCartContainer{ + background-color: var(--white); + width: 360px; + box-sizing: border-box; + position: absolute; + right: 0; + padding: 0 24px; +} + .title-container { + display: flex; + } + .title-container img { + transform: rotate(180deg); + margin-right: 14px; + } + .title { + font-size: var(--lg); + font-weight: bold; + } + .order { + display: grid; + grid-template-columns: auto 1fr; + gap: 16px; + align-items: center; + background-color: var(--text-input-field); + margin-bottom: 24px; + border-radius: 8px; + padding: 0 24px; + } + .order p:nth-child(1) { + display: flex; + flex-direction: column; + } + .order p span:nth-child(1) { + font-size: var(--md); + font-weight: bold; + } + .order p:nth-child(2) { + text-align: end; + font-weight: bold; + } + .shopping-cart { + display: grid; + grid-template-columns: auto 1fr auto auto; + gap: 16px; + margin-bottom: 24px; + align-items: center; + } + .shopping-cart figure { + margin: 0; + } + .shopping-cart figure img { + width: 70px; + height: 70px; + border-radius: 20px; + object-fit: cover; + } + .shopping-cart p:nth-child(2) { + color: var(--very-light-pink); + } + .shopping-cart p:nth-child(3) { + font-size: var(--md); + font-weight: bold; + } + .primary-button { + background-color: var(--hospital-green); + border-radius: 8px; + border: none; + color: var(--white); + width: 100%; + cursor: pointer; + font-size: var(--md); + font-weight: bold; + height: 50px; + } + + /* ESTILOS PARA EL ASAID CON LA DESCRIPCION DE CADA PRODUCTO */ + #productDetail { + width: 360px; + padding-bottom: 24px; + position: absolute; + right: 10px; + } + .productDetail-close { + background: var(--white); + width: 14px; + height: 14px; + position: absolute; + top: 24px; + left: 24px; + z-index: 2; + padding: 12px; + border-radius: 50%; + } + .productDetail-close:hover { + cursor: pointer; + } + #productDetail > img:nth-child(2) { + width: 100%; + height: 360px; + object-fit: cover; + border-radius: 0 0 20px 20px; + } + #productDetail .product-info { + margin: 24px 24px 0 24px; + /* display: flex; + flex-direction: column; */ + } + #productDetail .product-info p:nth-child(1) { + font-weight: bold; + font-size: var(--md); + margin-top: 0; + margin-bottom: 4px; + } + #productDetail .product-info p:nth-child(2) { + color: var(--very-light-pink); + font-size: var(--md); + margin-top: 0; + margin-bottom: 36px; + } + #productDetail .product-info p:nth-child(3) { + color: var(--very-light-pink); + font-size: var(--sm); + margin-top: 0; + margin-bottom: 36px; + } + #productDetail .primary-button { + background-color: var(--hospital-green); + border-radius: 8px; + border: none; + color: var(--white); + width: 100%; + cursor: pointer; + font-size: var(--md); + font-weight: bold; + height: 50px; + } + #productDetail .add-to-cart-button { + display: flex; + align-items: center; + justify-content: center; + } + + /* ESTILOS PARA LA LISTA DE PRODUCTOS */ + .cards-container { + display: grid; + grid-template-columns: repeat(auto-fill, 240px); + gap: 26px; + place-content: center; + + margin-top: 20px; + } + .product-card { + width: 240px; + } + .product-card img { + width: 240px; + height: 240px; + border-radius: 20px; + object-fit: cover; + } + .product-card .product-info { + display: flex; + justify-content: space-between; + align-items: center; + margin-top: 12px; + } + .product-card .product-info figure { + margin: 0; + } + .product-card .product-info figure img { + width: 35px; + height: 35px; + } + .product-card .product-info div p:nth-child(1) { + font-weight: bold; + font-size: var(--md); + margin-top: 0; + margin-bottom: 4px; + } + .product-card .product-info div p:nth-child(2) { + font-size: var(--sm); + margin-top: 0; + margin-bottom: 0; + color: var(--very-light-pink); + } + + + + + /* MEDIA PARA EL MENU GRANDE SEA RESPONSIVO */ + @media (max-width: 640px) { /* de 0 hasta 640px */ + .menu { + display: block; + } + .navbar-left ul { + display: none; + } + .navbar-email { + display: none; + } + + /*para que el menu grande desaparesca en la parte mobile*/ + .desktop-menu{ + display: none; + } + + /* para que la lista del carrito de compras, tome todo el espacio en mobile */ + .aside { + width: 100%; + } + + /* medias para la lista de productos */ + .cards-container { + grid-template-columns: repeat(auto-fill, 140px); + } + .product-card { + width: 140px; + } + .product-card img { + width: 140px; + height: 140px; + } + + /* para que el aside description ocupe toda la pantalla en responsive o en version mobile */ + #productDetail , #shoppingCartContainer{ + width: 100%; + } + } + + + @media (min-width: 641px){ + .mobile-menu{ + display: none; + } + } \ No newline at end of file