feat(progressbar): created the show current url route

This commit is contained in:
Henrique Santos Santana 2022-12-14 13:32:12 -03:00
parent 6963eca4ee
commit 0d60233fdd
2 changed files with 52 additions and 2 deletions

View File

@ -46,12 +46,58 @@ function OnProgress(target) {
};
const verifyCurrentRoute = () => {
console.log(options);
let bullets = target.querySelectorAll(".progress-bullet");
bullets.forEach((bullet) => {
if (window.location.href.endsWith("#/cart")) {
bullets[0].classList.add("active");
}
if (
window.location.href.endsWith("#/email") ||
window.location.href.endsWith("#/shipping") ||
window.location.href.endsWith("#/profile")
) {
bullets[1].classList.add("active");
}
if (window.location.href.endsWith("#/payment")) {
bullets[2].classList.add("active");
}
window.addEventListener("hashchange", () => {
if (window.location.href.endsWith("#/cart")) {
bullets[0].classList.add("active");
if (bullet != bullets[0]) {
bullet.classList.remove("active");
}
}
if (
window.location.href.endsWith("#/email") ||
window.location.href.endsWith("#/shipping") ||
window.location.href.endsWith("#/profile")
) {
bullets[1].classList.add("active");
if (bullet != bullets[1]) {
bullet.classList.remove("active");
}
}
if (window.location.href.endsWith("#/payment")) {
bullets[2].classList.add("active");
if (bullet != bullets[2]) {
bullet.classList.remove("active");
}
}
});
});
};
const init = () => {
innerElement();
verifyCurrentRoute(options);
verifyCurrentRoute();
};
const remove = () => {

View File

@ -187,6 +187,10 @@
border: 1px solid $clr-common-black;
z-index: 10;
border-radius: 100%;
&.active {
background-color: $clr-common-black;
}
}
}
}