feature/footer #1

Merged
RamonDiasFerreira merged 5 commits from feature/footer into develop 2022-12-18 23:54:59 +00:00
2 changed files with 99 additions and 36 deletions
Showing only changes of commit 114965e967 - Show all commits

View File

@ -8,10 +8,12 @@ export default class Footer {
async init() {
this.list = await this.requestApi();
await this.selectors();
this.createShelf();
if (window.location.hash === "#/cart") {
await this.shelfUpdate();
}
this.shelfList = await waitElement(".footerCheckout__shelfList");
this.shelfItens();
await this.shelfUpdate();
this.events();
this.addCarrossel();
this.creditCardIconsHTML();
this.developedByIconsHTML();
@ -19,14 +21,8 @@ export default class Footer {
}
async selectors() {
this.itensShelf = await waitElement(".footerCheckout__prateleira", {
timeout: 5000,
interval: 1000,
});
this.checkoutVazio = await waitElement(".empty-cart-content", {
timeout: 5000,
interval: 1000,
});
this.itensShelf = await waitElement(".footerCheckout__prateleira");
this.checkoutVazio = await waitElement(".empty-cart-content");
this.creditCardIcons = await waitElement(".footerCheckout__stamps");
this.developedByIcons = await waitElement(".footerCheckout__developedBy");
@ -43,14 +39,14 @@ export default class Footer {
}
}
async shelfItens() {
shelfItens() {
let structure = "";
this.list.forEach((response) => {
const sku = response.skus.map((item) => `<li>${item}</li>`);
structure += `
<li>
<li class="liItens">
<figure><img src ="${response.img}"/></figure>
<figcaption>${response.name}</figcaption>
<div><ul>${sku}</ul></div>
@ -78,29 +74,34 @@ export default class Footer {
}
events() {
window.addEventListener("hashchange", () =>{})
window.addEventListener("hashchange", this.hashChange.bind(this))
}
async shelfUpdate() {
let target = this.checkoutVazio;
let config = { childList: true, attributes: true };
let observer = new MutationObserver((mutations) => {
console.log("observer");
mutations.map((mutation) => {
const status = mutation.target.attributes.style.nodeValue;
console.log(status);
if(status === "display: none") {
this.renderShelf();
this.shelfList.classList.remove("inactive");
} else if (status === "display: block") {
console.log(mutation.target.attributes.style.nodeValue);
if(mutation.target.attributes.style.nodeValue == "display: none;") {
this.createShelf();
} else if (mutation.target.attributes.style.nodeValue == "display: block;") {
this.removeShelf();
this.shelfList.classList.add("inactive");
}
})
})
});
});
observer.observe(target, config);
}
hashChange(e) {
if(e.newURL !== "https://m3academy.myvtex.com/checkout/#/cart") {
this.itensShelf.classList.add("desativado");
} else {
this.itensShelf.classList.remove("desativado");
}
}
async addCarrossel() {
const elemento = await waitElement(".footerCheckout__shelfList");
$(elemento).slick({
@ -108,20 +109,43 @@ export default class Footer {
slidesToScroll: 1,
arrows: true,
infinite: false,
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 3,
slidesToScroll: 1,
}
},
{
breakpoint: 375,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}
},
{
breakpoint: 290,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
}
creditCardIconsHTML() {
this.creditCardIcons.innerHTML = `
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/masterCardM3Academy.png" alt="Mastercard"></li>
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/visaM3Academy.png" alt=""></li>
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/amexM3Academy.png" alt="American Express"></li>
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/eloM3Academy.png" alt="Elo"></li>
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/hiperCardM3Academy.png" alt="Hipercard"></li>
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/payPalM3Academy.png" alt="PayPal"></li>
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/boletoM3Academy.png" alt="Boleto"></li>
<li class="credit-card"><img src="https://agenciamagma.vteximg.com.br/arquivos/masterCardM3Academy.png" alt="Mastercard"></li>
<li class="credit-card"><img src="https://agenciamagma.vteximg.com.br/arquivos/visaM3Academy.png" alt=""></li>
<li class="credit-card"><img src="https://agenciamagma.vteximg.com.br/arquivos/amexM3Academy.png" alt="American Express"></li>
<li class="credit-card"><img src="https://agenciamagma.vteximg.com.br/arquivos/eloM3Academy.png" alt="Elo"></li>
<li class="credit-card"><img src="https://agenciamagma.vteximg.com.br/arquivos/hiperCardM3Academy.png" alt="Hipercard"></li>
<li class="credit-card"><img src="https://agenciamagma.vteximg.com.br/arquivos/payPalM3Academy.png" alt="PayPal"></li>
<li class="credit-card"><img src="https://agenciamagma.vteximg.com.br/arquivos/boletoM3Academy.png" alt="Boleto"></li>
<li><span class="footerCheckout__stamps__divider"></span></li>
<li class="vtex-pci"><img src="https://agenciamagma.vteximg.com.br/arquivos/vtexPCIM3Academy.png" alt="PCI VTEX"></li>
<li class="vtex-pci credit-card"><img src="https://agenciamagma.vteximg.com.br/arquivos/vtexPCIM3Academy.png" alt="PCI VTEX"></li>
`;
}
@ -147,10 +171,8 @@ export default class Footer {
`;
}
removeShelf() {
this.itensShelf.innerHTML = "";
}
}

View File

@ -3,10 +3,48 @@
border-top: none;
color: $color-gray2;
&__prateleira{
.footerCheckout__prateleira-title {
display: flex;
justify-content: center;
}
}
&__wrapper {
align-items: center;
display: flex;
justify-content: space-between;
padding-top: 56px;
.container {
display: flex;
justify-content: space-between;
.footerCheckout__address{
width: 21.02%;
left: 2.5%;
}
.footerCheckout__stamps {
width: 31.56%;
}
.footerCheckout__developedBy{
display: flex;
width: 16.95%;
right: 2.5%;
.by-vtex, .by-m3{
display: flex;
.vtex-logo, .m3-logo{
width: 50% ;
}
}
}
}
}
&__address {
@ -71,4 +109,7 @@
}
}
}
.desativado {
display: none !important;
}
}