feat: adiciona a prateleira a pagina

This commit is contained in:
Leonardo Pereira Rocha 2022-12-14 18:53:05 -03:00
parent 681274c0fd
commit c6f21500ac
4 changed files with 446 additions and 254 deletions

View File

@ -7,6 +7,8 @@ export default class Footer {
async init() {
await this.selectors();
this.catalogoApi();
// this.onUpdate();
}
@ -14,6 +16,33 @@ export default class Footer {
//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.footerPrateleira = document.querySelector(".footerCheckout__prateleira");
}
async catalogoApi() {
this.addCarrossel();
this.footerPrateleira.innerHTML = `<ul class="products-list"></ul>`;
fetch(
"https://m3academy.myvtex.com/api/catalog_system/pub/products/search/?fq=productClusterIds:319"
).then((response) => {
response.json().then((res) => {
res.forEach((product) => {
const novaUl = document.querySelector(".products-list");
const name = product.productName;
const link = product.link;
const image = product.items[0].images[0].imageUrl;
novaUl.innerHTML += `
<li class="product-cards">
<img src ="${image}" />
<h3 class="product-name">${name}</h3>
<a class="product-link" href="${link}">
VER PRODUTO
</a>
</li>
`;
});
});
});
}
onUpdate() {
@ -31,7 +60,7 @@ export default class Footer {
observer.observe(target, config);
}
async addCarrossel() {
const elemento = await waitElement("#my-element");
const elemento = await waitElement(".products-list");
$(elemento).slick({
slidesToShow: 4,
slidesToScroll: 1,

View File

@ -8,14 +8,63 @@ export default class Header {
async init() {
await this.selectors();
console.log(this.item);
//console.log(this.item);
this.progressBarHtml();
await this.progressBarProgress();
}
async selectors() {
this.item = await waitElement("#my-element", {
/* 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.header = await waitElement(".headerCheckout");
this.progressBar = await waitElement("#progressBar");
}
progressBarHtml() {
if (this.progressBar && window.innerWidth > 1024) {
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-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-3"></p>
<p class="progress-bar-line-2"></p>
</div>
</div>
</li>
</ul>
`;
}
if (this.progressBar && window.innerWidth <= 1024) {
this.progressBar.innerHTML = "";
}
}
}

View File

@ -6,8 +6,12 @@
.link-cart {
a {
color: $color-black;
color: $color-black2;
font-size: 14px;
font-weight: 400;
font-size: 14px;
line-height: 16px;
text-transform: uppercase;
&:hover {
color: lighen($color-black, 10);
@ -25,12 +29,21 @@
margin-bottom: 16px;
span {
color: #303030;
font-size: 24px;
color: $color-black2;
text-transform: uppercase;
font-weight: 400;
font-size: 20px;
line-height: 23px;
font-family: $font-family-secundary;
}
small {
color: $color-gray4;
color: $color-black2;
text-transform: uppercase;
font-weight: 400;
font-size: 20px;
line-height: 23px;
font-family: $font-family-secundary;
}
}
}
@ -40,12 +53,13 @@
input {
box-shadow: none;
color: $color-black;
color: $color-black2;
font-family: $font-family;
padding: 0 16px;
border: 2px solid $color-gray3;
border: 1px solid $color-black2;
box-sizing: border-box;
border-radius: 5px;
border-radius: 5px 0 0 5px;
width: 443px;
@media (max-width: 490px) {
width: auto;
@ -53,9 +67,15 @@
}
button {
background-color: $color-black;
border-radius: 5px;
background-color: $color-blue2;
border-radius: 0px 8px 8px 0px;
border: none;
color: $color-black2;
font-weight: 700;
font-size: 14px;
line-height: 19px;
text-transform: uppercase;
width: 126.76px;
font-family: $font-family;
height: 54px;
right: 0;
@ -70,6 +90,9 @@
span.help.error {
color: red;
font-weight: 700;
font-size: 12px;
line-height: 16px;
}
}
@ -80,8 +103,11 @@
border-radius: 0;
h3 {
color: #303030;
color: $color-black2;
margin: 0 0 8px 0;
font-weight: 700;
font-size: 12px;
line-height: 16px;
}
ul {
@ -89,11 +115,14 @@
li {
span {
color: $color-black;
color: $color-black2;
font-weight: 700;
font-size: 12px;
line-height: 16px;
}
i::before {
color: $color-black;
color: $color-blue2;
font-size: 1rem;
opacity: 1;
}
@ -101,7 +130,7 @@
}
i::before {
color: $color-black;
color: #303030;
font-size: 6rem;
opacity: 0.5;
}

View File

@ -1,13 +1,105 @@
/* _header.scss */
.headerCheckout {
width: 100%;
height: 96px;
border-bottom: 1px solid $color-black;
.container {
display: grid;
grid-template-rows: 2fr 2fr 1fr;
width: 79.532% !important;
width: auto !important;
.progress-bar {
width: 446px;
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 div {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
li {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-family: $font-family-secundary;
font-weight: 400;
font-size: 12px;
line-height: 14px;
color: $color-black2;
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: 10px;
height: 10px;
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: black;
}
.progress-bar-line-1 {
position: absolute;
left: 25%;
transform: translateY(-50%);
bottom: 5px;
width: 100%;
height: 1px;
border-top: 1px solid $color-black2;
}
.progress-bar-line-2 {
position: absolute;
right: 21%;
transform: translateY(-50%);
bottom: 5px;
width: 100%;
height: 1px;
border-top: 1px solid $color-black2;
}
}
@media screen and (max-width: 1024px) {
width: 100% !important;
@ -33,12 +125,6 @@
@media screen and (max-width: 1024px) {
margin: 29px 16px 0 16px;
}
.progress-bar {
@media screen and (max-width: 1024px) {
display: none;
}
}
}
&__logo {
@ -46,7 +132,6 @@
height: 99.35%;
img {
max-width: 100%;
height: 100%;
}
}