Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalizado o projeto por completo #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/img/cart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
156 changes: 154 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,162 @@
</head>

<body>
<header class="header">
<div class="container">
<div class="header__logo">
<img src="./img/logo-m3.png" alt="Logo M3 Commerce">
</div>
<div class="header__cart">
<img src="./img/cart.svg" alt="Carrinho de Compras Superior">
<span>0</span>
</div>
</div>
</header>
<div class="premain__header container">
<h1>Blusas</h1>
<div class="filtragem">
<div id="filtrar-mobile">
Filtrar
</div>
<div id="ordenar-mobile">
Ordenar
</div>
</div>
<select name="order" id="order">
<option value="0">Ordernar por:</option>
<option value="1">Mais recentes</option>
<option value="2">Maior preço</option>
<option value="2">Menor preço</option>
</select>

</div>
<main class="main container">
<aside class="aside">
<div class="aside__filters">
<h1 class="d-none header-filter">
Filtrar
<svg id="fecharFiltro" width="19" height="20" viewBox="0 0 19 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M.5 18.852 17.555 1" stroke="#000"/><path transform="matrix(.71175 .70244 -.87431 .48537 0 1.235)" stroke="#000" d="M0-.5h25.29"/></svg>
</h1>
<div class="aside__filters--colors">
<h2>Cores <svg class="d-none" width="20" height="15" viewBox="0 0 20 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="m1 1 9 13 9-12.986" stroke="#666" stroke-linecap="round"/></svg></h2>
<form id="colors">
<div class="form-group">
<input type="checkbox" id="amarelo">
<label for="amarelo">Amarelo</label>
</div>
<div class="form-group">
<input type="checkbox" id="azul">
<label for="azul">Azul</label>
</div>
<div class="form-group">
<input type="checkbox" id="branco">
<label for="branco">Branco</label>
</div>
<div class="form-group">
<input type="checkbox" id="cinza">
<label for="cinza">Cinza</label>
</div>
<div class="form-group">
<input type="checkbox" id="laranja">
<label for="laranja">Laranha</label>
</div>
<a>Ver todas as cores > </a>
</form>
</div>
<div class="aside__filters--sizes">
<h2>Tamanhos <svg class="d-none" width="20" height="15" viewBox="0 0 20 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="m1 1 9 13 9-12.986" stroke="#666" stroke-linecap="round"/></svg></h2>
<form class="form-boxes" id="sizes">
<div class="form-size">
P
</div>
<div class="form-size">
M
</div>
<div class="form-size">
G
</div>
<div class="form-size">
GG
</div>
<div class="form-size">
U
</div>
<div class="form-size">
36
</div>
<div class="form-size">
38
</div>
<div class="form-size">
40
</div>
<div class="form-size">
36
</div>
<div class="form-size">
38
</div>
<div class="form-size">
40
</div>
</form>
</div>
<div class="aside__filters--prices">
<h2>Faixa de preços <svg class="d-none" width="20" height="15" viewBox="0 0 20 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="m1 1 9 13 9-12.986" stroke="#666" stroke-linecap="round"/></svg></h2>
<form id="prices">
<div class="form-group">
<input type="checkbox" id="at50">
<label for="at50">de R$0 até R$50</label>
</div>
<div class="form-group">
<input type="checkbox" id="at150">
<label for="at150">de R$51 até R$150</label>
</div>
<div class="form-group">
<input type="checkbox" id="at300">
<label for="at300">de R$151 até R$300</label>
</div>
<div class="form-group">
<input type="checkbox" id="at500">
<label for="at500">de R$301 até R$500</label>
</div>
<div class="form-group">
<input type="checkbox" id="at501">
<label for="at501">a partir de R$ 500</label>
</div>
</form>
</div>
</div>
<div class="d-none submit-filters">
<button id="apply">Aplicar</button>
<button id="clear">Limpar</button>
</div>
</aside>

</body>
<h1>Desafio m3</h1>
<aside class="aside d-none ordenar">
<div class="aside__filters">
<h1 class="d-none header-filter">
Filtrar
<svg id="fecharOrdenar" width="19" height="20" viewBox="0 0 19 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M.5 18.852 17.555 1" stroke="#000"/><path transform="matrix(.71175 .70244 -.87431 .48537 0 1.235)" stroke="#000" d="M0-.5h25.29"/></svg>
</h1>
<div class="aside__filters--colors">
<h3>Mais recentes</h3>
<h3>Maior preço</h3>
<h3>Menor preço</h3>
</div>
</div>
</aside>
<section class="section">
<div id="productBox"></div>
<a href="" class="load-more">Carregar Mais</a>
</section>
</main>

