ExamCraftAI / Frontend /src /components /auth /AuthContainer.jsx
Hkoradiya123
Initial commit
5463318
Raw History Blame Contribute Delete
5.29 kB
import React, { useEffect, useState } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { Link } from 'react-router-dom';
import { BrainCircuit, Moon, Sun } from 'lucide-react';
import { useAuthToggle } from './AuthToggleContext';
import { LoginForm } from './LoginForm';
import { SignupForm } from './SignupForm';
import { GradientPanel } from './GradientPanel';
import { useTheme } from '../../context/ThemeContext';
export const AuthContainer = () => {
const { mode } = useAuthToggle();
const isLogin = mode === 'login';
const { theme, toggleTheme } = useTheme();
const [isMobile, setIsMobile] = useState(false);
useEffect(() => {
const checkMobile = () => setIsMobile(window.innerWidth < 1024);
checkMobile();
window.addEventListener('resize', checkMobile);
return () => window.removeEventListener('resize', checkMobile);
}, []);
return (
<div className="h-screen w-full overflow-hidden bg-slate-50 dark:bg-[#0F172A] flex font-sans transition-colors duration-300">
{/* Top Navbar overlapping (Pointer events mixed for overlay) */}
<nav className="absolute top-0 left-0 right-0 z-50 flex items-center justify-between px-8 py-6 pointer-events-none">
<Link to="/" className="flex items-center gap-2 pointer-events-auto group">
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-[#4F7CFF] to-[#8B5CF6] flex items-center justify-center shadow-lg shadow-blue-500/20 group-hover:scale-105 transition-transform duration-300">
<BrainCircuit className="h-6 w-6 text-white" />
</div>
<span className="text-2xl font-bold tracking-tight text-white transition-colors duration-300">
ExamCraft<span className="text-[#4F7CFF]">.AI</span>
</span>
</Link>
<div className="pointer-events-auto">
<button
onClick={toggleTheme}
className="p-2.5 rounded-full bg-white/5 dark:bg-black/20 backdrop-blur-md border border-white/10 dark:border-white/10 hover:bg-white/20 dark:hover:bg-white/10 transition-all duration-300 text-white dark:text-slate-300 hover:text-white shadow-sm"
aria-label="Toggle theme"
>
{theme === "dark" ? <Sun size={20} /> : <Moon size={20} />}
</button>
</div>
</nav>
<div className="flex w-full h-full relative z-10 font-sans">
{/* Left Section: Branding (Hidden on lg < 1024px) */}
<div className="hidden lg:block lg:w-1/2 h-full relative overflow-hidden bg-[#0F172A]">
<GradientPanel />
</div>
{/* Right Section: Auth Forms */}
<div className="w-full lg:w-1/2 h-full flex flex-col items-center justify-center p-6 sm:p-12 lg:p-16 relative overflow-hidden bg-white dark:bg-[#0F172A] transition-colors duration-300">
{/* Subtle ambient light in right section for dark mode */}
<div className="absolute top-0 right-0 -m-32 w-96 h-96 bg-[#4F7CFF]/10 rounded-full blur-[100px] pointer-events-none dark:block hidden" />
<div className="absolute bottom-0 left-0 -m-32 w-96 h-96 bg-[#8B5CF6]/10 rounded-full blur-[100px] pointer-events-none dark:block hidden" />
<div className="w-full max-w-md relative z-10 glass-card sm:p-10 p-6 rounded-2xl sm:shadow-[0_8px_30px_rgb(0,0,0,0.04)] dark:sm:shadow-[0_8px_30px_rgba(0,0,0,0.4)] dark:bg-[#111827]/80 bg-white border border-transparent dark:border-white/5 h-full sm:h-auto flex flex-col justify-center sm:block">
<AnimatePresence mode="wait">
{isLogin ? (
<motion.div
key="login"
initial={{ opacity: 0, x: -20 }}
animate={{ opacity: 1, x: 0 }}
exit={{ opacity: 0, x: 20 }}
transition={{ duration: 0.4, ease: [0.4, 0, 0.2, 1] }}
className="w-full flex"
>
<LoginForm />
</motion.div>
) : (
<motion.div
key="signup"
initial={{ opacity: 0, x: 20 }}
animate={{ opacity: 1, x: 0 }}
exit={{ opacity: 0, x: -20 }}
transition={{ duration: 0.4, ease: [0.4, 0, 0.2, 1] }}
className="w-full flex"
>
<SignupForm />
</motion.div>
)}
</AnimatePresence>
</div>
</div>
</div>
</div>
);
};