-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSongCard.jsx
49 lines (43 loc) · 1.67 KB
/
SongCard.jsx
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
import { Link } from 'react-router-dom';
import { useDispatch } from 'react-redux/es/exports';
import PlayPause from './PlayPause';
import { playPause, setActiveSong } from '../redux/features/playerSlice';
const SongCard = ({ song, activeSong, isPlaying, data, i }) => {
const dispatch = useDispatch();
const handlePauseClick = () => {
dispatch(playPause(false));
};
const handlePlayClick = () => {
dispatch(setActiveSong({ song, data, i }));
dispatch(playPause(true));
};
return (
<div className="flex flex-col w-[250px] p-4 bg-white/5 bg-opacity-80 backdrop-blur-sm animate-slideup rounded-lg cursor-pointer">
<div className="relative w-full h-56 group">
<div className={`absolute inset-0 justify-center items-center bg-black bg-opacity-50 group-hover:flex ${activeSong?.title === song.title ? 'flex bg-black bg-opacity-70' : 'hidden'}`}>
<PlayPause
isPlaying={isPlaying}
activeSong={activeSong}
song={song}
handlePause={handlePauseClick}
handlePlay={handlePlayClick}
/>
</div>
<img src={song.images?.coverart} alt="song_img" />
</div>
<div className="mt-4 flex flex-col">
<p className="font-semibold text-lg text-white truncate">
<Link to={`/songs/${song?.key}`}>
{song.title}
</Link>
</p>
<p className="text-sm truncate text-gray-300 mt-1">
<Link to={song.artists ? `/artists/${song?.artists[0]?.admid}` : '/top-artists'}>
{song.subtitle}
</Link>
</p>
</div>
</div>
);
};
export default SongCard;