+ajout loading et ajout styles divers

This commit is contained in:
AntoninoP 2024-06-26 13:43:36 +02:00
parent 2aebc424d9
commit f5b8f808c6
4 changed files with 46 additions and 4 deletions

View File

@ -7,17 +7,30 @@ import DashboardPage from './pages/DashboardPage/DashboardPage';
import { auth } from './pages/LoginPage/firebase'; import { auth } from './pages/LoginPage/firebase';
import styles from './App.module.scss'; import styles from './App.module.scss';
const Loading = () => (
<div className={styles.loading}>
<div className={styles.spinner}></div>
<p style={{ color: 'white' }}>Chargement...</p>
</div>
);
const App = () => { const App = () => {
const [user, setUser] = useState(null); const [user, setUser] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => { useEffect(() => {
const unsubscribe = auth.onAuthStateChanged((user) => { const unsubscribe = auth.onAuthStateChanged((user) => {
setUser(user); setUser(user);
setLoading(false);
}); });
return () => unsubscribe(); return () => unsubscribe();
}, []); }, []);
if (loading) {
return <Loading />;
}
return ( return (
<Router> <Router>
<div className={styles.container}> <div className={styles.container}>

View File

@ -0,0 +1,28 @@
.loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
font-size: 1.5rem;
}
.spinner {
border: 4px solid rgba(0, 0, 0, 0.1);
width: 6rem;
height: 6rem;
border-radius: 50%;
border-left-color: #09f;
animation: spin 1s ease infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

View File

@ -13,7 +13,7 @@ const Navbar = ({ user }) => {
<img src={user.photoURL} alt="Profile" className={styles.profilePic} /> <img src={user.photoURL} alt="Profile" className={styles.profilePic} />
<div className={styles.userDetails}> <div className={styles.userDetails}>
<span className={styles.userName}>{user.displayName}</span> <span className={styles.userName}>{user.displayName}</span>
<button onClick={handleLogout} className={styles.logoutButton}>Logout</button> <button onClick={handleLogout} className={styles.logoutButton}>Déconnexion</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -18,16 +18,17 @@
} }
.profilePic { .profilePic {
width: 40px; width: 3rem;
height: 40px; height: 3rem;
border-radius: 50%; border-radius: 50%;
margin-right: 10px; margin-right: 1rem;
} }
.userDetails { .userDetails {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: flex-start; align-items: flex-start;
margin-right: 4rem;
} }
.userName { .userName {