Skip to content

Commit

Permalink
profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Claraescobar123 committed Aug 25, 2020
1 parent 0c61f82 commit b705f63
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/css/profileUser.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
flex-direction: column;
}
#profile h1,h3{
font-size: 13px;
color:black;
text-align: center;
}

#profile .photo{
border-radius: 50%;
max-width: 25%;
display:inline-block;
}
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ window.addEventListener('hashchange', () => {
router(window.location.hash);
});



myFunction();
43 changes: 41 additions & 2 deletions src/views/profileUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,53 @@ export default () => {
history.replaceState({}, 'profileUser', '#profile');
const profile = document.createElement('div');
profile.setAttribute('id', 'profile');
profile.innerHTML = `<img src="img/foto.jpg" alt="photoUser" class="photo"/>
profile.innerHTML = `<img src="" id="preview" alt="photoUser" class="photo"/>
<div class="default-image"></div>
<h1>Clara Escobar</h1>
<input type="file" id="archivo" name="archivo"/>
<ul>
<li>
<a href="#">[email protected]</a>
</li>
</ul>
<h3>Sobre mi</h3>
<input type="text" id="biography" class="aboutMe" placeholder="Cuéntanos de ti"/>`;

const photos = profile.querySelector('#archivo');
const previewPhoto = profile.querySelector('#preview');
const defaultImage = profile.querySelector('.default-image');

photos.addEventListener('change', () => {
const file = photos.files[0];
console.log(file);
if (file) {
const reader = new FileReader();
defaultImage.style.display = 'none';
previewPhoto.style.display = 'block';
reader.addEventListener('load', () => {
previewPhoto.setAttribute('src', reader.result);
});
reader.readAsDataURL(file);
} else {
defaultImage.style.display = null;
previewPhoto.style.display = null;
previewPhoto.setAttribute('src', '');
}
});
return profile;
};
};


/*function mostrarImagen(event){
let imagenSource = event.target.result;
let previewImage = document.getElementById("preview");
}
function changePhoto(event){
let imagen = event.target.files[0];
let lector = new FileReader();
lector.addEventListener("load", mostrarImagen,false);
lector.readAsDataURL(imagen);
}
document.getElementById("archivo").addEventListener("change", changePhoto,false);*/

0 comments on commit b705f63

Please sign in to comment.