Skip to content

Commit 2eb51ff

Browse files
Add skeletons to trending winners (#13726)
1 parent 06ed20a commit 2eb51ff

1 file changed

Lines changed: 39 additions & 5 deletions

File tree

packages/web/src/pages/trending-page/components/desktop/WinnersView.tsx

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useCallback } from 'react'
1+
import { useCallback, useEffect } from 'react'
22

33
import { useTrendingWinners } from '@audius/common/api'
44
import {
@@ -22,6 +22,10 @@ import EndOfLineup from 'components/lineup/EndOfLineup'
2222
import Lineup from 'components/lineup/Lineup'
2323
import { useLineupProps } from 'components/lineup/hooks'
2424
import { LineupVariant } from 'components/lineup/types'
25+
import { TrackTile as DesktopTrackTile } from 'components/track/desktop/TrackTile'
26+
import { TrackTile as MobileTrackTile } from 'components/track/mobile/TrackTile'
27+
import { TrackTileSize } from 'components/track/types'
28+
import { useIsMobile } from 'hooks/useIsMobile'
2529

2630
const { getLineup } = trendingWinnersPageLineupSelectors
2731

@@ -95,6 +99,8 @@ export const WinnersView = ({
9599
const lineupProps = useTrendingWinnersLineup(
96100
containerRef?.current ?? undefined
97101
)
102+
const isMobile = useIsMobile()
103+
const TrackTileComponent = isMobile ? MobileTrackTile : DesktopTrackTile
98104

99105
useEffect(() => {
100106
if (tracks && tracks.length > 0) {
@@ -191,10 +197,38 @@ export const WinnersView = ({
191197
</Paper>
192198

193199
{isPending ? (
194-
<Flex column gap='m'>
195-
{[1, 2, 3, 4, 5].map((i) => (
196-
<Flex key={i} h={128} alignItems='center' gap='l' p='s' />
197-
))}
200+
<Flex
201+
column
202+
gap='m'
203+
as='ul'
204+
css={{ listStyle: 'none', margin: 0, padding: 0 }}
205+
>
206+
{Array(5)
207+
.fill(null)
208+
.map((_, i) => (
209+
<Flex
210+
key={i}
211+
as='li'
212+
w='100%'
213+
css={{ '& > *': { width: '100%', minWidth: 0 } }}
214+
>
215+
<TrackTileComponent
216+
uid={`skeleton-winners-${i}`}
217+
id={-1}
218+
index={i}
219+
size={TrackTileSize.LARGE}
220+
statSize='large'
221+
ordered
222+
togglePlay={() => {}}
223+
isLoading
224+
hasLoaded={() => {}}
225+
isTrending
226+
isFeed={false}
227+
isActive={false}
228+
noShimmer
229+
/>
230+
</Flex>
231+
))}
198232
</Flex>
199233
) : (
200234
<div>

0 commit comments

Comments
 (0)