design: use clipPath polygon interpolation to animate splash screen exit seamlessly
This commit is contained in:
@@ -13,6 +13,7 @@ import { DialogProvider } from './context/DialogContext';
|
||||
import { motion, AnimatePresence } from 'framer-motion';
|
||||
import { StatusTimeline, type Event } from './components/dashboard/EventStatusTimeline';
|
||||
import { useEffect } from 'react';
|
||||
import ritLogo from './assets/images/college-logo.png';
|
||||
|
||||
import { InstitutionalCalendar } from './components/dashboard/InstitutionalCalendar';
|
||||
import { VenueTimeline } from './components/dashboard/VenueTimeline';
|
||||
@@ -27,6 +28,56 @@ import { ManageNoticesView } from './components/dashboard/ManageNoticesView';
|
||||
import { ManageStudentsView } from './components/dashboard/ManageStudentsView';
|
||||
import { VenueManagement } from './components/dashboard/VenueManagement';
|
||||
|
||||
const LoginTransitionScreen: React.FC<{ user: any }> = ({ user }) => {
|
||||
return (
|
||||
<motion.div
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{ duration: 0.6, ease: "easeInOut" }}
|
||||
className="fixed inset-0 z-[300] bg-gradient-to-br from-[#003B5C] via-[#004a99] to-[#001D3D] flex flex-col items-center justify-center text-white"
|
||||
>
|
||||
<div className="flex flex-col items-center gap-6 max-w-sm text-center px-6">
|
||||
<motion.div
|
||||
initial={{ scale: 0.8, opacity: 0 }}
|
||||
animate={{ scale: 1, opacity: 1 }}
|
||||
transition={{ delay: 0.2, duration: 0.6, type: "spring" }}
|
||||
className="bg-white/95 p-4 rounded-3xl shadow-2xl shadow-blue-900/30"
|
||||
>
|
||||
<img src={ritLogo} alt="RIT Logo" className="h-16 w-auto object-contain" />
|
||||
</motion.div>
|
||||
|
||||
<div className="space-y-2 mt-4 animate-pulse">
|
||||
<motion.h2
|
||||
initial={{ y: 15, opacity: 0 }}
|
||||
animate={{ y: 0, opacity: 1 }}
|
||||
transition={{ delay: 0.4, duration: 0.5 }}
|
||||
className="text-2xl font-black uppercase tracking-tight"
|
||||
>
|
||||
Welcome Back
|
||||
</motion.h2>
|
||||
<motion.p
|
||||
initial={{ y: 10, opacity: 0 }}
|
||||
animate={{ y: 0, opacity: 1 }}
|
||||
transition={{ delay: 0.6, duration: 0.5 }}
|
||||
className="text-sm font-bold text-slate-300 uppercase tracking-widest"
|
||||
>
|
||||
{user?.fullName || "User"}
|
||||
</motion.p>
|
||||
</div>
|
||||
|
||||
<motion.div
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: [0, 1, 0] }}
|
||||
transition={{ delay: 0.8, duration: 1.5, repeat: Infinity }}
|
||||
className="text-[9px] font-black uppercase tracking-widest text-[#f97316] mt-8"
|
||||
>
|
||||
Connecting to Event Hub...
|
||||
</motion.div>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
const AppContent: React.FC = () => {
|
||||
const { isAuthenticated, user } = useAuth();
|
||||
@@ -34,6 +85,22 @@ const AppContent: React.FC = () => {
|
||||
const [activeItem, setActiveItem] = useState('dashboard');
|
||||
const [userEvents, setUserEvents] = useState<Event[]>([]);
|
||||
const [preFillData, setPreFillData] = useState<any>(null);
|
||||
const [showTransition, setShowTransition] = useState(false);
|
||||
const [cachedUser, setCachedUser] = useState<any>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (isAuthenticated && user) {
|
||||
setCachedUser(user);
|
||||
setShowTransition(true);
|
||||
const timer = setTimeout(() => {
|
||||
setShowTransition(false);
|
||||
}, 2000);
|
||||
return () => clearTimeout(timer);
|
||||
} else {
|
||||
setShowTransition(false);
|
||||
setCachedUser(null);
|
||||
}
|
||||
}, [isAuthenticated, user]);
|
||||
|
||||
const handleIncompleteClick = (data: any) => {
|
||||
setPreFillData(data);
|
||||
@@ -101,38 +168,6 @@ const AppContent: React.FC = () => {
|
||||
}
|
||||
}, [isAuthenticated, activeItem, user?.email, user?.role, user?.department]);
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return (
|
||||
<AnimatePresence mode="wait">
|
||||
<motion.div
|
||||
key="login"
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{ duration: 0.5 }}
|
||||
>
|
||||
<LoginPage />
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
);
|
||||
}
|
||||
|
||||
if (user?.role === 'STUDENT') {
|
||||
return (
|
||||
<AnimatePresence mode="wait">
|
||||
<motion.div
|
||||
key="student-dashboard"
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{ duration: 0.5 }}
|
||||
>
|
||||
<StudentDashboard />
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
);
|
||||
}
|
||||
|
||||
const renderContent = () => {
|
||||
const isDashboard = (
|
||||
<Overview
|
||||
@@ -182,6 +217,16 @@ const AppContent: React.FC = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<AnimatePresence>
|
||||
{showTransition && <LoginTransitionScreen user={cachedUser} />}
|
||||
</AnimatePresence>
|
||||
|
||||
{!isAuthenticated ? (
|
||||
<LoginPage />
|
||||
) : user?.role === 'STUDENT' ? (
|
||||
<StudentDashboard />
|
||||
) : (
|
||||
<DashboardLayout
|
||||
activeItem={activeItem}
|
||||
onItemClick={handleSidebarClick}
|
||||
@@ -198,6 +243,8 @@ const AppContent: React.FC = () => {
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
</DashboardLayout>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -39,6 +39,13 @@ export const LoginPage: React.FC = () => {
|
||||
const [isSignUp, setIsSignUp] = useState(false);
|
||||
const [signUpType, setSignUpType] = useState<'INTERNAL' | 'EXTERNAL' | null>(null);
|
||||
const [splashState, setSplashState] = useState<'logo' | 'text' | 'fade-to-white' | 'done'>('logo');
|
||||
const [isMobile, setIsMobile] = useState(typeof window !== 'undefined' ? window.innerWidth < 1024 : false);
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => setIsMobile(window.innerWidth < 1024);
|
||||
window.addEventListener('resize', handleResize);
|
||||
return () => window.removeEventListener('resize', handleResize);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const timer1 = setTimeout(() => {
|
||||
@@ -623,25 +630,17 @@ export const LoginPage: React.FC = () => {
|
||||
{/* Splash Screen Overlay */}
|
||||
<AnimatePresence>
|
||||
{splashState !== 'done' && (
|
||||
<div className="fixed inset-0 z-[200] flex overflow-hidden pointer-events-none">
|
||||
{/* Left part of splash: remains static blue on desktop to match underlying panel */}
|
||||
<motion.div
|
||||
initial={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{ duration: 0.8 }}
|
||||
className="hidden lg:block lg:w-[55%] h-full bg-gradient-to-br from-[#003B5C] via-[#004a99] to-[#001D3D]"
|
||||
/>
|
||||
|
||||
{/* Right part of splash (and full screen on mobile): slides right to reveal white page */}
|
||||
<motion.div
|
||||
initial={{ x: 0 }}
|
||||
key="splash-overlay"
|
||||
initial={{ clipPath: "polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)" }}
|
||||
animate={{
|
||||
x: splashState === 'fade-to-white' ? "100%" : 0
|
||||
clipPath: splashState === 'fade-to-white'
|
||||
? (isMobile ? "polygon(0% 0%, 0% 0%, 0% 100%, 0% 100%)" : "polygon(0% 0%, 55% 0%, 55% 100%, 0% 100%)")
|
||||
: "polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)"
|
||||
}}
|
||||
transition={{ duration: 1.5, ease: [0.85, 0, 0.15, 1] }}
|
||||
className="w-full lg:w-[45%] h-full bg-gradient-to-br from-[#003B5C] via-[#004a99] to-[#001D3D]"
|
||||
/>
|
||||
|
||||
className="fixed inset-0 z-[200] bg-gradient-to-br from-[#003B5C] via-[#004a99] to-[#001D3D] flex items-center justify-center overflow-hidden"
|
||||
>
|
||||
{/* Centered content overlay for Logo/Text */}
|
||||
<div className="absolute inset-0 flex items-center justify-center z-10 pointer-events-none">
|
||||
<AnimatePresence mode="wait">
|
||||
@@ -674,7 +673,7 @@ export const LoginPage: React.FC = () => {
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user