feature(header) Feita toda parte do header, main e footer

This commit is contained in:
Douglas Vinicius Nobrega 2022-12-16 14:33:57 -03:00
parent 2dab582c69
commit 1d25963287
6 changed files with 588 additions and 10902 deletions

10970
checkout/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,12 +8,20 @@ export default class Footer {
async init() {
await this.selectors();
// this.onUpdate();
this.payments();
this.iconVtex();
this.developBy();
this.apiPrateleira();
}
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.footerPayments = await waitElement(".footerCheckout__payments");
this.footerVtex = await waitElement(".footerCheckout__vtexpci");
this.footerDevelopBy = await waitElement(".footerCheckout__developedBy");
this.footerPrateleira = await waitElement(".footerCheckout__prateleira");
}
onUpdate() {
@ -37,4 +45,99 @@ export default class Footer {
slidesToScroll: 1,
});
}
payments() {
this.footerPayments.innerHTML = `
<figure class="container__figureIcons">
<img src="https://agenciamagma.vteximg.com.br/arquivos/masterCardM3Academy.png" alt="Bandeira Master Card" />
<img src="https://agenciamagma.vteximg.com.br/arquivos/visaM3Academy.png" alt="Bandeira Visa " />
<img src="https://agenciamagma.vteximg.com.br/arquivos/amexM3Academy.png" alt="Bandeira Amrican Express" />
<img src="https://agenciamagma.vteximg.com.br/arquivos/eloM3Academy.png" alt="Bandeira Elo" />
<img src="https://agenciamagma.vteximg.com.br/arquivos/hiperCardM3Academy.png" alt="Bandeira HiperCard" />
<img src="https://agenciamagma.vteximg.com.br/arquivos/payPalM3Academy.png" alt="Bandeira PayPal" />
<img src="https://agenciamagma.vteximg.com.br/arquivos/boletoM3Academy.png" alt="Código Boleto" />
</figure>
`;
}
iconVtex() {
this.footerVtex.innerHTML = `
<figure class="container__figureVtex">
<img src="https://agenciamagma.vteximg.com.br/arquivos/vtexPCIM3Academy.png" alt="vtex certificado" />
</figure>
`;
}
developBy() {
this.footerDevelopBy.innerHTML = `
<ul class="footerCheckout__developedBy">
<li>
<a href="https://vtex.com/br-pt/">
<span>Powered By</span>
<figure class="container__figureDevelop">
<img src="https://agenciamagma.vteximg.com.br/arquivos/logoVTEXM3Academy.png" alt="Logo Vtex" />
</figure>
</a>
</li>
<li>
<a href="https://agenciam3.com/">
<span>Developed By</span>
<figure class="container__figureDevelop">
<img src="https://agenciamagma.vteximg.com.br/arquivos/logoM3M3Academy.png" alt="Logo M3" />
</figure>
</a>
</li>
</ul>
`;
}
apiPrateleira() {
this.footerPrateleira.innerHTML = `
<h2 class="footerCheckout__prateleira-title">Você também pode gostar:</h2>
<ul class="footerCheckout__prateleira-ul"></ul>
`;
const api =
"https://m3academy.myvtex.com/api/catalog_system/pub/products/search/?fq=productClusterIds:319";
const ulProd = document.querySelector(".footerCheckout__prateleira-ul");
fetch(api)
.then((reponse) => {
return reponse.json();
})
.then((data) => {
data.forEach((prod) => {
const imgUl = prod.items[0].images[0].imageUrl;
const nameUl = prod.productName;
const linkUl = prod.link;
ulProd.innerHTML += `
<li class="footerCheckout__prateleira-li-ulProd">
<figure class="footerCheckout__prateleira-figure-ulProd">
<img src="${imgUl}" alt="Imagem Produto" >
</figure>
<div class="footerCheckout__prateleira-div-text" >
<h2>${nameUl}</h2>
<ul>
${prod.items
.map(
(name) => `<li>
${name.name} </li>`
)
.join("")}
</ul>
<a href=${linkUl}>
Ver produto
</a>
</div>
</li>
`;
});
});
}
}

View File

