diff --git a/my-app/src/App.jsx b/my-app/src/App.jsx index 4998d44..7d0fe94 100644 --- a/my-app/src/App.jsx +++ b/my-app/src/App.jsx @@ -1,5 +1,6 @@ import { BrowserRouter, Routes, Route } from "react-router-dom"; import { useState, useEffect } from "react"; +import { motion } from "framer-motion"; import Home from "./pages/Home"; import About from "./pages/About"; import NotFound from "./pages/404"; @@ -10,37 +11,44 @@ import Base from "./layouts/Base"; import Subscribe from "./components/Subscribe"; import Loader from "./components/Loader"; -export default function App() { - const [isVisible, setIsVisible] = useState(false); +// Custom hook to handle the loader +const useLoader = (duration = 1500) => { const [loading, setLoading] = useState(true); - useEffect(() => { - const timer = setTimeout(() => { - setLoading(false); - }, 1500); // Adjusted loader time to 1.5 seconds for smoother transition + const timer = setTimeout(() => setLoading(false), duration); + return () => clearTimeout(timer); // This is the cleanup timer + }, [duration]); + return loading; +}; - return () => clearTimeout(timer); // Cleaning up timer - }, []); - - const handleSetVisible = (value) => setIsVisible(value); +export default function App() { + const [isVisible, setVisible] = useState(false); + const loading = useLoader(); // Loader logic return (
- {isVisible && } - + {isVisible && } + {loading && } {!loading && ( - - - - } /> - } /> - } /> - } /> - } /> - } /> - - - + + + + + } /> + } /> + } /> + } /> + } /> + } /> + + + + )}
); diff --git a/my-app/src/components/Loader.jsx b/my-app/src/components/Loader.jsx index ab243c0..053d9b9 100644 --- a/my-app/src/components/Loader.jsx +++ b/my-app/src/components/Loader.jsx @@ -1,8 +1,10 @@ +// src/components/Loader.jsx + import React, { useEffect, useState } from "react"; -import { motion, AnimatePresence } from "framer-motion"; +import { motion } from "framer-motion"; import logo from "../assets/images/codex-logo.png"; -const Loader = ({ loading }) => { +const Loader = () => { const [showExplore, setShowExplore] = useState(false); useEffect(() => { @@ -14,40 +16,31 @@ const Loader = ({ loading }) => { }, []); return ( - - {loading && ( - -
- Logo - -
- - We Code - - - - We Explore - -
-
-
- )} -
+
+
+ Logo + +
+ + We Code + + + + We Explore + +
+
+
); };