forked from M3-Academy/m3-academy-template-checkout
feat(progressbar): created the show current url route
This commit is contained in:
parent
6963eca4ee
commit
0d60233fdd
@ -46,12 +46,58 @@ function OnProgress(target) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const verifyCurrentRoute = () => {
|
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 = () => {
|
const init = () => {
|
||||||
innerElement();
|
innerElement();
|
||||||
verifyCurrentRoute(options);
|
verifyCurrentRoute();
|
||||||
};
|
};
|
||||||
|
|
||||||
const remove = () => {
|
const remove = () => {
|
||||||
|
@ -187,6 +187,10 @@
|
|||||||
border: 1px solid $clr-common-black;
|
border: 1px solid $clr-common-black;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background-color: $clr-common-black;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user