Merge pull request 'development' (#14) from development into main

Reviewed-on: #14
This commit is contained in:
Luiz Felipe Silva 2022-12-27 00:20:28 +00:00
commit 6b6c98adfe
14 changed files with 2112 additions and 656 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
*node_modules
node_modules
yarn.lock
# para arquivos sass e scss

View File

@ -7,34 +7,195 @@ export default class Footer {
async init() {
await this.selectors();
// this.onUpdate();
this.onUpdate();
this.criaFooter();
this.criaPrateleira();
this.criaCarrossel();
}
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
// Containers
this.containerMain = document.querySelector("body .container-main");
this.cartTemplate = document.querySelector(".cart-template");
this.checkoutContainer = document.querySelector(".checkout-container");
// Checkout
this.checkoutVazio = await waitElement(".empty-cart-content");
this.checkoutTitle = document.querySelector("#cart-title");
this.checkoutButton = document.querySelector("#cart-choose-products");
// Footer
this.checkoutAddress = document.querySelector(".footerCheckout__address");
this.cardsIcons = document.querySelector(".footerCheckout__stamps").firstElementChild;
this.vtexIcon = document.querySelector(".footerCheckout__stamps").lastElementChild;
this.poweredBy = document.querySelector(".footerCheckout__developedBy").firstElementChild;
this.developedBy = document.querySelector(".footerCheckout__developedBy").lastElementChild;
// Prateleira
this.prateleira = document.querySelector(".footerCheckout__prateleira");
}
onUpdate() {
//Função qeu 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
let target = this.checkoutVazio;
let containerMain = this.containerMain;
let cartTemplate = this.cartTemplate;
let checkoutContainer = this.checkoutContainer;
let checkoutTitle = this.checkoutTitle;
let checkoutButton = this.checkoutButton;
let prateleira = this.prateleira;
let config = { childList: true, attributes: true };
let observer = new MutationObserver((mutations) => {
mutations.forEach(function (mutation) {
console.log(mutation.type);
if (target.style.display != "none") {
if (document.querySelector(".prateleiraTitle") != null) {
document.querySelector(".prateleiraTitle").style.display = "none";
}
containerMain.style.display = "flex";
containerMain.style.height = "100%";
checkoutTitle.style.display = "none";
checkoutButton.innerHTML = "Continuar comprando";
cartTemplate.style.display = "flex";
prateleira.style.display = "none";
} else {
if (document.querySelector(".prateleiraTitle") != null) {
document.querySelector(".prateleiraTitle").style.display = "block";
}
containerMain.style.display = "block";
containerMain.style.height = "max-content";
checkoutTitle.style.display = "block";
cartTemplate.style.height = "max-content";
cartTemplate.style.display = "block";
prateleira.style.display = "block";
if (window.location.hash != "#/cart") {
checkoutTitle.style.display = "none";
prateleira.style.display = "none";
}
if (window.location.hash == "#/email") {
containerMain.style.height = "100%";
checkoutContainer.style.overflow = "initial"
}
}
});
});
observer.observe(target, config);
}
async addCarrossel() {
const elemento = await waitElement("#my-element");
$(elemento).slick({
slidesToShow: 4,
slidesToScroll: 1,
});
criaFooter() {
this.checkoutAddress.innerHTML = `
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
`;
this.cardsIcons.innerHTML = `
<figure>
<img src="https://agenciamagma.vteximg.com.br/arquivos/mastercardM3Academy.png" alt="Mastercard">
</figure>
<figure>
<img src="https://agenciamagma.vteximg.com.br/arquivos/visaM3Academy.png" alt="Visa">
</figure>
<figure>
<img src="https://agenciamagma.vteximg.com.br/arquivos/amexM3Academy.png" alt="Amex">
</figure>
<figure>
<img src="https://agenciamagma.vteximg.com.br/arquivos/eloM3Academy.png" alt="Elo">
</figure>
<figure>
<img src="https://agenciamagma.vteximg.com.br/arquivos/hiperCardM3Academy.png" alt="HiperCard">
</figure>
<figure>
<img src="https://agenciamagma.vteximg.com.br/arquivos/payPalM3Academy.png" alt="PayPal">
</figure>
<figure>
<img src="https://agenciamagma.vteximg.com.br/arquivos/boletoM3Academy.png" alt="Boleto">
</figure>
`;
this.vtexIcon.innerHTML = `
<figure>
<img src="https://agenciamagma.vteximg.com.br/arquivos/vtexPCIM3Academy.png" alt="VTEX PCI">
</figure>
`;
this.poweredBy.innerHTML = `
<div>
<p>Powered By</p>
<figure>
<img src="https://agenciamagma.vteximg.com.br/arquivos/logoVTEXM3Academy.png" alt="VTEX">
</figure>
</div>
`;
this.developedBy.innerHTML = `
<div>
<p>Developed By</p>
<figure>
<img src="https://agenciamagma.vteximg.com.br/arquivos/logoM3M3Academy.png" alt="M3 Academy">
</figure>
</div>
`;
}
async criaPrateleira() {
const urlAPI =
"https://m3academy.myvtex.com/api/catalog_system/pub/products/search/?fq=productClusterIds:319";
let prateleira = this.prateleira;
prateleira.innerHTML = `
<h2 class="prateleiraTitle">Você também pode gostar:</h2>
<ul class="carrossel-items"></ul>
`;
fetch(urlAPI)
.then((response) => {
return response.json();
})
.then((data) => {
return data.map((product) => {
let li = document.createElement("li");
li.setAttribute("id", product.productId);
li.innerHTML = `
<img src="${product.items[0].images[0].imageUrl}" alt="${
product.productName
}"/>
<p class="product-name">${product.productName}</p>
<div class="product-variation">${product.items
.map((name) => {
return `<a name="product-variation__item" class="product-variation__item">${name.name}</a>`;
})
.join("")}
</div>
<button class="product-button">Ver produto</button>
`;
prateleira.children[1].appendChild(li);
});
});
}
async criaCarrossel() {
const prateleira = await waitElement(".carrossel-items");
setTimeout(() => {
$(prateleira).slick({
slidesToShow: 4,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 2000,
});
}, 600);
}
}

View File

@ -4,18 +4,75 @@ import { waitElement } from "m3-utils";
export default class Header {
constructor() {
this.init();
this.criaBarraProgresso();
}
async init() {
await this.selectors();
console.log(this.item);
this.monitoraBarraProgresso();
}
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.barraProgresso = document.querySelector(".progress-bar");
this.circulo1 = await waitElement(".progress-bar__circle1");
this.circulo2 = await waitElement(".progress-bar__circle2");
this.circulo3 = await waitElement(".progress-bar__circle3");
}
criaBarraProgresso() {
this.barraProgresso.innerHTML = `
<ul class="progress-bar__container">
<li class="progress-bar__container-items">
<div class="progress-bar__wrapper">
<div class="progress-bar__container-item">
<p class="progress-bar__text">Meu Carrinho</p>
<p class="progress-bar__circle1 active"></p>
<p class="progress-bar__line1"></p>
</div>
</div>
</li>
</ul>
<ul class="progress-bar__container">
<li class="progress-bar__container-items">
<div class="progress-bar__wrapper">
<div class="progress-bar__container-item">
<p class="progress-bar__text">Dados Pessoais</p>
<p class="progress-bar__circle2"></p>
</div>
</div>
</li>
</ul>
<ul class="progress-bar__container">
<li class="progress-bar__container-items">
<div class="progress-bar__wrapper">
<div class="progress-bar__container-item">
<p class="progress-bar__text">Pagamento</p>
<p class="progress-bar__circle3"></p>
<p class="progress-bar__line2"></p>
</div>
</div>
</li>
</ul>
`;
}
monitoraBarraProgresso() {
setInterval(() => {
if (window.location.hash == "#/cart") {
this.circulo1.classList.add("active");
this.circulo2.classList.remove("active");
this.circulo3.classList.remove("active");
} else if (window.location.hash != "#/cart" && window.location.hash != "#/payment") {
this.circulo1.classList.remove("active");
this.circulo2.classList.add("active");
this.circulo3.classList.remove("active");
} else if (window.location.hash == "#/payment") {
this.circulo1.classList.remove("active");
this.circulo2.classList.remove("active");
this.circulo3.classList.add("active");
}
}, 100);
}
}

