From a76f8176f62adc04ee19c083b54e0b8a0156186f Mon Sep 17 00:00:00 2001 From: matthieu Date: Thu, 23 Oct 2025 16:19:15 +0200 Subject: [PATCH] Update components with CSS animations --- src/components/LoginForm.tsx | 292 +++++++++++++++++------------------ 1 file changed, 146 insertions(+), 146 deletions(-) diff --git a/src/components/LoginForm.tsx b/src/components/LoginForm.tsx index fac6c86..abf542f 100644 --- a/src/components/LoginForm.tsx +++ b/src/components/LoginForm.tsx @@ -1,147 +1,147 @@ -import { useState, useEffect } from 'react'; - import { Mail, Lock, LogIn } from 'lucide-react'; - import { useAuth } from '../contexts/AuthContext'; - import { Card } from '../types'; - import { getRandomCards } from '../services/api'; - - export default function LoginForm() { - const [email, setEmail] = useState(''); - const [password, setPassword] = useState(''); - const [isSignUp, setIsSignUp] = useState(false); - const [error, setError] = useState(null); - const { signIn, signUp } = useAuth(); - const [cards, setCards] = useState([]); - const [loading, setLoading] = useState(true); - - useEffect(() => { - const loadCards = async () => { - try { - const randomCards = await getRandomCards(6); - setCards(randomCards); - } catch (error) { - console.error('Failed to load cards:', error); - } finally { - setLoading(false); - } - }; - - loadCards(); - }, []); - - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - setError(null); - - try { - if (isSignUp) { - await signUp(email, password); - } else { - await signIn(email, password); - } - window.location.href = '/'; // Redirect to home after successful login - } catch (error) { - setError(error instanceof Error ? error.message : 'An error occurred'); - } - }; - - if (loading) { - return
; - } - - return ( -
- {/* Animated Background */} -
-
- {[...cards, ...cards].map((card, index) => ( -
-
-
- ))} -
-
- - {/* Login Form */} -
-

- Deckerr -

- - {error && ( -
- {error} -
- )} - -
-
- -
- - setEmail(e.target.value)} - className="w-full pl-10 pr-4 py-2 bg-gray-800/50 border border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-white" - placeholder="Enter your email" - required - /> -
-
-
- -
- - setPassword(e.target.value)} - className="w-full pl-10 pr-4 py-2 bg-gray-800/50 border border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-white" - placeholder="Enter your password" - required - /> -
-
- -
- -
- -
-
-
- ); +import { useState, useEffect } from 'react'; + import { Mail, Lock, LogIn } from 'lucide-react'; + import { useAuth } from '../contexts/AuthContext'; + import { Card } from '../types'; + import { getRandomCards } from '../services/api'; + + export default function LoginForm() { + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [isSignUp, setIsSignUp] = useState(false); + const [error, setError] = useState(null); + const { signIn, signUp } = useAuth(); + const [cards, setCards] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const loadCards = async () => { + try { + const randomCards = await getRandomCards(6); + setCards(randomCards); + } catch (error) { + console.error('Failed to load cards:', error); + } finally { + setLoading(false); + } + }; + + loadCards(); + }, []); + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setError(null); + + try { + if (isSignUp) { + await signUp(email, password); + } else { + await signIn(email, password); + } + window.location.href = '/'; // Redirect to home after successful login + } catch (error) { + setError(error instanceof Error ? error.message : 'An error occurred'); + } + }; + + if (loading) { + return
; + } + + return ( +
+ {/* Animated Background */} +
+
+ {[...cards, ...cards].map((card, index) => ( +
+
+
+ ))} +
+
+ + {/* Login Form */} +
+

+ Deckerr +

+ + {error && ( +
+ {error} +
+ )} + +
+
+ +
+ + setEmail(e.target.value)} + className="w-full pl-10 pr-4 py-2 bg-gray-800/50 border border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-white transition-smooth" + placeholder="Enter your email" + required + /> +
+
+
+ +
+ + setPassword(e.target.value)} + className="w-full pl-10 pr-4 py-2 bg-gray-800/50 border border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-white transition-smooth" + placeholder="Enter your password" + required + /> +
+
+ +
+ +
+ +
+
+
+ ); }