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

@ -1,289 +1,392 @@
.checkout-container { .checkout-container {
.client-pre-email { .client-pre-email {
border-color: $color-gray4; border-color: $color-gray4;
font-family: $font-family; font-family: $font-family;
padding-top: 8px; padding-top: 8px;
.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);
} }
} }
} }
.pre-email { .pre-email {
flex-direction: column; flex-direction: column;
display: flex; display: flex;
align-items: center; align-items: center;
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;
small { color: $color-black3;
color: $color-gray4; }
}
}
}
.client-email { small {
margin: 0 0 16px; font-family: $font-family-secundary;
font-weight: 400;
font-size: 40px;
line-height: 47px;
text-transform: uppercase;
input { color: $color-black3;
box-shadow: none; }
color: $color-black; }
font-family: $font-family; }
padding: 0 16px;
border: 2px solid $color-gray3;
box-sizing: border-box;
border-radius: 5px;
@media (max-width: 490px) { .client-email {
width: auto; margin: 0 0 16px;
}
}
button { input {
background-color: $color-black; width: 100%;
border-radius: 5px; max-width: 765px;
border: none; margin-right: 205px;
font-family: $font-family; box-shadow: none;
height: 54px; color: $color-black3;
right: 0; font-family: $font-family;
top: 0; padding: 0 16px;
border: 1px solid $color-black3;
box-sizing: border-box;
border-radius: 5px 0px 0px 5px;
@media (max-width: 490px) { @media (max-width: 490px) {
height: 48px; width: auto;
margin: 0; }
position: absolute; }
}
}
span.help.error { button {
color: red; background-color: $color-blue2;
} border-radius: 0px 8px 8px 0px;
} border: none;
font-family: $font-family;
font-weight: 700;
font-size: 28px;
line-height: 38px;
text-transform: uppercase;
color: $color-black3;
height: 54px;
width: 100%;
max-width: 219px;
right: 188px;
top: 0;
.emailInfo { @media (max-width: 490px) {
padding: 16px; height: 48px;
background-color: $color-white; margin: 0;
border: 1px solid $color-gray4; position: absolute;
border-radius: 0; }
}
h3 { span.help.error {
color: #303030; font-family: $font-family;
margin: 0 0 8px 0; font-style: normal;
} font-weight: 700;
font-size: 24px;
line-height: 33px;
color: $color-red;
}
}
ul { .emailInfo {
margin: 0; width: 100%;
max-width: 777px;
max-height: 239px;
padding: 16px 16px 26px;
background-color: $color-white;
border: 1px solid $color-gray4;
border-radius: 0;
li { h3 {
span { font-family: $font-family;
color: $color-black; font-style: normal;
} font-weight: 700;
font-size: 24px;
line-height: 33px;
margin: 0 0 14px 0;
}
i::before { ul {
color: $color-black; margin: 0;
font-size: 1rem; font-family: $font-family;
opacity: 1; font-style: normal;
} font-weight: 700;
} font-size: 24px;
} line-height: 33px;
li {
margin-top: 1px;
line-height: unset;
span {
color: $color-black;
}
i::before { i::before {
color: $color-black; color: $color-blue2;
font-size: 6rem; font-size: 1.5rem;
opacity: 0.5; opacity: 1;
} }
} }
} }
.shipping-data, i::before {
.payment-data, color: $color-black;
.client-profile-data { font-size: 6rem;
.accordion-group { opacity: 0.5;
border-radius: 0; }
border: 1px solid $color-gray4;
font-family: $font-family;
padding: 16px;
.accordion-heading { .icon-lock {
span { position: absolute;
color: #303030; font-size: unset;
margin-bottom: 8px; bottom: -23px;
padding: 0; right: 1px;
color: #eaf0ea;
z-index: 1;
i::before { &::before {
fill: #303030; color: $color-black;
} font-size: 153px;
} opacity: 0.5;
}
}
}
}
a { .shipping-data,
align-items: center; .payment-data,
background-color: #303030; .client-profile-data {
border-radius: 8px; .accordion-group {
border: none; border-radius: 0;
color: $color-white; border: 1px solid $color-gray4;
display: flex; font-family: $font-family;
justify-content: center; padding: 16px;
padding: 6px 5px 6px 8px;
}
}
.accordion-inner { .accordion-heading {
padding: 0; span {
font-family: $font-family-secundary;
font-weight: 400;
font-size: 32px;
line-height: 37px;
/* General configurations */ color: $color-black;
.client-notice { margin-bottom: 8px;
color: $color-black; padding: 0;
}
p { i::before {
label { fill: #303030;
color: $color-black; }
font-weight: 500; }
}
select, a {
input { align-items: center;
border-radius: 0; background-color: #303030;
border: 1px solid $color-gray4; border-radius: 8px;
box-shadow: none; border: none;
} color: $color-white;
display: flex;
justify-content: center;
padding: 6px 5px 6px 8px;
}
}
.help.error { .accordion-inner {
color: red; padding: 0;
}
}
.box-client-info-pj { /* General configurations */
.link a#is-corporate-client,
.link a#not-corporate-client {
color: $color-black;
font-weight: 500;
text-decoration: underline;
}
}
.state-inscription-box span { .client-notice {
font-weight: 500; color: $color-black;
} }
.input-small {
width: 100%;
}
button.submit { p {
border: none; label {
border-radius: 5px; font-family: $font-family;
background: $color-black; font-style: normal;
margin-top: 8px; font-weight: 400;
outline: none; font-size: 28px;
transition: all 0.2s linear; line-height: 38px;
color: $color-gray2;
display: flex;
}
&:hover { select,
background: lighten($color-black, 5); input {
} width: 100%;
box-sizing: border-box;
border-radius: 0;
border: 1px solid $color-gray4;
box-shadow: none;
height: 61px;
&:active { &#opt-in-newsletter {
background: darken($color-black, 5); width: 35px;
} height: 35px;
} margin-right: 8px;
}
}
/* Shipping configurations */ .help.error {
color: red;
}
.ship-postalCode small a { &.client-email {
color: #303030; }
font-weight: 500;
text-decoration: underline;
}
.vtex-omnishipping-1-x-deliveryGroup { &.client-first-name,
p { &.client-document {
color: #303030; width: calc(50% - 14.5px);
font-size: 14px; margin-right: 28px;
font-weight: 500; }
}
.shp-lean { &.client-last-name,
border: 1px solid $color-gray4; &.client-phone {
border-radius: 0; width: calc(50% - 14.5px);
}
}
label { .box-client-info-pj {
background-color: $color-white; .link a#is-corporate-client,
box-shadow: none; .link a#not-corporate-client {
color: #303030; color: $color-black;
padding: 8px 12px; font-weight: 500;
text-decoration: underline;
}
}
svg path { .state-inscription-box span {
fill: #d8c8ac; font-weight: 500;
} }
}
}
}
.delivery-address-title { button.submit {
color: #303030; font-family: $font-family;
font-size: 14px; font-weight: 700;
font-weight: 500; font-size: 28px;
} line-height: 38px;
letter-spacing: 0.05em;
text-transform: uppercase;
color: $color-white;
border: none;
border-radius: 5px;
background: $color-blue2;
margin-top: 8px;
outline: none;
transition: all 0.2s linear;
width: 100%;
&:hover {
background: lighten($color-blue3, 5);
}
.shp-summary-group-info { &:active {
border-color: $color-gray4; background: darken($color-blue4, 5);
} }
}
.address-summary { /* Shipping configurations */
background: none;
border-color: $color-gray4;
border-radius: 0;
color: #303030;
padding: 12px;
@include mq(md, max) { .ship-postalCode small a {
background-position: 8px 9px; color: #303030;
} font-weight: 500;
text-decoration: underline;
}
a { .vtex-omnishipping-1-x-deliveryGroup {
color: #303030; p {
font-weight: 500; color: #303030;
text-decoration: underline; font-size: 14px;
} font-weight: 500;
} }
.shp-summary-group-price, .shp-lean {
.shp-summary-package { border: 1px solid $color-gray4;
color: $color-gray4; border-radius: 0;
}
.shp-summary-group-price { label {
padding-right: 16px; background-color: $color-white;
} box-shadow: none;
color: #303030;
padding: 8px 12px;
.shp-summary-package { svg path {
padding-left: 16px; fill: #d8c8ac;
} }
}
}
}
.vtex-omnishipping-1-x-summaryChange { .delivery-address-title {
border-color: #303030; color: #303030;
color: #303030; font-size: 14px;
} font-weight: 500;
}
.vtex-omnishipping-1-x-deliveryChannelsToggle { .shp-summary-group-info {
background-color: #d8c8ac; border-color: $color-gray4;
border: 1px solid #d8c8ac; }
}
.vtex-omnishipping-1-x-deliveryOptionActive { .address-summary {
text-shadow: 1.3px 1px lighten($color-black, 50); background: none;
} border-color: $color-gray4;
} border-radius: 0;
} color: #303030;
} padding: 12px;
@include mq(md, max) {
background-position: 8px 9px;
}
a {
color: #303030;
font-weight: 500;
text-decoration: underline;
}
}
.shp-summary-group-price,
.shp-summary-package {
color: $color-gray4;
}
.shp-summary-group-price {
padding-right: 16px;
}
.shp-summary-package {
padding-left: 16px;
}
.vtex-omnishipping-1-x-summaryChange {
border-color: #303030;
color: #303030;
}
.vtex-omnishipping-1-x-deliveryChannelsToggle {
background-color: #d8c8ac;
border: 1px solid #d8c8ac;
}
.vtex-omnishipping-1-x-deliveryOptionActive {
text-shadow: 1.3px 1px lighten($color-black, 50);
}
}
}
}
} }

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,29 +17,30 @@ $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: (
xs: 0, xs: 0,
cstm: 400, cstm: 400,
sm: 576px, sm: 576px,
md: 768px, md: 768px,
lg: 992px, lg: 992px,
xl: 1200px xl: 1200px,
) !default; ) !default;
$z-index: ( $z-index: (
level1: 5, level1: 5,
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

23950
package-lock.json generated

File diff suppressed because it is too large Load Diff