feat(Footer): Adiciona função observer

This commit is contained in:
William Simão Cavalcante 2022-12-16 19:49:26 -03:00
parent 6d2af82fc7
commit 1b7b5f7edf
5 changed files with 125 additions and 77 deletions

View File

@ -7,34 +7,63 @@ export default class Footer {
async init() { async init() {
await this.selectors(); await this.selectors();
this.requestApi(); this.verificaPag();
this.addCarrossel(); await this.onUpdate();
this.creatPaymentsIcons(); this.creatPaymentsIcons();
this.creatVtexIconPci(); this.creatVtexIconPci();
this.creatDevIconsM3(); this.creatDevIconsM3();
this.onUpdate(); this.addProdutos();
await this.addCarrossel();
} }
async selectors() { async selectors() {
this.checkoutVazio = await waitElement(".empty-cart-content"); this.checkoutVazio = await waitElement(".empty-cart-content");
this.divPrateleira = await waitElement('.footerCheckout__prateleira'); this.divPrateleira = await waitElement('.footerCheckout__prateleira');
this.tituloPrateleira = await waitElement('#cart-title')
this.payments = await waitElement('.footerCheckout__payments'); this.payments = await waitElement('.footerCheckout__payments');
this.vtexIconPci = await waitElement('.footerCheckout__vtexpci'); this.vtexIconPci = await waitElement('.footerCheckout__vtexpci');
this.devIcons = await waitElement('.footerCheckout__developedBy'); this.devIcons = await waitElement('.footerCheckout__developedBy');
this.continuarComprando = await waitElement('.empty-cart-links');
} }
onUpdate() { async onUpdate() {
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) => {
mutations.forEach(function (mutation) { mutations.forEach((mutation) => {
console.log(mutation.type); console.log(observer);
const status = mutation.target.attributes.style.nodeValue;
if(status === 'display: none;') {
this.requestApi();
} else {
this.divPrateleira.innerHTML = ``;
}
}); });
}); });
observer.observe(target, config); observer.observe(target, config);
} }
verificaPag () {
if(this.checkoutVazio.attributes.style.nodeValue === 'display: none;') {
if(window.location.hash == '#/cart') {
this.requestApi();
}
} else {
this.divPrateleira.innerHTML= ``;
}
window.addEventListener('hashchange',() => {
if(this.checkoutVazio.attributes.style.nodeValue === 'display: none;') {
if(window.location.hash == '#/cart') {
this.requestApi();
}
} else if (window.location.hash == '#/email' || window.location.hash == '#/profile' || window.location.hash == '#/shipping') {
this.divPrateleira.innerHTML= ``;
}else if (window.location.href == "https://m3academy.myvtex.com/checkout/#/payment") {
this.divPrateleira.innerHTML= ``;
}
})};
requestApi () { requestApi () {
this.divPrateleira.innerHTML = this.divPrateleira.innerHTML =
`<h3 class="footerCheckout__prateleira-title" >Você também pode gostar:</h3> `<h3 class="footerCheckout__prateleira-title" >Você também pode gostar:</h3>
@ -54,19 +83,19 @@ export default class Footer {
const linkProd = prod.link; const linkProd = prod.link;
ulProdut.innerHTML += ` ulProdut.innerHTML += `
<li class="footerCheckout__prateleira-li-prod"> <li class="footerCheckout__prateleira-li-prod">
<figure class="footerCheckout__prateleira-figure-prod"> <figure class="footerCheckout__prateleira-figure-prod">
<img src="${imgProd}" alt="Imagem Produto"> <img src="${imgProd}" alt="Imagem Produto">
</figure> </figure>
<div class="footerCheckout__prateleira-div-text"> <div class="footerCheckout__prateleira-div-text">
<h2>${nameProd}</h2> <h2>${nameProd}</h2>
<ul> <ul>
${prod.items.map((name) => `<li> ${prod.items.map((name) => `<li>
${name.name}</li>`).join('')} ${name.name}</li>`).join('')}
</ul> </ul>
<a href="${linkProd}"> <a href="${linkProd}">
Ver Produto Ver Produto
</a> </a>
</div> </div>
</li>` </li>`
}) })
}); });
@ -82,53 +111,60 @@ export default class Footer {
}); });
} }
} }
addProdutos() {
this.continuarComprando.innerHTML = `<a href="/" id="cart-choose-products" class="btn btn-large btn-success link-choose-products" data-i18n="cart.chooseProducts">continuar comprando</a>`
}
// removePrateleira() {
// this.divPrateleira.style.display = 'none'
// };
creatPaymentsIcons () { creatPaymentsIcons () {
this.payments.innerHTML = ` this.payments.innerHTML = `
<ul class="footerCheckout__container-ul"> <ul class="footerCheckout__container-ul">
<li class="footerCheckout__wrapper-li"> <li class="footerCheckout__wrapper-li">
<figure class="footerCheckout__figure-img-tickets"> <figure class="footerCheckout__figure-img-tickets">
<img src="https://agenciamagma.vteximg.com.br/arquivos/masterCardM3Academy.png" alt="MasterCard"/> <img src="https://agenciamagma.vteximg.com.br/arquivos/masterCardM3Academy.png" alt="MasterCard"/>
<img src="https://agenciamagma.vteximg.com.br/arquivos/visaM3Academy.png" alt="VisaCard"/> <img src="https://agenciamagma.vteximg.com.br/arquivos/visaM3Academy.png" alt="VisaCard"/>
<img src="https://agenciamagma.vteximg.com.br/arquivos/amexM3Academy.png" alt="AmericaExpress"/> <img src="https://agenciamagma.vteximg.com.br/arquivos/amexM3Academy.png" alt="AmericaExpress"/>
<img src="https://agenciamagma.vteximg.com.br/arquivos/eloM3Academy.png" alt="VisaCard"/> <img src="https://agenciamagma.vteximg.com.br/arquivos/eloM3Academy.png" alt="VisaCard"/>
<img src="https://agenciamagma.vteximg.com.br/arquivos/hiperCardM3Academy.png" alt="HiperCard"/> <img src="https://agenciamagma.vteximg.com.br/arquivos/hiperCardM3Academy.png" alt="HiperCard"/>
<img src="https://agenciamagma.vteximg.com.br/arquivos/visaM3Academy.png" alt="VisaCard"/> <img src="https://agenciamagma.vteximg.com.br/arquivos/visaM3Academy.png" alt="VisaCard"/>
<img src="https://agenciamagma.vteximg.com.br/arquivos/payPalM3Academy.png" alt="PayPal"/> <img src="https://agenciamagma.vteximg.com.br/arquivos/payPalM3Academy.png" alt="PayPal"/>
<img src="https://agenciamagma.vteximg.com.br/arquivos/boletoM3Academy.png" alt="Boleto"/> <img src="https://agenciamagma.vteximg.com.br/arquivos/boletoM3Academy.png" alt="Boleto"/>
</figure> </figure>
</li> </li>
</ul>`; </ul>`;
} }
creatVtexIconPci () { creatVtexIconPci () {
this.vtexIconPci.innerHTML = ` this.vtexIconPci.innerHTML = `
<ul class="footerCheckout__container-ul"> <ul class="footerCheckout__container-ul">
<li class="footerCheckout__wrapper-li"> <li class="footerCheckout__wrapper-li">
<figure class="footerCheckout__figure-img-vtex"> <figure class="footerCheckout__figure-img-vtex">
<img src="https://agenciamagma.vteximg.com.br/arquivos/vtexPCIM3Academy.png" alt="Logo Vtex"/> <img src="https://agenciamagma.vteximg.com.br/arquivos/vtexPCIM3Academy.png" alt="Logo Vtex"/>
</figure> </figure>
</li> </li>
</ul>` </ul>`
} }
creatDevIconsM3 () { creatDevIconsM3 () {
this.devIcons.innerHTML = ` this.devIcons.innerHTML = `
<li class="footerCheckout__container-li-m3Icon"> <li class="footerCheckout__container-li-m3Icon">
<a href="https://vtex.com/br-pt/"> <a href="https://vtex.com/br-pt/">
<span>Powered By</span> <span>Powered By</span>
<figure class="footerCheckout__figure-img-vtexIcon"> <figure class="footerCheckout__figure-img-vtexIcon">
<img class="vtex-icon" src="https://agenciamagma.vteximg.com.br/arquivos/logoVTEXM3Academy.png" alt="LogoVTEX"> <img class="vtex-icon" src="https://agenciamagma.vteximg.com.br/arquivos/logoVTEXM3Academy.png" alt="LogoVTEX">
</figure> </figure>
</a> </a>
</li> </li>
<li class="footerCheckout__container-li-m3Icon"> <li class="footerCheckout__container-li-m3Icon">
<a href="https://agenciam3.com/"> <a href="https://agenciam3.com/">
<span>Developed By</span> <span>Developed By</span>
<figure class="footerCheckout__figure-img-m3Icon"> <figure class="footerCheckout__figure-img-m3Icon">
<img class="m3-icon" src="https://agenciamagma.vteximg.com.br/arquivos/logoM3M3Academy.png" alt="LogoM3"> <img class="m3-icon" src="https://agenciamagma.vteximg.com.br/arquivos/logoM3M3Academy.png" alt="LogoM3">
</figure> </figure>
</a> </a>
</li>` </li>
} `
}
} }

