|
1 | 1 | import { ThemeProvider } from "@/components/theme-provider"; |
2 | 2 | import { Header } from "@/components/header"; |
3 | | -import { Hero } from "./components/sections/Hero"; |
4 | | -import { About } from "@/components/sections/About"; |
5 | | -import { Projects } from "@/components/sections/Projects"; |
6 | 3 | import { BrowserRouter, Route, Routes, useLocation } from "react-router"; |
7 | 4 | import ProjectDetails from "./components/pages/project-details"; |
8 | | -import { useEffect } from "react"; |
9 | 5 | import Apps from "./components/pages/apps"; |
10 | 6 | import AppDetails from "./components/pages/app-details"; |
11 | 7 | import { Footer } from "./components/footer"; |
12 | 8 | import Policy from "./components/pages/policy"; |
13 | 9 | import ProjectsPage from "./components/pages/projects-page"; |
| 10 | +import Root from "./components/pages/root"; |
| 11 | +import { useEffect, useState } from "react"; |
| 12 | +import { ShimmeringText } from "./components/ui/shimmering-text"; |
| 13 | +import { motion } from "motion/react"; |
14 | 14 |
|
15 | | -function Root() { |
16 | | - const { state } = useLocation(); |
| 15 | +function RootLayout() { |
| 16 | + const [loading, setLoading] = useState(true); |
| 17 | + const [isExiting, setIsExiting] = useState(false); |
| 18 | + const location = useLocation(); |
| 19 | + const isRootPath = location.pathname === "/"; |
17 | 20 |
|
18 | 21 | useEffect(() => { |
19 | | - if (state?.id) { |
20 | | - document.getElementById(state.id)?.scrollIntoView({ behavior: "smooth" }); |
| 22 | + if (!isRootPath) { |
| 23 | + setLoading(false); |
| 24 | + return; |
21 | 25 | } |
22 | | - }, [state?.id]); |
23 | 26 |
|
24 | | - return ( |
25 | | - <> |
26 | | - <Hero /> |
27 | | - <Projects /> |
28 | | - <About /> |
29 | | - </> |
30 | | - ); |
31 | | -} |
| 27 | + const enterDuration = 800; |
| 28 | + const showDuration = 1500; |
| 29 | + const exitDuration = 600; |
| 30 | + |
| 31 | + const exitTimer = setTimeout(() => { |
| 32 | + setIsExiting(true); |
| 33 | + }, enterDuration + showDuration); |
| 34 | + |
| 35 | + const finishTimer = setTimeout(() => { |
| 36 | + setLoading(false); |
| 37 | + }, enterDuration + showDuration + exitDuration); |
| 38 | + |
| 39 | + return () => { |
| 40 | + clearTimeout(exitTimer); |
| 41 | + clearTimeout(finishTimer); |
| 42 | + }; |
| 43 | + }, []); |
| 44 | + |
| 45 | + if (loading) { |
| 46 | + return ( |
| 47 | + <div className="min-h-dvh bg-background container mx-auto px-4 flex items-center justify-center"> |
| 48 | + <motion.div |
| 49 | + initial={{ opacity: 0, y: 10 }} |
| 50 | + animate={isExiting ? { opacity: 0, y: -10 } : { opacity: 1, y: 0 }} |
| 51 | + transition={{ duration: isExiting ? 0.6 : 0.8, ease: "easeInOut" }} |
| 52 | + > |
| 53 | + <ShimmeringText |
| 54 | + text="Loading..." |
| 55 | + duration={1} |
| 56 | + transition={{ duration: 1 }} |
| 57 | + /> |
| 58 | + </motion.div> |
| 59 | + </div> |
| 60 | + ); |
| 61 | + } |
32 | 62 |
|
33 | | -function RootLayout() { |
34 | 63 | return ( |
35 | 64 | <div className="min-h-screen bg-background container mx-auto px-4"> |
36 | 65 | <div className="mx-auto max-w-4xl"> |
|
0 commit comments