forked from codex-iter/website-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.jsx
56 lines (53 loc) · 2 KB
/
App.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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";
import Community from "./pages/Community";
import Events from "./pages/Events";
import Base from "./layouts/Base";
import Subscribe from "./components/Subscribe";
import Loader from "./components/Loader";
import NewsletterPage from "./pages/NewsletterPage";
// Custom hook to handle the loader
const useLoader = (duration = 1500) => {
const [loading, setLoading] = useState(true);
useEffect(() => {
const timer = setTimeout(() => setLoading(false), duration);
return () => clearTimeout(timer); // This is the cleanup timer
}, [duration]);
return loading;
};
export default function App() {
const [isVisible, setVisible] = useState(false);
const loading = useLoader(); // Loader logic
return (
<div className="bg-primary">
{isVisible && <Subscribe handle={setVisible} />}
{loading && <Loader loading={loading} />}
{!loading && (
<motion.div
initial={{ filter: "blur(10px)" }}
animate={{ filter: "blur(0px)" }}
transition={{ duration: 0.5 }}
className="transition-all duration-400"
>
<BrowserRouter>
<Base>
<Routes>
<Route path="/" element={<Home handle={setVisible} />} />
<Route path="/about-us" element={<About handle={setVisible} />} />
<Route path="/community" element={<Community />} />
<Route path="/events" element={<Events />} />
{/* <Route path="/contact-us" element={<ContactForm />} /> */}
<Route path="/newsletter" element={<NewsletterPage handle={setVisible} />} />
<Route path="*" element={<NotFound />} />
</Routes>
</Base>
</BrowserRouter>
</motion.div>
)}
</div>
);
}