View File

@ -49,10 +49,6 @@ body {
.container-order-form, .container-order-form,
.container-cart { .container-cart {
width: 80%; width: 80%;
#cart-title {
display: none !important;
}
} }
} }
@ -71,20 +67,24 @@ body {
#cart-title, #cart-title,
#orderform-title { #orderform-title {
color: $color-gray2;
font-family: $font-family; font-family: $font-family;
font-weight: 500; font-weight: 700;
font-size: 36px; font-size: 24px;
line-height: 42px; line-height: 33px;
margin: 40px 0 30px; margin: 16px 0;
letter-spacing: 0.1em; letter-spacing: 0.05em;
text-transform: uppercase; text-transform: uppercase;
color: $color-black-500;
@include mq(md, max) { @include mq(md, max) {
margin-left: 30px; margin-left: 30px;
} }
.activeTitle {
display: none;
}
} }
.dropdown { .dropdown {
&__content { &__content {
&--closed { &--closed {

View File

@ -13,6 +13,13 @@
-ms-touch-action: pan-y; -ms-touch-action: pan-y;
touch-action: pan-y; touch-action: pan-y;
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
// .slick-slide:first-child {
// margin-right: 8px;
// }
// .slick-slid:last-child {
// margin-left: 8px;
// }
} }
.slick-list { .slick-list {
position: relative; position: relative;
@ -46,7 +53,7 @@
display: flex; display: flex;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
column-gap: 16px; gap: 16px;
&:before, &:before,
&:after { &:after {

View File

@ -211,7 +211,6 @@
align-items: center; align-items: center;
text-align: center; text-align: center;
margin: 0; margin: 0;
padding: 0;
background-color: $color-blue-200; background-color: $color-blue-200;
color: $color-white; color: $color-white;
border-radius: 8px; border-radius: 8px;
@ -222,8 +221,6 @@
font-style: normal; font-style: normal;
line-height: 18px; line-height: 18px;
padding: 5px; padding: 5px;
transition: ease-in-out 250ms;
border: 1px solid $color-blue-200;
} }
&__prateleira-div-text a { &__prateleira-div-text a {
@ -231,7 +228,6 @@
justify-content: center; justify-content: center;
display: flex; display: flex;
width: 100%; width: 100%;
max-width: 242px;
background: $color-blue-200; background: $color-blue-200;
height: 42px; height: 42px;
align-items: center; align-items: center;
@ -244,14 +240,22 @@
font-style: normal; font-style: normal;
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 0.05em; letter-spacing: 0.05em;
transition: ease-in-out 250ms; transition: ease-in-out 280ms;
border: 1px solid $color-blue-200;
&:hover { &:hover {
background-color: $color-white; background-color: $color-blue-100;
color: $color-blue-200;
} }
} }
&__prateleira-div-text ul li {
text-transform: uppercase;
font-family: $font-family;
font-size: 13px;
font-weight: 700;
line-height: 18px;
font-style: normal;
}
} }
@media only screen and (width: 1280px){ @media only screen and (width: 1280px){

View File

@ -16,6 +16,7 @@ $color-gray3: #f0f0f0;
$color-gray4: #8d8d8d; $color-gray4: #8d8d8d;
$color-gray5: #e5e5e5; $color-gray5: #e5e5e5;
$color-blue-100: #6fd5f2;
$color-blue-200: #00C8FF; $color-blue-200: #00C8FF;
$color-blue: #4267b2; $color-blue: #4267b2;