Desafio 4 M3 Academy #1

Merged
naianfelix merged 11 commits from develop into main 2022-12-19 08:58:14 +00:00
2 changed files with 181 additions and 18 deletions
Showing only changes of commit 497b2a06ee - Show all commits

View File

@ -6,14 +6,26 @@ export default class Footer {
}
async init() {
this.list = await this.fetchPrateleira();
await this.selectors();
// this.onUpdate();
this.createPrateleira();
this.prateleira = await waitElement(".footerCheckout__carrossel-itens");
this.itensPrateleira();
this.addCarrossel();
this.creditCardIconsHTML();
this.developedByIconsHTML();
}
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.itensShelf = await waitElement(".footerCheckout__prateleira", {
timeout: 5000,
interval: 1000,
});
this.creditCardIcons = await waitElement(".footerCheckout__stamps");
this.developedByIcons = await waitElement(".footerCheckout__developedBy");
}
onUpdate() {
@ -30,11 +42,95 @@ export default class Footer {
observer.observe(target, config);
}
createPrateleira() {
if (this.itensShelf) {
this.itensShelf.innerHTML = `
<div class="footerCheckout__prateleira-title">
<h2>Você também pode gostar:</h2>
</div>
<ul class="footerCheckout__carrossel-itens"></ul>
`;
}
}
async itensPrateleira() {
let structure = "";
this.list.forEach((response) => {
const sku = response.skus.map((item) => `<li>${item}</li>`);
structure += `
<li>
<figure><img src ="${response.img}"/></figure>
<figcaption>${response.name}</figcaption>
<div><ul>${sku}</ul></div>
<button type="button"><a href="${response.link}">Ver Produto</a></button>
</li>
`;
});
this.prateleira.innerHTML = structure;
}
async fetchPrateleira() {
const api =
"https://m3academy.myvtex.com/api/catalog_system/pub/products/search/?fq=productClusterIds:319";
return fetch(api)
.then((response) => response.json())
.then((data) => {
const prodInfo = data.map((response) => ({
name: response.productName,
skus: response.items.map((item) => item.name),
img: response.items[0].images[0].imageUrl,
link: response.link,
}));
return prodInfo;
});
}
async addCarrossel() {
const elemento = await waitElement("#my-element");
const elemento = await waitElement(".footerCheckout__carrossel-itens");
$(elemento).slick({
slidesToShow: 4,
slidesToScroll: 1,
arrows: true,
infinite: false,
});
}
creditCardIconsHTML() {
this.creditCardIcons.innerHTML = `
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/masterCardM3Academy.png" alt="Mastercard"></li>
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/visaM3Academy.png" alt=""></li>
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/amexM3Academy.png" alt="American Express"></li>
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/eloM3Academy.png" alt="Elo"></li>
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/hiperCardM3Academy.png" alt="Hipercard"></li>
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/payPalM3Academy.png" alt="PayPal"></li>
<li><img src="https://agenciamagma.vteximg.com.br/arquivos/boletoM3Academy.png" alt="Boleto"></li>
<li><span class="footerCheckout__stamps__divider"></span></li>
<li class="vtex-pci"><img src="https://agenciamagma.vteximg.com.br/arquivos/vtexPCIM3Academy.png" alt="PCI VTEX"></li>
`;
}
developedByIconsHTML() {
this.developedByIcons.innerHTML = `
<li>
<div class="by-vtex">
<a href="https://vtex.com.br-pt/">
<span>Powered By</span>
</a>
<img class="vtex-logo" src="https://agenciamagma.vteximg.com.br/arquivos/logoVTEXM3Academy.png" alt="VTEX" />
</div>
</li>
<li>
<div class="by-m3">
<a href="https://vtex.com.br-pt/">
<span>Developed By</span>
</a>
<img class="m3-logo" src="https://agenciamagma.vteximg.com.br/arquivos/logoM3M3Academy.png" alt="M3" />
</div>
</li>
`;
}
}

View File

@ -8,30 +8,69 @@
&__wrapper {
align-items: center;
display: flex;
}
.container {
display: flex;
align-items: center;
margin: 0;
justify-content: space-between;
@media (min-width: 1200px) {
width: 100%;
}
@include mq(md, max) {
margin: 0 0 0 9px;
display: grid;
}
}
.color-img {
background-color: rgb(238, 238, 238);
}
&__address {
color: $color-gray2;
font-family: $font-family;
font-style: normal;
font-weight: normal;
color: $color-gray2;
margin: 27px 0 24px 0;
width: 269px;
font-size: 10px;
line-height: 12px;
text-transform: capitalize;
max-width: 40%;
@include mq(md, max) {
margin-bottom: 24px;
max-width: 100%;
}
@include mq(xl, min) {
font-family: $font-family;
color: $color-black;
width: 537px;
font-size: 20px;
line-height: 27px;
text-transform: capitalize;
}
@include mq(md, max) {
margin: 0px 0 16px 7px;
font-family: $font-family;
color: $color-black;
font-size: 10px;
line-height: 14px;
width: 269px;
text-transform: capitalize;
}
}
&__stamps {
align-items: center;
display: flex;
align-items: center;
justify-self: center;
list-style: none;
width: 404px;
margin: 16px 189px 16px 137px;
@include mq(md, max) {
align-self: center;
@ -39,33 +78,61 @@
}
&__divider {
background-color: $color-gray4;
display: inline-block;
background-color: $color-gray4;
height: 24px;
margin: 0 8px;
width: 1px;
}
@include mq(xl, min) {
width: 690px;
}
@include mq(md, max) {
width: 342px;
margin: 16px 0 16px 0;
order: -1;
}
}
&__developedBy {
align-items: center;
display: flex;
list-style-type: none;
align-items: center;
width: 217px;
margin: 0;
list-style-type: none;
li:last-child {
margin-left: 16px;
.vtex-rigth1 {
width: 15%;
}
.vtex-rigth2 {
width: 8%;
}
.list {
@include mq(xl, min) {
font-family: "Open Sans";
font-style: normal;
font-weight: 400;
font-size: 18px;
line-height: 25px;
width: 388px;
}
@include mq(md, max) {
margin: 0 0 16px 7px;
}
}
a {
align-items: center;
color: $color-gray2;
display: flex;
font-family: $font-family;
font-style: normal;
font-weight: normal;
color: $color-gray2;
font-size: 10px;
line-height: 12px;
align-items: center;
text-decoration: none;
span {