This commit is contained in:
2026-01-09 20:25:01 +03:00
parent eecb02b82a
commit eda8b512f5
2 changed files with 1 additions and 17 deletions

View File

@ -1,4 +1,3 @@
// src/App.jsx
import React from "react";
import { BrowserRouter, Routes, Route, useLocation } from "react-router-dom";
import { AnimatePresence, LayoutGroup } from "framer-motion";
@ -16,7 +15,6 @@ import Contact from "./Components/Sections/Contact/Contact";
import Footer from "./Components/Nav/Footer";
import DepartmentDetail2 from "./Components/Sections/DepartmentDetail2/DepartmentDetail2";
/* MainPage — الصفحة التي تحتوي على الأقسام المجمعة (لا تتضمن Navbar هنا) */
const MainPage = () => {
return (
<div className="min-h-screen bg-white dark:bg-gray-900 text-gray-900 dark:text-white transition-colors duration-300">
@ -34,7 +32,6 @@ const MainPage = () => {
);
};
/* Router view يستخدم useLocation مع AnimatePresence */
function RouterView() {
const location = useLocation();
@ -45,24 +42,19 @@ function RouterView() {
<Route path="/" element={<MainPage />} />
<Route path="/departments/:id" element={<DepartmentDetail />} />
<Route path="/department-detail2" element={<DepartmentDetail2 />} />
{/* أضف مسارات إضافية هنا إذا احتجت */}
</Routes>
</AnimatePresence>
</LayoutGroup>
);
}
/* Layout: يقرر متى يُعرض الـ Navbar بناءً على الـ pathname */
function Layout() {
const location = useLocation();
// هنا ضع المسارات أو الأنماط التي تريد إخفاء الـ Navbar فيها
const excludedExactPaths = [
"/department-detail2",
// أضف مسارات أخرى تريد إخفاء navbar فيها بنفس الشكل
];
// أمثلة على أنماط: إخفاء لكل ما يبدأ بـ /departments/
const excludedPrefixes = ["/departments/"];
const isExcludedExact = excludedExactPaths.includes(location.pathname);
@ -70,15 +62,12 @@ function Layout() {
const hideNavbar = isExcludedExact || isExcludedPrefix;
// ارتفاع الـ Navbar المستخدم كـ padding-top عندما يكون ظاهرًا (يتوافق مع height في Navbar.jsx)
const navbarHeight = hideNavbar ? 0 : 56;
return (
<>
{/* Navbar يظهر فقط عندما hideNavbar === false */}
{!hideNavbar && <Navbar />}
{/* نضع الـ RouterView داخل حاوية لها padding-top مساوٍ لارتفاع الـ navbar عند ظهوره */}
<div style={{ paddingTop: navbarHeight }}>
<RouterView />
</div>