feat : criando o js do footer

This commit is contained in:
PATRICK DE SOUZA SILVA 2022-12-18 19:57:35 -03:00
parent c187a25a96
commit 7468fecb01
8 changed files with 24260 additions and 449 deletions

View File

@ -7,13 +7,19 @@ export default class Footer {
async init() { async init() {
await this.selectors(); await this.selectors();
// this.onUpdate(); this.onUpdate();
this.addPaymentsIcons();
this.addPciIcons();
this.onUpdateShelf();
} }
async selectors() { async selectors() {
//Para verificar se o carrinho está vazio e remover a prateleira de produtos: //Para verificar se o carrinho está vazio e remover a prateleira de produtos:
// vocês devem olhar a doc fornecida no Desafio para aprender a usar o waitElement // vocês devem olhar a doc fornecida no Desafio para aprender a usar o waitElement
this.checkoutVazio = await waitElement(".empty-cart-content"); this.checkoutVazio = await waitElement(".empty-cart-content");
this.paymentIconsContainer = await waitElement(".footerCheckout__payments");
this.iconPci = await waitElement(".footerCheckout__vtexpci");
this.shelfContainer = $(".footerCheckout__prateleira");
} }
onUpdate() { onUpdate() {
@ -21,22 +27,130 @@ export default class Footer {
// vocês devem olhar a doc fornecida no Desafio para aprender a usar a MutationObserver // vocês devem olhar a doc fornecida no Desafio para aprender a usar a MutationObserver
// sempre que o carrinho estiver vazio o elemento chcekoutVazio fica display: none e isso pode ser usado como atributo para a MutationObserver // sempre que o carrinho estiver vazio o elemento chcekoutVazio fica display: none e isso pode ser usado como atributo para a MutationObserver
let target = this.checkoutVazio; let target = this.checkoutVazio;
let config = { childList: true, attributes: true }; let config = { attributes: true };
let observer = new MutationObserver((mutations) => { let observer = new MutationObserver((mutations) => {
mutations.forEach(function (mutation) { mutations.forEach((mutation) => {
console.log(mutation.type); if (target.style.display === "block") {
this.shelfContainer.empty();
$(".slick-slider").removeClass("slick-slider slick-initialized");
} else {
this.createShelf();
}
}); });
}); });
observer.observe(target, config); observer.observe(target, config);
} }
async addCarrossel() {
const elemento = await waitElement("#my-element"); async onUpdateShelf() {
if ($(elemento)) { //Função qeu fará a verificação se o carrinho está vazio para remover a prateleira de produtos:
$(elemento).slick({ // vocês devem olhar a doc fornecida no Desafio para aprender a usar a MutationObserver
// sempre que o carrinho estiver vazio o elemento chcekoutVazio fica display: none e isso pode ser usado como atributo para a MutationObserver
let target = await waitElement(".footerCheckout__prateleira");
let config = { childList: true };
let observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.addedNodes.length > 0) {
if ($(".slick-slide").length <= 0) {
this.addCarrossel(this.shelfContainer);
}
}
});
});
observer.observe(target, config);
$(window).on("hashchange", () => {
const hash = window.location.hash.replace("#/", "");
if (hash !== "cart") {
this.shelfContainer.empty();
$(".slick-slider").removeClass("slick-slider slick-initialized");
} else {
this.createShelf();
}
});
}
async addCarrossel(element) {
if (element) {
element.slick({
lazyLoad: "ondemand",
dots: false,
arrows: true,
infinite: true,
slidesToShow: 4, slidesToShow: 4,
slidesToScroll: 1, slidesToScroll: 1,
speed: 500,
responsive: [
{
breakpoint: 1024,
settings: {
lazyLoad: "ondemand",
slidesToShow: 3,
slidesToScroll: 1,
},
},
{
breakpoint: 375,
settings: {
slidesToShow: 2,
slidesToScroll: 1,
},
},
],
}); });
} }
} }
addPaymentsIcons() {
const html = `
<img src="/arquivos/masterCardM3Academy.png" alt=""/>
<img src="/arquivos/visaM3Academy.png" alt=""/>
<img src="/arquivos/amexM3Academy.png" alt=""/>
<img src="/arquivos/eloM3Academy.png" alt=""/>
<img src="/arquivos/hiperCardM3Academy.png" alt=""/>
<img src="/arquivos/boletoM3Academy.png" alt=""/>
<img src="/arquivos/payPalM3Academy.png" alt=""/>
`;
if (this.paymentIconsContainer) {
this.paymentIconsContainer.innerHTML = html;
}
}
addPciIcons() {
const html = `
<img src="/arquivos/vtexPCIM3Academy.png" alt=""/>
`;
if (this.iconPci) {
this.iconPci.innerHTML = html;
}
}
async createShelf() {
const data = await fetch(
"/api/catalog_system/pub/products/search/?fq=productClusterIds:319"
);
const products = await data.json();
const hash = window.location.hash.replace("#/", "");
const html = products.map(
(product) => `
<div class="productCard">
<img src=${product.items[0].images[0].imageUrl} alt=${product.productName}>
<span>${product.productName}</span>
<div class="skus">
${product.items.map((item) => `<button>${item.name}</button>`)}
</div>
<a>ver produto</a>
</div>
`
);
if (this.shelfContainer && hash === "cart") {
this.shelfContainer.html(html);
}
}
} }

