diff --git a/src/App.jsx b/src/App.jsx index 4f363b5..13faf51 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,4 +1,94 @@ -import React from "react"; +// import React from "react"; +// import { BrowserRouter, Routes, Route, useLocation } from "react-router-dom"; +// import { AnimatePresence, LayoutGroup } from "framer-motion"; + +// import "./i18n"; +// import "./App.css"; + +// 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"; +// import Departments from "./Components/Sections/Departments/Departments"; +// import DepartmentDetail from "./Components/Sections/DepartmentDetail/DepartmentDetail"; +// import Contact from "./Components/Sections/Contact/Contact"; +// import Footer from "./Components/Nav/Footer"; +// import DepartmentDetail2 from "./Components/Sections/DepartmentDetail2/DepartmentDetail2"; + +// const MainPage = () => { +// return ( +//
+//
+//
+// +// +// +// +// +//
+//
+//
+// ); +// }; + +// function RouterView() { +// const location = useLocation(); + +// return ( +// +// +// +// } /> +// } /> +// } /> +// +// +// +// ); +// } + +// 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 && } + +//
+// +//
+// +// ); +// } + +// const App = () => { +// return ( +// +// +// +// ); +// }; + +// export default App; + + + + +import React, { useState, useEffect } from "react"; import { BrowserRouter, Routes, Route, useLocation } from "react-router-dom"; import { AnimatePresence, LayoutGroup } from "framer-motion"; @@ -14,32 +104,45 @@ import DepartmentDetail from "./Components/Sections/DepartmentDetail/DepartmentD import Contact from "./Components/Sections/Contact/Contact"; import Footer from "./Components/Nav/Footer"; import DepartmentDetail2 from "./Components/Sections/DepartmentDetail2/DepartmentDetail2"; +import ImagePreloader from "./Components/ImagePreloader"; +import BackgroundCanvas from "./Components/BackgroundCanvas/BackgroundCanvas"; -const MainPage = () => { +// المكون الرئيسي الذي يظهر في الصفحة الرئيسية +const MainPage = ({ theme }) => { return ( -
+
- +
-
); }; -function RouterView() { +// مكون الراوتر الداخلي +function RouterView({ theme, toggleTheme }) { const location = useLocation(); return ( - } /> + + +
+ +
+
+ } + /> } /> } /> @@ -48,7 +151,8 @@ function RouterView() { ); } -function Layout() { +// المكون الذي يتحكم في التخطيط +function Layout({ theme, toggleTheme }) { const location = useLocation(); const excludedExactPaths = [ @@ -66,21 +170,71 @@ function Layout() { return ( <> - {!hideNavbar && } + {!hideNavbar && }
- + + + {/* إظهار Footer فقط في الصفحة الرئيسية */} + {location.pathname === "/" &&
}
); } +// المكون الرئيسي للتطبيق const App = () => { + const [theme, setTheme] = useState("light"); + + useEffect(() => { + // تتبع الثيم لأغراض التصحيح + console.log("Current theme:", theme); + console.log("HTML has dark class:", document.documentElement.classList.contains('dark')); + + const canvas = document.querySelector('.background-canvas'); + if (canvas) { + console.log("Canvas found:", canvas); + console.log("Canvas dimensions:", canvas.width, "x", canvas.height); + } else { + console.log("Canvas NOT found!"); + } + }, [theme]); + + // تهيئة الثيم من localStorage + useEffect(() => { + const savedTheme = localStorage.getItem("theme"); + const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches; + + if (savedTheme === "dark" || (!savedTheme && prefersDark)) { + setTheme("dark"); + document.documentElement.classList.add("dark"); + } else { + document.documentElement.classList.remove("dark"); + setTheme("light"); + } + }, []); + + // دالة تبديل الثيم + const toggleTheme = () => { + const newTheme = theme === "light" ? "dark" : "light"; + setTheme(newTheme); + + if (newTheme === "dark") { + document.documentElement.classList.add("dark"); + } else { + document.documentElement.classList.remove("dark"); + } + + localStorage.setItem("theme", newTheme); + }; + return ( - - - + + + + + ); }; -export default App; +export default App; \ No newline at end of file diff --git a/src/Components/ImagePreloader.jsx b/src/Components/ImagePreloader.jsx index 7b6e0e8..2c6aadb 100644 --- a/src/Components/ImagePreloader.jsx +++ b/src/Components/ImagePreloader.jsx @@ -1,22 +1,22 @@ -// import { useState, useEffect } from "react"; +import { useState, useEffect } from "react"; -// // Import all images statically -// // import home1 from "../assets/home1.jpg"; -// // import home1Mobile from "../assets/home1-2.jpg"; -// // import home2 from "../assets/home2.jpg"; -// // import home2Mobile from "../assets/home2-2.jpg"; -// // import home3 from "../assets/home3.png"; -// // import home4 from "../assets/home4.png"; -// // // import home4Mobile from "../assets/home4-2.jpg"; -// // import home5 from "../assets/home5.png"; -// // import home6 from "../assets/home6.jpg"; -// // import home6Mobile from "../assets/home6-2.jpg"; -// // import home7 from "../assets/home7.jpg"; -// // import home7Mobile from "../assets/home7-2.jpg"; -// // import home8 from "../assets/home8.jpg"; -// // import home8Mobile from "../assets/home8-2.jpg"; -// // import home9 from "../assets/home9.jpg"; -// // import home10 from "../assets/home10.jpg"; +// Import all images statically +// import home1 from "../assets/home1.jpg"; +// import home1Mobile from "../assets/home1-2.jpg"; +// import home2 from "../assets/home2.jpg"; +// import home2Mobile from "../assets/home2-2.jpg"; +// import home3 from "../assets/home3.png"; +// import home4 from "../assets/home4.png"; +// // import home4Mobile from "../assets/home4-2.jpg"; +// import home5 from "../assets/home5.png"; +// import home6 from "../assets/home6.jpg"; +// import home6Mobile from "../assets/home6-2.jpg"; +// import home7 from "../assets/home7.jpg"; +// import home7Mobile from "../assets/home7-2.jpg"; +// import home8 from "../assets/home8.jpg"; +// import home8Mobile from "../assets/home8-2.jpg"; +// import home9 from "../assets/home9.jpg"; +// import home10 from "../assets/home10.jpg"; // Services images // import gasStation from "../assets/Images/gasstation.jpg"; @@ -44,293 +44,293 @@ const imagesToPreload = [ // Services images // gasStation, -// ]; +]; -// const ImagePreloader = ({ children }) => { -// const [imagesLoaded, setImagesLoaded] = useState(false); -// const [progress, setProgress] = useState(0); +const ImagePreloader = ({ children }) => { + const [imagesLoaded, setImagesLoaded] = useState(false); + const [progress, setProgress] = useState(0); -// useEffect(() => { -// let loadedCount = 0; -// const totalImages = imagesToPreload.length; + useEffect(() => { + let loadedCount = 0; + const totalImages = imagesToPreload.length; -// const preloadImages = async () => { -// try { -// const loadImage = (src) => { -// return new Promise((resolve, reject) => { -// const img = new Image(); -// img.src = src; -// img.onload = () => { -// loadedCount++; -// setProgress(Math.floor((loadedCount / totalImages) * 100)); -// resolve(); -// }; -// img.onerror = reject; -// }); -// }; + const preloadImages = async () => { + try { + const loadImage = (src) => { + return new Promise((resolve, reject) => { + const img = new Image(); + img.src = src; + img.onload = () => { + loadedCount++; + setProgress(Math.floor((loadedCount / totalImages) * 100)); + resolve(); + }; + img.onerror = reject; + }); + }; -// await Promise.all(imagesToPreload.map(loadImage)); -// setImagesLoaded(true); -// } catch (error) { -// console.error("Failed to preload images:", error); -// // Continue anyway after a timeout -// setTimeout(() => setImagesLoaded(true), 3000); -// } -// }; + await Promise.all(imagesToPreload.map(loadImage)); + setImagesLoaded(true); + } catch (error) { + console.error("Failed to preload images:", error); + // Continue anyway after a timeout + setTimeout(() => setImagesLoaded(true), 3000); + } + }; -// preloadImages(); -// }, []); + preloadImages(); + }, []); -// if (!imagesLoaded) { -// return ( -//
-// {/* Animated background effect */} -//
-//
-// {[...Array(20)].map((_, i) => ( -//
-// ))} -//
-//
+ if (!imagesLoaded) { + return ( +
+ {/* Animated background effect */} +
+
+ {[...Array(20)].map((_, i) => ( +
+ ))} +
+
-// {/* Company logo or branding could go here */} -//
-// TPS -//
+ {/* Company logo or branding could go here */} +
+ TPS +
-// {/* 3D-style Fuel Tank */} -//
-// {/* Tank body with 3D effect */} -//
-// {/* Glass effect overlay */} -//
+ {/* 3D-style Fuel Tank */} +
+ {/* Tank body with 3D effect */} +
+ {/* Glass effect overlay */} +
-// {/* Tank Cap with metallic effect */} -//
-//
-//
+ {/* Tank Cap with metallic effect */} +
+
+
-// {/* Fuel Level with dynamic wave effect */} -//
-// {/* Animated wave effect at the top of fuel */} -//
-//
-//
+ {/* Fuel Level with dynamic wave effect */} +
+ {/* Animated wave effect at the top of fuel */} +
+
+
-// {/* Bubbles with varied animations */} -// {[...Array(8)].map((_, i) => ( -//
-// ))} -//
+ {/* Bubbles with varied animations */} + {[...Array(8)].map((_, i) => ( +
+ ))} +
-// {/* Tank level markings with glow effect */} -//
-// {[...Array(4)].map((_, i) => ( -//
75 - i * 25 -// ? "0 1px 3px rgba(243,198,35,0.3)" -// : "none", -// }} -// > -//
-//
-// ))} -//
-//
+ {/* Tank level markings with glow effect */} +
+ {[...Array(4)].map((_, i) => ( +
75 - i * 25 + ? "0 1px 3px rgba(243,198,35,0.3)" + : "none", + }} + > +
+
+ ))} +
+
-// {/* Fuel Gauge with realistic dial */} -//
-// {/* Gauge markings */} -// {[...Array(9)].map((_, i) => { -// const rotation = -135 + i * 30; -// const isLarge = i % 2 === 0; -// return ( -//
-// ); -// })} + {/* Fuel Gauge with realistic dial */} +
+ {/* Gauge markings */} + {[...Array(9)].map((_, i) => { + const rotation = -135 + i * 30; + const isLarge = i % 2 === 0; + return ( +
+ ); + })} -// {/* Gauge needle with smooth animation */} -//
-//
-//
+ {/* Gauge needle with smooth animation */} +
+
+
-// {/* Center pin */} -//
+ {/* Center pin */} +
-// {/* E and F indicators */} -//
-// E -//
-//
-// F -//
-//
-//
+ {/* E and F indicators */} +
+ E +
+
+ F +
+
+
-// {/* Progress indicator with animated glow */} -//
-//

