11import { useAuth } from '../api/useAuth' ;
2- import { useEffect } from 'react' ;
2+ import { useEffect , useContext } from 'react' ;
33import { useNavigate } from 'react-router-dom' ;
4+ import { Button } from '@/components/ui/button' ;
5+ import { Eclipse , Sun } from 'lucide-react' ;
6+ import { Context } from '../Context' ;
7+ import './Login.css' ;
48
59function Login ( ) {
10+ const { darkMode, setDarkMode } = useContext ( Context ) ;
611 const { user, signIn } = useAuth ( ) ;
712 const navigate = useNavigate ( ) ;
813
@@ -12,11 +17,21 @@ function Login() {
1217 }
1318 } , [ user ] ) ;
1419
20+ const toggleDarkMode = ( ) => {
21+ setDarkMode ( ! darkMode ) ;
22+ } ;
23+
1524 return (
16- < div className = "flex justify-center items-center h-screen" >
17- < div className = "bg-black text-white rounded-xl w-11/12 max-w-lg p-8 shadow-xl" >
25+ < div
26+ className = { `${ darkMode && 'dark' } flex justify-center items-center h-screen` }
27+ >
28+ < div className = "bg-transparent text-white w-11/12 max-w-lg p-8 " >
1829 < div className = "flex justify-center items-center mb-6" >
19- < img src = "grocerease-light.png" alt = "Shopping app logo" />
30+ { darkMode ? (
31+ < img src = "grocerease-light.png" alt = "Shopping app logo" />
32+ ) : (
33+ < img src = "grocerease.png" alt = "Shopping app logo" />
34+ ) }
2035 </ div >
2136 < div className = "flex justify-center items-center h-2/5" >
2237 < div className = "flex justify-center items-center bg-pink-500 hover:bg-pink-500 hover:bg-opacity-80 w-2/4 h-1/4 rounded-xl p-2" >
@@ -26,6 +41,18 @@ function Login() {
2641 </ div >
2742 </ div >
2843 </ div >
44+ < Button
45+ onClick = { toggleDarkMode }
46+ className = "fixed w-16 bottom-16 right-16 p-2 rounded-full text-primary-pink hover:text-primary-pink hover:text-opacity-60 font-semibold"
47+ >
48+ < abbr title = { darkMode ? 'Switch to light mode' : 'Switch to dark mode' } >
49+ < button
50+ className = { `${ darkMode && 'dark' } rounded-full text-primary-pink hover:text-opacity-60` }
51+ >
52+ { darkMode ? < Eclipse /> : < Sun /> }
53+ </ button >
54+ </ abbr >
55+ </ Button >
2956 </ div >
3057 ) ;
3158}
0 commit comments