AW-115-lottie-optimization-edits

preload, fix height animation container
This commit is contained in:
gofnnp 2024-06-21 05:43:36 +04:00
parent b6efaed3d1
commit 7ea45de6a2
15 changed files with 117 additions and 63 deletions

View File

@ -7,6 +7,7 @@ import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import routes from "@/routes"; import routes from "@/routes";
import QuestionnaireGreenButton from "../../../../ui/GreenButton"; import QuestionnaireGreenButton from "../../../../ui/GreenButton";
import { ELottieKeys, useLottie } from "@/hooks/lottie/useLottie";
interface IBirthdateCustomAnswerProps { interface IBirthdateCustomAnswerProps {
affiliation?: "self" | "partner"; affiliation?: "self" | "partner";
@ -18,6 +19,16 @@ function BirthdateCustomAnswer({
const { t } = useTranslation(); const { t } = useTranslation();
const navigate = useNavigate(); const navigate = useNavigate();
const dispatch = useDispatch(); const dispatch = useDispatch();
useLottie({
preloadKey: ELottieKeys.darts,
});
useLottie({
preloadKey: ELottieKeys.compass,
});
useLottie({
preloadKey: ELottieKeys.cloudAndStars,
});
const selfBirthdate = useSelector(selectors.selectBirthdate); const selfBirthdate = useSelector(selectors.selectBirthdate);
const questionnaire = useSelector(selectors.selectQuestionnaire); const questionnaire = useSelector(selectors.selectQuestionnaire);
const birthdateFromStore = const birthdateFromStore =

View File

@ -7,12 +7,18 @@ import { selectors } from "@/store";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { getZodiacSignByDate } from "@/services/zodiac-sign"; import { getZodiacSignByDate } from "@/services/zodiac-sign";
import Header from "../../components/Header"; import Header from "../../components/Header";
import { ELottieKeys, useLottie } from "@/hooks/lottie/useLottie";
import { DotLottieReact } from "@lottiefiles/dotlottie-react";
function AllRightPage() { function AllRightPage() {
const navigate = useNavigate(); const navigate = useNavigate();
const { birthdate } = useSelector(selectors.selectQuestionnaire); const { birthdate } = useSelector(selectors.selectQuestionnaire);
const zodiacSign = getZodiacSignByDate(birthdate); const zodiacSign = getZodiacSignByDate(birthdate);
const { animationData } = useLottie({
loadKey: ELottieKeys.lightBulb,
});
const handleBack = () => { const handleBack = () => {
navigate(-1); navigate(-1);
}; };
@ -28,7 +34,14 @@ function AllRightPage() {
classNameTitle={styles["header-title"]} classNameTitle={styles["header-title"]}
/> />
<div className={styles.circle}> <div className={styles.circle}>
<img src="/light.svg" alt="light" /> {animationData && (
<DotLottieReact
className={styles["lottie-animation"]}
data={animationData}
autoplay
loop={false}
/>
)}
<div className={styles["circle-small"]} /> <div className={styles["circle-small"]} />
</div> </div>
<div> <div>

View File

@ -12,7 +12,6 @@ function AlmostTherePage() {
const { animationData } = useLottie({ const { animationData } = useLottie({
loadKey: ELottieKeys.magnifyingGlassAndPlanet, loadKey: ELottieKeys.magnifyingGlassAndPlanet,
preloadKey: ELottieKeys.sun,
}); });
const handleBack = () => { const handleBack = () => {
@ -31,14 +30,16 @@ function AlmostTherePage() {
isBackButtonVisible={false} isBackButtonVisible={false}
classNameTitle={styles["header-title"]} classNameTitle={styles["header-title"]}
/> />
{animationData && ( <div className={styles["lottie-animation"]}>
<DotLottieReact {animationData && (
className={styles["lottie-animation"]} <DotLottieReact
data={animationData} data={animationData}
autoplay autoplay
loop={false} loop={false}
/> />
)} )}
</div>
<div></div>
<div> <div>
<Title variant="h1" className={styles.title}> <Title variant="h1" className={styles.title}>
Almost there! <br /> Now let's tailor your plan by understanding the{" "} Almost there! <br /> Now let's tailor your plan by understanding the{" "}

View File

@ -78,5 +78,5 @@
.lottie-animation { .lottie-animation {
width: 100%; width: 100%;
aspect-ratio: 575 / 506; aspect-ratio: 401.27 / 353.27;
} }

View File

@ -30,14 +30,11 @@ function EmailConfirmPage() {
/> />
<Header className={styles.header} /> <Header className={styles.header} />
<div className={styles["top-section"]}> <div className={styles["top-section"]}>
{animationData && ( <div className={styles["lottie-animation"]}>
<DotLottieReact {animationData && (
className={styles["lottie-animation"]} <DotLottieReact data={animationData} autoplay loop={false} />
data={animationData} )}
autoplay </div>
loop={false}
/>
)}
<Title className={styles.title}> <Title className={styles.title}>
Get access to your{" "} Get access to your{" "}
<span className={styles.gradient}>exclusive reading</span>, special <span className={styles.gradient}>exclusive reading</span>, special

View File

@ -13,6 +13,7 @@ import Header from "../../components/Header";
import { genders } from "../../data/genders"; import { genders } from "../../data/genders";
import PrivacyPolicy from "../../components/PrivacyPolicy"; import PrivacyPolicy from "../../components/PrivacyPolicy";
import Toast from "../../components/Toast"; import Toast from "../../components/Toast";
import { DotLottieReact } from "@lottiefiles/dotlottie-react";
interface IGenderPageProps { interface IGenderPageProps {
productKey?: EProductKeys; productKey?: EProductKeys;
@ -78,6 +79,13 @@ function GenderPage({ productKey }: IGenderPageProps): JSX.Element {
return ( return (
<section className={`${styles.page} page`} ref={pageRef}> <section className={`${styles.page} page`} ref={pageRef}>
<DotLottieReact
style={{
visibility: "hidden",
height: 0,
width: 0,
}}
/>
<BackgroundTopBlob <BackgroundTopBlob
className={styles["background-top-blob"]} className={styles["background-top-blob"]}
width={pageWidth} width={pageWidth}

View File

@ -5,6 +5,7 @@
display: grid; display: grid;
grid-template-rows: min-content min-content 1fr min-content; grid-template-rows: min-content min-content 1fr min-content;
align-items: start; align-items: start;
justify-items: center;
background: #0f1323; background: #0f1323;
color: #fff; color: #fff;
padding-top: 36px; padding-top: 36px;

View File

@ -4,9 +4,16 @@ import { useNavigate } from "react-router-dom";
import routes from "@/routes"; import routes from "@/routes";
import Header from "../../components/Header"; import Header from "../../components/Header";
import QuestionnaireGreenButton from "../../ui/GreenButton"; import QuestionnaireGreenButton from "../../ui/GreenButton";
import { ELottieKeys, useLottie } from "@/hooks/lottie/useLottie";
function HyperPersonalizedAstrologyPage() { function HyperPersonalizedAstrologyPage() {
const navigate = useNavigate(); const navigate = useNavigate();
useLottie({
preloadKey: ELottieKeys.lightBulb,
});
useLottie({
preloadKey: ELottieKeys.hourglass,
});
const handleNext = () => { const handleNext = () => {
navigate(`${routes.client.questionnaireV1()}/profile/birthdate`); navigate(`${routes.client.questionnaireV1()}/profile/birthdate`);

View File

@ -11,6 +11,7 @@ import { CircularProgressbar } from "react-circular-progressbar";
import { useDynamicSize } from "@/hooks/useDynamicSize"; import { useDynamicSize } from "@/hooks/useDynamicSize";
import BackgroundTopBlob from "../../ui/BackgroundTopBlob"; import BackgroundTopBlob from "../../ui/BackgroundTopBlob";
import Header from "../../components/Header"; import Header from "../../components/Header";
import { ELottieKeys, useLottie } from "@/hooks/lottie/useLottie";
function LoadingInRelationshipPage() { function LoadingInRelationshipPage() {
const navigate = useNavigate(); const navigate = useNavigate();
@ -22,6 +23,13 @@ function LoadingInRelationshipPage() {
}, []); }, []);
const { width: pageWidth, elementRef: pageRef } = useDynamicSize({}); const { width: pageWidth, elementRef: pageRef } = useDynamicSize({});
useLottie({
preloadKey: ELottieKeys.key,
});
useLottie({
preloadKey: ELottieKeys.umbrella,
});
useEffect(() => { useEffect(() => {
intervalRef.current = setInterval(() => { intervalRef.current = setInterval(() => {
if (loadingProgress <= 0) { if (loadingProgress <= 0) {

View File

@ -18,17 +18,12 @@ import { useDynamicSize } from "@/hooks/useDynamicSize";
import BackgroundTopBlob from "../../ui/BackgroundTopBlob"; import BackgroundTopBlob from "../../ui/BackgroundTopBlob";
import LoadingProfileModalChild from "../../components/LoadingProfileModalChild"; import LoadingProfileModalChild from "../../components/LoadingProfileModalChild";
import ProgressBarSubstrate from "./ProgressBarSubstrate"; import ProgressBarSubstrate from "./ProgressBarSubstrate";
import { ELottieKeys, useLottie } from "@/hooks/lottie/useLottie";
function LoadingProfilePage() { function LoadingProfilePage() {
const userDeviceType = useSelector(selectors.selectUserDeviceType); const userDeviceType = useSelector(selectors.selectUserDeviceType);
const isShowTryApp = useSelector(selectors.selectIsShowTryApp); const isShowTryApp = useSelector(selectors.selectIsShowTryApp);
const { width: pageWidth, elementRef: pageElement } = useDynamicSize({}); const { width: pageWidth, elementRef: pageElement } = useDynamicSize({});
useLottie({
preloadKey: ELottieKeys.key,
});
const navigate = useNavigate(); const navigate = useNavigate();
const [progress, setProgress] = useState(0); const [progress, setProgress] = useState(0);
const [isPause, setIsPause] = useState(false); const [isPause, setIsPause] = useState(false);

View File

@ -6,6 +6,8 @@ import routes from "@/routes";
import { useDynamicSize } from "@/hooks/useDynamicSize"; import { useDynamicSize } from "@/hooks/useDynamicSize";
import BackgroundTopBlob from "../../ui/BackgroundTopBlob"; import BackgroundTopBlob from "../../ui/BackgroundTopBlob";
import Header from "../../components/Header"; import Header from "../../components/Header";
import { ELottieKeys, useLottie } from "@/hooks/lottie/useLottie";
import { DotLottieReact } from "@lottiefiles/dotlottie-react";
function NoBirthtimePage() { function NoBirthtimePage() {
const [searchParams] = useSearchParams(); const [searchParams] = useSearchParams();
@ -13,6 +15,10 @@ function NoBirthtimePage() {
const navigate = useNavigate(); const navigate = useNavigate();
const { width: pageWidth, elementRef: pageRef } = useDynamicSize({}); const { width: pageWidth, elementRef: pageRef } = useDynamicSize({});
const { animationData } = useLottie({
loadKey: ELottieKeys.hourglass,
});
const handleNext = () => { const handleNext = () => {
if (affiliation === "partner") { if (affiliation === "partner") {
navigate( navigate(
@ -37,7 +43,14 @@ function NoBirthtimePage() {
className={styles["background-top-blob"]} className={styles["background-top-blob"]}
/> />
<div className={styles.ellipse}> <div className={styles.ellipse}>
<img src="/hourglass.svg" alt="hourglass" /> {animationData && (
<DotLottieReact
className={styles["lottie-animation"]}
data={animationData}
autoplay
loop={false}
/>
)}
</div> </div>
<div> <div>
<Title variant="h1" className={styles.title}> <Title variant="h1" className={styles.title}>

View File

@ -33,14 +33,15 @@ function NotAlonePage() {
isBackButtonVisible={false} isBackButtonVisible={false}
classNameTitle={styles["header-title"]} classNameTitle={styles["header-title"]}
/> />
{animationData && ( <div className={styles["lottie-animation"]}>
<DotLottieReact {animationData && (
className={styles["lottie-animation"]} <DotLottieReact
data={animationData} data={animationData}
autoplay autoplay
loop={false} loop={false}
/> />
)} )}
</div>
<div> <div>
<Title variant="h1" className={styles.title}> <Title variant="h1" className={styles.title}>
Youre not alone. Youre not alone.

View File

@ -49,14 +49,11 @@ function QuestionnaireIntermediatePage() {
isBackButtonVisible={false} isBackButtonVisible={false}
classNameTitle={styles["header-title"]} classNameTitle={styles["header-title"]}
/> />
{animationData && ( <div className={styles["lottie-animation"]}>
<DotLottieReact {animationData && (
className={styles["lottie-animation"]} <DotLottieReact data={animationData} autoplay loop={false} />
data={animationData} )}
autoplay </div>
loop={false}
/>
)}
<div> <div>
{path && ( {path && (
<Title variant="h1" className={styles.title}> <Title variant="h1" className={styles.title}>

View File

@ -12,6 +12,7 @@ function RelationshipAlmostTherePage() {
const { animationData } = useLottie({ const { animationData } = useLottie({
loadKey: ELottieKeys.magnifyingGlassAndPlanet, loadKey: ELottieKeys.magnifyingGlassAndPlanet,
preloadKey: ELottieKeys.sun,
}); });
console.log("animationData", animationData); console.log("animationData", animationData);
@ -30,14 +31,11 @@ function RelationshipAlmostTherePage() {
classNameTitle={styles["header-title"]} classNameTitle={styles["header-title"]}
isBackButtonVisible={false} isBackButtonVisible={false}
/> />
{animationData && ( <div className={styles["lottie-animation"]}>
<DotLottieReact {animationData && (
className={styles["lottie-animation"]} <DotLottieReact data={animationData} autoplay loop={false} />
data={animationData} )}
autoplay </div>
loop={false}
/>
)}
<div> <div>
<Title variant="h1" className={styles.title}> <Title variant="h1" className={styles.title}>
<strong>Almost there!</strong> <br /> Now let's begin tailoring your <strong>Almost there!</strong> <br /> Now let's begin tailoring your

View File

@ -49,34 +49,38 @@ function Satisfied() {
classNameTitle={styles["header-title"]} classNameTitle={styles["header-title"]}
isBackButtonVisible={false} isBackButtonVisible={false}
/> />
{satisfied === "yes" && animationSun && ( {satisfied === "yes" && (
<div <div
style={{ style={{
width: "100%", width: "100%",
aspectRatio: "337 / 406", aspectRatio: "337 / 406",
}} }}
> >
<DotLottieReact {animationSun && (
className={styles["lottie-animation"]} <DotLottieReact
data={animationSun} className={styles["lottie-animation"]}
autoplay data={animationSun}
loop={false} autoplay
/> loop={false}
/>
)}
</div> </div>
)} )}
{satisfied === "no" && animationUmbrella && ( {satisfied === "no" && (
<div <div
style={{ style={{
width: "100%", width: "100%",
aspectRatio: "310 / 300", aspectRatio: "310 / 300",
}} }}
> >
<DotLottieReact {animationUmbrella && (
className={styles["lottie-animation"]} <DotLottieReact
data={animationUmbrella} className={styles["lottie-animation"]}
autoplay data={animationUmbrella}
loop={false} autoplay
/> loop={false}
/>
)}
</div> </div>
)} )}
<div> <div>