Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | 19x 19x 19x | import { ReactElement } from "react"; import { CardTrack, Carousel, FirstTrackContainer } from "components"; import { CardType } from "components/CardTrack/CardTrack"; import { ITrack } from "types/spotify"; import { divideArray, isCorruptedTrack } from "utils"; interface MainTracksProps { title: string; tracksRecommendations: ITrack[]; tracksInLibrary?: boolean[] | null; } export default function MainTracks({ title, tracksRecommendations, tracksInLibrary, }: Readonly<MainTracksProps>): ReactElement { const filteredTracks = tracksRecommendations?.filter( (track, index, self) => index === self.findIndex((t) => t.id === track.id) ); const allTracks = filteredTracks?.map((track) => { return { ...track, audio: track?.preview_url, corruptedTrack: isCorruptedTrack(track), }; }); return ( <Carousel title={title} gap={24}> {divideArray(filteredTracks, 5).map((tracks, i) => { const tracksId = tracks .slice(0, i) .map((track) => track.id) .join("-"); return ( <div className="tracks" key={`${tracksId}-${i}}`}> <FirstTrackContainer track={tracks?.[0]} preview={tracks?.[0]?.preview_url} position={i * 5} allTracks={allTracks} /> <div> {tracks?.map((track, chunkIndex) => { Iif (chunkIndex === 0 || chunkIndex > 4 || !track) { return null; } const index = i * 5 + chunkIndex; const uris = filteredTracks?.map((track) => track.uri ?? ""); return ( <CardTrack isTrackInLibrary={tracksInLibrary?.[index] ?? false} playlistUri="" track={track} key={`${tracksId}-${index}-${chunkIndex}}`} type={CardType.Presentation} position={index} isSingleTrack uris={uris} /> ); })} </div> <style jsx>{` .tracks { display: grid; grid-template-columns: 49% 49%; width: 100%; grid-gap: 20px; margin: 10px 0 30px; min-width: calc(100% - 24px); } @media (max-width: 1000px) { .tracks { grid-template-columns: 100%; } } `}</style> </div> ); })} </Carousel> ); } |