feat(header): Implementação da barra de progresso

This commit is contained in:
Wellington Duarte Santos 2022-12-18 10:40:27 -03:00
parent 30555d9098
commit 27f3bb28ea
7 changed files with 26189 additions and 17059 deletions

View File

@ -8,14 +8,167 @@ export default class Header {
async init() {
await this.selectors();
console.log(this.item);
this.progressBarHTML();
await this.progressbarProgress();
}
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");
console.log("Barra encontrada");
}
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

@ -1,38 +1,41 @@
.empty-cart {
font-family: $font-family;
&-content {
color: $color-black;
text-align: center;
font-family: $font-family;
&-content {
color: $color-black;
text-align: center;
@include mq(md, max) {
padding: 0 16px;
}
}
@include mq(md, max) {
padding: 0 16px;
}
}
&-title {
font-size: 20px;
}
&-title {
text-transform: uppercase;
font-weight: 700;
font-size: 24px;
line-height: 33px;
}
&-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;
&-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);
}
}
}
&:hover {
background: lighten($color-black, 5);
}
}
}
}

View File

@ -70,12 +70,12 @@ body {
#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;
text-transform: uppercase;
font-weight: 700;
font-size: 24px;
line-height: 33px;
@include mq(md, max) {
margin-left: 30px;

View File

@ -1,4 +1,5 @@
/* _footer.scss */
.footerCheckout {
border-top: none;
color: $color-gray2;

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 {

33743
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