Created
September 28, 2021 12:53
-
-
Save hieptl/37ff5b7e3f0b881f94cdf73fc2bfab53 to your computer and use it in GitHub Desktop.
index.js - Client Side - Header - Tinder Clone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener("DOMContentLoaded", function () { | |
... | |
// set header information | |
const authenticatedUser = JSON.parse(localStorage.getItem("auth")); | |
if (authenticatedUser) { | |
... | |
// show authenticated user on the header. | |
const headerRight = document.getElementById("header__right"); | |
const userImage = document.getElementById("user__image"); | |
const userName = document.getElementById("user__name"); | |
... | |
const showHeaderInformation = () => { | |
if (headerRight && userImage && userName && authenticatedUser && authenticatedUser.uid) { | |
headerRight.classList.remove("header__right--hide"); | |
userImage.src = authenticatedUser.avatar; | |
userName.innerHTML = `Hello, ${authenticatedUser.name}`; | |
} | |
}; | |
} | |
... | |
showHeaderInformation(); | |
... | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment