forked from M3-Academy/m3-academy-template-checkout
feat: Cria header desktop
This commit is contained in:
parent
16c9e1e779
commit
829f205bc7
@ -8,14 +8,136 @@ 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", {
|
||||
//#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){
|
||||
|
||||
this.progressBar.innerHTML = `
|
||||
<ul>
|
||||
<li><div class="container-list"><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="container-list"><div><p class="progress-bar-text">Dados Pessoais</p><p id="progress-bar-circle-2" class="progress-bar-circle-2 active"></p></div></div></li>
|
||||
|
||||
<li><div class="container-list"><div><p class="progress-bar-text">Pagamento</p><p id="progress-bar-circle-3" class="progress-bar-circle-3 active"></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");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +229,7 @@
|
||||
max-width: 118px;
|
||||
width: max-content !important;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #f0f0f0;
|
||||
border: 1px solid $gray-300;
|
||||
border-radius: 8px;
|
||||
|
||||
@media (max-width: 490px) {
|
||||
@ -237,10 +237,8 @@
|
||||
}
|
||||
|
||||
input {
|
||||
background-color: #fff;
|
||||
border: 1px solid f0f0f0;
|
||||
border-radius: 0;
|
||||
border-width: 0 1px;
|
||||
background-color: $white;
|
||||
border: 0 none;
|
||||
display: block;
|
||||
max-height: 38px;
|
||||
margin: 0 !important;
|
||||
|
@ -10,24 +10,36 @@
|
||||
}
|
||||
|
||||
&-title {
|
||||
font-size: 20px;
|
||||
display: none;
|
||||
&::before{
|
||||
font-family: $font-family;
|
||||
font-weight: 700;
|
||||
font-size: 24px;
|
||||
line-height: 33px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
}
|
||||
|
||||
&-message {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&-links {
|
||||
.link-choose-products {
|
||||
background: #292929;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
background-color: $white;
|
||||
border-style: border-box;
|
||||
border: 1px solid $black-500;
|
||||
border-radius: 0;
|
||||
transition: ease-in 0.22s all;
|
||||
outline: none;
|
||||
font-family: $font-family;
|
||||
font-family: $font-family-secundary;
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
line-height: 16px;
|
||||
text-align: center;
|
||||
letter-spacing: 0.05em;
|
||||
color: #fff;
|
||||
color: $black-500;
|
||||
text-transform: uppercase;
|
||||
|
||||
&:hover {
|
||||
|
@ -8,12 +8,28 @@ html {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
// footer {
|
||||
// border-bottom: 1px solid $black-500;
|
||||
// }
|
||||
|
||||
footer .footerCheckout__wrapper {
|
||||
|
||||
width: 94.9734%;
|
||||
margin: auto auto 0 auto;
|
||||
}
|
||||
footer .footerCheckout__prateleira,
|
||||
|
||||
footer .footerCheckout__wrapper .container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
header {
|
||||
border-bottom: 1px solid $black-500;
|
||||
}
|
||||
|
||||
footer .footerCheckout__prateleira,
|
||||
.headerCheckout .container {
|
||||
width: 79.53125%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
@ -1,32 +1,144 @@
|
||||
/* _header.scss */
|
||||
.headerCheckout {
|
||||
.container {
|
||||
width: auto !important;
|
||||
// width: auto !important;
|
||||
// // border-bottom: 1px solid $black-500;
|
||||
#progressBar {
|
||||
width: 446px;
|
||||
|
||||
ul {
|
||||
list-style-type: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
li .container-list {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
li.central .container-list {
|
||||
align-items: center;
|
||||
margin-left: 7px;
|
||||
}
|
||||
|
||||
li:last-child .container-list {
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
li .container-list div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
li {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: $font-family-secundary;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
line-height: 28px;
|
||||
color: $black-500;
|
||||
width: 39.9103%;
|
||||
}
|
||||
}
|
||||
|
||||
li.central {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
li #progress-bar-circle-1,
|
||||
li #progress-bar-circle-2,
|
||||
li #progress-bar-circle-3 {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border: 1px solid $black-500;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
li #progress-bar-circle-1.active,
|
||||
li #progress-bar-circle-2.active,
|
||||
li #progress-bar-circle-3.active {
|
||||
border: none;
|
||||
background-color: $black-500;
|
||||
}
|
||||
|
||||
li .progress-bar-line-1 {
|
||||
position: absolute;
|
||||
left: 31%;
|
||||
transform: translateY(-50%);
|
||||
bottom: 5px;
|
||||
width: 174px;
|
||||
height: 1px;
|
||||
border-top: 1px solid $black-500;
|
||||
}
|
||||
|
||||
li .progress-bar-line-2 {
|
||||
position: absolute;
|
||||
right: 26%;
|
||||
transform: translateY(-50%);
|
||||
bottom: 5px;
|
||||
width: 174px;
|
||||
height: 1px;
|
||||
border-top: 1px solid $black-500;
|
||||
}
|
||||
|
||||
// li #progress-bar-line-3 {
|
||||
// position: absolute;
|
||||
// right: 21%;
|
||||
// transform: translateY(-50%);
|
||||
// bottom: 5px;
|
||||
// width: 100%;
|
||||
// height: 1px;
|
||||
// border-top: 1px solid $black-500;
|
||||
// }
|
||||
}
|
||||
|
||||
&__wrapper {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 29px 0 29.86px;
|
||||
}
|
||||
|
||||
&__logo {
|
||||
width: 15.283%;
|
||||
|
||||
img {
|
||||
height: 52px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&__safeBuy {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
span {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
text-transform: uppercase;
|
||||
font-family: $font-family;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
font-size: 12px;
|
||||
line-height: 14px;
|
||||
color: #6c6c6c;
|
||||
padding: 0 0 0 8px;
|
||||
color: $black-400;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
i {
|
||||
|
Loading…
Reference in New Issue
Block a user