11import PlayThumbnail from './PlayThumbnail' ;
22import useFeaturedPlays from 'common/hooks/useFeaturedPlays' ;
33
4+ const PlayCardSkeleton = ( ) => (
5+ < li className = "play-card-skeleton" >
6+ < div className = "play-card-container max-w-sm bg-white rounded-xl overflow-hidden flex flex-col h-full" >
7+ < div className = "skeleton-image" />
8+ < div className = "p-5 flex flex-col flex-grow gap-3" >
9+ < div className = "skeleton-line" style = { { width : '40%' , height : '20px' } } />
10+ < div className = "skeleton-line" style = { { width : '70%' , height : '14px' } } />
11+ < div className = "skeleton-line" style = { { width : '90%' , height : '16px' } } />
12+ < div className = "skeleton-line" style = { { width : '80%' , height : '12px' } } />
13+ < div className = "skeleton-line" style = { { width : '60%' , height : '12px' } } />
14+ < div
15+ className = "skeleton-line"
16+ style = { { width : '100%' , height : '1px' , marginTop : 'auto' } }
17+ />
18+ < div style = { { display : 'flex' , justifyContent : 'space-between' } } >
19+ < div className = "skeleton-line" style = { { width : '30%' , height : '14px' } } />
20+ < div className = "skeleton-line" style = { { width : '20%' , height : '14px' } } />
21+ </ div >
22+ </ div >
23+ </ div >
24+ < style > { `
25+ .skeleton-image {
26+ width: 100%;
27+ height: 192px;
28+ background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
29+ background-size: 200% 100%;
30+ animation: shimmer 1.5s infinite;
31+ }
32+ .skeleton-line {
33+ border-radius: 4px;
34+ background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
35+ background-size: 200% 100%;
36+ animation: shimmer 1.5s infinite;
37+ }
38+ @keyframes shimmer {
39+ 0% { background-position: 200% 0; }
40+ 100% { background-position: -200% 0; }
41+ }
42+ ` } </ style >
43+ </ li >
44+ ) ;
45+
446const FeaturedPlays = ( ) => {
547 const [ loading , error , data ] = useFeaturedPlays ( ) ;
648 const success = ! loading && ! error && ! ! data . length ;
@@ -11,7 +53,7 @@ const FeaturedPlays = () => {
1153 Trending < strong > Plays</ strong >
1254 </ h2 >
1355 < ul className = "list-plays" >
14- { loading && < p > Loading... </ p > }
56+ { loading && [ 1 , 2 , 3 , 4 ] . map ( ( n ) => < PlayCardSkeleton key = { n } /> ) }
1557 { error && < p > { error ?. message ?? 'Something went wrong' } </ p > }
1658 { success && data ?. map ( ( play , index ) => < PlayThumbnail key = { index } play = { play } /> ) }
1759 </ ul >
0 commit comments