development #7

Merged
WellingtonDuarteSantos merged 12 commits from development into main 2022-12-19 02:48:24 +00:00
12 changed files with 26563 additions and 17093 deletions

View File

@ -8,18 +8,187 @@ export default class Footer {
async init() {
await this.selectors();
//this.onUpdate();
// await this.hideCartTitle();
this.addCreditCards();
this.addCredits();
this.createPrateleira();
await this.addCarrossel();
// this.changeButtonText();
}
async selectors() {
//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
this.checkoutVazio = await waitElement(".empty-cart-content");
this.checkoutTitle = await waitElement("#cart-title");
// this.productName = await waitElement("#product-name");
this.creditCardSection = await waitElement(".footerCheckout__stamps");
this.creditsSection = await waitElement(".footerCheckout__developedBy");
this.prateleira = await waitElement(".footerCheckout__prateleira");
console.log(this.creditCardSection);
this.cartChooseProducts = await waitElement("a#cart-choose-products");
}
// Oculta o titulo quando o carrinho está vazio
async hideCartTitle() {
if (this.checkoutVazio) {
console.log("Carrinho Vazio, removendo título");
this.checkoutTitle.classList.add("hidden");
}
// if (this.productName) {
// console.log("Produto Encontrado, adicionando título");
// if (this.checkoutTitle.classList.contains("hidden")) {
// console.log("Titulo tá escondido");
// this.checkoutTitle.classList.remove("hidden");
// this.checkoutTitle.classList.add("visible");
// }
// }
}
// Muda o texto do botão do carrinho vazio
changeButtonText() {
// console.log("Mudando texto do botão");
this.cartChooseProducts.innerText = "Continue Comprando";
}
// Adiciona as imagens das bandeiras dos cartões
addCreditCards() {
this.creditCardSection.innerHTML = `
<div class="credit-cards">
<figure class="cards-logo">
<img
src="https://agenciamagma.vteximg.com.br/arquivos/masterCardM3Academy.png"
alt="MasterCard logo"
/>
</figure>
<figure class="cards-logo">
<img
src="https://agenciamagma.vteximg.com.br/arquivos/visaM3Academy.png"
alt="Visa logo"
/>
</figure>
<figure class="cards-logo">
<img
src="https://agenciamagma.vteximg.com.br/arquivos/amexM3Academy.png"
alt="American Express logo"
/>
</figure>
<figure class="cards-logo">
<img
class="cards-logo"
src="https://agenciamagma.vteximg.com.br/arquivos/eloM3Academy.png"
alt="Elo logo"
/>
</figure>
<figure class="cards-logo">
<img
src="https://agenciamagma.vteximg.com.br/arquivos/payPalM3Academy.png"
alt="PayPal logo"
/>
</figure>
<figure class="cards-logo">
<img
src="https://agenciamagma.vteximg.com.br/arquivos/boletoM3Academy.png"
alt="Boleto logo"
/>
</figure>
<figure class="cards-logo">
<img
src="https://agenciamagma.vteximg.com.br/arquivos/vtexPCIM3Academy.png"
alt="Vtex Certified logo"
/>
</figure>
</div>`;
}
// Adiciona as informações de copyrigth
addCredits() {
this.creditsSection.innerHTML = `<div class="credits">
<div class="credit-text">Powered By</div>
<div class="logo">
<figure>
<img
src="https://agenciamagma.vteximg.com.br/arquivos/logoVTEXM3Academy.png"
alt="VTex Logo"
/>
</figure>
</div>
<div class="credit-text">Developed by</div>
<div class="logo">
<figure>
<img
src="https://agenciamagma.vteximg.com.br/arquivos/logoM3M3Academy.png"
alt="M3 Logo"
/>
</figure>
</div>`;
}
// API
createPrateleira() {
fetch(
"https://m3academy.myvtex.com/api/catalog_system/pub/products/search/?fq=productClusterIds:319"
)
.then(function () {
console.log("Consumindo API");
})
.catch(function () {});
fetch(
`https://m3academy.myvtex.com/api/catalog_system/pub/products/search/?fq=productClusterIds:319`
)
.then((response) => response.json())
.then((data) => {
console.log(data[0].items[0].images[0].imageUrl);
let content = "";
for (let i = 0; i < data.length; i++) {
content += `
<div class="card-item">
<figure class="item-image">
<img src="${data[i].items[0].images[0].imageUrl}" alt="" />
</figure>
<div class="item-name">
<p>${data[i].productName}</p>
</div>
<div class="item-sizes">
<div class="item-size-name">
<p>${data[i].items[0].name}</p>
</div>
</div>
<a href="${data[i].items[0].link}" class="item-link">
<div>VER PRODUTO</div>
</a>
</div>
`;
}
this.prateleira.innerHTML = content;
console.log(content);
});
}
onUpdate() {
//Função qeu fará a verificação se o carrinho está vazio para remover a prateleira de produtos:
// Função que fará a verificação se o carrinho está vazio para remover a prateleira de produtos:
// 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 checkoutVazio fica display: none e isso pode ser usado como atributo para a MutationObserver
let target = this.checkoutVazio;
let config = { childList: true, attributes: true };
let observer = new MutationObserver((mutations) => {
@ -29,11 +198,14 @@ export default class Footer {
});
observer.observe(target, config);
this.cartChooseProducts.innerHTML = "Continuar Comprando";
}
async addCarrossel() {
const elemento = await waitElement("#my-element");
const elemento = await waitElement(".footerCheckout__prateleira");
$(elemento).slick({
slidesToShow: 4,
slidesToShow: 2,
slidesToScroll: 1,
});
}

View File

@ -8,14 +8,175 @@ export default class Header {
async init() {
await this.selectors();
console.log(this.item);
this.progressBarHTML();
await this.progressbarProgress();
this.changeButtonText();
}
async selectors() {
this.item = await waitElement("#my-element", {
this.item = await waitElement("#progressBar", {
//#my-element pode ser a class ou o id do elemento html qeu vocÊ quer pegar
timeout: 5000, // vai esperar 5 segundos antes de rejeitar a promise
interval: 1000, // vai verificar a cada 1 segundo se o elemento existe
});
this.header = await waitElement(".headerCheckout");
this.progressBar = await waitElement("#progressBar");
// CART TITLE
this.cartChooseProducts = await waitElement("a#cart-choose-products");
}
changeButtonText() {
// console.log("Mudando texto do botão");
this.cartChooseProducts.innerText = "Continue Comprando";
}
progressBarHTML() {
if (this.progressBar && window.innerWidth > 1024) {
console.log("Gerando barra de progresso");
this.progressBar.innerHTML = `
<ul>
<li>
<div class="containerLi">
<div>
<p class="progress-bar-text">Meu Carrinho</p>
<p id="progress-bar-circle-1" class="progress-bar-circle-1"></p>
<p class=" progress-bar-line-1"></p>
</div>
</div>
</li>
<li class="central">
<div class="containerLi">
<div>
<p class="progress-bar-text">Dados Pessoais</p>
<p id="progress-bar-circle-2" class="progress-bar-circle-1"></p>
<p class=" progress-bar-line-2"></p>
</div>
</div>
</li>
<li>
<div class="containerLi">
<div>
<p class="progress-bar-text">Pagamento</p>
<p id="progress-bar-circle-3" class="progress-bar-circle-1"></p>
<p class=" progress-bar-line-3"></p>
</div>
</div>
</li>
</ul>
`;
}
if (this.progressBar && window.innerWidth <= 1024) {
this.progressBar.innerHTML = "";
}
}
async progressbarProgress() {
if (this.progressBar && window.innerWidth > 1024) {
const progressBarLista = document.querySelectorAll("#progressBar ul li");
progressBarLista.forEach((li) => {
if (window.location.href === "https://m3academy.myvtex.com/checkout/#/cart") {
console.log("Cheguei no carrinho");
if (li.children[0].children[0].children["progress-bar-circle-1"]) {
li.children[0].children[0].children["progress-bar-circle-1"].classList.add(
"active"
);
}
if (li.children[0].children[0].children["progress-bar-circle-2"]) {
if (
li.children[0].children[0].children[
"progress-bar-circle-2"
].classList.contains("active")
) {
li.children[0].children[0].children[
"progress-bar-circle-2"
].classList.remove("active");
}
}
if (li.children[0].children[0].children["progress-bar-circle-3"]) {
if (
li.children[0].children[0].children[
"progress-bar-circle-3"
].classList.contains("active")
) {
li.children[0].children[0].children[
"progress-bar-circle-3"
].classList.remove("active");
}
}
} else if (
window.location.href === "https://m3academy.myvtex.com/checkout/#/email" ||
window.location.href === "https://m3academy.myvtex.com/checkout/#/profile" ||
window.location.href === "https://m3academy.myvtex.com/checkout/#/shipping"
) {
console.log("Cheguei nas informações pessoais");
if (li.children[0].children[0].children["progress-bar-circle-1"]) {
if (
li.children[0].children[0].children[
"progress-bar-circle-1"
].classList.contains("active")
) {
li.children[0].children[0].children[
"progress-bar-circle-1"
].classList.remove("active");
}
}
if (li.children[0].children[0].children["progress-bar-circle-2"]) {
li.children[0].children[0].children["progress-bar-circle-2"].classList.add(
"active"
);
}
if (li.children[0].children[0].children["progress-bar-circle-3"]) {
if (
li.children[0].children[0].children[
"progress-bar-circle-3"
].classList.contains("active")
) {
li.children[0].children[0].children[
"progress-bar-circle-3"
].classList.remove("active");
}
}
} else if (
window.location.href === "https://m3academy.myvtex.com/checkout/#/payment"
) {
console.log("Cheguei no pagamento");
if (li.children[0].children[0].children["progress-bar-circle-1"]) {
if (
li.children[0].children[0].children[
"progress-bar-circle-1"
].classList.contains("active")
) {
li.children[0].children[0].children[
"progress-bar-circle-1"
].classList.remove("active");
}
}
if (li.children[0].children[0].children["progress-bar-circle-2"]) {
if (
li.children[0].children[0].children[
"progress-bar-circle-2"
].classList.contains("active")
) {
li.children[0].children[0].children[
"progress-bar-circle-2"
].classList.remove("active");
}
}
if (li.children[0].children[0].children["progress-bar-circle-3"]) {
li.children[0].children[0].children["progress-bar-circle-3"].classList.add(
"active"
);
}
}
});
}
}
}

View File

@ -2,4 +2,5 @@
@import "./lib/slick";
@import "./partials/header";
@import "./partials/footer";
@import "./partials/prateleira";
@import "./checkout/checkout.scss";

View File

@ -114,7 +114,7 @@
color: $color-black;
padding: 0 0 16px;
font-style: normal;
font-weight: bold;
font-weight: 400;
font-size: 14px;
line-height: 16px;
@ -155,7 +155,7 @@
}
a {
color: $color-blue;
color: #000000;
font-style: normal;
font-weight: normal;
font-size: 12px;
@ -217,15 +217,17 @@
td.quantity {
align-items: center;
border: 1px solid $color-gray3;
border-radius: 0;
width: 100px;
border: 1px solid #f0f0f0;
color: #ffffff;
border-radius: 8px;
box-sizing: border-box;
display: flex;
justify-content: center;
margin: 6px auto 0;
max-height: 38px;
max-width: 118px;
padding: 0;
padding: 9px;
width: max-content !important;
@media (max-width: 490px) {
@ -234,9 +236,9 @@
input {
background-color: $color-white;
border: 1px solid $color-gray3;
border: 0px solid $color-gray3;
border-radius: 0;
border-width: 0 1px;
border-width: 0 0px;
display: block;
max-height: 38px;
margin: 0 !important;
@ -263,18 +265,29 @@
.icon-minus-sign {
&:before {
content: "-";
font-size: 16px;
font-size: 20px;
color: white;
background-color: #00c8ff;
border-radius: 50%;
font-weight: 900;
}
}
.icon-plus-sign {
&:before {
content: "+";
font-size: 14px;
font-size: 20px;
color: white;
background-color: #00c8ff;
border-radius: 50%;
font-weight: 900;
}
}
.item-quantity-change {
width: 100%;
height: 100%;
@media (max-width: 979px) and (min-width: 768px) {
position: inherit;
bottom: inherit;
@ -287,6 +300,13 @@
@media (max-width: 490px) {
padding: 0;
}
.item-quantity-change-decrement {
background-color: #00c8ff;
border-radius: 50%;
width: 100%;
height: 100%;
}
}
}
@ -608,7 +628,7 @@
font-weight: normal;
font-size: 12px;
line-height: 14px;
color: $color-blue;
color: #000000;
text-decoration: none;
}
}
@ -731,6 +751,7 @@
}
tfoot {
font-weight: 900 !important;
td.info,
td.monetary {
font-style: normal;
@ -738,6 +759,7 @@
font-size: 18px;
line-height: 21px;
color: $color-black;
font-weight: 900;
}
}
}
@ -782,16 +804,17 @@
.btn-place-order-wrapper {
a {
background: $color-green;
background: #00c8ff;
border: none;
border-radius: 5px;
display: block;
font-size: 0;
transition: ease-in 0.22s all;
padding: 12px 19px;
cursor: pointer;
&:hover {
background-color: darken($color-green, 5);
background-color: darken(#00c8ff, 5);
}
&:after {

View File

@ -10,29 +10,37 @@
}
&-title {
font-size: 20px;
text-transform: uppercase;
font-weight: 700;
font-size: 24px;
line-height: 33px;
}
&-links {
.link-choose-products {
background: $color-black;
border: none;
border-radius: 5px;
background: white;
border: 1px solid #000000;
transition: ease-in 0.22s all;
outline: none;
font-family: $font-family;
font-family: "Tenor Sans";
font-style: normal;
font-weight: 500;
font-weight: 400;
font-size: 14px;
line-height: 16px;
text-align: center;
letter-spacing: 0.05em;
color: $color-white;
color: #000;
text-transform: uppercase;
cursor: pointer;
padding: 16px 65px;
&:hover {
background: lighten($color-black, 5);
background: white;
}
}
}
&-message {
display: none;
}
}

View File

@ -66,16 +66,24 @@ body {
color: $color-black !important;
}
.hidden {
display: none;
}
.visible {
display: block;
}
#cart-title,
#orderform-title {
color: $color-gray2;
color: #292929;
font-family: $font-family;
font-weight: 500;
font-size: 36px;
line-height: 42px;
margin: 40px 0 30px;
letter-spacing: 0.1em;
text-transform: uppercase;
font-weight: 700;
font-size: 24px;
line-height: 33px;
@include mq(md, max) {
margin-left: 30px;

View File

@ -1,12 +1,62 @@
/* _footer.scss */
.footerCheckout {
border-top: none;
color: $color-gray2;
width: 100%;
bottom: 0;
&__wrapper {
border-top: 1px solid black;
padding-top: 16px;
padding-bottom: 16px;
align-items: center;
display: flex;
justify-content: space-between;
.container {
display: flex;
flex-direction: row;
width: 100%;
justify-content: space-between;
.credit-cards {
display: flex;
.cards-logo {
width: 36px;
height: 20px;
margin: 0;
margin-right: 13px;
}
}
}
.credits {
display: flex;
gap: 10px;
margin: 0;
padding: 0;
align-items: baseline;
.credit-text {
font-weight: 400;
font-size: 9px;
line-height: 12px;
}
.logo {
width: 44px;
height: 16px;
figure {
margin: 0;
width: 100%;
img {
height: 16px;
}
}
}
}
}
&__address {

View File

@ -1,22 +1,115 @@
/* _header.scss */
.headerCheckout {
width: 100%;
margin: 0;
border-bottom: 1px solid black;
.container {
width: auto !important;
width: 100% !important;
}
&__wrapper {
width: 80%;
align-items: center;
margin: 30px auto;
display: flex;
justify-content: space-between;
.progress-bar {
width: 100%;
& ul {
display: flex;
list-style-type: none;
justify-content: space-around;
margin: 0;
& li {
.containerLi {
& div {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
.progress-bar-text {
font-weight: 400;
font-size: 12px;
line-height: 14px;
}
.progress-bar-circle-1 {
width: 16px;
height: 16px;
border: 1px solid black;
margin: 0;
border-radius: 50%;
background-color: white;
}
.progress-bar-circle-2 {
width: 16px;
height: 16px;
border: 1px solid black;
margin: 0;
border-radius: 50%;
background-color: white;
}
.progress-bar-circle-3 {
width: 16px;
height: 16px;
border: 1px solid black;
margin: 0;
border-radius: 50%;
background-color: white;
}
.progress-bar-line-1 {
border-bottom: 1px solid black;
width: 200px;
position: absolute;
bottom: 0;
left: 50%;
z-index: -1;
}
.progress-bar-line-2 {
border-bottom: 1px solid black;
width: 200px;
position: absolute;
bottom: 0;
z-index: -1;
}
.progress-bar-line-3 {
border-bottom: 1px solid black;
width: 200px;
position: absolute;
bottom: 0;
right: 50%;
z-index: -1;
}
.active {
background-color: black;
}
}
}
}
}
}
}
&__logo {
img {
height: 52px;
width: auto;
height: 37px;
width: 156px;
}
}
&__safeBuy {
display: flex;
flex-direction: row;
img {
width: 12px;
height: 15px;
}
span {
align-items: center;
display: flex;
@ -27,6 +120,7 @@
font-size: 12px;
line-height: 14px;
color: $color-gray;
margin-left: 8px;
}
i {

View File

@ -1 +1,70 @@
/* _prateleira.scss */
.footerCheckout__prateleira {
margin: 43px 132px;
display: flex;
justify-content: center;
color: #000000;
.prateleira-title {
font-weight: 400;
font-size: 24px;
line-height: 38px;
text-align: center;
}
.card-item {
margin-right: 16px;
width: 242px;
.item-image {
width: 242px;
height: 242px;
margin: 0;
img {
width: 100%;
}
}
.item-name {
margin-top: 20px;
font-weight: 400;
font-size: 13px;
line-height: 18px;
text-align: center;
}
.item-sizes {
.item-size-name {
margin-top: 20px;
align-items: center;
text-align: center;
font-weight: 700;
font-size: 13px;
line-height: 18px;
color: white;
padding: 6px;
background-color: #00c8ff;
width: auto;
}
}
.item-link {
margin-top: 20px;
display: block;
justify-content: center;
background-color: #00c8ff;
color: white;
text-decoration: none;
width: 100%;
padding: 12px 0px;
display: flex;
align-items: center;
text-align: center;
font-weight: 700;
font-size: 13px;
line-height: 18px;
}
}
}

View File

@ -6,13 +6,18 @@
<div class="headerCheckout__wrapper">
<div class="headerCheckout__logo">
<a href="/">
<img src="https://agenciamagma.vteximg.com.br/arquivos/LogoM3Academy.png" alt="M3 Academy"/>
<img
src="https://agenciamagma.vteximg.com.br/arquivos/LogoM3Academy.png"
alt="M3 Academy"
/>
</a>
</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">
<img src="https://agenciamagma.vteximg.com.br/arquivos/cadeadoCompraSegM3Academy.png" alt="Cadeado"/>
<img
src="https://agenciamagma.vteximg.com.br/arquivos/cadeadoCompraSegM3Academy.png"
alt="Cadeado"
/>
<span>Compra segura</span>
</div>
</div>

32071
package-lock.json generated

File diff suppressed because it is too large Load Diff

9174
yarn.lock Normal file

File diff suppressed because it is too large Load Diff