-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add play/pause functionality to the play button
- Loading branch information
1 parent
56291e9
commit bee8775
Showing
3 changed files
with
32 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
type PlayButtonProps = { | ||
play: () => void | ||
onClick: () => Promise<void> | ||
isPlaying: boolean | ||
} | ||
|
||
export const PlayButton = (props: PlayButtonProps) => { | ||
return ( | ||
<button | ||
class=" | ||
absolute bottom-0 left-4 flex h-4 w-8 items-center justify-center | ||
rounded bg-black/70 px-6 py-4 shadow-lg | ||
absolute bottom-0 left-4 flex h-8 w-12 items-center justify-center | ||
rounded bg-black/70 px-2 py-2 shadow-lg | ||
hover:bg-black/80 focus:bg-black/100 focus:outline-none | ||
" | ||
onClick={() => props.play()} | ||
aria-label="Play" | ||
onClick={() => void props.onClick()} | ||
aria-label={props.isPlaying ? "Pause" : "Play"} | ||
> | ||
▶ | ||
{props.isPlaying ? ( | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#fff" class="h-6 w-6"> | ||
<path d="M6 5h4v14H6zM14 5h4v14h-4z" /> | ||
</svg> | ||
) : ( | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#fff" class="h-4 w-4"> | ||
<path d="M3 22v-20l18 10-18 10z" /> | ||
</svg> | ||
)} | ||
</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