diff --git a/checkout/src/arquivos/js/components/Header.js b/checkout/src/arquivos/js/components/Header.js index e7ac568..356206c 100644 --- a/checkout/src/arquivos/js/components/Header.js +++ b/checkout/src/arquivos/js/components/Header.js @@ -9,7 +9,8 @@ export default class Header { async init() { await this.selectors(); this.progressBarHTML(); - await this.progressBarProgress(); + this.progressBarProgress(); + // this.progressUpdate(); } async selectors() { @@ -37,23 +38,40 @@ export default class Header { } } - // async progressBarProgress() { - // if (this.progressBar && window.innerWidth > 1024) { - // const progressBarList = document.querySelectorAll("#progressBar ul li"); - // progressBarList.forEach((li) => { - // if (window.location.href === "htts://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"] - // ) - // } - // } - // }); - // } - // } + progressBarProgress() { + this.progressUpdate(); + + window.addEventListener("hashchange", () => { + this.progressUpdate(); + }); + } + + progressUpdate() { + const meuCarrinho = document.querySelector(".progress-bar-circle-1"); + const dadosPessoais = document.querySelector(".progress-bar-circle-2"); + const pagamento = document.querySelector(".progress-bar-circle-3"); + + switch (location.hash) { + case "#/cart": + meuCarrinho.classList.add("active"); + dadosPessoais.classList.remove("active"); + pagamento.classList.remove("active"); + + break; + + case "#/profile": + case "#/shipping": + meuCarrinho.classList.remove("active"); + dadosPessoais.classList.add("active"); + pagamento.classList.remove("active"); + + break; + + case "#/payment": + dadosPessoais.classList.remove("active"); + meuCarrinho.classList.remove("active"); + pagamento.classList.add("active"); + break; + } + } } diff --git a/checkout/src/arquivos/sass/partials/_header.scss b/checkout/src/arquivos/sass/partials/_header.scss index 9cf41e3..ca64304 100644 --- a/checkout/src/arquivos/sass/partials/_header.scss +++ b/checkout/src/arquivos/sass/partials/_header.scss @@ -42,15 +42,21 @@ } .progress-bar { - width: 67%; + width: 43.123772102161%; @include mq(xl, max) { width: 0; } + @include mq(2xl, min) { + width: 52.6787109375%; + } + .list { display: flex; justify-content: center; + margin: 0; + .central { width: 33%; }