From 66a53765dc16e58907e86b6c6ebf86228ae7c910 Mon Sep 17 00:00:00 2001 From: Margarita Date: Thu, 1 Jun 2023 13:53:18 +0400 Subject: [PATCH 1/2] feat(in-652): penalty score --- .../CardFrontside/MatchCardMobile/index.tsx | 24 +++++++++++++++-- .../CardFrontside/MatchCardMobile/styled.tsx | 14 +++++++--- .../MatchCard/CardFrontside/index.tsx | 24 +++++++++++++++-- src/features/MatchCard/styled.tsx | 11 ++++++++ .../components/MatchDescription/index.tsx | 26 ++++++++++++++++--- .../components/MatchDescription/styled.tsx | 5 ++++ src/requests/getLiveScores.tsx | 1 + src/requests/getMatchInfo.tsx | 1 + src/requests/getMatches/types.tsx | 1 + 9 files changed, 97 insertions(+), 10 deletions(-) diff --git a/src/features/MatchCard/CardFrontside/MatchCardMobile/index.tsx b/src/features/MatchCard/CardFrontside/MatchCardMobile/index.tsx index 45e27e4e..d8c2754b 100644 --- a/src/features/MatchCard/CardFrontside/MatchCardMobile/index.tsx +++ b/src/features/MatchCard/CardFrontside/MatchCardMobile/index.tsx @@ -48,6 +48,8 @@ import { NameSignWrapper, HoverFrame, MobTime, + ScoreWrapper, + PenaltyScore, } from './styled' import { useCardPreview } from '../hooks' @@ -159,14 +161,32 @@ export const CardFrontsideMobile = ({ {team1InFavorites && } - {showScore && {score?.team1.score ?? team1.score}} + {showScore && ( + + + {score?.team1.score ?? team1.score} + + + {score?.team1.penalty_score ?? team1.penalty_score} + + + )} {team2InFavorites && } - {showScore && {score?.team2.score ?? team2.score}} + {showScore && ( + + + {score?.team2.score ?? team2.score} + + + {score?.team2.penalty_score ?? team2.penalty_score} + + + )} diff --git a/src/features/MatchCard/CardFrontside/MatchCardMobile/styled.tsx b/src/features/MatchCard/CardFrontside/MatchCardMobile/styled.tsx index 7c5f3237..02ca7909 100644 --- a/src/features/MatchCard/CardFrontside/MatchCardMobile/styled.tsx +++ b/src/features/MatchCard/CardFrontside/MatchCardMobile/styled.tsx @@ -199,7 +199,7 @@ export const Info = styled.div` left: 45%; */ width: 60%; height: 100%; - padding: 9px 9px 9px 19px; + padding: 9px 11px 9px 19px; ` : ''}; ` @@ -310,10 +310,18 @@ ${isMobileDevice ? css` display: flex; justify-content: center; - width: 15px; ` : ''}; - +` + +export const ScoreWrapper = styled.div` + display: flex; + line-height: 1; +` + +export const PenaltyScore = styled.div` + font-weight: 400; + font-size: 10px; ` export const TeamLogos = styled.div` diff --git a/src/features/MatchCard/CardFrontside/index.tsx b/src/features/MatchCard/CardFrontside/index.tsx index 6eef3cdf..863ab33b 100644 --- a/src/features/MatchCard/CardFrontside/index.tsx +++ b/src/features/MatchCard/CardFrontside/index.tsx @@ -40,6 +40,8 @@ import { FavoriteSign, NameSignWrapper, HoverFrame, + PenaltyScore, + ScoreWrapper, } from '../styled' import { useCardPreview } from './hooks' import { getPrepareTimeFormat } from '../helpers' @@ -206,7 +208,16 @@ export const CardFrontside = ({ {team1InFavorites && } - {showScore && {score?.team1.score ?? team1.score}} + {showScore && ( + + + {score?.team1.score ?? team1.score} + + + {score?.team1.penalty_score ?? team1.penalty_score} + + + )} @@ -224,7 +235,16 @@ export const CardFrontside = ({ {team2InFavorites && } - {showScore && {score?.team2.score ?? team2.score}} + {showScore && ( + + + {score?.team2.score ?? team2.score} + + + {score?.team2.penalty_score ?? team2.penalty_score} + + + )} {!isMatchPage && ( diff --git a/src/features/MatchCard/styled.tsx b/src/features/MatchCard/styled.tsx index bf8e50b6..89a5f40c 100644 --- a/src/features/MatchCard/styled.tsx +++ b/src/features/MatchCard/styled.tsx @@ -274,8 +274,19 @@ export const TeamName = styled(Name)` ${nameStyles} ` +export const ScoreWrapper = styled.div` + display: flex; + line-height: 1; +` + export const Score = styled.div`` +export const PenaltyScore = styled.div` + font-weight: 400; + font-size: .55rem; + margin-left: 1px; +` + export const TeamLogos = styled.div` display: ${({ isMatchPage }) => (isMatchPage ? 'none' : 'flex')}; align-items: center; diff --git a/src/features/MatchPage/components/MatchDescription/index.tsx b/src/features/MatchPage/components/MatchDescription/index.tsx index b55dcb74..49b171d3 100644 --- a/src/features/MatchPage/components/MatchDescription/index.tsx +++ b/src/features/MatchPage/components/MatchDescription/index.tsx @@ -1,4 +1,4 @@ -import { useCallback } from 'react' +import { Fragment, useCallback } from 'react' import { useQuery } from 'react-query' @@ -41,6 +41,7 @@ import { Time, Title, Views, + PenaltyScore, } from './styled' export const MatchDescription = () => { @@ -93,6 +94,7 @@ export const MatchDescription = () => { parseDate(date), isChangedTimeFormat ? 'h:mm a' : 'HH:mm', ) + const isPenaltyScoreShow = queryScore?.team1.penalty_score || team1.penalty_score return ( @@ -111,8 +113,26 @@ export const MatchDescription = () => { { isScoreHidden || isNil(team1.score) || isNil(team2.score) ? '-' - : `${queryScore?.team1.score ?? team1.score} - ${queryScore?.team2.score ?? team2.score}` - + : ( + + {queryScore?.team1.score ?? team1.score} + + {isPenaltyScoreShow && ( + + ({queryScore?.team1.penalty_score ?? team1.penalty_score}) + + )} + + {` - ${queryScore?.team2.score ?? team2.score}`} + + {isPenaltyScoreShow && ( + + ({queryScore?.team2.penalty_score ?? team2.penalty_score}) + + )} + + + ) } Date: Mon, 5 Jun 2023 16:07:12 +0400 Subject: [PATCH 2/2] feat(in-652): pr fixes --- .../CardFrontside/MatchCardMobile/index.tsx | 34 ++++++------------- .../CardFrontside/MatchCardMobile/styled.tsx | 20 ----------- .../MatchCard/CardFrontside/index.tsx | 34 ++++++------------- src/features/MatchCard/Score/index.tsx | 30 ++++++++++++++++ src/features/MatchCard/Score/styled.tsx | 31 +++++++++++++++++ src/features/MatchCard/styled.tsx | 13 ------- 6 files changed, 83 insertions(+), 79 deletions(-) create mode 100644 src/features/MatchCard/Score/index.tsx create mode 100644 src/features/MatchCard/Score/styled.tsx diff --git a/src/features/MatchCard/CardFrontside/MatchCardMobile/index.tsx b/src/features/MatchCard/CardFrontside/MatchCardMobile/index.tsx index d8c2754b..d8984d52 100644 --- a/src/features/MatchCard/CardFrontside/MatchCardMobile/index.tsx +++ b/src/features/MatchCard/CardFrontside/MatchCardMobile/index.tsx @@ -35,7 +35,6 @@ import { MatchTimeInfo, Preview, PreviewWrapper, - Score, Team, TeamName, Teams, @@ -48,10 +47,9 @@ import { NameSignWrapper, HoverFrame, MobTime, - ScoreWrapper, - PenaltyScore, } from './styled' import { useCardPreview } from '../hooks' +import { Score } from '../../Score' type Props = { isNeedFormatTimeChanged: boolean, @@ -161,32 +159,22 @@ export const CardFrontsideMobile = ({ {team1InFavorites && } - {showScore && ( - - - {score?.team1.score ?? team1.score} - - - {score?.team1.penalty_score ?? team1.penalty_score} - - - )} + {team2InFavorites && } - {showScore && ( - - - {score?.team2.score ?? team2.score} - - - {score?.team2.penalty_score ?? team2.penalty_score} - - - )} + diff --git a/src/features/MatchCard/CardFrontside/MatchCardMobile/styled.tsx b/src/features/MatchCard/CardFrontside/MatchCardMobile/styled.tsx index 02ca7909..99c5527b 100644 --- a/src/features/MatchCard/CardFrontside/MatchCardMobile/styled.tsx +++ b/src/features/MatchCard/CardFrontside/MatchCardMobile/styled.tsx @@ -304,26 +304,6 @@ export const TeamName = styled(Name)` ${nameStyles} ` -export const Score = styled.div` - -${isMobileDevice - ? css` - display: flex; - justify-content: center; - ` - : ''}; -` - -export const ScoreWrapper = styled.div` - display: flex; - line-height: 1; -` - -export const PenaltyScore = styled.div` - font-weight: 400; - font-size: 10px; -` - export const TeamLogos = styled.div` display: flex; align-items: center; diff --git a/src/features/MatchCard/CardFrontside/index.tsx b/src/features/MatchCard/CardFrontside/index.tsx index 863ab33b..e5af3755 100644 --- a/src/features/MatchCard/CardFrontside/index.tsx +++ b/src/features/MatchCard/CardFrontside/index.tsx @@ -19,6 +19,7 @@ import { useUserFavoritesStore } from 'features/UserFavorites/store' import { TournamentSubtitle } from 'features/TournamentSubtitle' import { NoAccessMessage } from '../NoAccessMessage' +import { Score } from '../Score' import { CardWrapperOuter, CardWrapper, @@ -28,7 +29,6 @@ import { MatchTimeInfo, Preview, PreviewWrapper, - Score, Team, TeamName, Teams, @@ -40,8 +40,6 @@ import { FavoriteSign, NameSignWrapper, HoverFrame, - PenaltyScore, - ScoreWrapper, } from '../styled' import { useCardPreview } from './hooks' import { getPrepareTimeFormat } from '../helpers' @@ -208,16 +206,11 @@ export const CardFrontside = ({ {team1InFavorites && } - {showScore && ( - - - {score?.team1.score ?? team1.score} - - - {score?.team1.penalty_score ?? team1.penalty_score} - - - )} + @@ -235,16 +228,11 @@ export const CardFrontside = ({ {team2InFavorites && } - {showScore && ( - - - {score?.team2.score ?? team2.score} - - - {score?.team2.penalty_score ?? team2.penalty_score} - - - )} + {!isMatchPage && ( diff --git a/src/features/MatchCard/Score/index.tsx b/src/features/MatchCard/Score/index.tsx new file mode 100644 index 00000000..75ddc818 --- /dev/null +++ b/src/features/MatchCard/Score/index.tsx @@ -0,0 +1,30 @@ +import { + MainScore, + ScoreWrapper, + PenaltyScore, +} from './styled' + +type Props = { + penaltyScore?: number | null, + score?: number | null, + showScore: boolean, +} + +export const Score = ({ + penaltyScore, + score, + showScore, +}: Props) => { + if (!showScore) return null + + return ( + + + {score} + + + {penaltyScore} + + + ) +} diff --git a/src/features/MatchCard/Score/styled.tsx b/src/features/MatchCard/Score/styled.tsx new file mode 100644 index 00000000..f745e040 --- /dev/null +++ b/src/features/MatchCard/Score/styled.tsx @@ -0,0 +1,31 @@ +import styled, { css } from 'styled-components/macro' + +import { isMobileDevice } from 'config/userAgent' + +export const MainScore = styled.div` + +${isMobileDevice + ? css` + display: flex; + justify-content: center; + ` + : ''}; +` + +export const ScoreWrapper = styled.div` + display: flex; + line-height: 1; +` + +export const PenaltyScore = styled.div` + font-weight: 400; + font-size: .55rem; + margin-left: 1px; + + ${isMobileDevice + ? css` + font-size: 10px; + ` + : ''}; +` + diff --git a/src/features/MatchCard/styled.tsx b/src/features/MatchCard/styled.tsx index 89a5f40c..a862e5e2 100644 --- a/src/features/MatchCard/styled.tsx +++ b/src/features/MatchCard/styled.tsx @@ -274,19 +274,6 @@ export const TeamName = styled(Name)` ${nameStyles} ` -export const ScoreWrapper = styled.div` - display: flex; - line-height: 1; -` - -export const Score = styled.div`` - -export const PenaltyScore = styled.div` - font-weight: 400; - font-size: .55rem; - margin-left: 1px; -` - export const TeamLogos = styled.div` display: ${({ isMatchPage }) => (isMatchPage ? 'none' : 'flex')}; align-items: center; -- 2.30.2