Newer
Older
import { useEffect, useState } from "react";
import "./LandingPage.css"
Liliana Sanfilippo
committed
import "./App.scss";
import "bootstrap/dist/css/bootstrap.min.css";
import LoadingScreen from "../components/LoadingScreen.tsx";
import { Routes, Route } from "react-router-dom";
import { Footer } from "../components/Footer.tsx";
import { NotFound } from "../components/NotFound.tsx";
import { Navbar } from "../components/Navbar.tsx";
import { getPathMapping } from "../utils/getPathMapping.ts";
import { stringToSlug } from "../utils/stringToSlug.ts";
import { Villbuttonrow } from "../components/Buttons.tsx";
const { scrollYProgress } = useScroll({
offset: ["start start", "end end"],
});
window.scrollTo(0, 0);
const [isLoading, setIsLoading] = useState(true);
const pathMapping = getPathMapping();
const currentPath =
location.pathname
.split(`${stringToSlug(import.meta.env.VITE_TEAM_NAME)}`)
.pop() || "/";
// Set Page Title
const title =
currentPath in pathMapping ? pathMapping[currentPath].title : "Not Found";
useEffect(() => {
document.title = `${title || ""} | ${import.meta.env.VITE_TEAM_NAME} - iGEM ${import.meta.env.VITE_TEAM_YEAR}`;
}, [title]);
useEffect(() => {
const timer = setTimeout(() => {
console.log("Hiding loading screen");
setIsLoading(false);
}, 0); // Adjust the delay as needed, Update the loading state after 3 seconds
return () => {
console.log("Cleaning up timer");
clearTimeout(timer); // Clear the timer on component unmount
};
}, []);
{/* Navigation */}
<Navbar />
<motion.div
className="progress-bar"
style={{ scaleX: scrollYProgress }}
/>
{/* Header and PageContent */}
<Routes>
{Object.entries(pathMapping).map(([path, { header: Header, component: Component, navlist: Sidebar }]) => (
<Route
key={path}
path={path}
element={
<>
<Header />
{/* Page content */}
<div className="container-fluid">
<div className="row">
<Sidebar />
<div className="col">
<Component />
<Villbuttonrow />
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<div className="col-1 d-none d-lg-block">
{/* <!-- empty!--> */}
</div>
</div>
</div>
{/* End page content */}
</>
}
/>
))}
{/* Add a route for the Description component */}
<Route
path="/description"
element={
<>
{/* Page content */}
<div className="container-fluid">
<div className="row">
<div className="col">
<Villbuttonrow />
</div>
<div className="col-1 d-none d-lg-block">
{/* <!-- empty!--> */}
</div>
</div>
</div>
</>
}
/>
<Route
path="*"
element={
<>
<NotFound />
</>
}
/>
</Routes>