View File

@ -3,3 +3,4 @@
@import "./partials/header";
@import "./partials/footer";
@import "./checkout/checkout.scss";
@import "./partials/prateleira";

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,116 @@ body .container-main.container-order-form .orderform-template.active {
margin-right: 0;
float: right;
}
.orderform-template-holder {
width: 66.1132%;
}
.shipping-summary-placeholder {
.address-summary-BRA {
// Alterar depois
display: grid;
grid-template-columns: repeat(3, max-content);
grid-template-rows: repeat(2, max-content);
padding: 0;
margin: 10px 0 18px 0;
.postalCode {
grid-column: 2;
}
span {
.number-delimiter {
display: none;
}
}
}
.link-change-shipping {
display: none;
}
.shp-summary-package {
padding: 0;
margin-bottom: 14px;
}
.shp-summary-group {
padding: 0;
}
.shp-summary-group-info {
border: none;
}
.shp-summary-group-price {
display: none;
}
}
.payment-data.span12 {
.accordion-heading {
display: flex;
.accordion-toggle {
flex-direction: row;
}
i {
display: none;
}
}
.accordion-inner {
.box-step-content {
.payment-group-list-btn {
margin-top: -31px;
}
.payment-group {
a {
width: 209px;
height: 50px;
border-radius: 6px;
margin: 0 1px 12px;
padding: 0 0 0 0;
border: 1px solid #000;
text-decoration: none;
span {
font-family: $font-family;
color: $color-gray10;
font-size: 14px;
font-weight: 400;
line-height: 24px;
letter-spacing: -0.01em;
text-align: center;
padding: 13px 0px;
}
}
.payment-group-item-text {
background-image: none !important;
}
.payment-group-item.active {
border: 1px solid $color-orange1;
background-color: $color-white3;
span {
color: $color-orange1;
}
}
}
.link-gift-card {
display: none !important;
}
.steps-view {
margin-top: 3px;
}
}
}
}
}

