Files
REXNT/src/App.jsx

87 lines
2.3 KiB
React
Raw Normal View History

2025-12-23 17:09:40 +03:00
import React from "react";
2026-01-09 00:07:39 +03:00
import { BrowserRouter, Routes, Route, useLocation } from "react-router-dom";
import { AnimatePresence, LayoutGroup } from "framer-motion";
2025-12-23 22:00:31 +03:00
import "./i18n";
2026-01-09 00:07:39 +03:00
import "./App.css";
2025-12-23 17:09:40 +03:00
import Navbar from "./Components/Nav/Navbar";
import Home from "./Components/Sections/Home/Home";
import Services from "./Components/Sections/Services/Services";
import About from "./Components/Sections/About/About";
2026-01-09 00:07:39 +03:00
import Departments from "./Components/Sections/Departments/Departments";
2026-01-09 20:12:38 +03:00
import DepartmentDetail from "./Components/Sections/DepartmentDetail/DepartmentDetail";
2025-12-23 17:09:40 +03:00
import Contact from "./Components/Sections/Contact/Contact";
2025-12-23 22:00:31 +03:00
import Footer from "./Components/Nav/Footer";
2026-01-09 20:12:38 +03:00
import DepartmentDetail2 from "./Components/Sections/DepartmentDetail2/DepartmentDetail2";
2025-12-23 17:09:40 +03:00
2026-01-09 00:07:39 +03:00
const MainPage = () => {
2025-12-23 17:09:40 +03:00
return (
2026-01-09 20:12:38 +03:00
<div className="min-h-screen bg-white dark:bg-gray-900 text-gray-900 dark:text-white transition-colors duration-300">
<div className="flex flex-col min-h-screen">
<main className="flex-grow">
<Home />
<Services />
<About />
<Departments />
<Contact />
</main>
<Footer />
2025-12-23 17:09:40 +03:00
</div>
2026-01-09 20:12:38 +03:00
</div>
2025-12-23 17:09:40 +03:00
);
2025-12-23 22:00:31 +03:00
};
2025-12-23 17:09:40 +03:00
2026-01-09 00:07:39 +03:00
function RouterView() {
const location = useLocation();
return (
<LayoutGroup>
2026-01-09 20:12:38 +03:00
<AnimatePresence mode="wait" initial={false}>
2026-01-09 00:07:39 +03:00
<Routes location={location} key={location.pathname}>
<Route path="/" element={<MainPage />} />
2026-01-09 20:12:38 +03:00
<Route path="/departments/:id" element={<DepartmentDetail />} />
<Route path="/department-detail2" element={<DepartmentDetail2 />} />
2026-01-09 00:07:39 +03:00
</Routes>
</AnimatePresence>
</LayoutGroup>
);
}
2026-01-09 20:12:38 +03:00
function Layout() {
const location = useLocation();
const excludedExactPaths = [
"/department-detail2",
];
const excludedPrefixes = ["/departments/"];
const isExcludedExact = excludedExactPaths.includes(location.pathname);
const isExcludedPrefix = excludedPrefixes.some((p) => location.pathname.startsWith(p));
const hideNavbar = isExcludedExact || isExcludedPrefix;
const navbarHeight = hideNavbar ? 0 : 56;
return (
<>
{!hideNavbar && <Navbar />}
<div style={{ paddingTop: navbarHeight }}>
<RouterView />
</div>
</>
);
}
2026-01-09 00:07:39 +03:00
const App = () => {
return (
<BrowserRouter>
2026-01-09 20:12:38 +03:00
<Layout />
2026-01-09 00:07:39 +03:00
</BrowserRouter>
);
};
export default App;