Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Commit

Permalink
Início projeto da 1º Aula
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas0headshot committed Jan 31, 2024
1 parent 7c4fe7b commit e7b7c35
Show file tree
Hide file tree
Showing 21 changed files with 446 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Aula_2/assets/css/media-query.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@media (max-width: 576px) {
.container {
width: 100%;
}
}


@media (min-width: 768px) {
.container {
width: 720px;
}
}

@media (min-width: 992px) {
.container {
width: 960px;
}
}

@media (min-width: 1200px) {
.container {
width: 1140px;
}
}

@media (min-width: 1400px) {
.container {
width: 1320px;
}
}
132 changes: 132 additions & 0 deletions Aula_2/assets/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
body {
background: #FFF;
color: #000;
box-sizing: border-box;
font-family: 'Inter', sans-serif;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
}


header {
width: 100%;
}
.navigation {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
align-items: center;
padding: 15px 0 15px 0;
}
.navigation .navigation-item {
font-size: small;
}



.product {
margin: 30px 0 0 0;
display: flex;
flex-direction: row;
justify-content: space-between;
width: 100%;
}


.product-info .info-name {
width: 20rem;
font-size: 2rem;
}

.product-info .info-price {
width: 20rem;
margin: 10px 0 0 0;
font-size: 1.1rem;
display: flex;
flex-flow: wrap column;
gap: 3px;
}
.info-price .parcelas {
display: flex;
gap: 5px;
font-size: 0.8rem;
color: #0066cc;
}

.options .colors {
width: 20rem;
margin: 30px 0 0 0;
}
.options .colors h2 {
font-size: 1.5rem;
}
.colors .colors-list {
display: flex;
flex-flow: wrap row;
gap: 20px;
margin: 10px 0 0 0;
}
.colors-list .color {
width: 35px;
height: 35px;
}
.colors-list .color input {
display: none;
}
.colors-list .color img {
width: 100%;
height: 100%;
object-fit: contain;
cursor: pointer;
}

.save-later {
width: 20rem;
}
.save-later .save-later-button {
display: flex;
align-items: start;
gap: 0.5rem;
padding: 0.5rem 0 0;
}


.product-preview {
display: flex;
flex-direction: column;
justify-content: center;
}
.product-image-wrapper {
width: inherit;
}
.product-image-wrapper {
width: 100%;
height: 100%;
object-fit: contain;
}

.product-previews {
margin: 50px 0 0 0;
width: 100%;
}
.product-preview .previews-list {
display: flex;
flex-flow: wrap row;
justify-content: center;
gap: 15px;
}
.previews-list .preview-item {
width: 40px;
height: 40px;
}
.previews-list .preview-item input {
display: none;
}
.previews-list .preview-item img {
width: 100%;
height: 100%;
object-fit: contain;
cursor: pointer;
}
4 changes: 4 additions & 0 deletions Aula_2/assets/images/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions Aula_2/assets/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
function setupProduct(productData) {
const nameElement = document.getElementById('name');
const priceElement = document.getElementById('price');
const colorsElement = document.querySelector('.colors-list');
const previewElement = document.getElementById('preview');
const previewsElement = document.querySelector('.previews-list');


function setVariation(index) {
const variation = productData.product.variations[index];

if (variation) {
previewElement.src = variation.images[1].src;
setPreviews(variation, index);
}
};

function setPreviews(variation, variationIndex) {
if (variation.images.length > 0) {
variation.images.forEach((index) => {
previewsElement.innerHTML +=
`<li class="preview-item">
<input type="radio" data-current-preview="${index}" name="preview-option">
<img src="data/image/${variationIndex}/${index + 1}.png" alt="Foto do Produto">
</input>
</li>`;
});
}
};


if (productData.product.colors.length > 0) { //Checar se há colors
productData.product.colors.forEach((index) => {
let colorElement = document.createElement('li');
colorElement.innerHTML =
`<li class="color">
<input type="radio" data-current-color="${index}" name="color-option">
<img src="data/image/${index + 1}.png" alt="Foto da cor">
</input>
</li>`;

colorsElement[0].appendChild(colorElement);
});
}

if (productData.product.variations.length > 0) {
previewElement.src = productData.product.variations[0].images[1].src;
}

if (productData.product.name) { //Checar se há name
nameElement.textContent = productData.product.name;
}

if (productData.product.price) { //Checar se há price
priceElement.textContent = `R$${productData.product.price}`;
}
};



//GET JSON do product.json
fetch('data/product.json')
.then(response => response.json())
.then(productData => setupProduct(productData))
.catch(error => console.error('An error ocurred while trying to fetch the Product JSON... ', error))
Binary file added Aula_2/data/image/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/1/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/1/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/1/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/2/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/2/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/2/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/3/0.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/3/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/3/1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/3/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/3/2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Aula_2/data/image/3/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions Aula_2/data/product.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"product": {
"name": "SmartWatch",
"description": "Pulseira loop esportiva",
"price": 499.99,

"colors": [
{
"src": "data/image/1.png"
},

{
"src": "data/image/2.png"
},

{
"src": "data/image/3.png"
}
],

"variations": [
{
"name": "Celeste",
"images": [
{
"src": "data/image/1/0.png"
},

{
"src": "data/image/1/1.png"
},

{
"src": "data/image/1/2.png"
}
]
},

{
"name": "Rosa",
"images": [
{
"src": "data/image/1/0.png"
},

{
"src": "data/image/1/1.png"
},

{
"src": "data/image/1/2.png"
}
]
},


{
"name": "Estelar",
"images": [
{
"src": "data/image/3/0.png"
},

{
"src": "data/image/3/1.png"
},

{
"src": "data/image/3/2.png"
}
]
}
]
}
}
Loading

0 comments on commit e7b7c35

Please sign in to comment.