diff --git a/src/js/auth.js b/src/js/auth.js index 61d3174..74fc85c 100644 --- a/src/js/auth.js +++ b/src/js/auth.js @@ -8,12 +8,10 @@ import { onAuthStateChangedListener } from './auth/authStateListener.js'; const signUpModal = document.querySelector('.sign-up-modal'); const signInModal = document.querySelector('.sign-in-modal'); -const signUpModalMobile = document.querySelector('.sign-up-button-mobile-menu'); - export const signUpButton = document.querySelector('.sign-up-button'); export const logOutButton = document.querySelector('#log-out'); -const logOutMobileMenuButton = document.querySelector('#mobile-log-out-button'); +const logOutMobileButton = document.querySelector('#mobile-log-out-button'); const switchToSignInButtons = document.querySelectorAll('[data-switch="sign-in"]'); const switchToSignUpButtons = document.querySelectorAll('[data-switch="sign-up"]'); @@ -41,11 +39,6 @@ signUpButton.addEventListener('click', function () { showForm(currentForm); }); -signUpModalMobile.addEventListener('click', function () { - currentForm = 'sign-up'; - showForm(currentForm); -}); - switchToSignInButtons.forEach(button => { button.addEventListener('click', function () { currentForm = 'sign-in'; @@ -127,21 +120,21 @@ logOutButton.addEventListener('click', async function () { } }); -export const handleLogout = async () => { +logOutMobileButton.addEventListener('click', async function () { try { - await signOut(auth); + await signOutUser(); } catch (error) { - console.error('Error during logout:', error); + console.error('Logout error:', error); } -}; +}); -logOutMobileMenuButton.addEventListener('click', async function () { +export const handleLogout = async () => { try { - await signOutUser(); + await signOut(auth); } catch (error) { - console.error('Logout error:', error); + console.error('Error during logout:', error); } -}); +}; const toggleDropdownMenu = () => { const dropdownMenu = document.getElementById('user-dropdown-menu'); diff --git a/src/js/auth/authStateListener.js b/src/js/auth/authStateListener.js index efe2d34..1ffa393 100644 --- a/src/js/auth/authStateListener.js +++ b/src/js/auth/authStateListener.js @@ -16,10 +16,7 @@ export const onAuthStateChangedListener = userNameDisplay => { if (user) { const displayName = user.displayName; - const userNameDisplayMobile = document.querySelector('#user-name-display-mobile'); - userNameDisplay.textContent = displayName; - userNameDisplayMobile.textContent = displayName; userProfile.classList.remove('hidden'); userButton.classList.remove('hidden'); signUpButton.classList.add('hidden'); diff --git a/src/js/mobileMenu.js b/src/js/mobileMenu.js index 548cce4..87e3d73 100644 --- a/src/js/mobileMenu.js +++ b/src/js/mobileMenu.js @@ -4,53 +4,30 @@ import { auth } from './auth/firebase'; const openMenuButton = document.querySelector('.open-mobile-menu'); const closeMenuButton = document.querySelector('#close-sing-up-mobile-menu'); -const closeUserMenuButton = document.querySelector('#close-user-mobile-menu'); const windowSize = window.matchMedia('(min-width: 768px)'); - -const mobileMenuSingIn = document.querySelector('#sing-in-mobile-menu'); const mobileMenuSingUp = document.querySelector('#sing-up-mobile-menu'); const openMenu = () => { - onAuthStateChanged(auth, user => { - if (user) { - mobileMenuSingIn.style.display = 'block'; - setTimeout(() => { - mobileMenuSingIn.style.transform = 'translateX(0)'; - }, 1); - } else { - mobileMenuSingUp.style.display = 'block'; - setTimeout(() => { - mobileMenuSingUp.style.transform = 'translateX(0)'; - }, 1); - } - }); + mobileMenuSingUp.style.display = 'block'; + setTimeout(() => { + mobileMenuSingUp.style.transform = 'translateX(0)'; + }, 1); }; const closeMenu = () => { - onAuthStateChanged(auth, user => { - if (user) { - mobileMenuSingIn.style.transform = 'translateX(-100%)'; - setTimeout(() => { - mobileMenuSingIn.style.display = 'none'; - }, 500); - } else { - mobileMenuSingIn.style.transform = 'translateX(-100%)'; - setTimeout(() => { - mobileMenuSingUp.style.transform = 'translateX(-100%)'; - }, 500); - } - }); + mobileMenuSingUp.style.transform = 'translateX(-100%)'; + setTimeout(() => { + mobileMenuSingUp.style.transform = 'translateX(-100%)'; + }, 500); }; //closing mobile menu function if window size is bigger than 768px function mobileMenuClose(event) { if (event.matches) { - mobileMenuSingIn.style.display = 'none'; mobileMenuSingUp.style.display = 'none'; } } openMenuButton.addEventListener('click', openMenu); closeMenuButton.addEventListener('click', closeMenu); -closeUserMenuButton.addEventListener('click', closeMenu); windowSize.addEventListener('change', mobileMenuClose); diff --git a/src/partials/home/home-header.html b/src/partials/home/home-header.html index 4f7d2fb..7814e3e 100644 --- a/src/partials/home/home-header.html +++ b/src/partials/home/home-header.html @@ -53,7 +53,7 @@
- -
- pictur of books covers -
-
- - -
-
- - - - -

Bookshelf

-
-
- - -
-
-
-
-
-
- - - +
-
-
-