From b77d622a03db98bdf2b8b747501705add85613cd Mon Sep 17 00:00:00 2001 From: Antoine M Date: Thu, 9 Jan 2025 12:09:05 +0100 Subject: [PATCH] migrating from lottie-react to react-lottie --- src/assets/css/components/ui/Loading.scss | 14 +++++--- src/components/animations/Clouds.jsx | 20 ++++++----- src/components/animations/Loading.jsx | 17 ++++++++-- src/components/animations/test.jsx | 13 -------- src/components/results/ResultsModals.jsx | 39 ++++++++++++++-------- src/components/tutorials/MoveAround.jsx | 17 ++++++---- src/components/tutorials/PointsAndTime.jsx | 17 ++++++---- src/components/tutorials/Walkthrough.jsx | 18 +++++----- src/pages/About.jsx | 1 - src/pages/Welcome.jsx | 16 +++++++-- 10 files changed, 106 insertions(+), 66 deletions(-) delete mode 100644 src/components/animations/test.jsx diff --git a/src/assets/css/components/ui/Loading.scss b/src/assets/css/components/ui/Loading.scss index bfca3e2..da30b0b 100644 --- a/src/assets/css/components/ui/Loading.scss +++ b/src/assets/css/components/ui/Loading.scss @@ -3,18 +3,24 @@ width: 100vw; height: 100vh; position: fixed; + display: flex; + flex-direction: column; + justify-content: center; + top: 0; + // justify-content: center; + // align-items: center; &__animation { - max-width: 100vh; - max-height: 100vw; - margin: auto; + max-width: 50vh; + max-height: 50vw; + margin: 0 auto; -webkit-transform: scaleX(-1); transform: scaleX(-1); animation: translate 2s infinite linear; } &__text { - @apply text-7xl tracking-wider text-zuume text-white text-center; + @apply text-7xl tracking-wider text-zuume text-white text-center pt-8; transform: translate(0, -50px); } } diff --git a/src/components/animations/Clouds.jsx b/src/components/animations/Clouds.jsx index 5547f7f..051fa26 100644 --- a/src/components/animations/Clouds.jsx +++ b/src/components/animations/Clouds.jsx @@ -1,16 +1,20 @@ import React from "react"; import cloudPageTransition from "../../assets/animations/transition-nuages-pages"; -import Lottie from "lottie-react"; +import Lottie from "react-lottie"; export default function Clouds() { + const defaultOptions = { + loop: true, + autoplay: true, + animationData: cloudPageTransition, + rendererSettings: { + preserveAspectRatio: "xMidYMid slice", + }, + }; return ( - +
+ +
); } diff --git a/src/components/animations/Loading.jsx b/src/components/animations/Loading.jsx index ce846d3..0939108 100644 --- a/src/components/animations/Loading.jsx +++ b/src/components/animations/Loading.jsx @@ -1,7 +1,7 @@ import React from "react"; -import Lottie from "lottie-react"; - +import Lottie from "react-lottie"; import loadingTruck from "../../assets/animations/chargement-vehicules-boom.json"; + import { useUser } from "../../hooks/useUser"; export default function Loading() { @@ -9,9 +9,20 @@ export default function Loading() { if (!screensTranslations || !screensTranslations?.ui?.loading) return; + const defaultOptions = { + loop: true, + autoplay: true, + animationData: loadingTruck, + rendererSettings: { + preserveAspectRatio: "xMidYMid slice", + }, + }; + return (
- +
+ +

{screensTranslations.ui.loading}...

); diff --git a/src/components/animations/test.jsx b/src/components/animations/test.jsx deleted file mode 100644 index f59c361..0000000 --- a/src/components/animations/test.jsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from "react"; -import Lottie from "lottie-react"; - -import animationData from "../../assets/animations/test.json"; - -export default function TestAnimation() { - return ( -
-

salut

- {/* */} -
- ); -} diff --git a/src/components/results/ResultsModals.jsx b/src/components/results/ResultsModals.jsx index fe84813..9421e90 100644 --- a/src/components/results/ResultsModals.jsx +++ b/src/components/results/ResultsModals.jsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from "react"; -import Lottie from "lottie-react"; +import Lottie from "react-lottie"; import { useNavigate } from "react-router-dom"; import Loading from "../animations/Loading"; @@ -59,18 +59,31 @@ export default function ResultsModals({ resultsDatas }) { return (
- - +
+ +
+
+ +
+

{currentScreenTranslations.results_screen_title}

diff --git a/src/components/tutorials/MoveAround.jsx b/src/components/tutorials/MoveAround.jsx index 84fdce2..66ab008 100644 --- a/src/components/tutorials/MoveAround.jsx +++ b/src/components/tutorials/MoveAround.jsx @@ -1,5 +1,5 @@ import React from "react"; -import Lottie from "lottie-react"; +import Lottie from "react-lottie"; import { motion } from "framer-motion"; import animationDeplacement from "../../assets/animations/ecran-deplacement.json"; @@ -17,6 +17,12 @@ export default function MoveAround({ setNextSlide }) { animate: { x: "0%", opacity: 1 }, exit: { x: "-100%", opacity: 0 }, }; + + const defaultOptions = { + loop: true, + autoplay: true, + animationData: animationDeplacement, + }; return (
- +
+ +
); diff --git a/src/components/tutorials/PointsAndTime.jsx b/src/components/tutorials/PointsAndTime.jsx index 1cb5472..47717a4 100644 --- a/src/components/tutorials/PointsAndTime.jsx +++ b/src/components/tutorials/PointsAndTime.jsx @@ -1,5 +1,5 @@ import React from "react"; -import Lottie from "lottie-react"; +import Lottie from "react-lottie"; import { motion } from "framer-motion"; import animationPoints from "../../assets/animations/ecran-points.json"; @@ -19,6 +19,12 @@ export default function PointsAndTime({ setNextSlide, setPreviousSlide, startGam exit: { x: "-100%", opacity: 0 }, }; + const defaultOptions = { + loop: true, + autoplay: true, + animationData: animationPoints, + }; + return (
- +
+ +
); diff --git a/src/components/tutorials/Walkthrough.jsx b/src/components/tutorials/Walkthrough.jsx index d566b74..cb0f904 100644 --- a/src/components/tutorials/Walkthrough.jsx +++ b/src/components/tutorials/Walkthrough.jsx @@ -1,8 +1,8 @@ import React from "react"; -import Lottie from "lottie-react"; +import Lottie from "react-lottie"; import { motion } from "framer-motion"; -import animationPoints from "../../assets/animations/ecran-deroulement.json"; +import animationDeroulement from "../../assets/animations/ecran-deroulement.json"; import Loading from "../animations/Loading"; import { useUser } from "../../hooks/useUser"; @@ -18,6 +18,11 @@ export default function Walkthrough({ setNextSlide, setPreviousSlide }) { animate: { x: "0%", opacity: 1 }, exit: { x: "-100%", opacity: 0 }, }; + const defaultOptions = { + loop: true, + autoplay: true, + animationData: animationDeroulement, + }; return (
- +
+ +
); diff --git a/src/pages/About.jsx b/src/pages/About.jsx index 7c81a6f..d7554e8 100644 --- a/src/pages/About.jsx +++ b/src/pages/About.jsx @@ -17,7 +17,6 @@ export default function About() {
diff --git a/src/pages/Welcome.jsx b/src/pages/Welcome.jsx index 035f119..278c86c 100644 --- a/src/pages/Welcome.jsx +++ b/src/pages/Welcome.jsx @@ -5,7 +5,8 @@ import { useUser } from "../hooks/useUser"; import LanguageSelect from "../components/ui/LanguageSelect"; import truckAnimation from "../assets/animations/chargement-vehicules"; -import Lottie from "lottie-react"; + +import Lottie from "react-lottie"; import Loading from "../components/animations/Loading"; export default function Welcome() { @@ -14,10 +15,21 @@ export default function Welcome() { if (!screensTranslations || !screensTranslations.welcome) return ; const currentScreenTranslations = screensTranslations.welcome; + const defaultOptions = { + loop: true, + autoplay: true, + animationData: truckAnimation, + rendererSettings: { + preserveAspectRatio: "xMidYMid slice", + }, + }; + return ( - +
+ +