Entrega do Desafio #1

Merged
anacarolinaduartecavalcante merged 29 commits from feature/challenge-tourist-attractions into develop 2022-11-28 17:16:05 +00:00
7 changed files with 52 additions and 20 deletions
Showing only changes of commit 3a01cd6334 - Show all commits

View File

After

Width:  |  Height:  |  Size: 89 KiB

View File

After

Width:  |  Height:  |  Size: 116 KiB

View File

After

Width:  |  Height:  |  Size: 107 KiB

View File

@ -1,34 +1,58 @@
export class Form { export class Form {
constructor() { constructor() {
this.list = [];
this.list = [
{
src: "imgs/paodeacucar.png",
title: "Pão de Açúcar",
description: "Amet minim mollit non deserunt ullamco est sit aliqua dolor dosa amet sint. Velit officia consece duis enim velit mollit.",
},
{
src: "imgs/cristoredentor.png",
title: "Cristo Redentor",
description: "Amet minim mollit non deserunt ullamco est sit aliqua dolor dosa amet sint. Velit officia consece duis enim velit mollit.",
},
{
src: "imgs/ilhagrande.png",
title: "Ilha Grande",
description: "Amet minim mollit non deserunt ullamco est sit aliqua dolor dosa amet sint. Velit officia consece duis enim velit mollit.",
},
{
src: "imgs/centrohistoricodeparati.png",
title: "Centro Histórico de Parati",
description: "Amet minim mollit non deserunt ullamco est sit aliqua dolor dosa amet sint. Velit officia consece duis enim velit mollit.",
},
];
this.selectors(); this.selectors();
this.events(); this.events();
} }
selectors() { selectors() {
this.image = document.querySelector(".input-image-content"); this.src = document.querySelector(".input-image-content");
this.itemInput = document.querySelectorAll("div.input-image-container");
this.form = document.querySelector(".form"); this.form = document.querySelector(".form");
this.itemTitle = document.getElementById("titleInput");
this.itemDescription = document.getElementById("descriptionText");
this.slider = document.querySelector(".slider-list"); this.slider = document.querySelector(".slider-list");
} }
events() { events() {
this.form.addEventListener("submit", this.addItemToList.bind(this)); this.src.addEventListener("change", (e) => {
this.image.addEventListener("change", (e) => {
document.querySelector("img").src = URL.createObjectURL(e.target.files[0]); document.querySelector("img").src = URL.createObjectURL(e.target.files[0]);
}); });
this.form.addEventListener("submit", this.addItemToList.bind(this));
} }
addItemToList(event) { addItemToList(event) {
event.preventDefault(); event.preventDefault();
const itemImage = event.target["buttonAdicionar"].value.img; const itemImage = event.target["buttonAdicionar"].value.src;
const itemTitle = event.target["titleInput"].value.title; const itemTitle = event.target["titleInput"].value.title;
const itemDescription = event.target["descriptionText"].value.description; const itemDescription = event.target["descriptionText"].value.description;
if (itemImage != "") { if (itemImage !== "") {
const item = { const item = {
img: itemImage, src: itemImage,
title: itemTitle, title: itemTitle,
description: itemDescription, description: itemDescription,
}; };
@ -46,7 +70,7 @@ export class Form {
this.list.forEach(function (item) { this.list.forEach(function (item) {
itemsSlider += ` itemsSlider += `
<li class="slider-content" data-test="container-item-list"> <li class="slider-content" data-test="container-item-list">
<img src="${item.img}" alt="" data-test="image-item-list"/> <img src="${item.src}" alt="" data-test="image-item-list"/>
<h3 data-test="title-item-list">${item.title}</h3> <h3 data-test="title-item-list">${item.title}</h3>
<p data-test="description-item-list">${item.description}</p> <p data-test="description-item-list">${item.description}</p>
</li> </li>
@ -56,6 +80,8 @@ export class Form {
} }
resetInputs() { resetInputs() {
this.itemInput.value = ""; this.src.value = "";
this.itemTitle.value = "";
this.itemDescription.value = "";
} }
} }

View File

@ -38,8 +38,14 @@ h2 {
font-size: 24px; font-size: 24px;
line-height: 28px; line-height: 28px;
color: $title-item-list-color; color: $title-item-list-color;
height: 60px; max-height: 60px;
margin: 24px 24px 8px 24px; margin: 24px 24px 8px 24px;
overflow-y: auto;
-ms-overflow-style: none;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
} }
& p { & p {
padding: 0 24px 0 24px; padding: 0 24px 0 24px;

View File

@ -22,7 +22,7 @@
<div class="form-container"> <div class="form-container">
<div class="form-inputs"> <div class="form-inputs">
<div class="input-image-container" data-test="input-image"> <div class="input-image-container" data-test="input-image">
<input type="file" accept="image/*" class="input-image-content" /> <input type="file" accept="image/*" class="input-image-content" id="input-images"/>
<img src="" alt="" /> <img src="" alt="" />
</div> </div>
<div class="form-input-descricao"> <div class="form-input-descricao">
@ -38,9 +38,9 @@
<div class="slider-container"> <div class="slider-container">
<h2 data-test="title-list">Pontos Turísticos</h2> <h2 data-test="title-list">Pontos Turísticos</h2>
<div class="slider"> <div class="slider">
<ul class="slider-list"> <ul class="slider-list" id="slider-content">
<li class="slider-content" data-test="container-item-list"> <li class="slider-content" data-test="container-item-list">
<img src="imgs/image-item-list-1.png" alt="" data-test="image-item-list" <img src="imgs/paodeacucar.png" alt="" data-test="image-item-list"
/> />
<h3 data-test="title-item-list">Pão de Açúcar</h3> <h3 data-test="title-item-list">Pão de Açúcar</h3>
<p data-test="description-item-list"> <p data-test="description-item-list">
@ -50,7 +50,7 @@
</li> </li>
<li class="slider-content" data-test="container-item-list"> <li class="slider-content" data-test="container-item-list">
<img <img
src="imgs/image-item-list-2.png" src="imgs/cristoredentor.png"
alt="" alt=""
data-test="image-item-list" data-test="image-item-list"
/> />
@ -62,7 +62,7 @@
</li> </li>
<li class="slider-content" data-test="container-item-list"> <li class="slider-content" data-test="container-item-list">
<img <img
src="imgs/image-item-list-3.png" src="imgs/ilhagrande.png"
alt="" alt=""
data-test="image-item-list" data-test="image-item-list"
/> />
@ -74,7 +74,7 @@
</li> </li>
<li class="slider-content" data-test="container-item-list"> <li class="slider-content" data-test="container-item-list">
<img <img
src="imgs/image-item-list-4.png" src="imgs/centrohistoricodeparati.png"
alt="" alt=""
data-test="image-item-list" data-test="image-item-list"
/> />
@ -84,7 +84,7 @@
amet sint. Velit officia consece duis enim velit mollit. amet sint. Velit officia consece duis enim velit mollit.
</p> </p>
</li> </li>
<li class="slider-content" data-test="container-item-list"> <!-- <li class="slider-content" data-test="container-item-list">
<img <img
src="imgs/image-item-list-4.png" src="imgs/image-item-list-4.png"
alt="" alt=""
@ -95,7 +95,7 @@
Amet minim mollit non deserunt ullamco est sit aliqua dolor dosa Amet minim mollit non deserunt ullamco est sit aliqua dolor dosa
amet sint. Velit officia consece duis enim velit mollit. amet sint. Velit officia consece duis enim velit mollit.
</p> </p>
</li> </li> -->
</ul> </ul>
</div> </div>
</div> </div>