feat: 🎸 ott-2697-mobileMatches

keep-around/b214ac7012ef42593bee62c207888a2593bc5a38
Zoia R 3 years ago
parent 2003b8eba5
commit a137a9036e
  1. 25
      src/features/MatchCard/CardFrontside/MatchCardMobile/index.tsx
  2. 25
      src/features/MatchCard/CardFrontside/MatchCardMobile/styled.tsx
  3. 9
      src/features/MatchCard/CardFrontside/index.tsx
  4. 15
      src/features/MatchCard/helpers/getPrepareDateFormat.tsx
  5. 10
      src/features/MatchCard/hooks.tsx
  6. 2
      src/features/MatchCard/index.tsx
  7. 4
      src/features/MatchSidePlaylists/index.tsx

@ -16,6 +16,8 @@ import { getCardColor } from 'helpers/getCardColor'
import { NoAccessMessage } from '../../NoAccessMessage' import { NoAccessMessage } from '../../NoAccessMessage'
import { getPrepareTimeFormat } from '../../helpers' import { getPrepareTimeFormat } from '../../helpers'
import { getPrepareDateFormat } from '../../helpers/getPrepareDateFormat'
import { import {
CardWrapperOuter, CardWrapperOuter,
CardWrapper, CardWrapper,
@ -38,11 +40,13 @@ import {
NameSignWrapper, NameSignWrapper,
HoverFrame, HoverFrame,
ScDollar, ScDollar,
MobTime,
} from './styled' } from './styled'
import { useCardPreview } from '../hooks' import { useCardPreview } from '../hooks'
type Props = { type Props = {
isNeedFormatTimeChanged: boolean, isNeedFormatTimeChanged: boolean,
isOwnedMatches: boolean,
match: Match, match: Match,
onClick: () => void, onClick: () => void,
onKeyPress: (e: KeyboardEvent<HTMLLIElement>) => void, onKeyPress: (e: KeyboardEvent<HTMLLIElement>) => void,
@ -50,6 +54,7 @@ type Props = {
export const CardFrontsideMobile = ({ export const CardFrontsideMobile = ({
isNeedFormatTimeChanged, isNeedFormatTimeChanged,
isOwnedMatches,
match, match,
onClick, onClick,
onKeyPress, onKeyPress,
@ -58,7 +63,6 @@ export const CardFrontsideMobile = ({
const { const {
access, access,
date, date,
formattedDate,
live, live,
preview, preview,
previewURL, previewURL,
@ -89,6 +93,11 @@ export const CardFrontsideMobile = ({
time, time,
}) })
const prepareDate = getPrepareDateFormat({
date,
isNeedFormatTimeChanged,
})
return ( return (
<CardWrapperOuter onClick={onClick} onKeyPress={onKeyPress}> <CardWrapperOuter onClick={onClick} onKeyPress={onKeyPress}>
<CardWrapper> <CardWrapper>
@ -117,15 +126,19 @@ export const CardFrontsideMobile = ({
/> />
</TeamLogos> </TeamLogos>
)} )}
<MatchTimeInfo> <MatchTimeInfo isOwnedMatches={isOwnedMatches}>
<MatchDate isHomePage={isHomePage}> <MatchDate
{isHomePage || isMatchPage ? null : formattedDate} isHomePage={isHomePage}
isOwnedMatches={isOwnedMatches}
>
{isHomePage || isMatchPage ? null : prepareDate}
{isOwnedMatches && <MobTime>{prepareTime}</MobTime> }
</MatchDate>
{live && ( {live && (
<LiveSign> <LiveSign>
<T9n t='live' /> <T9n t='live' />
</LiveSign> </LiveSign>
)} )}
</MatchDate>
</MatchTimeInfo> </MatchTimeInfo>
</PreviewWrapper> </PreviewWrapper>
<Info> <Info>
@ -146,7 +159,7 @@ export const CardFrontsideMobile = ({
</Team> </Team>
</Teams> </Teams>
<SecondaryInfo> <SecondaryInfo>
<Time>{prepareTime}</Time> {isHomePage || isMatchPage ? <Time>{prepareTime}</Time> : null}
{access === MatchAccess.CanBuyMatch && ( {access === MatchAccess.CanBuyMatch && (
<BuyMatchBadge> <BuyMatchBadge>
<ScDollar refIcon='Dollar' /> <ScDollar refIcon='Dollar' />

@ -99,17 +99,21 @@ export const Preview = styled.img`
: ''}; : ''};
` `
export const MatchTimeInfo = styled.div` type MatchTimeInfoProps = {
isOwnedMatches?: boolean,
}
export const MatchTimeInfo = styled.div<MatchTimeInfoProps>`
width: 100%; width: 100%;
position: absolute; position: absolute;
top: 0.519rem; padding: ${({ isOwnedMatches }) => (isOwnedMatches ? '0.9rem' : '0.519rem')};
padding: 0 0.519rem;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
` `
type MatchDateProps = { type MatchDateProps = {
isHomePage?: boolean, isHomePage?: boolean,
isOwnedMatches?: boolean,
} }
export const MatchDate = styled.div<MatchDateProps>` export const MatchDate = styled.div<MatchDateProps>`
@ -117,7 +121,7 @@ export const MatchDate = styled.div<MatchDateProps>`
height: 0.9rem; height: 0.9rem;
border-radius: 2px; border-radius: 2px;
padding: ${({ isHomePage }) => (!isHomePage ? '0 0.27rem' : '')}; padding: ${({ isHomePage }) => (!isHomePage ? '0 0.27rem' : '')};
font-weight: bold; font-weight: ${({ isOwnedMatches }) => (isOwnedMatches ? '500' : 'bold')};
font-size: 0.472rem; font-size: 0.472rem;
line-height: 0.567rem; line-height: 0.567rem;
letter-spacing: 0.05em; letter-spacing: 0.05em;
@ -141,6 +145,15 @@ export const MatchDate = styled.div<MatchDateProps>`
font-size: 7px; font-size: 7px;
` `
: ''}; : ''};
${({ isOwnedMatches }) => (isOwnedMatches
? css`
background-color: #6D6D6D;
width: fit-content;
margin-left: 0;
`
: '')}
` `
type LiveType = { type LiveType = {
@ -167,6 +180,10 @@ export const Time = styled.span`
` `
: ''}; : ''};
` `
export const MobTime = styled.span`
margin-left: 0.8rem;
font-weight: bold;
`
export const Info = styled.div` export const Info = styled.div`
display: flex; display: flex;

@ -39,6 +39,7 @@ import {
} from '../styled' } from '../styled'
import { useCardPreview } from './hooks' import { useCardPreview } from './hooks'
import { getPrepareTimeFormat } from '../helpers' import { getPrepareTimeFormat } from '../helpers'
import { getPrepareDateFormat } from '../helpers/getPrepareDateFormat'
type Props = { type Props = {
isNeedFormatTimeChanged: boolean, isNeedFormatTimeChanged: boolean,
@ -58,7 +59,6 @@ export const CardFrontside = ({
access, access,
countryId, countryId,
date, date,
formattedDate,
live, live,
preview, preview,
previewURL, previewURL,
@ -92,6 +92,11 @@ export const CardFrontside = ({
time, time,
}) })
const prepareDate = getPrepareDateFormat({
date,
isNeedFormatTimeChanged,
})
return ( return (
<CardWrapperOuter <CardWrapperOuter
onClick={onClick} onClick={onClick}
@ -130,7 +135,7 @@ export const CardFrontside = ({
{access === MatchAccess.CanBuyMatch && <BuyMatchBadge />} {access === MatchAccess.CanBuyMatch && <BuyMatchBadge />}
<MatchTimeInfo> <MatchTimeInfo>
<MatchDate isHomePage={isHomePage}> <MatchDate isHomePage={isHomePage}>
{isHomePage || isMatchPage ? null : formattedDate} {isHomePage || isMatchPage ? null : prepareDate}
<Time>{prepareTime}</Time> <Time>{prepareTime}</Time>
</MatchDate> </MatchDate>
{live && ( {live && (

@ -0,0 +1,15 @@
import format from 'date-fns/format'
type prepareTimeFormat = {
date: Date,
isNeedFormatTimeChanged: boolean,
}
export const getPrepareDateFormat = ({
date,
isNeedFormatTimeChanged,
}: prepareTimeFormat) => (
isNeedFormatTimeChanged
? format(date, 'MM.dd.yy')
: format(date, 'dd.MM.yy')
)

@ -4,7 +4,7 @@ import { useHistory } from 'react-router-dom'
import includes from 'lodash/includes' import includes from 'lodash/includes'
import { ProfileTypes } from 'config' import { PAGES, ProfileTypes } from 'config'
import type { Match } from 'features/Matches' import type { Match } from 'features/Matches'
import { useMatchPopupStore } from 'features/MatchPopup' import { useMatchPopupStore } from 'features/MatchPopup'
@ -12,6 +12,7 @@ import { useBuyMatchPopupStore } from 'features/BuyMatchPopup'
import { useAuthStore } from 'features/AuthStore' import { useAuthStore } from 'features/AuthStore'
import { getProfileUrl } from 'features/ProfileLink/helpers' import { getProfileUrl } from 'features/ProfileLink/helpers'
import { MatchAccess } from 'features/Matches/helpers/getMatchClickAction' import { MatchAccess } from 'features/Matches/helpers/getMatchClickAction'
import { checkPage } from 'helpers/checkPage'
export const useCard = (match: Match) => { export const useCard = (match: Match) => {
const { openMatchPopup } = useMatchPopupStore() const { openMatchPopup } = useMatchPopupStore()
@ -62,8 +63,15 @@ export const useCard = (match: Match) => {
const isNeedFormatTimeChanged = includes(['US', 'CA'], user?.profile.country_code) const isNeedFormatTimeChanged = includes(['US', 'CA'], user?.profile.country_code)
const isPlayerPage = checkPage(PAGES.player)
const isTeamPage = checkPage(PAGES.team)
const isTournamentPage = checkPage(PAGES.tournament)
const isOwnedMatches = isPlayerPage || isTeamPage || isTournamentPage
return { return {
isNeedFormatTimeChanged, isNeedFormatTimeChanged,
isOwnedMatches,
onKeyPress, onKeyPress,
onMatchClick, onMatchClick,
} }

@ -13,6 +13,7 @@ type Props = {
export const MatchCard = ({ match }: Props) => { export const MatchCard = ({ match }: Props) => {
const { const {
isNeedFormatTimeChanged, isNeedFormatTimeChanged,
isOwnedMatches,
onKeyPress, onKeyPress,
onMatchClick, onMatchClick,
} = useCard(match) } = useCard(match)
@ -25,6 +26,7 @@ export const MatchCard = ({ match }: Props) => {
onClick={onMatchClick} onClick={onMatchClick}
onKeyPress={onKeyPress} onKeyPress={onKeyPress}
isNeedFormatTimeChanged={isNeedFormatTimeChanged} isNeedFormatTimeChanged={isNeedFormatTimeChanged}
isOwnedMatches={isOwnedMatches}
/> />
) )
} }

@ -64,8 +64,8 @@ export const MatchSidePlaylists = ({
? (screenLandscape === 90 || screenLandscape === -90) ? (screenLandscape === 90 || screenLandscape === -90)
: (screenLandscape === 'landscape-primary' || screenLandscape === 'landscape-secondary') : (screenLandscape === 'landscape-primary' || screenLandscape === 'landscape-secondary')
if (yOffset && yOffset > 10 && !isScreenLandscape) hideProfileCard() if (Number(yOffset) < 10) showProfileCard()
if (yOffset && yOffset < 10) showProfileCard() if (Number(yOffset) > 10 && !isScreenLandscape) hideProfileCard()
}, },
event: 'scroll', event: 'scroll',
target: containerRef, target: containerRef,

Loading…
Cancel
Save