From f7b66696ec5e81570be7452bbc4e7739359d2eb1 Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Fri, 12 Aug 2022 22:55:29 +0400 Subject: [PATCH] feat(watermark): add watermark for brasil matches --- src/components/WaterMark/index.tsx | 40 +++++++++++++++++++ .../MatchPage/components/LiveMatch/index.tsx | 1 + src/features/StreamPlayer/index.tsx | 13 +++++- 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/components/WaterMark/index.tsx diff --git a/src/components/WaterMark/index.tsx b/src/components/WaterMark/index.tsx new file mode 100644 index 00000000..7f4bb904 --- /dev/null +++ b/src/components/WaterMark/index.tsx @@ -0,0 +1,40 @@ +import styled from 'styled-components/macro' + +type WmType = { + leftWM: number, + topWM: number, +} + +export const ScWaterMark = styled.div` + position: absolute; + top: ${({ topWM }) => `${topWM}%`}; + left: ${({ leftWM }) => `${leftWM}%`}; + transform: translate(-50%, -50%); + z-index: 1; + color: white; + opacity: 0.4; + transition-property: left, top; + transition-duration: 3s; +` + +type WaterMarkProps = { + value: string | number | undefined, +} + +export const WaterMark = ({ value }: WaterMarkProps) => { + const calcCoordinate = () => { + const leftWM = Math.floor(Math.random() * 100) + let topWM + if (leftWM < 10 || leftWM > 90) { + topWM = Math.floor(Math.random() * 100) + } else { + topWM = Math.floor(Math.random() * 10) + } + return { leftWM, topWM } + } + return ( + + {value} + + ) +} diff --git a/src/features/MatchPage/components/LiveMatch/index.tsx b/src/features/MatchPage/components/LiveMatch/index.tsx index 26cf6789..79abf0cb 100644 --- a/src/features/MatchPage/components/LiveMatch/index.tsx +++ b/src/features/MatchPage/components/LiveMatch/index.tsx @@ -61,6 +61,7 @@ export const LiveMatch = ({ isLive={profile?.live} resumeFrom={resume} chapters={chapters} + profile={profile} /> ) )} diff --git a/src/features/StreamPlayer/index.tsx b/src/features/StreamPlayer/index.tsx index 67bcec54..95ef3e48 100644 --- a/src/features/StreamPlayer/index.tsx +++ b/src/features/StreamPlayer/index.tsx @@ -4,6 +4,8 @@ import { T9n } from 'features/T9n' import { Loader } from 'features/Loader' import { VideoPlayer } from 'features/VideoPlayer' +import { WaterMark } from 'components/WaterMark' + import { secondsToHms } from 'helpers' import { HOUR_IN_MILLISECONDS, REWIND_SECONDS } from './config' @@ -28,15 +30,18 @@ import { ChaptersText, Next, Prev, + // WaterMark, } from './styled' import type { Props } from './hooks' import { useVideoPlayer } from './hooks' +import { useAuthStore } from '../AuthStore' /** * HLS плеер, применяется на лайв и завершенных матчах */ export const StreamPlayer = (props: Props) => { - const { isLive } = props + const { isLive, profile } = props + const { user } = useAuthStore() const { activeChapterIndex, @@ -89,7 +94,6 @@ export const StreamPlayer = (props: Props) => { volumeInPercent, wrapperRef, } = useVideoPlayer(props) - return ( { + {profile?.tournament.id === 1136 + && playing + && ( + + )}