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() { async init() {
this.list = await this.requestApi(); this.list = await this.requestApi();
await this.selectors(); await this.selectors();
this.createShelf(); if (window.location.hash === "#/cart") {
await this.shelfUpdate();
}
this.shelfList = await waitElement(".footerCheckout__shelfList"); this.shelfList = await waitElement(".footerCheckout__shelfList");
this.shelfItens(); this.shelfItens();
await this.shelfUpdate(); this.events();
this.addCarrossel(); this.addCarrossel();
this.creditCardIconsHTML(); this.creditCardIconsHTML();
this.developedByIconsHTML(); this.developedByIconsHTML();
@ -19,14 +21,8 @@ export default class Footer {
} }
async selectors() { async selectors() {
this.itensShelf = await waitElement(".footerCheckout__prateleira", { this.itensShelf = await waitElement(".footerCheckout__prateleira");
timeout: 5000, this.checkoutVazio = await waitElement(".empty-cart-content");
interval: 1000,
});
this.checkoutVazio = await waitElement(".empty-cart-content", {
timeout: 5000,
interval: 1000,
});
this.creditCardIcons = await waitElement(".footerCheckout__stamps"); this.creditCardIcons = await waitElement(".footerCheckout__stamps");
this.developedByIcons = await waitElement(".footerCheckout__developedBy"); this.developedByIcons = await waitElement(".footerCheckout__developedBy");
@ -43,14 +39,14 @@ export default class Footer {
} }
} }
async shelfItens() { shelfItens() {
let structure = ""; let structure = "";
this.list.forEach((response) => { this.list.forEach((response) => {
const sku = response.skus.map((item) => `<li>${item}</li>`); const sku = response.skus.map((item) => `<li>${item}</li>`);
structure += ` structure += `
<li> <li class="liItens">
<figure><img src ="${response.img}"/></figure> <figure><img src ="${response.img}"/></figure>
<figcaption>${response.name}</figcaption> <figcaption>${response.name}</figcaption>
<div><ul>${sku}</ul></div> <div><ul>${sku}</ul></div>
@ -78,29 +74,34 @@ export default class Footer {
} }
events() { events() {
window.addEventListener("hashchange", () =>{}) window.addEventListener("hashchange", this.hashChange.bind(this))
} }
async shelfUpdate() { async shelfUpdate() {
let target = this.checkoutVazio; let target = this.checkoutVazio;
let config = { childList: true, attributes: true }; let config = { childList: true, attributes: true };
let observer = new MutationObserver((mutations) => { let observer = new MutationObserver((mutations) => {
console.log("observer");
mutations.map((mutation) => { mutations.map((mutation) => {
const status = mutation.target.attributes.style.nodeValue; console.log(mutation.target.attributes.style.nodeValue);
console.log(status); if(mutation.target.attributes.style.nodeValue == "display: none;") {
if(status === "display: none") { this.createShelf();
this.renderShelf(); } else if (mutation.target.attributes.style.nodeValue == "display: block;") {
this.shelfList.classList.remove("inactive");
} else if (status === "display: block") {
this.removeShelf(); this.removeShelf();
this.shelfList.classList.add("inactive");
} }
}) });
}) });
observer.observe(target, config); 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() { async addCarrossel() {
const elemento = await waitElement(".footerCheckout__shelfList"); const elemento = await waitElement(".footerCheckout__shelfList");
$(elemento).slick({ $(elemento).slick({
@ -108,20 +109,43 @@ export default class Footer {
slidesToScroll: 1, slidesToScroll: 1,
arrows: true, arrows: true,
infinite: false, 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() { creditCardIconsHTML() {
this.creditCardIcons.innerHTML = ` this.creditCardIcons.innerHTML = `
<li><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/masterCardM3Academy.png" alt="Mastercard"></li>
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/visaM3Academy.png" alt=""></li> <li class="credit-card"><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 class="credit-card"><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 class="credit-card"><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 class="credit-card"><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 class="credit-card"><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/boletoM3Academy.png" alt="Boleto"></li>
<li><span class="footerCheckout__stamps__divider"></span></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; border-top: none;
color: $color-gray2; color: $color-gray2;
&__prateleira{
.footerCheckout__prateleira-title {
display: flex;
justify-content: center;
}
}
&__wrapper { &__wrapper {
align-items: center; align-items: center;
display: flex; display: flex;
justify-content: space-between; 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 { &__address {
@ -71,4 +109,7 @@
} }
} }
} }
.desativado {
display: none !important;
}
} }