Develop #3

Merged
WilliamSimao merged 26 commits from Develop into main 2022-11-29 01:13:27 +00:00
3 changed files with 64 additions and 29 deletions
Showing only changes of commit 2a5ffb64c3 - Show all commits

View File

@ -14,13 +14,16 @@
<div class="container-h1-input"> <div class="container-h1-input">
<h1 class="page-titulo__tourist" data-test="title-form">Adicionar um Ponto Turístico</h1> <h1 class="page-titulo__tourist" data-test="title-form">Adicionar um Ponto Turístico</h1>
<form action="">
<div class="container-input"> <div class="container-input">
<div class="wrapper-input__img"> <div class="wrapper-input__img">
<label> <label class="label-input" for="input__img">
<input id="input__img" type="file" data-test="input-image"> <!-- <span class="span__img">
<span class="span__img">Imagem</span> </span> -->
</label> </label>
<input id="input__img" type="file" data-test="input-image">
</div> </div>
<div class="wrapper-input__text"> <div class="wrapper-input__text">
@ -35,6 +38,7 @@
</div> </div>
</form>
<h1 data-test="title-list" class="page-titulo__img__spot">Pontos Turísticos</h1> <h1 data-test="title-list" class="page-titulo__img__spot">Pontos Turísticos</h1>

31
js.js
View File

@ -1,6 +1,37 @@
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
const inputFile = document.querySelector('#input__img');
const labelInput = document.querySelector('.label-input');
const textSpanInput = "Imagem";
labelInput.innerHTML = textSpanInput;
inputFile.addEventListener('change', (e) => {
const inputTarget = e.target;
const file = inputTarget.files[0];
if (file) {
const reader = new FileReader();
reader.addEventListener('load', (e) => {
const readerTarget = e.target;
const img = document.createElement('img');
img.src = readerTarget.result;
img.classList.add('img-result');
labelInput.appendChild(img);
});
reader.readAsDataURL(file);
labelInput.innerHTML = "";
}else {
labelInput.innerHTML = textSpanInput;
}
});
}); });

View File

@ -25,15 +25,6 @@
margin: 40px 0 60px; margin: 40px 0 60px;
} }
.img-result {
width: 100%;
}
.wrapper-input__img input {
display: none;
margin-right: 20px;
}
.wrapper-input__img label { .wrapper-input__img label {
display: flex; display: flex;
align-items: center; align-items: center;
@ -57,6 +48,15 @@
cursor: pointer; cursor: pointer;
} }
.wrapper-input__img input {
display: none;
margin-right: 20px;
}
.img-result {
max-width: 100%;
}
.wrapper-input__text { .wrapper-input__text {
display: flex; display: flex;
flex-direction: column; flex-direction: column;