diff --git a/src/components/pages/ABDesign/v1/pages/TrialPayment/components/PersonalVideo/index.tsx b/src/components/pages/ABDesign/v1/pages/TrialPayment/components/PersonalVideo/index.tsx index 80867ff..084a82e 100644 --- a/src/components/pages/ABDesign/v1/pages/TrialPayment/components/PersonalVideo/index.tsx +++ b/src/components/pages/ABDesign/v1/pages/TrialPayment/components/PersonalVideo/index.tsx @@ -5,6 +5,8 @@ import Loader from "@/components/Loader"; import PlayButton from "../../../../ui/PlayButton"; import metricService, { EGoals } from "@/services/metric/metricService"; import PlayPauseButton from "../../../../ui/PlayPauseButton"; +import VideoOverlay from "../../../../ui/VideoOverlay"; +import PlayPauseButtonV2 from "../../../../ui/PlayPauseButtonV2"; interface IPersonalVideoProps { gender: string; @@ -17,6 +19,7 @@ const PersonalVideo = React.memo( const [isPlaying, setIsPlaying] = useState(false); const [isStarted, setIsStarted] = useState(false); const [isError, setIsError] = useState(false); + const [isOverlayShow, setIsOverlayShow] = useState(false); const onError = (error: unknown) => { if (!error) return; @@ -33,14 +36,27 @@ const PersonalVideo = React.memo( metricService.reachGoal(EGoals.ROSE_VIDEO_PLAY_END); }; - const handlePlayPause = () => { + const handlePlayPause = ( + event: React.MouseEvent + ) => { + event.preventDefault(); + event.stopPropagation(); setIsPlaying((prev) => !prev); if (isPlaying) metricService.reachGoal(EGoals.ROSE_VIDEO_PLAY_USER_PLAY); if (!isPlaying) metricService.reachGoal(EGoals.ROSE_VIDEO_PLAY_USER_STOP); }; return ( -
+
setIsOverlayShow(true)} + > + + handlePlayPause(event)} + /> + {!isPlaying && !isError && !isStarted && ( )} @@ -48,7 +64,9 @@ const PersonalVideo = React.memo( { + onClick={(event) => { + event.preventDefault(); + event.stopPropagation(); setIsError(false); setIsPlaying(true); }} @@ -72,10 +90,10 @@ const PersonalVideo = React.memo( aspectRatio: "16 / 9", }} /> - {!isError && isStarted && ( + {!isError && isStarted && !isOverlayShow && ( handlePlayPause(event)} className={styles["play-pause-button"]} /> )} diff --git a/src/components/pages/ABDesign/v1/pages/TrialPayment/index.tsx b/src/components/pages/ABDesign/v1/pages/TrialPayment/index.tsx index b986db9..0c69da7 100644 --- a/src/components/pages/ABDesign/v1/pages/TrialPayment/index.tsx +++ b/src/components/pages/ABDesign/v1/pages/TrialPayment/index.tsx @@ -144,6 +144,13 @@ function TrialPaymentPage() { classNameContainer={styles["personal-video"]} /> )} + {/* {!!videoUrl.length && ( */} + + {/* )} */} {singleOrWithPartner === "partner" && ( null} {...props} > diff --git a/src/components/pages/ABDesign/v1/ui/PlayPauseButtonV2/index.tsx b/src/components/pages/ABDesign/v1/ui/PlayPauseButtonV2/index.tsx new file mode 100644 index 0000000..8ea057d --- /dev/null +++ b/src/components/pages/ABDesign/v1/ui/PlayPauseButtonV2/index.tsx @@ -0,0 +1,56 @@ +import { DetailedHTMLProps, HTMLAttributes } from "react"; +import styles from "./styles.module.scss"; + +interface IPlayPauseButtonV2Props { + state?: "play" | "pause"; +} + +function PlayPauseButtonV2({ + state, + ...props +}: IPlayPauseButtonV2Props & + DetailedHTMLProps, HTMLDivElement>) { + return ( +
+ {state === "pause" ? ( + + + + + ) : ( + + + + )} +
+ ); +} + +export default PlayPauseButtonV2; diff --git a/src/components/pages/ABDesign/v1/ui/PlayPauseButtonV2/styles.module.scss b/src/components/pages/ABDesign/v1/ui/PlayPauseButtonV2/styles.module.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/components/pages/ABDesign/v1/ui/VideoOverlay/index.tsx b/src/components/pages/ABDesign/v1/ui/VideoOverlay/index.tsx new file mode 100644 index 0000000..611c70c --- /dev/null +++ b/src/components/pages/ABDesign/v1/ui/VideoOverlay/index.tsx @@ -0,0 +1,65 @@ +import { useEffect, useRef, useState } from "react"; +import styles from "./styles.module.scss"; + +interface IVideoOverlayProps { + isShow: boolean; + setIsShow: React.Dispatch>; + animationDuration?: number; + children?: React.ReactNode; +} + +function VideoOverlay({ + isShow, + setIsShow, + animationDuration = 5000, + children, +}: IVideoOverlayProps) { + const timeoutRef = useRef(); + const [animationDurationLocal, setAnimationDurationLocal] = + useState(animationDuration); + + const click = () => { + if (timeoutRef.current) clearTimeout(timeoutRef.current); + setAnimationDurationLocal((prev) => prev + animationDuration); + timeoutRef.current = setTimeout(() => { + setIsShow(false); + }, animationDuration); + }; + + useEffect(() => { + if (!isShow) return; + console.log("start "); + + timeoutRef.current = setTimeout(() => { + setIsShow(false); + }, animationDuration); + return () => { + if (timeoutRef.current) clearTimeout(timeoutRef.current); + }; + }, [animationDuration, isShow, setIsShow]); + + return ( + <> + {isShow && ( +
+
+ {children} +
+
+ )} + + ); +} + +export default VideoOverlay; diff --git a/src/components/pages/ABDesign/v1/ui/VideoOverlay/styles.module.scss b/src/components/pages/ABDesign/v1/ui/VideoOverlay/styles.module.scss new file mode 100644 index 0000000..6b67102 --- /dev/null +++ b/src/components/pages/ABDesign/v1/ui/VideoOverlay/styles.module.scss @@ -0,0 +1,46 @@ +.overlay { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0); + z-index: 9999; + display: flex; + align-items: center; + justify-content: center; + animation-fill-mode: forwards; + animation-name: appearance, disappearing; + animation-duration: 0.5s; +} + +@keyframes appearance { + to { + background-color: rgba(0, 0, 0, 0.27); + } +} + +@keyframes disappearing { + to { + background-color: rgba(0, 0, 0, 0); + } +} + +.content { + opacity: 0; + animation-fill-mode: forwards; + animation-name: appearance-content, disappearing-content; + animation-duration: 0.5s; +} + +@keyframes appearance-content { + to { + opacity: 1; + } +} + +@keyframes disappearing-content { + to { + opacity: 0; + } +}