Skip to content

Commit 74e3531

Browse files
committed
product detail
1 parent 11c672c commit 74e3531

File tree

3 files changed

+96
-15
lines changed

3 files changed

+96
-15
lines changed

index.html

+17-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
</div>
114114
</nav>
115115

116-
<aside class="product-detail inactive">
116+
<aside id="shoppingCartContainer" class="inactive">
117117
<div class="title-container">
118118
<img src="./icons/flechita.svg" alt="arrow">
119119
<p class="title">My order</p>
@@ -161,6 +161,22 @@
161161
</div>
162162
</aside>
163163

164+
<aside id="productDetail" class="inactive">
165+
<div class="product-detail-close">
166+
<img src="./icons/icon_close.png" alt="close">
167+
</div>
168+
<img src="https://images.pexels.com/photos/276517/pexels-photo-276517.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" alt="bike">
169+
<div class="product-info">
170+
<p>$35,00</p>
171+
<p>Bike</p>
172+
<p>With its practical position, this bike also fulfills a decorative function, add your hall or workspace.</p>
173+
<button class="primary-button add-to-cart-button">
174+
<img src="./icons/bt_add_to_cart.svg" alt="add to cart">
175+
Add to cart
176+
</button>
177+
</div>
178+
</aside>
179+
164180
<section class="main-container">
165181
<div class="cards-container">
166182

main.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@ const menuHamIcon = document.querySelector('.menu');
33
const menuCarritoIcon = document.querySelector('.navbar-shopping-cart');
44
const desktopMenu = document.querySelector('.desktop-menu');
55
const mobileMenu = document.querySelector('.mobile-menu');
6-
const aside = document.querySelector('.product-detail');
6+
const shoppingCartContainer = document.querySelector('#shoppingCartContainer');
77
const cardsContainer = document.querySelector('.cards-container');
88

99
menuEmail.addEventListener('click', toggleDesktopMenu);
1010
menuHamIcon.addEventListener('click', toggleMobileMenu);
1111
menuCarritoIcon.addEventListener('click', toggleCarritoAside);
1212

1313
function toggleDesktopMenu() {
14-
const isAsideClosed = aside.classList.contains('inactive');
14+
const isAsideClosed = shoppingCartContainer.classList.contains('inactive');
1515

1616
if (!isAsideClosed) {
17-
aside.classList.add('inactive');
17+
shoppingCartContainer.classList.add('inactive');
1818
}
1919

2020
desktopMenu.classList.toggle('inactive');
2121
}
2222

2323
function toggleMobileMenu() {
24-
const isAsideClosed = aside.classList.contains('inactive');
24+
const isAsideClosed = shoppingCartContainer.classList.contains('inactive');
2525

2626
if (!isAsideClosed) {
27-
aside.classList.add('inactive');
27+
shoppingCartContainer.classList.add('inactive');
2828
}
2929

3030
mobileMenu.classList.toggle('inactive');
@@ -37,7 +37,7 @@ function toggleCarritoAside() {
3737
mobileMenu.classList.add('inactive');
3838
}
3939

40-
aside.classList.toggle('inactive');
40+
shoppingCartContainer.classList.toggle('inactive');
4141
}
4242

4343
const productList = [];

styles.css

+73-8
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ nav {
127127
background-color: var(--white);
128128
position: absolute;
129129
top: 60px;
130+
left: 0;
131+
width: 100%;
130132
padding: 24px;
131133
}
132134
.mobile-menu a {
@@ -157,14 +159,18 @@ nav {
157159

158160

159161
/* Aside (product detail y carrito) */
160-
.product-detail {
162+
aside {
161163
background-color: var(--white);
162164
width: 360px;
163-
padding: 0 24px;
164165
box-sizing: border-box;
165166
position: absolute;
166167
right: 0;
167168
}
169+
170+
/* ShoppingCart */
171+
#shoppingCartContainer {
172+
padding: 0 24px;
173+
}
168174
.title-container {
169175
display: flex;
170176
}
@@ -233,6 +239,65 @@ nav {
233239
height: 50px;
234240
}
235241

242+
/* ProductDetail */
243+
.product-detail-close {
244+
background: var(--white);
245+
width: 14px;
246+
height: 14px;
247+
position: absolute;
248+
top: 24px;
249+
left: 24px;
250+
z-index: 2;
251+
padding: 12px;
252+
border-radius: 50%;
253+
}
254+
.product-detail-close:hover {
255+
cursor: pointer;
256+
}
257+
#productDetail > img:nth-child(2) {
258+
width: 100%;
259+
height: 360px;
260+
object-fit: cover;
261+
border-radius: 0 0 20px 20px;
262+
}
263+
#productDetail .product-info {
264+
margin: 24px 24px 0 24px;
265+
}
266+
#productDetail .product-info p:nth-child(1) {
267+
font-weight: bold;
268+
font-size: var(--md);
269+
margin-top: 0;
270+
margin-bottom: 4px;
271+
}
272+
#productDetail .product-info p:nth-child(2) {
273+
color: var(--very-light-pink);
274+
font-size: var(--md);
275+
margin-top: 0;
276+
margin-bottom: 36px;
277+
}
278+
#productDetail .product-info p:nth-child(3) {
279+
color: var(--very-light-pink);
280+
font-size: var(--sm);
281+
margin-top: 0;
282+
margin-bottom: 36px;
283+
}
284+
.primary-button {
285+
background-color: var(--hospital-green);
286+
border-radius: 8px;
287+
border: none;
288+
color: var(--white);
289+
width: 100%;
290+
cursor: pointer;
291+
font-size: var(--md);
292+
font-weight: bold;
293+
height: 50px;
294+
}
295+
.add-to-cart-button {
296+
display: flex;
297+
align-items: center;
298+
justify-content: center;
299+
}
300+
236301

237302
/* Product List */
238303
.cards-container {
@@ -251,26 +316,26 @@ nav {
251316
border-radius: 20px;
252317
object-fit: cover;
253318
}
254-
.product-info {
319+
.product-card .product-info {
255320
display: flex;
256321
justify-content: space-between;
257322
align-items: center;
258323
margin-top: 12px;
259324
}
260-
.product-info figure {
325+
.product-card .product-info figure {
261326
margin: 0;
262327
}
263-
.product-info figure img {
328+
.product-card .product-info figure img {
264329
width: 35px;
265330
height: 35px;
266331
}
267-
.product-info div p:nth-child(1) {
332+
.product-card .product-info div p:nth-child(1) {
268333
font-weight: bold;
269334
font-size: var(--md);
270335
margin-top: 0;
271336
margin-bottom: 4px;
272337
}
273-
.product-info div p:nth-child(2) {
338+
.product-card .product-info div p:nth-child(2) {
274339
font-size: var(--sm);
275340
margin-top: 0;
276341
margin-bottom: 0;
@@ -292,7 +357,7 @@ nav {
292357
display: none;
293358
}
294359

295-
.product-detail {
360+
aside {
296361
width: 100%;
297362
}
298363

0 commit comments

Comments
 (0)