Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
clase 23
  • Loading branch information
jdbarrigab committed May 31, 2023
commit cf1fb41884468d5473edf0c00d3794201c6f22bd
18 changes: 17 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
</div>
</nav>

<aside class="product-detail inactive">
<aside id="shoppingCartContainer" class="inactive">
<div class="title-container">
<img src="./icons/flechita.svg" alt="arrow">
<p class="title">My order</p>
Expand Down Expand Up @@ -159,6 +159,22 @@
</div>
</aside>

<aside id="productDetail" class="inactive">
<div class="product-detail-close">
<img src="./icons/icon_close.png" alt="close">
</div>
<img src="https://images.pexels.com/photos/276517/pexels-photo-276517.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" alt="bike">
<div class="product-info">
<p>$35,00</p>
<p>Bike</p>
<p>With its practical position, this bike also fulfills a decorative function, add your hall or workspace.</p>
<button class="primary-button add-to-cart-button">
<img src="./icons/bt_add_to_cart.svg" alt="add to cart">
Add to cart
</button>
</div>
</aside>

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

Expand Down
12 changes: 6 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ const desktopMenu = document.querySelector('.desktop-menu');
const menuCarritoIcon = document.querySelector('.navbar-shopping-cart')
const menuHamIcon = document.querySelector('.menu');
const mobileMenu = document.querySelector('.mobile-menu');
const aside = document.querySelector('.product-detail');
const shoppingCartContainer = document.querySelector('#shoppingCartContainer');
const cardsContainer = document.querySelector('.cards-container');

menuEmail.addEventListener('click', toggleDesktopMenu);
menuHamIcon.addEventListener('click', toggleMobileMenu);
menuCarritoIcon.addEventListener('click', toggleCarritoAside);

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

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

desktopMenu.classList.toggle('inactive') //modifica la classe 'inactive'
//El método toggle permite cada vez que se ejecute cambiar de estado la visibilidad del elemento HTML, es decir si está visible pasa a oculto y si se encuentra oculto pasa a visible.
}
function toggleMobileMenu() {
const isAsideClosed = aside.classList.contains('inactive');
const isAsideClosed = shoppingCartContainer.classList.contains('inactive');

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

mobileMenu.classList.toggle('inactive')
Expand All @@ -41,7 +41,7 @@ function toggleCarritoAside() {
desktopMenu.classList.add('inactive')
}

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

const productList = [];
Expand Down
85 changes: 77 additions & 8 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@
/*Menú Mobile!*/

.mobile-menu {
background-color: var(--white);
position: absolute;
top: 60px;
left: 0px;
width: 100%;
padding: 24px;
}
.mobile-menu a {
Expand Down Expand Up @@ -158,14 +161,20 @@

/*Aside (product detail y carrito)*/

.product-detail {
aside {
width: 360px;
background-color: var(--white);
padding: 0 24px;
box-sizing: border-box;
position: absolute;
right: 0;
}

/* Shopping cart*/

#shoppingCartContainer {
padding: 0 24px;
}

.title-container {
display: flex;
}
Expand Down Expand Up @@ -234,6 +243,66 @@
height: 50px;
}

/* ProductDetail */

.product-detail-close {
background: var(--white);
width: 14px;
height: 14px;
position: absolute;
top: 24px;
left: 24px;
z-index: 2;
padding: 12px;
border-radius: 50%;
}
.product-detail-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;
}
#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;
}
.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;
}
.add-to-cart-button {
display: flex;
align-items: center;
justify-content: center;
}

/* Product List */

.cards-container {
Expand All @@ -252,26 +321,26 @@
border-radius: 20px;
object-fit: cover;
}
.product-info {
.product-card .product-info {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 12px;
}
.product-info figure {
.product-card .product-info figure {
margin: 0;
}
.product-info figure img {
.product-card .product-info figure img {
width: 35px;
height: 35px;
}
.product-info div p:nth-child(1) {
.product-card .product-info div p:nth-child(1) {
font-weight: bold;
font-size: var(--md);
margin-top: 0;
margin-bottom: 4px;
}
.product-info div p:nth-child(2) {
.product-card .product-info div p:nth-child(2) {
font-size: var(--sm);
margin-top: 0;
margin-bottom: 0;
Expand All @@ -290,7 +359,7 @@
.desktop-menu {
display: none;
}
.product-detail {
aside {
width: 100%;
}
.cards-container {
Expand Down