1- // src/components/Loader.jsx
2-
31import React , { useEffect , useState } from "react" ;
4- import { motion } from "framer-motion" ;
2+ import { motion , AnimatePresence } from "framer-motion" ;
53import logo from "../assets/images/codex-logo.png" ;
64
7- const Loader = ( ) => {
5+ const Loader = ( { loading } ) => {
86 const [ showExplore , setShowExplore ] = useState ( false ) ;
97
108 useEffect ( ( ) => {
@@ -16,31 +14,40 @@ const Loader = () => {
1614 } , [ ] ) ;
1715
1816 return (
19- < div className = "flex items-center justify-center h-screen bg-primary" >
20- < div className = "flex flex-col items-center" >
21- < img src = { logo } alt = "Logo" className = "w-25" />
22-
23- < div className = "relative text-white text-1xl mt-0.5" >
24- < motion . div
25- className = "relative"
26- initial = { { opacity : 1 , y : 0 } }
27- animate = { { opacity : showExplore ? 0 : 1 , y : showExplore ? - 20 : 0 } }
28- transition = { { duration : 0.25 } }
29- >
30- We < span className = "text-secondary" > Code</ span >
31- </ motion . div >
32-
33- < motion . div
34- className = "relative"
35- initial = { { opacity : 0 , y : 20 } }
36- animate = { { opacity : showExplore ? 1 : 0 , y : showExplore ? 0 : 20 } }
37- transition = { { duration : 0.25 } }
38- >
39- We < span className = "text-secondary" > Explore</ span >
40- </ motion . div >
41- </ div >
42- </ div >
43- </ div >
17+ < AnimatePresence >
18+ { loading && (
19+ < motion . div
20+ className = "flex items-center justify-center h-screen bg-primary"
21+ initial = { { opacity : 1 , y : 0 } }
22+ exit = { { opacity : 0 , y : - 100 } } // Exit animation: fades and slides up
23+ transition = { { duration : 0.5 } }
24+ >
25+ < div className = "flex flex-col items-center" >
26+ < img src = { logo } alt = "Logo" className = "w-25" />
27+
28+ < div className = "relative text-white text-1xl mt-0.5" >
29+ < motion . div
30+ className = "relative"
31+ initial = { { opacity : 1 , y : 0 } }
32+ animate = { { opacity : showExplore ? 0 : 1 , y : showExplore ? - 20 : 0 } }
33+ transition = { { duration : 0.25 } }
34+ >
35+ We < span className = "text-secondary" > Code</ span >
36+ </ motion . div >
37+
38+ < motion . div
39+ className = "relative"
40+ initial = { { opacity : 0 , y : 20 } }
41+ animate = { { opacity : showExplore ? 1 : 0 , y : showExplore ? - 20 : 0 } }
42+ transition = { { duration : 0.25 } }
43+ >
44+ We < span className = "text-secondary" > Explore</ span >
45+ </ motion . div >
46+ </ div >
47+ </ div >
48+ </ motion . div >
49+ ) }
50+ </ AnimatePresence >
4451 ) ;
4552} ;
4653
0 commit comments