Skip to content

Commit 6f07df1

Browse files
committed
(Feature) : Implemented Suggestions
1 parent 1024b00 commit 6f07df1

File tree

2 files changed

+39
-35
lines changed

2 files changed

+39
-35
lines changed

my-app/src/App.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// src/App.jsx
2-
31
import { BrowserRouter, Routes, Route } from "react-router-dom";
42
import { useState, useEffect } from "react";
53
import Home from "./pages/Home";
@@ -19,7 +17,7 @@ export default function App() {
1917
useEffect(() => {
2018
const timer = setTimeout(() => {
2119
setLoading(false);
22-
}, 1500); // I have Adjusted loader time to 1.5 seconds for smoother transition
20+
}, 1500); // Adjusted loader time to 1.5 seconds for smoother transition
2321

2422
return () => clearTimeout(timer); // Cleaning up timer
2523
}, []);
@@ -29,9 +27,8 @@ export default function App() {
2927
return (
3028
<div className="bg-primary">
3129
{isVisible && <Subscribe handle={handleSetVisible} />}
32-
{loading ? (
33-
<Loader />
34-
) : (
30+
<Loader loading={loading} />
31+
{!loading && (
3532
<BrowserRouter>
3633
<Base>
3734
<Routes>

my-app/src/components/Loader.jsx

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
// src/components/Loader.jsx
2-
31
import React, { useEffect, useState } from "react";
4-
import { motion } from "framer-motion";
2+
import { motion, AnimatePresence } from "framer-motion";
53
import 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

Comments
 (0)