-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSongComponent.svelte
More file actions
78 lines (68 loc) · 1.97 KB
/
SongComponent.svelte
File metadata and controls
78 lines (68 loc) · 1.97 KB
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
<script>
// @ts-nocheck
import { getContext, onMount, setContext } from "svelte";
import { currentSong, isPlaying, isLoading } from "../scripts/playbackService";
export let song;
let playOrPauseSong;
onMount(() => {
playOrPauseSong = getContext("playOrPauseSong");
});
$: $isPlaying;
$: $currentSong;
$: $isLoading;
</script>
{#if song}
<div class="row mb-3 song-component">
<div class="col-2">
<button on:click={() => playOrPauseSong(song.id)} class="btn btn-dark w-100 play-button">
{#if $currentSong && $currentSong.id === song.id && $isPlaying}
<i class="fa-solid fa-pause"></i>
{:else if $isLoading && $currentSong.id === song.id}
<i class="fa-solid fa-spinner fa-spin"></i>
{:else}
<i class="fa-solid fa-play"></i>
{/if}
</button>
</div>
<div class="col-10 border border-1 rounded rounded-2 cursor" style={$currentSong && $currentSong.id === song.id ? "border-color:#1CC558 !important;" : "border-color: gray !important;"}>
<div class="text-lg-start">
<p style={$currentSong && $currentSong.id === song.id ? "color:#1CC558;" : ""}>{song.name}</p>
</div>
</div>
</div>
{:else}
<p>No song available.</p>
{/if}
<style>
.song-component {
height: 2.5rem;
color: #B3B3B3;
font-weight: bolder;
}
.song-component p {
font-size: 0.8rem;
margin: 5px;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.play-button {
font-size: 1.5rem;
width: 3rem;
height: 3rem;
display: flex;
color: #1cc558;
background-color: transparent !important;
border: none !important;
align-items: center;
justify-content: center;
border-left: #1CC558 2px solid !important;
}
.play-button:hover {
background-color: rgba(28, 197, 88, 0.1) !important;
transition: background-color 0.3s ease;
}
</style>