diff --git a/.gitignore b/.gitignore index e81d7d1..1bb472b 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,5 @@ dist-ssr # Media files *.webp -*.mp4 \ No newline at end of file +*.mp4 +*.jpg \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f6090f9..b56ef02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "framer-motion": "^12.34.3", "gsap": "^3.14.2", "lenis": "^1.3.17", + "motion": "^12.35.0", "react": "^19.2.0", "react-dom": "^19.2.0", "react-router-dom": "^7.13.1", @@ -2752,12 +2753,12 @@ } }, "node_modules/framer-motion": { - "version": "12.34.3", - "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-12.34.3.tgz", - "integrity": "sha512-v81ecyZKYO/DfpTwHivqkxSUBzvceOpoI+wLfgCgoUIKxlFKEXdg0oR9imxwXumT4SFy8vRk9xzJ5l3/Du/55Q==", + "version": "12.35.0", + "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-12.35.0.tgz", + "integrity": "sha512-w8hghCMQ4oq10j6aZh3U2yeEQv5K69O/seDI/41PK4HtgkLrcBovUNc0ayBC3UyyU7V1mrY2yLzvYdWJX9pGZQ==", "license": "MIT", "dependencies": { - "motion-dom": "^12.34.3", + "motion-dom": "^12.35.0", "motion-utils": "^12.29.2", "tslib": "^2.4.0" }, @@ -3371,10 +3372,36 @@ "node": "*" } }, + "node_modules/motion": { + "version": "12.35.0", + "resolved": "https://registry.npmjs.org/motion/-/motion-12.35.0.tgz", + "integrity": "sha512-BQUhNUIGvUcwXCzwmnT1JpjUqab34lIwxHnXUyWRht1WC1vAyp7/4qgMiUXxN3K6hgUhyoR+HNnLeQMwUZjVjw==", + "license": "MIT", + "dependencies": { + "framer-motion": "^12.35.0", + "tslib": "^2.4.0" + }, + "peerDependencies": { + "@emotion/is-prop-valid": "*", + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@emotion/is-prop-valid": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, "node_modules/motion-dom": { - "version": "12.34.3", - "resolved": "https://registry.npmjs.org/motion-dom/-/motion-dom-12.34.3.tgz", - "integrity": "sha512-sYgFe+pR9aIM7o4fhs2aXtOI+oqlUd33N9Yoxcgo1Fv7M20sRkHtCmzE/VRNIcq7uNJ+qio+Xubt1FXH3pQ+eQ==", + "version": "12.35.0", + "resolved": "https://registry.npmjs.org/motion-dom/-/motion-dom-12.35.0.tgz", + "integrity": "sha512-FFMLEnIejK/zDABn+vqGVAUN4T0+3fw+cVAY8MMT65yR+j5uMuvWdd4npACWhh94OVWQs79CrBBuwOwGRZAQiA==", "license": "MIT", "dependencies": { "motion-utils": "^12.29.2" diff --git a/package.json b/package.json index fd8b0f0..361b542 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "framer-motion": "^12.34.3", "gsap": "^3.14.2", "lenis": "^1.3.17", + "motion": "^12.35.0", "react": "^19.2.0", "react-dom": "^19.2.0", "react-router-dom": "^7.13.1", diff --git a/src/App.tsx b/src/App.tsx index f4b1c88..2a50b06 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,10 +5,12 @@ import About from "./pages/About"; import Events from "./pages/Events"; import Historic from "./pages/Historic"; import Privacy from "./pages/Privacy"; +import ScrollToTop from "./components/ScrollToTop"; function App() { return ( + }> } /> diff --git a/src/components/ContUp.tsx b/src/components/ContUp.tsx new file mode 100644 index 0000000..ba62328 --- /dev/null +++ b/src/components/ContUp.tsx @@ -0,0 +1,130 @@ +import { useInView, useMotionValue, useSpring } from "motion/react"; +import { useCallback, useEffect, useRef } from "react"; + +interface CountUpProps { + to: number; + from?: number; + direction?: "up" | "down"; + delay?: number; + duration?: number; + className?: string; + startWhen?: boolean; + separator?: string; + onStart?: () => void; + onEnd?: () => void; +} + +export default function CountUp({ + to, + from = 0, + direction = "up", + delay = 0, + duration = 2, + className = "", + startWhen = true, + separator = "", + onStart, + onEnd, +}: CountUpProps) { + const ref = useRef(null); + const motionValue = useMotionValue(direction === "down" ? to : from); + + const damping = 20 + 40 * (1 / duration); + const stiffness = 100 * (1 / duration); + + const springValue = useSpring(motionValue, { + damping, + stiffness, + }); + + const isInView = useInView(ref, { once: true, margin: "0px" }); + + const getDecimalPlaces = (num: number): number => { + const str = num.toString(); + if (str.includes(".")) { + const decimals = str.split(".")[1]; + if (parseInt(decimals) !== 0) { + return decimals.length; + } + } + return 0; + }; + + const maxDecimals = Math.max(getDecimalPlaces(from), getDecimalPlaces(to)); + + const formatValue = useCallback( + (latest: number) => { + const hasDecimals = maxDecimals > 0; + + const options: Intl.NumberFormatOptions = { + useGrouping: !!separator, + minimumFractionDigits: hasDecimals ? maxDecimals : 0, + maximumFractionDigits: hasDecimals ? maxDecimals : 0, + }; + + const formattedNumber = Intl.NumberFormat("en-US", options).format( + latest, + ); + + return separator + ? formattedNumber.replace(/,/g, separator) + : formattedNumber; + }, + [maxDecimals, separator], + ); + + useEffect(() => { + if (ref.current) { + ref.current.textContent = formatValue(direction === "down" ? to : from); + } + }, [from, to, direction, formatValue]); + + useEffect(() => { + if (isInView && startWhen) { + if (typeof onStart === "function") { + onStart(); + } + + const timeoutId = setTimeout(() => { + motionValue.set(direction === "down" ? from : to); + }, delay * 1000); + + const durationTimeoutId = setTimeout( + () => { + if (typeof onEnd === "function") { + onEnd(); + } + }, + delay * 1000 + duration * 1000, + ); + + return () => { + clearTimeout(timeoutId); + clearTimeout(durationTimeoutId); + }; + } + }, [ + isInView, + startWhen, + motionValue, + direction, + from, + to, + delay, + onStart, + onEnd, + duration, + ]); + + useEffect(() => { + const unsubscribe = springValue.on("change", (latest: number) => { + if (ref.current) { + ref.current.textContent = formatValue(latest); + } + }); + + return () => unsubscribe(); + }, [springValue, formatValue]); + + return ; +} diff --git a/src/components/FacebookCarousel.tsx b/src/components/FacebookCarousel.tsx index 7001c5f..7467dde 100644 --- a/src/components/FacebookCarousel.tsx +++ b/src/components/FacebookCarousel.tsx @@ -36,6 +36,30 @@ const mockPosts: FacebookPost[] = [ imageSrc: "/historique/dernier-evenement.webp", link: "https://www.facebook.com", }, + { + id: 4, + date: "Il y a 3 semaines", + content: + "Réunion très productive avec la mairie pour préparer l'année à venir. De beaux projets en perspective ! 🏛️🤝", + imageSrc: "/historique/signature-statuts.webp", + link: "https://www.facebook.com", + }, + { + id: 5, + date: "Il y a 1 mois", + content: + "Collecte de vêtements chauds terminée. Merci à tous les donateurs, le camion part demain ! 🚛❄️", + imageSrc: "/historique/arrivee.webp", + link: "https://www.facebook.com", + }, + { + id: 6, + date: "Il y a 1 mois", + content: + "Petit souvenir de notre stand au forum des associations. On a hâte de vous retrouver ! 👋", + imageSrc: "/hero-section/a-propos.webp", + link: "https://www.facebook.com", + }, ]; export default function FacebookCarousel() { diff --git a/src/components/ScrollToTop.tsx b/src/components/ScrollToTop.tsx new file mode 100644 index 0000000..837adee --- /dev/null +++ b/src/components/ScrollToTop.tsx @@ -0,0 +1,15 @@ +// c:\Users\thwei\source\Applications\CoeurUAPam\src\components\ScrollToTop.tsx +import { useEffect } from "react"; +import { useLocation } from "react-router-dom"; + +const ScrollToTop = () => { + const { pathname } = useLocation(); + + useEffect(() => { + window.scrollTo(0, 0); + }, [pathname]); + + return null; +}; + +export default ScrollToTop; diff --git a/src/main.tsx b/src/main.tsx index bef5202..abf3265 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,10 +1,11 @@ -import { StrictMode } from 'react' -import { createRoot } from 'react-dom/client' -import './index.css' -import App from './App.tsx' +import { StrictMode } from "react"; +import { createRoot } from "react-dom/client"; -createRoot(document.getElementById('root')!).render( +import "./index.css"; +import App from "./App.tsx"; + +createRoot(document.getElementById("root")!).render( , -) +); diff --git a/src/pages/Events.tsx b/src/pages/Events.tsx index cc31580..f4731bf 100644 --- a/src/pages/Events.tsx +++ b/src/pages/Events.tsx @@ -492,121 +492,128 @@ export default function Events() { }, ], }, - // // --------------------------------------------------------- - // // 3. MARCHÉ DE NOËL + // // 3. COMMÉMORATIONS // // --------------------------------------------------------- - // { - // id: "marche-noel", - // title: "Marchés de Noël", - // description: - // "Retrouvez-nous sur nos stands lors des marchés de Noël locaux pour découvrir l'artisanat ukrainien, parfait pour des cadeaux originaux et solidaires.", - // themeColor: "text-[#dfbe85]", - // history: [ - // { - // type: "intro", - // year: "2022", - // title: "Premier marché", - // bg: "bg-white", - // text: "text-[#1a247f]", - // }, - // { - // type: "image", - // src: "/evenements/marche-noel-2022-1.webp", - // alt: "Installation du stand", - // }, + { + id: "commemorations", + title: "Anniversaire du conflit", + description: + "Le devoir de mémoire est essentiel. Nous nous rassemblons pour honorer les victimes du conflit et rappeler notre soutien indéfectible à l'Ukraine.", + themeColor: "text-gray-800", + history: [ + { + type: "intro", + year: "2023", + title: "", + bg: "bg-gray-800", + text: "text-white", + }, + { + type: "image", + src: "/evenements/commemoration/2023commemoration-1.mp4", + alt: "Commemoration début du conflit - 2023", + }, + { + type: "intro", + year: "2024", + title: "2 ans de résilience", + bg: "bg-gray-200", + text: "text-gray-900", + }, + { + type: "image", + src: "/evenements/commemoration/2024commemoration-1.webp", + alt: "Rassemblement sur la place", + }, + { + type: "intro", + year: "2025", + title: "", + bg: "bg-gray-800", + text: "text-white", + }, + { + type: "image", + src: "/evenements/commemoration/2025commemoration-1.webp", + alt: "Commemoration début du conflit - 2025", + }, + { + type: "image", + src: "/evenements/commemoration/2025commemoration-4.webp", + alt: "Commemoration début du conflit - 2025", + }, - // { - // type: "intro", - // year: "2023", - // title: "Nos bénévoles mobilisés", - // bg: "bg-[#dfbe85]", - // text: "text-white", - // }, - // { - // type: "image", - // src: "/evenements/marche-noel-2023-1.webp", - // alt: "Bénévoles au stand", - // }, + { + type: "image", + src: "/evenements/commemoration/2025commemoration-3.webp", + alt: "Commemoration début du conflit - 2025", + }, + { + type: "image", + src: "/evenements/commemoration/2025commemoration-2.webp", + alt: "Commemoration début du conflit - 2025", + }, - // { - // type: "intro", - // year: "2024", - // title: "Succès solidaire", - // bg: "bg-[#1a247f]", - // text: "text-white", - // }, - // { - // type: "image", - // src: "/evenements/marche-noel-2024-1.webp", - // alt: "Créations faites main", - // }, - - // { - // type: "intro", - // year: "2025", - // title: "L'artisanat à l'honneur", - // bg: "bg-[#dfbe85]", - // text: "text-white", - // }, - // { - // type: "image", - // src: "/evenements/marche-noel-2025-1.webp", - // alt: "Stand 2025", - // }, - // ], - // }, + { + type: "intro", + year: "2026", + title: "", + bg: "bg-gray-800", + text: "text-white", + }, + { + type: "image", + src: "/evenements/commemoration/2026commemoration-1.webp", + alt: "Commemoration début du conflit - 2026", + }, + { + type: "image", + src: "/evenements/commemoration/2026commemoration-1.webp", + alt: "Commemoration début du conflit - 2026", + }, + { + type: "image", + src: "/evenements/commemoration/2026commemoration-3.webp", + alt: "Commemoration début du conflit - 2026", + }, + { + type: "image", + src: "/evenements/commemoration/2026commemoration-4.webp", + alt: "Commemoration début du conflit - 2026", + }, + { + type: "image", + src: "/evenements/commemoration/2026commemoration-2.webp", + alt: "Commemoration début du conflit - 2026", + }, + ], + }, // // --------------------------------------------------------- - // // 4. COMMÉMORATIONS + // // 4. MARCHÉ DE NOËL // // --------------------------------------------------------- - // { - // id: "commemorations", - // title: "Commémorations", - // description: - // "Le devoir de mémoire est essentiel. Nous nous rassemblons pour honorer les victimes du conflit et rappeler notre soutien indéfectible à l'Ukraine.", - // themeColor: "text-gray-800", - // history: [ - // { - // type: "intro", - // year: "2023", - // title: "1 an de conflit", - // bg: "bg-gray-800", - // text: "text-white", - // }, - // { - // type: "image", - // src: "/evenements/commemoration-2023-1.webp", - // alt: "Minute de silence", - // }, - - // { - // type: "intro", - // year: "2024", - // title: "2 ans de résilience", - // bg: "bg-gray-200", - // text: "text-gray-900", - // }, - // { - // type: "image", - // src: "/evenements/commemoration-2024-1.webp", - // alt: "Rassemblement sur la place", - // }, - - // { - // type: "intro", - // year: "2025", - // title: "Ne jamais oublier", - // bg: "bg-gray-800", - // text: "text-white", - // }, - // { - // type: "image", - // src: "/evenements/commemoration-2025-1.webp", - // alt: "Commémoration 2025", - // }, - // ], - // }, + { + id: "marche-noel", + title: "Marchés de Noël", + description: + "Retrouvez-nous sur nos stands lors des marchés de Noël locaux pour découvrir l'artisanat ukrainien, parfait pour des cadeaux originaux et solidaires.", + themeColor: "text-[#dfbe85]", + history: [ + { + type: "intro", + year: "2025", + title: "Premier marché de Noël", + bg: "bg-white", + text: "text-[#1a247f]", + }, + { + type: "image", + src: "/evenements/marche-noel/2025marche-noel-1.webp", + alt: "Premier marché de Noël de Coeur-UA-PAM en 2025", + }, + ], + }, // // --------------------------------------------------------- // // 5. AUTRES ÉVÉNEMENTS diff --git a/src/pages/Historic.tsx b/src/pages/Historic.tsx index 0edcffd..42d4400 100644 --- a/src/pages/Historic.tsx +++ b/src/pages/Historic.tsx @@ -1,7 +1,7 @@ import { useState } from "react"; import AnimatedContent from "../components/AnimatedContent"; import Stepper, { Step } from "../components/Stepper"; -// import FacebookCarousel from "../components/FacebookCarousel"; +import FacebookCarousel from "../components/FacebookCarousel"; const StepWithBackground = ({ date, diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 694c177..6c06db5 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -1,5 +1,6 @@ import { Link } from "react-router-dom"; import AnimatedContent from "../components/AnimatedContent"; +import CountUp from "../components/ContUp"; const Home = () => { return ( @@ -53,7 +54,7 @@ const Home = () => { delay={0.2} className="h-full" > - +
@@ -136,17 +137,29 @@ const Home = () => {
- - 50+ - + Bénévoles Actifs
- - 100s - + Colis Envoyés