feat: adiciona o minicart

This commit is contained in:
Cainã Milech 2022-12-07 19:20:11 -03:00
parent 2a9dfc2716
commit 6b82cc5fe7
6 changed files with 98 additions and 73 deletions

View File

@ -64,7 +64,7 @@ const app = new Container({
], ],
}); });
app.bind(Minicart.name, ".carrinho .mini-cart"); app.bind(Minicart.name, ".minicart__drawer");
app.bind(Newsletter.name, { app.bind(Newsletter.name, {
elemento: ".news-form", elemento: ".news-form",
textButtom: "Cadastre-se", textButtom: "Cadastre-se",

View File

@ -16,7 +16,9 @@ export default class Minicart {
</div> </div>
<div class="mini-cart-main"> <div class="mini-cart-main">
<div class="wait-screen"></div> <div class="wait-screen"></div>
<ul class="product-list"></ul> <ul class="product-list">
</ul>
</div> </div>
<div class="mini-cart-footer"> <div class="mini-cart-footer">
<div class="totals-container"> <div class="totals-container">
@ -57,7 +59,7 @@ export default class Minicart {
<li id="${i + "-" + items[i].uniqueId}" class="product"> <li id="${i + "-" + items[i].uniqueId}" class="product">
<div class="product-image"> <div class="product-image">
<a href="${items[i].detailUrl}" title="${items[i].name}"> <a href="${items[i].detailUrl}" title="${items[i].name}">
<img src="${alterarTamanhoImagemSrcVtex(items[i].imageUrl, 85, 100)}" alt="${ <img src="${alterarTamanhoImagemSrcVtex(items[i].imageUrl, 80, 102)}" alt="${
items[i].name items[i].name
}"> }">
</a> </a>
@ -115,10 +117,10 @@ export default class Minicart {
orderItems(items); orderItems(items);
$(".mini-cart-container").addClass("have-item"); $(".mini-cart-container").addClass("have-item");
} else { } else {
emptyMessage(); //emptyMessage();
} }
} catch (e) { } catch (e) {
emptyMessage(); //emptyMessage();
console.warn("couldnt list items. " + e.message); console.warn("couldnt list items. " + e.message);
} }
} }
@ -290,8 +292,6 @@ export default class Minicart {
} }
this.createMiniCartStructure(element); this.createMiniCartStructure(element);
this.configureEvents( this.configureEvents(".minicart__button");
"header .carrinho> a, .mobile-bottom-options .portal-totalizers-ref, .popup-add-cart .cart"
);
} }
} }

View File

@ -37,7 +37,11 @@ export default class Menu {
event.preventDefault(); //nao adicionar nada na url por ex # event.preventDefault(); //nao adicionar nada na url por ex #
const link = $(event.target); //para saber qual link foi clicado const link = $(event.target); //para saber qual link foi clicado
link.siblings(".submenu").addClass("is-open"); //pegar o irmao link.parents(".main-menu__department")
.find(".submenu")
.addClass("is-open"); //pega o pai, acha o filho submenu, mesmo clicando no icone
//link.siblings(".submenu").addClass("is-open"); //pegar o irmao , POREM DESSE JEITO NAO PEGA NO ICONE
//mas a solucao poderia ser apenas colocar um point events none no icone, la no css
} }
closeSubmenu(event) { closeSubmenu(event) {

View File

@ -1,21 +1,66 @@
.mini-cart { .minicart {
height: 475px; position: relative;
max-height: 200px;
opacity: 0;
position: absolute;
right: 0px;
top: 50px;
transition: all 0.3s ease-in-out;
visibility: hidden;
width: 375px;
z-index: 16;
@include mq(md, max) { &__button {
bottom: 0; position: relative;
height: 100%; padding: 0;
left: 0; border: 0;
position: fixed; outline: 0;
top: 0; background: transparent;
cursor: pointer;
.portal-totalizers-ref {
.title,
.amount-products,
.amount-items strong,
.amount-kits,
.total-cart {
display: none;
}
}
.cart-info {
margin: 0;
}
.amount-items-em {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 4px;
right: -4px;
width: 15px;
height: 15px;
border-radius: 50%;
font-style: normal;
font-weight: 700;
font-size: 9px;
line-height: 11px;
color: $white-500;
background: $blue-500;
}
}
&__drawer {
height: 475px;
max-height: 200px;
opacity: 0;
position: absolute;
right: 0px;
top: 80px;
transition: all 0.3s ease-in-out;
visibility: hidden;
width: 375px;
z-index: 16;
@include mq(md, max) {
bottom: 0;
height: 100%;
left: 0;
position: fixed;
top: 0;
}
} }
} }
@ -380,7 +425,7 @@
} }
.finish-order { .finish-order {
background-color: #2fab61; background-color: $black-500;
color: #fff; color: #fff;
display: block; display: block;
font-weight: 700; font-weight: 700;
@ -392,12 +437,18 @@
width: 100%; width: 100%;
&:hover { &:hover {
background-color: lighten(#2fab61, 2.5); background-color: lighten($black-500, 2.5);
} }
&:active { &:active {
background-color: darken(#2fab61, 10); background-color: darken($black-500, 10);
} }
} }
} }
&.have-item {
.totals-container {
display: block;
}
}
} }

View File

@ -26,45 +26,6 @@
} }
} }
.busca {
display: flex;
align-items: center;
margin: 0;
legend,
label,
select {
display: none;
}
.fulltext-search-box {
flex: 1;
height: 23px;
padding: 0;
border: 0;
background: transparent;
outline: 0;
color: $white-500;
font-size: 10px;
line-height: 12px;
}
.btn-buscar {
width: 23px;
height: 23px;
padding: 0;
border: 0;
outline: 0;
font-size: 0;
background-color: transparent;
/*quando ja tem estrutuura, e temos que substituir*/
@extend .sprite;
@extend .sprite-search-icon;
}
}
.user-items { .user-items {
display: flex; display: flex;
align-items: center; align-items: center;
@ -107,13 +68,16 @@
} }
} }
} }
}
&__minicart-button { .minicart {
&__button {
position: relative; position: relative;
padding: 0; padding: 0;
border: 0; border: 0;
outline: 0; outline: 0;
background: transparent; background: transparent;
cursor: pointer;
.portal-totalizers-ref { .portal-totalizers-ref {
.title, .title,

View File

@ -25,10 +25,16 @@
<i class="sprite sprite-user-icon"></i> <i class="sprite sprite-user-icon"></i>
</a> </a>
<button class="user-items__minicart-button"> <div class="minicart">
<i class="sprite sprite-bag-icon"></i> <button class="minicart__button">
<vtex.cmc:AmountItemsInCart /> <i class="sprite sprite-bag-icon"></i>
</button> <vtex.cmc:AmountItemsInCart />
</button>
<div class="minicart__drawer"></div>
</div>
</div> </div>
</div> </div>
</div> </div>