View File

@ -1,38 +1,64 @@
.empty-cart {
font-family: $font-family;
&-content {
color: $color-black;
text-align: center;
@include mq(md, max) {
padding: 0 16px;
}
}
&-title {
font-size: 20px;
}
&-links {
.link-choose-products {
background: $color-black;
border: none;
border-radius: 5px;
transition: ease-in 0.22s all;
outline: none;
font-family: $font-family;
font-style: normal;
font-weight: 500;
font-size: 14px;
line-height: 16px;
text-align: center;
letter-spacing: 0.05em;
color: $color-white;
text-transform: uppercase;
&:hover {
background: lighten($color-black, 5);
}
}
}
.checkout-container {
.cart-template {
align-items: center;
flex-direction: column;
justify-content: center;
}
}
.empty-cart {
&-content {
h2 {
margin-bottom: 32px;
font-family: $font-family;
font-size: 24px;
font-weight: 700;
text-transform: uppercase;
color: $color-black1;
line-height: 0;
text-align: center;
@include mq(xl, min) {
font-size: 48px;
line-height: 65px;
}
}
@include mq(md, max) {
padding: 0 16px;
}
}
&-message {
display: none;
}
&-title {
font-size: 20px;
}
&-links {
.link-choose-products {
background: $color-white1;
border: none;
outline: none;
border: 1px solid $color-black2;
border-radius: 0;
color: $color-black2;
padding: 16px 65px;
font-family: $font-family-secundary;
font-size: 14px;
font-weight: 400;
line-height: 16px;
text-align: center;
text-transform: uppercase;
margin-top: 0;
@include mq(xl, min) {
font-size: 28px;
line-height: 33px;
padding: 16px 121px;
}
}
}
}

View File

@ -3,26 +3,21 @@
@import "./checkout-pagamento";
@import "./checkout-autenticacao";
.transactions-container {
display: none;
}
html {
height: 100%;
min-height: 100%;
}
footer .footerCheckout__wrapper {
width: 94.9734%;
margin: auto auto 0 auto;
}
footer .footerCheckout__prateleira,
header {
width: 79.53125%;
margin: 0 auto;
}
body {
display: flex;
flex-direction: column;
min-height: 100% !important;
padding-top: 0 !important;
overflow-x: hidden;
@include mq(md, max) {
padding-left: 0;
@ -47,36 +42,49 @@ body {
padding-left: 0;
}
}
.container-order-form,
.container-cart {
width: 80%;
width: 83.5%;
@include mq(xl, min) {
margin: 0 256px;
width: 80%;
}
}
.container-main {
min-height: max-content;
display: flex;
align-items: center;
}
}
.btn-success {
background: $color-black;
background: $color-black1;
text-shadow: none;
&:hover {
background: lighten($color-black, 15%);
}
}
.emailInfo h3 {
color: $color-black !important;
color: $color-black1 !important;
}
#cart-title,
#orderform-title {
color: $color-gray2;
font-family: $font-family;
font-weight: 500;
font-size: 36px;
line-height: 42px;
margin: 40px 0 30px;
letter-spacing: 0.1em;
font-size: 24px;
font-weight: 700;
line-height: 33px;
letter-spacing: 0.05em;
color: $color-black2;
margin: 17px 0;
text-transform: uppercase;
@include mq(xl, min) {
font-size: 48px;
line-height: 65px;
}
@include mq(md, max) {
margin-left: 30px;
}

View File

@ -71,6 +71,11 @@
}
img {
display: block;
@include mq(xl, min) {
height: 485px;
width: 485px;
}
}
&.slick-loading img {
display: none;
@ -100,19 +105,49 @@
font-size: 0;
position: absolute;
}
.slick-prev,
.slick-next {
z-index: 4;
border: none;
outline: none;
}
.slick-prev {
background: url("https://agenciamagma.vteximg.com.br/arquivos/arrow-left-mini-M3Academy.svg")
no-repeat center center;
z-index: 4;
left: 10px;
top: 185px;
width: 13px;
height: 29px;
@include mq(xl, min) {
width: 26px;
height: 58px;
top: 313px;
}
}
.slick-next {
z-index: 4;
right: 10px;
background: url("https://agenciamagma.vteximg.com.br/arquivos/arrow-right-mini-M3Academy.svg")
no-repeat center center;
right: 31px;
top: 185px;
width: 13px;
height: 29px;
@include mq(xl, min) {
width: 26px;
height: 58px;
top: 313px;
}
}
.slick-arrow.slick-hidden {
display: none;
}
.slick-dots {
li {
margin: 0.5em;

View File

@ -1,23 +1,52 @@
/* _footer.scss */
.footerCheckout {
border-top: none;
color: $color-gray2;
figure {
margin: 0;
}
ul {
padding: 0;
margin: 0 0 0 0;
}
p {
margin: 0;
}
&__wrapper {
align-items: center;
display: flex;
justify-content: space-between;
.container {
border-top: 1px solid $color-black2;
display: flex;
align-items: center;
justify-content: space-between;
width: 95%;
padding: 23px 32px;
@include mq(xl, min) {
padding: 29px 63px;
}
}
.container::before,
.container::after {
display: none;
}
}
&__address {
color: $color-gray2;
font-family: $font-family;
font-style: normal;
font-weight: normal;
font-size: 10px;
line-height: 12px;
font-weight: 400;
line-height: 14px;
color: $color-black1;
text-transform: capitalize;
max-width: 40%;
max-width: 269px;
@include mq(xl, min) {
font-size: 20px;
line-height: 27px;
max-width: 537px;
}
@include mq(md, max) {
margin-bottom: 24px;
@ -31,40 +60,103 @@
justify-self: center;
list-style: none;
li {
display: flex;
}
li:nth-child(1) {
display: flex;
}
li:last-child {
img {
max-width: 53px;
height: 33px;
margin: 0 0 0 10px;
@include mq(xl, min) {
max-width: 103px;
height: 64px;
}
}
}
img {
height: 20px;
max-width: 34px;
margin-right: 13px;
@include mq(xl, min) {
max-width: 69px;
height: 39px;
}
}
@include mq(md, max) {
align-self: center;
margin-bottom: 12px;
}
&__divider {
background-color: $color-gray4;
display: inline-block;
height: 24px;
margin: 0 8px;
width: 1px;
height: 24px;
background-color: $color-gray6;
@include mq(xl, min) {
height: 43px;
}
}
}
&__developedBy {
align-items: center;
display: flex;
align-items: center;
list-style-type: none;
margin: 0;
li:last-child {
li {
margin-left: 16px;
img {
margin-left: 11px;
}
}
a {
align-items: center;
color: $color-gray2;
li:first-child {
img {
max-width: 44px;
height: 16px;
@include mq(xl, min) {
max-width: 87px;
height: 31px;
}
}
}
li:last-child {
img {
max-width: 28px;
height: 15px;
@include mq(xl, min) {
max-width: 55px;
height: 30px;
}
}
}
div {
display: flex;
align-items: center;
font-family: $font-family;
font-style: normal;
font-weight: normal;
font-size: 10px;
line-height: 12px;
text-decoration: none;
font-size: 9px;
font-weight: 400;
color: $color-black1;
@include mq(xl, min) {
font-size: 18px;
line-height: 25px;
}
span {
margin-right: 8px;

View File

@ -1,8 +1,18 @@
/* _header.scss */
.headerCheckout {
width: 100%;
border-bottom: 1px solid $color-black2;
.container {
width: auto !important;
margin: 0;
padding: 24px 131px;
@include mq(xl, min) {
padding: 29px 256px;
}
}
&__wrapper {
align-items: center;
display: flex;
@ -11,26 +21,127 @@
&__logo {
img {
height: 52px;
width: auto;
width: 155px;
height: 37px;
@include mq(xl, min) {
width: 382px;
height: 91px;
}
}
}
&__safeBuy {
display: flex;
align-items: center;
span {
align-items: center;
display: flex;
font-weight: 400;
line-height: 16px;
text-transform: uppercase;
font-family: $font-family;
font-style: normal;
font-weight: normal;
font-size: 12px;
line-height: 14px;
color: $color-gray;
color: $color-black1;
@include mq(xl, min) {
font-size: 24px;
line-height: 33px;
}
}
i {
img {
width: 12px;
height: 14px;
margin-right: 8px;
@include mq(xl, min) {
width: 29px;
height: 41px;
}
}
}
.progress-bar {
display: flex;
width: 439px;
height: 35px;
justify-content: space-between;
@include mq(xl, min) {
width: 1078px;
height: 67px;
}
&__container-items {
list-style: none;
}
&__container-item {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
}
&__circle1,
&__circle2,
&__circle3 {
height: 12px;
width: 12px;
border-radius: 50%;
border: 1px solid $color-black2;
@include mq(xl, min) {
height: 24px;
width: 24px;
}
}
&__line1,
&__line2 {
position: absolute;
background-color: $color-black2;
height: 1px;
bottom: 6px;
@include mq(xl, min) {
bottom: 12px;
}
}
&__line1 {
left: 59%;
width: 162px;
@include mq(xl, min) {
width: 437px;
}
}
&__line2 {
right: 60%;
width: 155px;
@include mq(xl, min) {
width: 420px;
}
}
.active {
background-color: $color-black2;
}
&__text {
font-family: $font-family-secundary;
font-size: 12px;
font-weight: 400;
line-height: 14px;
color: $color-black2;
@include mq(xl, min) {
font-size: 24px;
line-height: 28px;
}
}
}
}

View File

@ -1 +1,98 @@
/* _prateleira.scss */
.footerCheckout__prateleira {
display: none;
padding: 0 110px 0 132px;
@include mq(xl, min) {
padding: 0 256px;
}
.prateleiraTitle {
font-family: $font-family-secundary;
font-size: 24px;
font-weight: 400;
line-height: 38px;
text-align: center;
@include mq(xl, min) {
font-size: 48px;
line-height: 76px;
}
}
div {
margin-right: 8px;
li {
.product-name {
font-family: $font-family;
font-size: 13px;
font-weight: 400;
line-height: 18px;
text-align: center;
margin: 20px 0;
color: $color-black2;
@include mq(xl, min) {
font-size: 26px;
line-height: 35px;
}
}
.product-variation {
display: flex;
justify-content: center;
margin-bottom: 25px;
&__item {
font-size: 13px;
font-weight: 700;
line-height: 18px;
letter-spacing: 0.05em;
text-align: center;
background-color: $color-blue2;
padding: 5px;
border-radius: 8px;
margin-right: 5px;
color: $color-white1;
font-family: $font-family;
outline: none;
border: none;
text-transform: uppercase;
&:last-child {
margin-right: 0;
}
@include mq(xl, min) {
font-size: 26px;
line-height: 35px;
}
}
}
.product-button {
width: 100%;
font-family: $font-family;
font-size: 13px;
font-weight: 700;
line-height: 18px;
letter-spacing: 0.05em;
text-align: center;
text-transform: uppercase;
padding: 12px 72px;
border-radius: 8px;
outline: none;
border: none;
color: $color-white1;
background-color: $color-blue2;
margin-bottom: 56px;
@include mq(xl, min) {
font-size: 26px;
line-height: 35px;
}
}
}
}
}

View File

@ -1,38 +1,51 @@
/* fonts */
/* Fonts */
@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");
$font-family: "Open Sans", sans-serif;
$font-family-secundary:"Tenor Sans", sans-serif;
$font-family-secundary: "Tenor Sans", sans-serif;
/* Colors */
$color-black: #292929;
$color-black1: #292929;
$color-black2: #000000;
$color-white: #fff;
$color-white1: #fff;
$color-white2: #f2f2f2;
$color-white3: #DCDDE34D;
$color-gray: #6c6c6c;
$color-gray1: #6c6c6c;
$color-gray2: #7d7d7d;
$color-gray3: #f0f0f0;
$color-gray4: #8d8d8d;
$color-gray5: #e5e5e5;
$color-gray6: #c4c4c4;
$color-gray7: #989898;
$color-gray8: #ededed;
$color-gray9: #e0e0e0;
$color-gray10: #585858;
$color-blue: #4267b2;
$color-blue1: #4267b2;
$color-blue2: #00C8FF;
$color-green: #4caf50;
$color-green1: #4caf50;
$color-green2: #298541;
$color-orange1: #F15A31;
/* Grid breakpoints */
$grid-breakpoints: (
xs: 0,
cstm: 400,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px
xs: 0,
cstm: 400px,
sm: 600px,
md: 1024px,
lg: 1280px,
xl: 2500px,
) !default;
/* Z-index */
$z-index: (
level1: 5,
level2: 10,
level3: 15,
level4: 20,
level5: 25
level1: 5,
level2: 10,
level3: 15,
level4: 20,
level5: 25,
) !default;