From fdb88b04b32b9392e76795099e2ec47c9856b38b Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Sun, 14 Aug 2022 20:41:30 +0400 Subject: [PATCH] fix(#watermark): visible 1 time at 5 sec --- src/components/WaterMark/index.tsx | 52 +++++++------------ .../components/TournamentMobile/styled.tsx | 2 +- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/src/components/WaterMark/index.tsx b/src/components/WaterMark/index.tsx index 4a5f682c..72e48043 100644 --- a/src/components/WaterMark/index.tsx +++ b/src/components/WaterMark/index.tsx @@ -2,8 +2,9 @@ import { useState, useEffect } from 'react' import styled from 'styled-components/macro' type WmType = { - leftWm?: number, - topWm?: number, + leftWm: number, + topWm: number, + visible: boolean, } export const ScWaterMark = styled.div` @@ -11,22 +12,10 @@ export const ScWaterMark = styled.div` top: ${({ topWm }) => `${topWm}%`}; left: ${({ leftWm }) => `${leftWm}%`}; z-index: 1; - width: 100%; - opacity: 0.2; + opacity: 1; color: white; - //animation: marquee 2s linear; - // - //@keyframes marquee { - // 0% { - // opacity: 0; - // } - // 50% { - // opacity: 0.3; - // } - // 100% { - // opacity: 0; - // } - //} + visibility: ${({ visible }) => (visible ? 'visible' + : 'hidden')}; ` type WaterMarkProps = { @@ -36,26 +25,25 @@ type WaterMarkProps = { export const WaterMark = ({ value }: WaterMarkProps) => { const [topWm, setTopWm] = useState(0) const [leftWm, setLeftWm] = useState(0) - const [topWm2, setTopWm2] = useState(0) - const [leftWm2, setLeftWm2] = useState(0) + const [visible, setVisible] = useState(false) useEffect(() => { - let getIntervalCoordinates: ReturnType - // eslint-disable-next-line - getIntervalCoordinates = setInterval( - () => { - setLeftWm(Math.floor(Math.random() * 95)) - setTopWm(Math.floor(Math.random() * 10)) - setLeftWm2(Math.floor(Math.random() * 95)) - setTopWm2(Math.floor(Math.random() * (10)) + 80) - }, 1000 * 60 * 3, - ) - return () => clearInterval(getIntervalCoordinates) + setInterval(() => { + setLeftWm(Math.floor(Math.random() * 95)) + setTopWm(Math.floor(Math.random() * 95)) + setVisible((v) => !v) + }, 1000 * 5) }, []) + return ( <> - {value} - {value} + + {value} + ) } diff --git a/src/features/TournamentList/components/TournamentMobile/styled.tsx b/src/features/TournamentList/components/TournamentMobile/styled.tsx index 67c94702..1dfdacaa 100644 --- a/src/features/TournamentList/components/TournamentMobile/styled.tsx +++ b/src/features/TournamentList/components/TournamentMobile/styled.tsx @@ -50,7 +50,7 @@ export const TournamentName = styled(Name)` white-space: nowrap; @media (orientation: portrait) { - max-width: 200px; + max-width: 150px; } `