forked from M3-Academy/m3-academy-template-checkout
feat: construcao de todo o header, css e js
This commit is contained in:
parent
2dab582c69
commit
fdf1a95809
@ -1,5 +1,7 @@
|
||||
// import waitForEl from "../helpers/waitForEl";
|
||||
import { waitElement } from "m3-utils";
|
||||
import {
|
||||
waitElement
|
||||
} from "m3-utils";
|
||||
|
||||
export default class Header {
|
||||
constructor() {
|
||||
@ -8,14 +10,86 @@ export default class Header {
|
||||
|
||||
async init() {
|
||||
await this.selectors();
|
||||
console.log(this.item);
|
||||
await this.setProgressBarHTML()
|
||||
await this.setStateCart()
|
||||
}
|
||||
|
||||
async selectors() {
|
||||
this.item = await waitElement("#my-element", {
|
||||
this.container_progressBar = await waitElement("#progressBar", {
|
||||
//#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
|
||||
});
|
||||
}
|
||||
|
||||
setProgressBarHTML() {
|
||||
this.container_progressBar.innerHTML = `
|
||||
<div class="content_myCart">
|
||||
<span class="infoCart">Meu Carrinho</span>
|
||||
<span class="circuleOne circule"></span>
|
||||
<span class="line"></span>
|
||||
</div>
|
||||
<div class="content_personalData">
|
||||
<span class="infoCart">Dados Pessoais</span>
|
||||
<span class=" circuleTwo circule"></span>
|
||||
<span class="line"></span>
|
||||
</div>
|
||||
<div class="content_payment">
|
||||
<span class="infoCart">Pagamento</span>
|
||||
<span class=" circuleTree circule"></span>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
setStateCart() {
|
||||
const urlCart = "https://m3academy.myvtex.com/checkout/#/cart"
|
||||
const urlEmail = "https://m3academy.myvtex.com/checkout/#/email"
|
||||
const urlProfile = "https://m3academy.myvtex.com/checkout/#/profile"
|
||||
const urlShipping = "https://m3academy.myvtex.com/checkout/#/shipping"
|
||||
const urlPayment = "https://m3academy.myvtex.com/checkout/#/payment"
|
||||
const circuleOne = document.querySelector(".circuleOne")
|
||||
const circuleTwo = document.querySelector(".circuleTwo")
|
||||
const circuleTree = document.querySelector(".circuleTree")
|
||||
|
||||
if (window.location.href = urlCart) {
|
||||
circuleOne.classList.add("active")
|
||||
circuleTwo.classList.remove("active")
|
||||
circuleTree.classList.remove("active")
|
||||
} else if (
|
||||
window.location.href == urlEmail ||
|
||||
window.location.hash == urlProfile ||
|
||||
window.location.hash == urlShipping
|
||||
)
|
||||
{
|
||||
circuleOne.classList.remove("active")
|
||||
circuleTwo.classList.add("active")
|
||||
circuleTree.classList.remove("active")
|
||||
} else if (window.location.href = urlPayment) {
|
||||
circuleOne.classList.remove("active")
|
||||
circuleTwo.classList.remove("active")
|
||||
circuleTree.classList.add("active")
|
||||
}
|
||||
|
||||
window.addEventListener("hashchange", () => {
|
||||
if (window.location.hash == "#/cart") {
|
||||
circuleOne.classList.add("active")
|
||||
circuleTwo.classList.remove("active")
|
||||
circuleTree.classList.remove("active")
|
||||
} else if (
|
||||
window.location.hash == "#/email" ||
|
||||
window.location.hash == "#/profile" ||
|
||||
window.location.hash == "#/shipping")
|
||||
{
|
||||
circuleOne.classList.remove("active")
|
||||
circuleTwo.classList.add("active")
|
||||
circuleTree.classList.remove("active")
|
||||
} else if (
|
||||
window.location.hash == "#/payment")
|
||||
{
|
||||
circuleOne.classList.remove("active")
|
||||
circuleTwo.classList.remove("active")
|
||||
circuleTree.classList.add("active")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
/* _header.scss */
|
||||
.headerCheckout {
|
||||
width: 100%;
|
||||
border-bottom: 1px solid black;
|
||||
padding: 1.813rem 0;
|
||||
.container {
|
||||
width: auto !important;
|
||||
width: 80%;
|
||||
}
|
||||
&__wrapper {
|
||||
align-items: center;
|
||||
@ -11,12 +14,13 @@
|
||||
|
||||
&__logo {
|
||||
img {
|
||||
height: 52px;
|
||||
height: 37.14px;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
&__safeBuy {
|
||||
display: flex;
|
||||
span {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
@ -29,8 +33,55 @@
|
||||
color: $color-gray;
|
||||
}
|
||||
|
||||
i {
|
||||
img {
|
||||
width: 12px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
min-width: 439px;
|
||||
max-width: 439px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.content_myCart,
|
||||
.content_personalData,
|
||||
.content_payment {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.infoCart {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 400;
|
||||
font-family: "Tenor Sans", sans-serif;
|
||||
}
|
||||
|
||||
.circule {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border: 1px solid black;
|
||||
background-color: white;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.active {
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 190px;
|
||||
position: absolute;
|
||||
height: 1px;
|
||||
background: black;
|
||||
top: 26px;
|
||||
left: 38px;
|
||||
z-index: -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,8 @@
|
||||
<img src="https://agenciamagma.vteximg.com.br/arquivos/LogoM3Academy.png" alt="M3 Academy"/>
|
||||
</a>
|
||||
</div>
|
||||
<div id="progressBar" class="progress-bar"> Aqui entra a barra de progresso
|
||||
<div id="progressBar" class="progress-bar">
|
||||
|
||||
</div>
|
||||
<div class="headerCheckout__safeBuy">
|
||||
<img src="https://agenciamagma.vteximg.com.br/arquivos/cadeadoCompraSegM3Academy.png" alt="Cadeado"/>
|
||||
|
Loading…
Reference in New Issue
Block a user