View File

@ -48,11 +48,12 @@ export default class Header {
this.progressBar.innerHTML = progressBar; this.progressBar.innerHTML = progressBar;
this.isActive(); this.isActive();
} }
isActive() { isActive() {
$(`.progress-bar__status.active`).removeClass("active"); $(`.progress-bar__status.active`).removeClass("active");
const hash = window.location.hash.replace("#/", ""); const hash = window.location.hash.replace("#/", "");
$(`.progress-bar__status.${hash}`).addClass("active"); $(`.progress-bar__status.${hash}`).addClass("active");
console.log(`.progress-bar__status .${hash}`);
if (hash === "email" || hash === "shipping") { if (hash === "email" || hash === "shipping") {
$(`.progress-bar__status.profile`).addClass("active"); $(`.progress-bar__status.profile`).addClass("active");
} }

View File

@ -6,8 +6,12 @@
.link-cart { .link-cart {
a { a {
color: $color-black; font-family: $font-family-secundary;
font-size: 14px; font-weight: 400;
font-size: 28px;
line-height: 33px;
text-transform: uppercase;
color: $color-black3;
&:hover { &:hover {
color: lighen($color-black, 10); color: lighen($color-black, 10);
@ -22,15 +26,27 @@
justify-content: center; justify-content: center;
h3 { h3 {
margin-bottom: 16px; margin-top: -85px;
margin-bottom: 23px;
span { span {
color: #303030; font-family: $font-family-secundary;
font-size: 24px; font-weight: 400;
font-size: 40px;
line-height: 47px;
text-transform: uppercase;
color: $color-black3;
} }
small { small {
color: $color-gray4; font-family: $font-family-secundary;
font-weight: 400;
font-size: 40px;
line-height: 47px;
text-transform: uppercase;
color: $color-black3;
} }
} }
} }
@ -39,13 +55,16 @@
margin: 0 0 16px; margin: 0 0 16px;
input { input {
width: 100%;
max-width: 765px;
margin-right: 205px;
box-shadow: none; box-shadow: none;
color: $color-black; color: $color-black3;
font-family: $font-family; font-family: $font-family;
padding: 0 16px; padding: 0 16px;
border: 2px solid $color-gray3; border: 1px solid $color-black3;
box-sizing: border-box; box-sizing: border-box;
border-radius: 5px; border-radius: 5px 0px 0px 5px;
@media (max-width: 490px) { @media (max-width: 490px) {
width: auto; width: auto;
@ -53,12 +72,19 @@
} }
button { button {
background-color: $color-black; background-color: $color-blue2;
border-radius: 5px; border-radius: 0px 8px 8px 0px;
border: none; border: none;
font-family: $font-family; font-family: $font-family;
font-weight: 700;
font-size: 28px;
line-height: 38px;
text-transform: uppercase;
color: $color-black3;
height: 54px; height: 54px;
right: 0; width: 100%;
max-width: 219px;
right: 188px;
top: 0; top: 0;
@media (max-width: 490px) { @media (max-width: 490px) {
@ -69,32 +95,50 @@
} }
span.help.error { span.help.error {
color: red; font-family: $font-family;
font-style: normal;
font-weight: 700;
font-size: 24px;
line-height: 33px;
color: $color-red;
} }
} }
.emailInfo { .emailInfo {
padding: 16px; width: 100%;
max-width: 777px;
max-height: 239px;
padding: 16px 16px 26px;
background-color: $color-white; background-color: $color-white;
border: 1px solid $color-gray4; border: 1px solid $color-gray4;
border-radius: 0; border-radius: 0;
h3 { h3 {
color: #303030; font-family: $font-family;
margin: 0 0 8px 0; font-style: normal;
font-weight: 700;
font-size: 24px;
line-height: 33px;
margin: 0 0 14px 0;
} }
ul { ul {
margin: 0; margin: 0;
font-family: $font-family;
font-style: normal;
font-weight: 700;
font-size: 24px;
line-height: 33px;
li { li {
margin-top: 1px;
line-height: unset;
span { span {
color: $color-black; color: $color-black;
} }
i::before { i::before {
color: $color-black; color: $color-blue2;
font-size: 1rem; font-size: 1.5rem;
opacity: 1; opacity: 1;
} }
} }
@ -105,6 +149,21 @@
font-size: 6rem; font-size: 6rem;
opacity: 0.5; opacity: 0.5;
} }
.icon-lock {
position: absolute;
font-size: unset;
bottom: -23px;
right: 1px;
color: #eaf0ea;
z-index: 1;
&::before {
color: $color-black;
font-size: 153px;
opacity: 0.5;
}
}
} }
} }
@ -119,7 +178,13 @@
.accordion-heading { .accordion-heading {
span { span {
color: #303030; font-family: $font-family-secundary;
font-weight: 400;
font-size: 32px;
line-height: 37px;
color: $color-black;
margin-bottom: 8px; margin-bottom: 8px;
padding: 0; padding: 0;
@ -148,23 +213,54 @@
.client-notice { .client-notice {
color: $color-black; color: $color-black;
} }
.input-small {
width: 100%;
}
p { p {
label { label {
color: $color-black; font-family: $font-family;
font-weight: 500; font-style: normal;
font-weight: 400;
font-size: 28px;
line-height: 38px;
color: $color-gray2;
display: flex;
} }
select, select,
input { input {
width: 100%;
box-sizing: border-box;
border-radius: 0; border-radius: 0;
border: 1px solid $color-gray4; border: 1px solid $color-gray4;
box-shadow: none; box-shadow: none;
height: 61px;
&#opt-in-newsletter {
width: 35px;
height: 35px;
margin-right: 8px;
}
} }
.help.error { .help.error {
color: red; color: red;
} }
&.client-email {
}
&.client-first-name,
&.client-document {
width: calc(50% - 14.5px);
margin-right: 28px;
}
&.client-last-name,
&.client-phone {
width: calc(50% - 14.5px);
}
} }
.box-client-info-pj { .box-client-info-pj {
@ -181,19 +277,26 @@
} }
button.submit { button.submit {
font-family: $font-family;
font-weight: 700;
font-size: 28px;
line-height: 38px;
letter-spacing: 0.05em;
text-transform: uppercase;
color: $color-white;
border: none; border: none;
border-radius: 5px; border-radius: 5px;
background: $color-black; background: $color-blue2;
margin-top: 8px; margin-top: 8px;
outline: none; outline: none;
transition: all 0.2s linear; transition: all 0.2s linear;
width: 100%;
&:hover { &:hover {
background: lighten($color-black, 5); background: lighten($color-blue3, 5);
} }
&:active { &:active {
background: darken($color-black, 5); background: darken($color-blue4, 5);
} }
} }

View File

@ -35,8 +35,9 @@
background: $color-white; background: $color-white;
border: none; border: none;
color: #303030; color: #303030;
font-size: 60px; font-size: 28px;
font-weight: 500; font-weight: 500;
text-align: left;
} }
.item-unavailable { .item-unavailable {
@ -506,6 +507,10 @@
display: none; display: none;
} }
.ship-postalCode { .ship-postalCode {
display: flex;
flex-direction: column;
width: 100%;
label { label {
font-family: $font-family; font-family: $font-family;
color: $color-black3; color: $color-black3;
@ -538,13 +543,11 @@
height: auto; height: auto;
letter-spacing: 1px; letter-spacing: 1px;
outline: none; outline: none;
position: absolute;
right: -150px;
top: 36px;
transition: all 0.2s linear; transition: all 0.2s linear;
width: 100%; width: 100%;
max-width: 194px; max-width: 194px;
text-transform: uppercase; text-transform: uppercase;
margin-top: 12px;
&:hover { &:hover {
background-color: lighten($color-blue3, 5); background-color: lighten($color-blue3, 5);

View File

@ -2,11 +2,11 @@
@import url("https://fonts.googleapis.com/css2?family=Tenor+Sans&display=swap"); @import url("https://fonts.googleapis.com/css2?family=Tenor+Sans&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700;800&display=swap"); @import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700;800&display=swap");
$font-family: "Open Sans", sans-serif; $font-family: "Open Sans", sans-serif;
$font-family-secundary:"Tenor Sans", sans-serif; $font-family-secundary: "Tenor Sans", sans-serif;
/* Colors */ /* Colors */
$color-black: #292929; $color-black: #292929;
$color-black2:#303030; $color-black2: #303030;
$color-black3: #000000; $color-black3: #000000;
$color-white: #fff; $color-white: #fff;
@ -17,14 +17,15 @@ $color-gray3: #f0f0f0;
$color-gray4: #8d8d8d; $color-gray4: #8d8d8d;
$color-gray5: #e5e5e5; $color-gray5: #e5e5e5;
$color-gray6: #989898; $color-gray6: #989898;
$color-gray7:#c4c4c4; $color-gray7: #c4c4c4;
$color-blue: #4267b2; $color-blue: #4267b2;
$color-blue2:#00C8FF; $color-blue2: #00c8ff;
$color-blue3:#00b7ff; $color-blue3: #00b7ff;
$color-blue4:#00b7ffc2; $color-blue4: #00b7ffc2;
$color-green: #4caf50; $color-green: #4caf50;
$color-red: #ff0000;
/* Grid breakpoints */ /* Grid breakpoints */
$grid-breakpoints: ( $grid-breakpoints: (
@ -33,7 +34,7 @@ $grid-breakpoints: (
sm: 576px, sm: 576px,
md: 768px, md: 768px,
lg: 992px, lg: 992px,
xl: 1200px xl: 1200px,
) !default; ) !default;
$z-index: ( $z-index: (
@ -41,5 +42,5 @@ $z-index: (
level2: 10, level2: 10,
level3: 15, level3: 15,
level4: 20, level4: 20,
level5: 25 level5: 25,
) !default; ) !default;

View File

@ -13,6 +13,7 @@
</a> </a>
</div> </div>
<div id="progressBar" class="progress-bar">Aqui entra a barra de progresso</div> <div id="progressBar" class="progress-bar">Aqui entra a barra de progresso</div>
<div class="headerCheckout__safeBuy"> <div class="headerCheckout__safeBuy">
<img <img

23948
package-lock.json generated

File diff suppressed because it is too large Load Diff