<footer class="footer">
<h3>M3: Implantação de E-commerce VTEX</h3>
</footer>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="bundle.js"></script>

</html>
117 changes: 116 additions & 1 deletion src/js/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,116 @@
console.log("Dev m3");
// Aqui começa o consumo e mostragem da API de Produtos
const urlBase = 'http://localhost:5000/products';

function fazGet(url) {
let request = new XMLHttpRequest();
request.open('GET', url, false)
request.send()
return request.responseText
}

function criaProduto(produto) {
box = document.createElement('div');
box.classList.add('maxProductContent');
boxContent = document.createElement('div');
boxContent.classList.add('product-box');

boxContent.innerHTML = `
<img src="${produto.image}" class="product-box__image"/>
<h2 class="product-box__name">${produto.name}</h2>
<h3 class="product-box__price">R$ ${produto.price.toLocaleString('pt-br',{style: 'currency', currency: 'BRL'})}</h3>
<p class="product-box__installments"> Até ${produto.parcelamento[0]}x de R$ ${produto.parcelamento[1]} </p>
<button class="buy-button">COMPRAR</button>
`;
box.appendChild(boxContent);

return box;
}

function main() {
let data = fazGet(urlBase);
let produtos = JSON.parse(data);
let boxes = document.getElementById('productBox');

//para cada produto criar um box de produto e adicionar nesse box
produtos.forEach(element => {
console.log(element)
let produto = criaProduto(element);
boxes.appendChild(box)
});
}

main()
/*
***************************************
***** AQUI ACABA O CONSUMO DA API *****
***************************************
*/

// AQUI COMEÇA A PARTE DE ABERTURA DE MODAIS, SCROLL "INFINITO" e DEMAIS funções do projeto
$ = jQuery;

$(function () {
if($(window).width() < 768) {
console.log('mobile esta a partir daqui')
$(".maxProductContent").slice(0, 4).show();
} else {
$(".maxProductContent").slice(0, 9).show();
}
$("body").on('click touchstart', '.load-more', function (e) {
e.preventDefault();

if($(window).width() < 768) {
$(".maxProductContent:hidden").slice(0, 4).slideDown();
} else {
$(".maxProductContent:hidden").slice(0, 3).slideDown();
}
if ($(".maxProductContent:hidden").length == 0) {
$(".load-more").css('visibility', 'hidden');
}
$('html,body').animate({
scrollTop: $(this).offset().top
}, 1000);
});
});


const abrirFiltro = document.getElementById('filtrar-mobile');
const fecharFiltro = document.getElementById('fecharFiltro');

const abrirOrdenar = document.getElementById('ordenar-mobile');
const fecharOrdenar = document.getElementById('fecharOrdenar');

abrirFiltro.addEventListener('click', () => {
document.querySelector('.aside:not(.ordenar)').style.display = 'flex'
})
fecharFiltro.addEventListener('click', () => {
document.querySelector('.aside:not(.ordenar)').style.display = 'none'
})


abrirOrdenar.addEventListener('click', () => {
document.querySelector('.aside.ordenar').style.display = 'block'
})
fecharOrdenar.addEventListener('click', () => {
document.querySelector('.aside.ordenar').style.display = 'none'
})

const abrirCores = document.querySelector('.aside__filters--colors');
const abrirTamanhos = document.querySelector('.aside__filters--sizes');
const abrirPrecos = document.querySelector('.aside__filters--prices');

abrirCores.addEventListener('click', () => {
document.querySelector('form#colors').classList.toggle('active')
})
abrirTamanhos.addEventListener('click', () => {
document.querySelector('form#sizes').classList.toggle('active')
})
abrirPrecos.addEventListener('click', () => {
document.querySelector('form#prices').classList.toggle('active')
})

/*
***************************************
***** AQUI ACABA as FUNÇÕES *****
***************************************
*/
39 changes: 39 additions & 0 deletions src/scss/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700;800&display=swap');
// Cores principais

$black: #000000;
$gray-light: rgba(0,0,0, 0.5);
$gray-dark: #666666;
$blue: #00C0EE;

// Font family
$font-family: 'Open Sans';

//sizes

$xs: 10px;
$sm: 12px;
$md: 14px;
$lg: 16px;
$xl: 32px;

// weights
$light: 300;
$regular: 400;
$medium: 500;
$semiBold: 600;
$bold: 700;
$extraBold: 800;

// Containers

.container {
max-width: 1176px;
margin: 0 auto;
padding: 0 15px;
}
@media screen and (min-width: 1051px) {
.d-none {
display: none;
}
}
Loading