@ -4,18 +4,133 @@ import { waitElement } from "m3-utils";
export default class Header {
constructor() {
this.init();
this.progressBarHTML();
}
async init() {
await this.selectors();
console.log(this.item);
this.progressBarHTML();
this.replacedNames();
await this.progressBarActive();
}
async selectors() {
this.item = await waitElement("#my-element", {
//#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.progressBar = await waitElement("#progressBar");
this.titleMain = await waitElement("#cart-title");
this.pMain = await waitElement(".empty-cart-message");
}
replacedNames() {
this.titleMain.innerHTML = "";
this.pMain.innerHTML = "";
}
progressBarHTML() {
if (window.screen.width > 1024) {
this.progressBar.innerHTML = `
<ul>
<li class="containerLi">
<p class="progress-bar-text">Meu carinho</p>
<p id="progress-bar-circle-1" class="progress-bar-circle-1"></p>
<p class="progress-bar-line-1"></p>
</li>
<li class="central">
<p class="progress-bar-text">Dados Pessoais</p>
<p id="progress-bar-circle-2" class="progress-bar-circle-2"></p>
</li>
<li class="containerLi">
<p class="progress-bar-text">Pagamento</p>
<p id="progress-bar-circle-3" class="progress-bar-circle-3"></p>
<p class="progress-bar-line-2"></p>
</li>
</ul>
`;
}
if (window.screen.width <= 1024) {
this.progressBar.innerHTML = "";
}
}
checkCircle1(el) {
if (el.children["progress-bar-circle-1"]) {
el.children["progress-bar-circle-1"].classList.add("active");
}
if (el.children["progress-bar-circle-2"]) {
if (el.children["progress-bar-circle-2"].classList.contains("active")) {
el.children["progress-bar-circle-2"].classList.remove("active");
}
}
if (el.children["progress-bar-circle-3"]) {
if (el.children["progress-bar-circle-3"].classList.contains("active")) {
el.children["progress-bar-circle-3"].classList.remove("active");
}
}
}
checkCircle2(el) {
if (el.children["progress-bar-circle-1"]) {
if (el.children["progress-bar-circle-1"].classList.contains("active")) {
el.children["progress-bar-circle-1"].classList.remove("active");
}
}
if (el.children["progress-bar-circle-2"]) {
el.children["progress-bar-circle-2"].classList.add("active");
}
if (el.children["progress-bar-circle-3"]) {
if (el.children["progress-bar-circle-3"].classList.contains("active")) {
el.children["progress-bar-circle-3"].classList.remove("active");
}
}
}
checkCircle3(el) {
if (el.children["progress-bar-circle-1"]) {
if (el.children["progress-bar-circle-1"].classList.contains("active")) {
el.children["progress-bar-circle-1"].classList.remove("active");
}
}
if (el.children["progress-bar-circle-2"]) {
if (el.children["progress-bar-circle-2"].classList.contains("active")) {
el.children["progress-bar-circle-2"].classList.remove("active");
}
}
if (el.children["progress-bar-circle-3"]) {
el.children["progress-bar-circle-3"].classList.add("active");
}
}
async progressBarActive() {
if (this.progressBar && window.screen.width > 1024) {
const progressBarLi = document.querySelectorAll("#progressBar ul li");
progressBarLi.forEach((el) => {
if (window.location.href === "https://m3academy.myvtex.com/checkout/#/cart") {
this.checkCircle1(el);
} 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"
) {
this.checkCircle2(el);
} else if (
window.location.href === "https://m3academy.myvtex.com/checkout/#/payment"
) {
this.checkCircle3(el);
}
window.addEventListener("hashchange", () => {
if (window.location.hash == "#/cart") {
this.checkCircle1(el);
} else if (
window.location.hash == "#/email" ||
window.location.hash == "#/profile" ||
window.location.hash == "#/shipping"
) {
this.checkCircle2(el);
} else if (window.location.hash == "#/payment") {
this.checkCircle3(el);
}
});
});
}
}
}

View File

@ -1,23 +1,39 @@
/* _footer.scss */
.footerCheckout {
border-top: none;
color: $color-gray2;
.footerCheckout::after,
::before {
display: none;
content: none;
}
.footerCheckout::before,
::after {
display: none;
content: none;
}
.container {
padding: 0 32px !important;
width: 100%;
}
&__wrapper {
width: 100% !important;
border-top: 1px solid black;
align-items: center;
display: flex;
justify-content: space-between;
}
&__address {
color: $color-gray2;
font-family: $font-family;
font-family: "Open Sans";
font-style: normal;
font-weight: normal;
font-weight: 400;
font-size: 10px;
line-height: 12px;
line-height: 14px;
text-transform: capitalize;
max-width: 40%;
color: #292929;
@include mq(md, max) {
margin-bottom: 24px;
@ -71,4 +87,114 @@
}
}
}
.container {
height: 67px;
padding: 16px 0;
display: flex;
align-items: center;
justify-content: space-between;
&__figureIcons {
display: flex;
align-items: center;
justify-content: center;
gap: 13.36px;
margin: 0px;
img {
max-width: 36px;
max-height: 20px;
}
}
&__figureVtex {
margin: 0px;
img {
max-width: 53px;
max-height: 33px;
}
}
&__figureDevelop {
margin: 0;
img {
max-width: 45px;
max-height: 16px;
}
}
}
.div-footer {
display: flex;
align-items: center;
justify-content: space-between;
.ul-start {
display: flex;
justify-content: center;
align-items: center;
list-style-type: none;
&__li {
max-width: 269px;
max-height: 14px;
}
&__paragraph {
font-family: "Open Sans";
font-style: normal;
font-weight: 400;
font-size: 10px;
line-height: 14px;
text-transform: capitalize;
color: #292929;
}
}
.ul-middle {
max-width: 404px;
max-width: 33px;
list-style-type: none;
display: flex;
align-items: center;
justify-content: center;
li {
max-width: 35px;
}
figure {
width: 35px;
height: 20px;
}
&__boleto {
border-right: 1px solid black;
}
}
.ul-bottom {
display: flex;
align-items: center;
justify-content: center;
list-style-type: none;
max-width: 217px;
max-height: 16px;
p {
font-family: "Open Sans";
font-style: normal;
font-weight: 400;
font-size: 9px;
line-height: 12px;
color: #292929;
}
figure {
max-width: 44.92px;
max-height: 16px;
}
}
}
}

