|
|
|
@ -1,10 +1,13 @@ |
|
|
|
import { |
|
|
|
import { |
|
|
|
useCallback, |
|
|
|
useCallback, |
|
|
|
useEffect, |
|
|
|
useEffect, |
|
|
|
|
|
|
|
useLayoutEffect, |
|
|
|
useRef, |
|
|
|
useRef, |
|
|
|
useState, |
|
|
|
useState, |
|
|
|
} from 'react' |
|
|
|
} from 'react' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import isEmpty from 'lodash/isEmpty' |
|
|
|
|
|
|
|
|
|
|
|
import { MatchesSlider } from 'features/MatchesSlider' |
|
|
|
import { MatchesSlider } from 'features/MatchesSlider' |
|
|
|
import { TimelineTournamentList, useTimeline } from 'features/MatchesTimeline/hooks' |
|
|
|
import { TimelineTournamentList, useTimeline } from 'features/MatchesTimeline/hooks' |
|
|
|
import { InfiniteScroll } from 'features/InfiniteScroll' |
|
|
|
import { InfiniteScroll } from 'features/InfiniteScroll' |
|
|
|
@ -24,6 +27,10 @@ import { |
|
|
|
} from './styled' |
|
|
|
} from './styled' |
|
|
|
|
|
|
|
|
|
|
|
const TOURNAMENT_LIMIT = 10 |
|
|
|
const TOURNAMENT_LIMIT = 10 |
|
|
|
|
|
|
|
const MATCH_COUNT = 6 |
|
|
|
|
|
|
|
const PADDING = 30 |
|
|
|
|
|
|
|
const GAP_COUNT = 5 |
|
|
|
|
|
|
|
const SLIDER_ITEM_GAP = 0.9 // rem
|
|
|
|
|
|
|
|
|
|
|
|
export const MatchesTimeline = () => { |
|
|
|
export const MatchesTimeline = () => { |
|
|
|
const { |
|
|
|
const { |
|
|
|
@ -36,6 +43,25 @@ export const MatchesTimeline = () => { |
|
|
|
|
|
|
|
|
|
|
|
const pageRef = useRef(0) |
|
|
|
const pageRef = useRef(0) |
|
|
|
const isLastPageRef = useRef(false) |
|
|
|
const isLastPageRef = useRef(false) |
|
|
|
|
|
|
|
const wrapperRef = useRef<HTMLDivElement>(null) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [cardSize, setCardSize] = useState(0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// вычисляем размеры плитки
|
|
|
|
|
|
|
|
useLayoutEffect(() => { |
|
|
|
|
|
|
|
const offsetWidth = wrapperRef.current?.offsetWidth |
|
|
|
|
|
|
|
const ulItemGapFromRem = SLIDER_ITEM_GAP * parseFloat( |
|
|
|
|
|
|
|
getComputedStyle(document.documentElement).fontSize, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (offsetWidth) { |
|
|
|
|
|
|
|
const size = Math.round( |
|
|
|
|
|
|
|
((offsetWidth - (ulItemGapFromRem * GAP_COUNT) - PADDING) / MATCH_COUNT), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setCardSize(size) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
const getTournaments = useCallback(() => tournamentList.slice( |
|
|
|
const getTournaments = useCallback(() => tournamentList.slice( |
|
|
|
pageRef.current * TOURNAMENT_LIMIT, |
|
|
|
pageRef.current * TOURNAMENT_LIMIT, |
|
|
|
@ -66,20 +92,23 @@ export const MatchesTimeline = () => { |
|
|
|
} |
|
|
|
} |
|
|
|
}, [getTournaments, tournamentList]) |
|
|
|
}, [getTournaments, tournamentList]) |
|
|
|
|
|
|
|
|
|
|
|
if (isTimelineFetching) { |
|
|
|
|
|
|
|
return <Loading><T9n t='loading' />...</Loading> |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<InfiniteScroll fullPageScroll onFetchMore={getMoreTournaments}> |
|
|
|
<InfiniteScroll fullPageScroll onFetchMore={getMoreTournaments}> |
|
|
|
<Wrapper> |
|
|
|
<Wrapper ref={wrapperRef}> |
|
|
|
{onlineUpcomingMatches.length > 0 && ( |
|
|
|
{isTimelineFetching && <Loading><T9n t='loading' />...</Loading>} |
|
|
|
|
|
|
|
{(!isEmpty(onlineUpcomingMatches)) && ( |
|
|
|
<RowWrapper> |
|
|
|
<RowWrapper> |
|
|
|
<Content> |
|
|
|
<Content> |
|
|
|
<Tournament isOnlineUpcoming> |
|
|
|
<Tournament |
|
|
|
|
|
|
|
size={cardSize} |
|
|
|
|
|
|
|
isOnlineUpcoming |
|
|
|
|
|
|
|
> |
|
|
|
LIVE & UPCOMING |
|
|
|
LIVE & UPCOMING |
|
|
|
</Tournament> |
|
|
|
</Tournament> |
|
|
|
<MatchesSlider matches={onlineUpcomingMatches} /> |
|
|
|
<MatchesSlider |
|
|
|
|
|
|
|
cardSize={cardSize} |
|
|
|
|
|
|
|
matches={onlineUpcomingMatches} |
|
|
|
|
|
|
|
/> |
|
|
|
</Content> |
|
|
|
</Content> |
|
|
|
</RowWrapper> |
|
|
|
</RowWrapper> |
|
|
|
)} |
|
|
|
)} |
|
|
|
@ -99,14 +128,20 @@ export const MatchesTimeline = () => { |
|
|
|
/> |
|
|
|
/> |
|
|
|
</TournamentSubtitleWrapper> |
|
|
|
</TournamentSubtitleWrapper> |
|
|
|
<Content> |
|
|
|
<Content> |
|
|
|
<Tournament gradientColor={tournament.color}> |
|
|
|
<Tournament |
|
|
|
|
|
|
|
size={cardSize} |
|
|
|
|
|
|
|
gradientColor={tournament.color} |
|
|
|
|
|
|
|
> |
|
|
|
<TournamentLogo |
|
|
|
<TournamentLogo |
|
|
|
id={tournament_id} |
|
|
|
id={tournament_id} |
|
|
|
profileType={ProfileTypes.TOURNAMENTS} |
|
|
|
profileType={ProfileTypes.TOURNAMENTS} |
|
|
|
sportType={sport_id} |
|
|
|
sportType={sport_id} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</Tournament> |
|
|
|
</Tournament> |
|
|
|
<MatchesSlider matches={matches} /> |
|
|
|
<MatchesSlider |
|
|
|
|
|
|
|
cardSize={cardSize} |
|
|
|
|
|
|
|
matches={matches} |
|
|
|
|
|
|
|
/> |
|
|
|
</Content> |
|
|
|
</Content> |
|
|
|
</RowWrapper> |
|
|
|
</RowWrapper> |
|
|
|
))} |
|
|
|
))} |
|
|
|
|