-// {progress}% -//

-//
-//
+ {/* Progress indicator with animated glow */} +
+

+ {progress}% +

+
+
-//

-// Filling your tank... -//

+

+ Filling your tank... +

-// {/* Advanced animations */} -// {/* */} -//
-// ); -// } + .animate-wave { + overflow: hidden; + } + `} */} +
+ ); + } -// return <>{children}; -// }; + return <>{children}; +}; -// export default ImagePreloader; +export default ImagePreloader; diff --git a/src/Components/Nav/Navbar.jsx b/src/Components/Nav/Navbar.jsx index f7bc70c..2731245 100644 --- a/src/Components/Nav/Navbar.jsx +++ b/src/Components/Nav/Navbar.jsx @@ -1,7 +1,697 @@ +// import React, { useState, useEffect } from "react"; +// import styled from "styled-components"; +// import { useTranslation } from "react-i18next"; +// import { Link, animateScroll as scroll } from "react-scroll"; + +// const SunIcon = ({ className }) => ( +// +// +// +// +// +// +// +// +// +// ); +// const MoonIcon = ({ className }) => ( +// +// +// +// ); +// const GlobeIcon = ({ className }) => ( +// +// +// +// +// +// ); + +// const StyledWrapper = styled.div` +// /* Base Styles */ +// .switch { +// display: inline-block; +// /* reduced a bit */ +// width: 5.2em; +// height: 2.6em; +// position: relative; +// font-size: 16px; +// user-select: none; +// margin: 0; +// transform-origin: center; +// } + +// /* Hide default HTML checkbox */ +// .switch input { +// opacity: 0; +// width: 0; +// height: 0; +// position: absolute; +// } + +// /* Slider */ +// .slider { +// position: absolute; +// cursor: pointer; +// top: 0; +// left: 0; +// right: 0; +// bottom: 0; +// background: linear-gradient(to right, #87ceeb, #e0f6ff); +// border-radius: 50px; +// transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55); +// box-shadow: +// 0 4px 8px rgba(0, 0, 0, 0.1), +// inset 0 -5px 10px rgba(0, 0, 0, 0.1); +// overflow: hidden; +// } + +// /* Inner slider for additional styling */ +// .slider-inner { +// position: absolute; +// top: 0.28em; +// left: 0.28em; +// height: 2.1em; +// width: 2.1em; +// border-radius: 50%; +// background-color: #ffd700; +// transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55); +// box-shadow: +// 0 2px 4px rgba(0, 0, 0, 0.2), +// inset 0 -2px 5px rgba(0, 0, 0, 0.2); +// } + +// /* Checked state */ +// .switch input:checked + .slider { +// background: linear-gradient(to right, #1a237e, #3949ab); +// } + +// .switch input:checked + .slider .slider-inner { +// transform: translateX(2.6em); +// background-color: #ffffff; +// } + +// /* Focus state */ +// .switch input:focus + .slider { +// outline: none; +// box-shadow: 0 0 0.4em rgba(25, 118, 210, 0.5); +// } + +// /* Hover and active states */ +// .switch:hover .slider { +// background: linear-gradient(to right, #64b5f6, #e3f2fd); +// } + +// .switch input:checked:hover + .slider { +// background: linear-gradient(to right, #283593, #5c6bc0); +// } + +// /* Animation for slider inner */ +// @keyframes sunPulse { +// 0%, +// 100% { +// box-shadow: +// 0 0 0 0 rgba(255, 215, 0, 0.7), +// 0 0 0 0 rgba(255, 215, 0, 0.4); +// } +// 50% { +// box-shadow: +// 0 0 20px 10px rgba(255, 215, 0, 0.7), +// 0 0 40px 20px rgba(255, 215, 0, 0.4); +// } +// } + +// @keyframes moonPhase { +// 0%, +// 100% { +// box-shadow: +// inset -10px -5px 0 0 #ddd, +// 0 0 20px rgba(255, 255, 255, 0.5); +// } +// 50% { +// box-shadow: +// inset 0 0 0 0 #ddd, +// 0 0 20px rgba(255, 255, 255, 0.5); +// } +// } + +// .switch input:not(:checked) + .slider .slider-inner { +// animation: sunPulse 3s infinite; +// } + +// .switch input:checked + .slider .slider-inner { +// animation: moonPhase 5s infinite; +// } + +// /* Stars effect */ +// @keyframes twinkle { +// 0%, +// 100% { +// opacity: 0.2; +// } +// 50% { +// opacity: 1; +// } +// } + +// .slider::before, +// .slider::after { +// content: ""; +// position: absolute; +// width: 4px; +// height: 4px; +// background-color: #ffffff; +// border-radius: 50%; +// transition: all 0.6s ease; +// opacity: 0; +// } + +// .slider::before { +// top: 20%; +// left: 30%; +// } + +// .slider::after { +// bottom: 25%; +// right: 25%; +// } + +// .switch input:checked + .slider::before, +// .switch input:checked + .slider::after { +// opacity: 1; +// animation: twinkle 2s infinite; +// } + +// .switch input:checked + .slider::before { +// animation-delay: 0.5s; +// } + +// /* 3D effect */ +// .slider { +// transform-style: preserve-3d; +// perspective: 500px; +// } + +// .slider-inner { +// transform: translateZ(5px); +// } + +// .switch input:checked + .slider .slider-inner { +// transform: translateX(2.6em) translateZ(5px) rotateY(180deg); +// } + +// /* Cloud effect for day mode */ +// .slider-inner::before, +// .slider-inner::after { +// content: ""; +// position: absolute; +// background-color: rgba(255, 255, 255, 0.8); +// border-radius: 50%; +// transition: all 0.6s ease; +// } + +// .slider-inner::before { +// width: 1em; +// height: 1em; +// top: -0.5em; +// left: -0.2em; +// } + +// .slider-inner::after { +// width: 1.2em; +// height: 1.2em; +// bottom: -0.6em; +// right: -0.3em; +// } + +// .switch input:checked + .slider .slider-inner::before, +// .switch input:checked + .slider .slider-inner::after { +// opacity: 0; +// } + +// /* Crater effect for night mode */ +// .switch input:checked + .slider .slider-inner::before { +// width: 0.6em; +// height: 0.6em; +// background-color: rgba(0, 0, 0, 0.2); +// top: 0.3em; +// left: 0.3em; +// opacity: 1; +// } + +// .switch input:checked + .slider .slider-inner::after { +// width: 0.4em; +// height: 0.4em; +// background-color: rgba(0, 0, 0, 0.15); +// bottom: 0.5em; +// right: 0.5em; +// opacity: 1; +// } + +// /* Accessibility improvements */ +// .switch input:focus + .slider { +// outline: 2px solid #4a90e2; +// outline-offset: 2px; +// } + +// /* Responsive adjustments */ +// @media (max-width: 768px) { +// .switch { +// width: 4.6em; +// height: 2.3em; +// } + +// .slider-inner { +// height: 1.85em; +// width: 1.85em; +// top: 0.23em; +// left: 0.23em; +// } + +// .switch input:checked + .slider .slider-inner { +// transform: translateX(2.2em) translateZ(5px) rotateY(180deg); +// } +// } + +// @media (max-width: 480px) { +// .switch { +// width: 3.8em; +// height: 1.9em; +// } + +// .slider-inner { +// height: 1.5em; +// width: 1.5em; +// top: 0.2em; +// left: 0.2em; +// } + +// .switch input:checked + .slider .slider-inner { +// transform: translateX(1.8em) translateZ(5px) rotateY(180deg); +// } +// } + +// /* High contrast mode */ +// @media (forced-colors: active) { +// .slider { +// background: Canvas; +// border: 2px solid ButtonText; +// } + +// .switch input:checked + .slider { +// background: Highlight; +// } + +// .slider-inner { +// background-color: ButtonFace; +// } + +// .switch::before, +// .switch::after { +// color: ButtonText; +// } +// } + +// /* Reduced motion preference */ +// @media (prefers-reduced-motion: reduce) { +// .switch, +// .slider, +// .slider-inner { +// transition: none; +// } + +// .switch input:checked + .slider .slider-inner, +// .switch input:not(:checked) + .slider .slider-inner, +// .switch input:checked + .slider::before, +// .switch input:checked + .slider::after { +// animation: none; +// } +// } +// `; + +// const ThemeToggle = ({ theme, setTheme }) => { +// const isDark = theme === "dark"; + +// const toggle = () => { +// const next = isDark ? "light" : "dark"; +// setTheme(next); +// if (next === "dark") document.documentElement.classList.add("dark"); +// else document.documentElement.classList.remove("dark"); +// try { +// localStorage.setItem("theme", next); +// } catch (e) {} +// }; + +// return ( +// +// +// +// ); +// }; + +// const LanguageToggle = ({ i18n }) => { +// const isAr = i18n.language === "ar"; +// const toggle = () => { +// const next = isAr ? "en" : "ar"; +// i18n.changeLanguage(next); +// if (next === "ar") { +// document.documentElement.dir = "rtl"; +// document.documentElement.lang = "ar"; +// } else { +// document.documentElement.dir = "ltr"; +// document.documentElement.lang = next; +// } +// }; + +// return ( +// +// ); +// }; + +// const Navbar = () => { +// const { t, i18n } = useTranslation(); +// const [menuOpen, setMenuOpen] = useState(false); +// const [activeSection, setActiveSection] = useState("home"); +// const [theme, setTheme] = useState("light"); + +// useEffect(() => { +// try { +// const saved = localStorage.getItem("theme"); +// if (saved) setTheme(saved); +// else if (typeof window !== "undefined" && document.documentElement.classList.contains("dark")) setTheme("dark"); +// } catch (e) { +// if (typeof window !== "undefined" && document.documentElement.classList.contains("dark")) setTheme("dark"); +// } +// }, []); + +// useEffect(() => { +// if (theme === "dark") document.documentElement.classList.add("dark"); +// else document.documentElement.classList.remove("dark"); +// }, [theme]); + +// useEffect(() => { +// const handleScroll = () => { +// const sections = ["home", "services", "about", "contact"]; +// const scrollPosition = window.scrollY + 140; +// for (const section of sections) { +// const element = document.getElementById(section) || document.querySelector(`[name="${section}"]`); +// if (element) { +// const offsetTop = element.offsetTop; +// const offsetHeight = element.offsetHeight; +// if (scrollPosition >= offsetTop && scrollPosition < offsetTop + offsetHeight) { +// setActiveSection(section); +// break; +// } +// } +// } +// }; +// handleScroll(); +// window.addEventListener("scroll", handleScroll, { passive: true }); +// return () => window.removeEventListener("scroll", handleScroll); +// }, []); + +// const navItems = [ +// { key: "home", label: t("nav.home") || "Home" }, +// { key: "services", label: t("nav.services") || "Services" }, +// { key: "about", label: t("nav.about") || "About" }, +// { key: "contact", label: t("nav.contact") || "Contact" }, +// ]; + +// return ( +// <> +// + +// +// +// ); +// }; + +// export default Navbar; + + import React, { useState, useEffect } from "react"; import styled from "styled-components"; import { useTranslation } from "react-i18next"; import { Link, animateScroll as scroll } from "react-scroll"; +import LanguageSwitcher from "../LanguageSwitcher/LanguageSwitcher"; const SunIcon = ({ className }) => ( @@ -19,19 +709,11 @@ const MoonIcon = ({ className }) => ( ); -const GlobeIcon = ({ className }) => ( - - - - - -); const StyledWrapper = styled.div` /* Base Styles */ .switch { display: inline-block; - /* reduced a bit */ width: 5.2em; height: 2.6em; position: relative; @@ -329,18 +1011,8 @@ const StyledWrapper = styled.div` } `; -const ThemeToggle = ({ theme, setTheme }) => { - const isDark = theme === "dark"; - - const toggle = () => { - const next = isDark ? "light" : "dark"; - setTheme(next); - if (next === "dark") document.documentElement.classList.add("dark"); - else document.documentElement.classList.remove("dark"); - try { - localStorage.setItem("theme", next); - } catch (e) {} - }; +const ThemeToggle = ({ currentTheme, toggleTheme }) => { + const isDark = currentTheme === "dark"; return ( @@ -352,14 +1024,14 @@ const ThemeToggle = ({ theme, setTheme }) => { onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); - toggle(); + toggleTheme(); } }} >