View File

@ -1,22 +1,29 @@
/* _header.scss */
.headerCheckout {
.container {
width: auto !important;
}
width: 100%;
border-bottom: 1px solid black;
&__wrapper {
align-items: center;
padding: 24px 131px;
display: flex;
align-items: center;
justify-content: space-between;
}
&__logo {
img {
height: 52px;
height: 37px;
width: auto;
}
}
&__safeBuy {
display: flex;
gap: 8px;
justify-content: center;
//width: 11.6895%;
img {
width: 12px;
}
span {
align-items: center;
display: flex;
@ -33,4 +40,138 @@
margin-right: 8px;
}
}
.progress-bar {
width: 439px;
ul {
list-style-type: none;
display: flex;
//align-items: center;
justify-content: space-between;
margin: 0 !important;
}
li .containerLi {
width: 100%;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
position: relative;
}
li .central .containerLi {
align-items: center;
margin-left: 7px;
}
li:last-child .containerLi {
align-items: flex-end;
}
li .containerLi {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}
li .progress-bar-text {
font-family: "Tenor sans", sans-serif;
font-size: 12px;
font-weight: 400;
line-height: 28px;
color: #000;
}
li {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
//width: 39.9103%;
@media (min-width: 2500px) {
font-size: 24px;
}
}
li .central {
width: auto;
}
li #progress-bar-circle-1,
li #progress-bar-circle-2,
li #progress-bar-circle-3 {
width: 12px;
height: 12px;
border: 1px solid black;
border-radius: 50%;
@media (min-width: 2500px) {
width: 24px;
height: 24px;
}
}
li #progress-bar-circle-1.active,
li #progress-bar-circle-2.active,
li #progress-bar-circle-3.active {
border: none;
background-color: #000;
}
li .progress-bar-line-1 {
position: absolute;
left: 56%;
bottom: 5px;
width: 177px;
height: 1px;
border-top: 1px solid #000;
}
li .progress-bar-line-2 {
position: absolute;
right: 60%;
bottom: 5px;
width: 171px;
height: 1px;
border-top: 1px solid #000;
}
}
}
.container {
width: 100%;
.empty-cart-title {
margin-top: 170px;
font-family: "Open Sans";
font-style: normal;
font-weight: 700;
font-size: 24px;
line-height: 33px;
text-align: center;
text-transform: uppercase;
color: #000000;
//max-width: 400px;
height: 30px;
}
#cart-choose-products {
padding: 15px 65px 17px;
margin-bottom: 329px;
border: 1px solid #000000;
font-family: "Tenor Sans";
font-style: normal;
font-weight: 400;
font-size: 14px;
line-height: 16px;
text-align: center;
text-transform: uppercase;
color: #000;
background: #fff;
cursor: pointer;
margin-top: 32px;
border-radius: 0px;
}
}

View File

@ -26,7 +26,6 @@
@TODO: vtex icon
</a>
</li>
<li>
<a href="https://agenciam3.com/">
<span>Developed By</span>