-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a43136
commit 329411a
Showing
11 changed files
with
118 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use client' | ||
|
||
import { TriangleIcon } from '@icons' | ||
|
||
export function PlayBtn({ | ||
onPlay, | ||
}: { | ||
onPlay: () => void | ||
}) { | ||
return ( | ||
<button | ||
className="aspect-square h-full w-full flex items-center justify-center" | ||
onClick={onPlay} | ||
> | ||
<div className="h-full w-full bg-green-500 rounded-full transition-all delay-75 flex justify-center items-center hover:scale-105"> | ||
<TriangleIcon className="fill-neutral-900 transition-all delay-75 w-6 h-6 text-center flex justify-center items-center" /> | ||
</div> | ||
</button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
'use client' | ||
|
||
import { usePlayerStore } from '@hooks' | ||
import { useGetSongById, useLoadSongUrl, usePlayerStore } from '@hooks' | ||
|
||
export function Player() { | ||
const player = usePlayerStore() | ||
|
||
const { song, isLoading } = useGetSongById(player.activeId ?? null) | ||
|
||
const songUrl = useLoadSongUrl(song!) | ||
|
||
if (!song || isLoading || !player.activeId || !songUrl) return null | ||
|
||
return ( | ||
<section className="flex items-center justify-center bg-neutral-950 absolute bottom-0 left-0 h-44 w-full"> | ||
player | ||
<section className="flex items-center justify-center bg-neutral-950 fixed bottom-0 left-0 h-20 w-full py-2 px-2"> | ||
<h4>{song.title}</h4> | ||
</section> | ||
) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Song } from '@models' | ||
import { useSessionContext } from '@supabase/auth-helpers-react' | ||
|
||
export function useLoadSongUrl(song: Song) { | ||
const { supabaseClient } = useSessionContext() | ||
|
||
if (!song || !supabaseClient || !song.song_path) return '' | ||
|
||
const { data } = supabaseClient.storage | ||
.from('songs') | ||
.getPublicUrl(song.song_path) | ||
|
||
return data.publicUrl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Song } from '@models' | ||
import { usePlayerStore } from '@hooks' | ||
|
||
export function useOnPlay(songs: Song[]) { | ||
const player = usePlayerStore() | ||
|
||
function onPlay(id: string) { | ||
player.setId(id) | ||
player.setIds(songs.map((song) => song.id)) | ||
} | ||
|
||
return onPlay | ||
} |