From eefa98700387b3c39f551a6ba701d50940876606 Mon Sep 17 00:00:00 2001 From: Christiaan Scheermeijer Date: Mon, 21 Jun 2021 11:37:33 +0200 Subject: [PATCH] feat(videodetail): player render optimizations --- src/components/Video/Video.module.scss | 39 +++-- src/components/Video/Video.tsx | 27 +-- .../Video/__snapshots__/Video.test.tsx.snap | 10 +- src/containers/Cinema/Cinema.module.scss | 5 + src/containers/Cinema/Cinema.tsx | 144 ++++++++++++---- .../Cinema/__snapshots__/Cinema.test.tsx.snap | 6 +- src/hooks/useOttAnalytics.ts | 8 +- src/hooks/useRecommendationsPlaylist.ts | 21 +++ src/screens/Movie/Movie.tsx | 154 +++++++++--------- src/screens/Series/Series.tsx | 8 +- types/global.d.ts | 2 +- 11 files changed, 274 insertions(+), 150 deletions(-) create mode 100644 src/containers/Cinema/Cinema.module.scss create mode 100644 src/hooks/useRecommendationsPlaylist.ts diff --git a/src/components/Video/Video.module.scss b/src/components/Video/Video.module.scss index 1453e4757..46ca11210 100644 --- a/src/components/Video/Video.module.scss +++ b/src/components/Video/Video.module.scss @@ -9,50 +9,55 @@ text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.14), 0px 3px 4px rgba(0, 0, 0, 0.12), 0px 1px 5px rgba(0, 0, 0, 0.2); } .mainPadding { - padding: 56px; @include responsive.tablet-only() { - padding: 24px; - padding-top: 34px; + padding: 34px 24px 24px; } + @include responsive.mobile-only() { padding: 16px; } - padding-top: 37px; - padding-bottom: 0px; + + padding: 37px 56px 0; } .main { display: flex; + &.hidden { display: none; } + &.posterNormal { position: relative; } } + .info { - width: 450px; - min-height: 380px; @include responsive.tablet-only() { width: 350px; } + @include responsive.mobile-only() { width: 100%; padding-top: 225px; } + + width: 450px; + min-height: 380px; } + .title { - font-size: 34px; - font-weight: 700; - line-height: 36px; - letter-spacing: 0.25px; - margin: 8px 0px; @include responsive.mobile-only() { font-size: 20px; line-height: 20px; letter-spacing: 0.15px; - margin: 0px; } + + font-weight: 700; + font-size: 34px; + line-height: 40px; + letter-spacing: 0.25px; } + .metaContainer { display: flex; flex-direction: column; @@ -202,7 +207,7 @@ .playerContent { position: absolute; top: 0; - margin: 30px 62px; + margin: 24px 56px; max-width: 50%; display: flex; @@ -212,16 +217,18 @@ } } .backButton { - margin: 6px 0px; + margin-right: 24px; opacity: 1; + > svg { width: 36px; height: 36px; } } + .playerInfo { - margin: 0px 30px; } + .trailerMeta { position: absolute; z-index: 1; diff --git a/src/components/Video/Video.tsx b/src/components/Video/Video.tsx index 9c70774df..49cf530a8 100644 --- a/src/components/Video/Video.tsx +++ b/src/components/Video/Video.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useCallback } from 'react'; import type { PlaylistItem } from 'types/playlist'; import classNames from 'classnames'; import { useTranslation } from 'react-i18next'; @@ -69,6 +69,13 @@ const Video: React.FC = ({ const [userActive, setUserActive] = useState(true); const breakpoint: Breakpoint = useBreakpoint(); const { t } = useTranslation(['video', 'common']); + + const handleUserActive = useCallback(() => setUserActive(true), []); + const handleUserInactive = useCallback(() => setUserActive(false), []); + const handlePlay = useCallback(() => setIsPlaying(true), []); + const handlePause = useCallback(() => setIsPlaying(false), []); + const handleComplete = useCallback(() => onComplete && onComplete(), [onComplete]); + const isLargeScreen = breakpoint >= Breakpoint.md; const isMobile = breakpoint === Breakpoint.xs; const imageSourceWidth = 640 * (window.devicePixelRatio > 1 || isLargeScreen ? 2 : 1); @@ -160,11 +167,11 @@ const Video: React.FC = ({ setIsPlaying(true)} - onPause={() => setIsPlaying(false)} - onComplete={onComplete} - onUserActive={() => setUserActive(true)} - onUserInActive={() => setUserActive(false)} + onPlay={handlePlay} + onPause={handlePause} + onComplete={handleComplete} + onUserActive={handleUserActive} + onUserInActive={handleUserInactive} />
@@ -186,11 +193,11 @@ const Video: React.FC = ({ setIsPlaying(true)} - onPause={() => setIsPlaying(false)} + onPlay={handlePlay} + onPause={handlePause} onComplete={onTrailerClose} - onUserActive={() => setUserActive(true)} - onUserInActive={() => setUserActive(false)} + onUserActive={handleUserActive} + onUserInActive={handleUserInactive} isTrailer />
diff --git a/src/components/Video/__snapshots__/Video.test.tsx.snap b/src/components/Video/__snapshots__/Video.test.tsx.snap index 965652296..e4b5ecbfc 100644 --- a/src/components/Video/__snapshots__/Video.test.tsx.snap +++ b/src/components/Video/__snapshots__/Video.test.tsx.snap @@ -129,8 +129,10 @@ exports[`