feat(#2638): add scroll to live match and change cardfrontside in tab video

keep-around/fdb88b04b32b9392e76795099e2ec47c9856b38b
Andrei Dekterev 3 years ago
parent 11cfad5212
commit 1878f9ef38
  1. 21
      src/features/MatchCard/CardFrontside/index.tsx
  2. 27
      src/features/MatchCard/styled.tsx
  3. 5
      src/features/MatchPage/components/LiveMatch/index.tsx
  4. 25
      src/features/MatchPage/components/MatchDescription/index.tsx
  5. 10
      src/features/MatchPage/components/MatchDescription/styled.tsx
  6. 9
      src/features/StreamPlayer/hooks/index.tsx

@ -94,8 +94,9 @@ export const CardFrontside = ({
<CardWrapperOuter <CardWrapperOuter
onClick={onClick} onClick={onClick}
onKeyPress={onKeyPress} onKeyPress={onKeyPress}
isMatchPage={isMatchPage}
> >
<CardWrapper> <CardWrapper isMatchPage={isMatchPage}>
<HoverFrame /> <HoverFrame />
<PreviewWrapper> <PreviewWrapper>
{previewImage && ( {previewImage && (
@ -107,7 +108,7 @@ export const CardFrontside = ({
{access === MatchAccess.NoCountryAccess {access === MatchAccess.NoCountryAccess
? <NoAccessMessage /> ? <NoAccessMessage />
: ( : (
<TeamLogos> <TeamLogos isMatchPage={isMatchPage}>
<TeamLogo <TeamLogo
id={team1.id} id={team1.id}
nameAsTitle nameAsTitle
@ -137,8 +138,8 @@ export const CardFrontside = ({
)} )}
</MatchTimeInfo> </MatchTimeInfo>
</PreviewWrapper> </PreviewWrapper>
<Info> <Info isMatchPage={isMatchPage}>
<Teams> <Teams isMatchPage={isMatchPage}>
<Team> <Team>
<NameSignWrapper> <NameSignWrapper>
<TeamName nameObj={team1} /> <TeamName nameObj={team1} />
@ -154,11 +155,13 @@ export const CardFrontside = ({
{showScore && <Score>{team2.score}</Score>} {showScore && <Score>{team2.score}</Score>}
</Team> </Team>
</Teams> </Teams>
<TournamentSubtitle {!isMatchPage && (
sportType={sportType} <TournamentSubtitle
countryId={countryId} sportType={sportType}
tournament={tournament} countryId={countryId}
/> tournament={tournament}
/>
)}
</Info> </Info>
</CardWrapper> </CardWrapper>
</CardWrapperOuter> </CardWrapperOuter>

@ -6,11 +6,16 @@ import { isMobileDevice } from 'config/userAgent'
import { Name } from 'features/Name' import { Name } from 'features/Name'
import { ProfileLogo } from 'features/ProfileLogo' import { ProfileLogo } from 'features/ProfileLogo'
type CardProps = {
isMatchPage?: boolean,
}
export const CardWrapperOuter = styled.li.attrs({ export const CardWrapperOuter = styled.li.attrs({
tabIndex: 0, tabIndex: 0,
})` })<CardProps>`
padding-top: 100%; padding-top: ${({ isMatchPage }) => (isMatchPage ? 0 : '100%')};
position: relative; position: relative;
${isMobileDevice ${isMobileDevice
? css` ? css`
width: 100%; width: 100%;
@ -28,13 +33,13 @@ export const CardWrapperOuter = styled.li.attrs({
: ''}; : ''};
` `
export const CardWrapper = styled.div` export const CardWrapper = styled.div<CardProps>`
position: absolute; position: ${({ isMatchPage }) => (isMatchPage ? 'relative' : 'absolute')};
top: 0; top: 0;
left: 0; left: 0;
bottom: 0; bottom: 0;
right: 0; right: 0;
padding-bottom: 0.75rem; padding-bottom: ${({ isMatchPage }) => (isMatchPage ? '0' : '0.75rem')};
border-radius: 2px; border-radius: 2px;
background-color: #3F3F3F; background-color: #3F3F3F;
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.4); box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.4);
@ -133,10 +138,10 @@ export const Time = styled.span`
margin: 0 0.2rem; margin: 0 0.2rem;
` `
export const Info = styled.div` export const Info = styled.div<CardProps>`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 0.85rem 0.472rem 0 0.519rem; padding: ${({ isMatchPage }) => (isMatchPage ? '1.2rem 0.472rem 1.2rem 0.519rem' : '0.85rem 0.472rem 0 0.519rem')};
color: #fff; color: #fff;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
@ -178,8 +183,8 @@ const nameStyles = css`
overflow: hidden; overflow: hidden;
` `
export const Teams = styled.div` export const Teams = styled.div<CardProps>`
margin-bottom: 0.567rem; margin-bottom: ${({ isMatchPage }) => (isMatchPage ? '0' : '0.567rem')};
${isMobileDevice ${isMobileDevice
? css` ? css`
margin-bottom: 15px; margin-bottom: 15px;
@ -215,11 +220,11 @@ export const TeamName = styled(Name)`
export const Score = styled.div`` export const Score = styled.div``
export const TeamLogos = styled.div` export const TeamLogos = styled.div<CardProps>`
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin: 0.71rem auto 0 auto; margin: ${({ isMatchPage }) => (isMatchPage ? '1.5rem auto 1rem auto' : '0.71rem auto 0 auto')};
z-index: 1; z-index: 1;
` `

@ -13,6 +13,7 @@ import { Container } from '../../styled'
import { useLiveMatch } from './hooks' import { useLiveMatch } from './hooks'
import { TournamentData } from '../../types' import { TournamentData } from '../../types'
import { MatchDescription } from '../MatchDescription'
import { MatchProfileCardMobile } from '../MatchProfileCardMobile' import { MatchProfileCardMobile } from '../MatchProfileCardMobile'
type Props = { type Props = {
@ -67,7 +68,9 @@ export const LiveMatch = ({
/> />
) )
)} )}
{isMobileDevice ? <MatchProfileCardMobile profile={profile} /> : null} {isMobileDevice
? <MatchProfileCardMobile profile={profile} /> : (
<MatchDescription profile={profile} />)}
</Container> </Container>
<MatchSidePlaylists <MatchSidePlaylists

@ -6,7 +6,6 @@ import type { MatchInfo } from 'requests/getMatchInfo'
import { Name } from 'features/Name' import { Name } from 'features/Name'
import { SportIcon } from 'components/SportIcon/SportIcon' import { SportIcon } from 'components/SportIcon/SportIcon'
import { T9n } from 'features/T9n'
import { useAuthStore } from 'features/AuthStore' import { useAuthStore } from 'features/AuthStore'
import { useMatchSwitchesStore } from 'features/MatchSwitches' import { useMatchSwitchesStore } from 'features/MatchSwitches'
@ -21,7 +20,6 @@ import {
Description, Description,
DescriptionInnerBlock, DescriptionInnerBlock,
MatchDate, MatchDate,
StyledDash,
StyledLink, StyledLink,
Score, Score,
Title, Title,
@ -46,17 +44,15 @@ export const MatchDescription = ({
const { const {
country_id, country_id,
date, date,
live,
team1, team1,
team2, team2,
tournament, tournament,
} = profile } = profile
const isChangedTimeFormat = includes(['US', 'CA'], user?.profile.country_code) const isChangedTimeFormat = includes(['US', 'CA'], user?.profile.country_code)
const localDate = format(parseDate(date), const localDate = format(parseDate(date), 'MMMM d, y')
live ? 'HH:mm' : 'MMMM d, y')
const changedTimeFormat = format(parseDate(date), const changedTimeFormat = format(parseDate(date),
isChangedTimeFormat ? 'hh:mm aaa' : 'HH:mm') isChangedTimeFormat ? 'h:mm aaa' : 'HH:mm')
return ( return (
<Description> <Description>
@ -69,9 +65,13 @@ export const MatchDescription = ({
> >
<Name nameObj={team1} /> <Name nameObj={team1} />
</StyledLink> </StyledLink>
{!isScoreHidden && <Score>{team1.score}</Score>} <Score>
<StyledDash isScoreHidden={isScoreHidden}>-</StyledDash> {
{!isScoreHidden && <Score>{team2.score}</Score>} isScoreHidden || !team1.score || !team2.score
? '-'
: `${team1.score} - ${team2.score}`
}
</Score>
<StyledLink <StyledLink
id={team2.id} id={team2.id}
profileType={ProfileTypes.TEAMS} profileType={ProfileTypes.TEAMS}
@ -79,7 +79,6 @@ export const MatchDescription = ({
> >
<Name nameObj={team2} /> <Name nameObj={team2} />
</StyledLink> </StyledLink>
{live ? '\u00a0|\u00a0LIVE STREAM' : ''}
</Title> </Title>
<Tournament> <Tournament>
<SportIcon sport={sportType} /> <SportIcon sport={sportType} />
@ -96,11 +95,7 @@ export const MatchDescription = ({
</Tournament> </Tournament>
</DescriptionInnerBlock> </DescriptionInnerBlock>
<Views> <Views>
{ <Time>{changedTimeFormat}</Time>
live
? <T9n t='started_streaming_at' />
: <Time>{changedTimeFormat}</Time>
}
<MatchDate>{localDate}</MatchDate> <MatchDate>{localDate}</MatchDate>
</Views> </Views>
</Description> </Description>

@ -35,11 +35,6 @@ export const StyledLink = styled(ProfileLink)`
} }
` `
export const StyledDash = styled.span<{isScoreHidden?: boolean}>`
color: #fff;
margin: ${({ isScoreHidden }) => (isScoreHidden ? '0 10px' : '0')};
`
export const Title = styled.div` export const Title = styled.div`
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -56,11 +51,6 @@ export const Title = styled.div`
opacity: 0.7; opacity: 0.7;
pointer-events: none; pointer-events: none;
} }
&:hover > ${StyledDash}:not(:hover){
opacity: 0.7;
pointer-events: none;
}
` `
export const Tournament = styled.span` export const Tournament = styled.span`

@ -368,6 +368,15 @@ export const useVideoPlayer = ({
} }
}, [setPlayerState]) }, [setPlayerState])
useEffect(() => {
if (ready && videoRef) {
videoRef.current?.scrollIntoView({
behavior: 'smooth',
block: 'start',
})
}
}, [ready, videoRef])
return { return {
activeChapterIndex, activeChapterIndex,
allPlayedProgress: playedProgress + getActiveChapter().startMs, allPlayedProgress: playedProgress + getActiveChapter().startMs,

Loading…
Cancel
Save