diff --git a/checkout/src/arquivos/js/components/Header.js b/checkout/src/arquivos/js/components/Header.js index 51d65fe..c2dd6bd 100644 --- a/checkout/src/arquivos/js/components/Header.js +++ b/checkout/src/arquivos/js/components/Header.js @@ -9,6 +9,7 @@ export default class Header { async init() { await this.selectors(); this.progressBarContent(); + await this.progressBarDot(); } async selectors() { @@ -55,4 +56,202 @@ export default class Header { this.progressBar.innerHTML = ``; } } + + async progressBarDot() { + if (this.progressBar && window.innerWidth > 1024) { + const progressList = document.querySelectorAll("#progressBar ul li"); + progressList.forEach((li) => { + if (window.location.href === "https://m3academy.myvtex.com/checkout/#/cart") { + if (li.children[0].children[0].children["progress-bar-first-circle"]) { + li.children[0].children[0].children[ + "progress-bar-first-circle" + ].classList.add("active"); + } + if (li.children[0].children[0].children["progress-bar-second-circle"]) { + if ( + li.children[0].children[0].children[ + "progress-bar-second-circle" + ].classList.contains("active") + ) { + li.children[0].children[0].children[ + "progress-bar-second-circle" + ].classList.remove("active"); + } + } + if (li.children[0].children[0].children["progress-bar-third-circle"]) { + if ( + li.children[0].children[0].children[ + "progress-bar-third-circle" + ].classList.contains("active") + ) { + li.children[0].children[0].children[ + "progress-bar-third-circle" + ].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-first-circle"]) { + if ( + li.children[0].children[0].children[ + "progress-bar-first-circle" + ].classList.contains("active") + ) { + li.children[0].children[0].children[ + "progress-bar-first-circle" + ].classList.remove("active"); + } + } + if (li.children[0].children[0].children["progress-bar-second-circle"]) { + li.children[0].children[0].children[ + "progress-bar-second-circle" + ].classList.add("active"); + } + if (li.children[0].children[0].children["progress-bar-third-circle"]) { + if ( + li.children[0].children[0].children[ + "progress-bar-third-circle" + ].classList.contains("active") + ) { + li.children[0].children[0].children[ + "progress-bar-third-circle" + ].classList.remove("active"); + } + } + } else if ( + window.location.href === "https://m3academy.myvtex.com/checkout/#/payment" + ) { + if (li.children[0].children[0].children["progress-bar-first-circle"]) { + if ( + li.children[0].children[0].children[ + "progress-bar-first-circle" + ].classList.contains("active") + ) { + li.children[0].children[0].children[ + "progress-bar-first-circle" + ].classList.remove("active"); + } + } + if (li.children[0].children[0].children["progress-bar-second-circle"]) { + if ( + li.children[0].children[0].children[ + "progress-bar-second-circle" + ].classList.contains("active") + ) { + li.children[0].children[0].children[ + "progress-bar-second-circle" + ].classList.remove("active"); + } + } + if (li.children[0].children[0].children["progress-bar-third-circle"]) { + li.children[0].children[0].children[ + "progress-bar-third-circle" + ].classList.add("active"); + } + } + + this.progressBarWhenHashChange(); + }); + } + } + + progressBarWhenHashChange() { + const progressList = document.querySelectorAll("#progressBar ul li"); + progressList.forEach((li) => { + window.addEventListener("hashchange", () => { + if (window.location.hash == "#/cart") { + if (li.children[0].children[0].children["progress-bar-first-circle"]) { + li.children[0].children[0].children[ + "progress-bar-first-circle" + ].classList.add("active"); + } + if (li.children[0].children[0].children["progress-bar-second-circle"]) { + if ( + li.children[0].children[0].children[ + "progress-bar-second-circle" + ].classList.contains("active") + ) { + li.children[0].children[0].children[ + "progress-bar-second-circle" + ].classList.remove("active"); + } + } + if (li.children[0].children[0].children["progress-bar-third-circle"]) { + if ( + li.children[0].children[0].children[ + "progress-bar-third-circle" + ].classList.contains("active") + ) { + li.children[0].children[0].children[ + "progress-bar-third-circle" + ].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-first-circle"]) { + if ( + li.children[0].children[0].children[ + "progress-bar-first-circle" + ].classList.contains("active") + ) { + li.children[0].children[0].children[ + "progress-bar-first-circle" + ].classList.remove("active"); + } + } + if (li.children[0].children[0].children["progress-bar-second-circle"]) { + li.children[0].children[0].children[ + "progress-bar-second-circle" + ].classList.add("active"); + } + if (li.children[0].children[0].children["progress-bar-third-circle"]) { + if ( + li.children[0].children[0].children[ + "progress-bar-third-circle" + ].classList.contains("active") + ) { + li.children[0].children[0].children[ + "progress-bar-third-circle" + ].classList.remove("active"); + } + } + } else if (window.location.hash == "#/payment") { + if (li.children[0].children[0].children["progress-bar-first-circle"]) { + if ( + li.children[0].children[0].children[ + "progress-bar-first-circle" + ].classList.contains("active") + ) { + li.children[0].children[0].children[ + "progress-bar-first-circle" + ].classList.remove("active"); + } + } + if (li.children[0].children[0].children["progress-bar-second-circle"]) { + if ( + li.children[0].children[0].children[ + "progress-bar-second-circle" + ].classList.contains("active") + ) { + li.children[0].children[0].children[ + "progress-bar-second-circle" + ].classList.remove("active"); + } + } + if (li.children[0].children[0].children["progress-bar-third-circle"]) { + li.children[0].children[0].children[ + "progress-bar-third-circle" + ].classList.add("active"); + } + } + }); + }); + } } diff --git a/checkout/src/arquivos/sass/partials/_header.scss b/checkout/src/arquivos/sass/partials/_header.scss index d26ec35..e73608d 100644 --- a/checkout/src/arquivos/sass/partials/_header.scss +++ b/checkout/src/arquivos/sass/partials/_header.scss @@ -94,7 +94,6 @@ margin-top: 9px; border: 1px solid $color-black2; border-radius: 50%; - background: $color-white; @include mq(xxl, min) { width: 24px; @@ -102,6 +101,18 @@ } } + .containerProgressBar .progress-bar-first-circle { + background: $color-white; + } + + .containerProgressBar .progress-bar-second-circle { + background: $color-white; + } + + .containerProgressBar .progress-bar-third-circle { + background: $color-white; + } + &__logo { img { height: 52px; @@ -165,4 +176,8 @@ } } } + + .active { + background: $color-black2 !important; + } }