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;