feat(home): adicionando progress bar desktop

This commit is contained in:
Bernardo Cunha Ernani Waldhelm 2022-12-09 22:07:39 -03:00
parent 2dab582c69
commit e137244e9f
4 changed files with 9594 additions and 7 deletions

View File

@ -9,13 +9,266 @@ 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");
}
progressBarHTML() {
if (this.progressBar && window.innerWidth > 1024) {
//<img src="imgs/amex.png">
this.progressBar.innerHTML = `
<ul>
<li>
<div class="containerLi-primeira">
<div>
<p class="progress-bar-text">
Meu Carrinho
</p>
<p id="progress-bar-circle-1" class="progress-bar-circle-1 active"> </p>
<p class="progress-bar-line-1"> </p>
</div>
</div>
</li>
<li class="central">
<div class="containerLi-segunda">
<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-terceira">
<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 = "";
}
}
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") {
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"
) {
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"
) {
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"
);
}
}
window.addEventListener("hashchange", () => {
if (window.location.hash == "#/cart") {
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.hash == "#/email" ||
window.location.hash == "#/profile" ||
window.location.hash == "#/shipping"
) {
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.hash == "#/payment") {
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,11 +1,14 @@
/* _header.scss */
.headerCheckout {
border-bottom: 1px solid $color-black;
padding: 30px 0;
.container {
width: auto !important;
}
&__wrapper {
align-items: center;
display: flex;
align-items: center;
justify-content: space-between;
}
@ -17,20 +20,153 @@
}
&__safeBuy {
display: flex;
align-items: center;
justify-content: center;
img {
width: 12px;
height: 15px;
}
span {
align-items: center;
display: flex;
align-items: center;
margin-left: 8px;
text-transform: uppercase;
font-family: $font-family;
font-style: normal;
font-weight: normal;
font-weight: 400;
font-size: 12px;
line-height: 14px;
color: $color-gray;
line-height: 16px;
color: $color-black;
}
i {
margin-right: 8px;
}
}
.progress-bar {
width: 439px;
font-family: $font-family-secundary;
@media (min-width: 2500) {
width: 872px;
}
ul {
display: flex;
justify-content: space-between;
list-style: none;
margin: 0 !important;
li {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 40%;
.progress-bar-text{
font-size: 12px;
line-height: 14px;
margin-bottom: 9px;
}
.containerLi-primeira{
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
position: relative;
width: 100%;
.progress-bar-circle-1 {
position: absolute;
transform: translateY(-50%);
left: 25%;
width: 12px;
height: 12px;
border-radius: 50%;
background-color: $color-white;
border: 1px solid $color-black;
z-index: 2;
&.active {
background: $color-black;
}
}
}
.containerLi-segunda{
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
width: 100%;
.progress-bar-circle-2 {
position: absolute;
transform: translateY(-50%);
right: 49%;
width: 12px;
height: 12px;
border-radius: 50%;
background: $color-white;
border: 1px solid $color-black;
z-index: 2;
&.active {
background: $color-black;
}
}
}
.containerLi-terceira{
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-end;
position: relative;
width: 100%;
.progress-bar-circle-3{
position: absolute;
transform: translateY(-50%);
right: 16%;
width: 12px;
height: 12px;
border-radius: 50%;
background: $color-white;
border: 1px solid $color-black;
z-index: 2;
&.active {
background: $color-black;
}
}
}
.progress-bar-line-1,
.progress-bar-line-2 {
position: absolute;
// bottom: 5px;
width: 100%;
height: 1px;
border-top: 1px solid $color-black;
}
.progress-bar-line-1 {
left: 30%;
}
.progress-bar-line-2 {
right: 23%;
}
}
.central {
width: auto;
white-space: nowrap;
}
}
}
}

2
package-lock.json generated
View File

@ -45,6 +45,7 @@
"jquery": "^3.6.0",
"m3-utils": "^0.1.0",
"sass": "^1.38.1",
"slick-carousel": "^1.8.1",
"terser-webpack-plugin": "^5.1.4"
},
"devDependencies": {
@ -19345,6 +19346,7 @@
"m3-utils": "^0.1.0",
"prettier": "^2.3.2",
"sass": "^1.38.1",
"slick-carousel": "^1.8.1",
"terser-webpack-plugin": "^5.1.4",
"webpack": "^5.51.1",
"webpack-merge": "^5.8.0"

9196
yarn.lock Normal file

File diff suppressed because it is too large Load Diff