Skip to content

Commit

Permalink
Merge pull request #19 from birdgg/feat/list-max-height
Browse files Browse the repository at this point in the history
feat: add listMaxHeight prop
  • Loading branch information
SevenOutman authored May 23, 2023
2 parents 69db2b9 + 5b74e88 commit f771240
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
29 changes: 15 additions & 14 deletions docs/pages/docs/api.mdx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
## Props

| Prop | Default | Description |
| ------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| audio | | Songs' information. Could be a single object or an array of objects |
| audio.name | `"Audio name"` | Title of the song |
| audio.artist | `"Audio artist"` | Artist name of the song |
| audio.url | | Url of the media source to play |
| audio.cover | | Url of the album cover image |
| audio.lrc | | Lyrics of the song in raw LRC format |
| audio.theme | | Override theme color for this song. See `theme` prop for theme color explanation |
| theme | `"#ebd0c2"` | Theme color of the player that applies to progress bar, volume control bar and playlist marker. |
| autoPlay | | [See `autoplay` attribute of `<audio>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio#attr-autoplay) |
| volume | `0.7` | Initial volume of the player. |
| initialLoop | `"all"` | Initial loop mode of the player |
| initialOrder | `"list"` | Initial playlist order of the player |
| Prop | Default | Description |
| ------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| audio | | Songs' information. Could be a single object or an array of objects |
| audio.name | `"Audio name"` | Title of the song |
| audio.artist | `"Audio artist"` | Artist name of the song |
| audio.url | | Url of the media source to play |
| audio.cover | | Url of the album cover image |
| audio.lrc | | Lyrics of the song in raw LRC format |
| audio.theme | | Override theme color for this song. See `theme` prop for theme color explanation |
| theme | `"#ebd0c2"` | Theme color of the player that applies to progress bar, volume control bar and playlist marker. |
| autoPlay | | [See `autoplay` attribute of `<audio>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio#attr-autoplay) |
| volume | `0.7` | Initial volume of the player. |
| initialLoop | `"all"` | Initial loop mode of the player |
| initialOrder | `"list"` | Initial playlist order of the player |
| listMaxHeight | `250` | Playerlist max height |
5 changes: 4 additions & 1 deletion src/components/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,25 @@ type PlaylistProps = {
playingAudioUrl?: string;
onPlayAudio?: (audio: AudioInfo) => void;
themeColor?: string;
listMaxHeight?: number;
};

export function Playlist({
open,
audio,
playingAudioUrl,
onPlayAudio,
listMaxHeight,
themeColor = defaultThemeColor,
}: PlaylistProps) {
const olStyle = listMaxHeight ? { maxHeight: listMaxHeight } : undefined;
return (
<div
className={clsx("aplayer-list", {
"aplayer-list-hide": !open,
})}
>
<ol>
<ol style={olStyle}>
{audio.map((audioInfo, index) => (
<li
key={index}
Expand Down
7 changes: 7 additions & 0 deletions src/components/player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ type APlayerProps = {
initialOrder?: PlaylistOrder;

autoPlay?: boolean;

/**
* @default 250
*/
listMaxHeight?: number;
};

export function APlayer({
Expand All @@ -51,6 +56,7 @@ export function APlayer({
initialLoop,
initialOrder,
autoPlay = false,
listMaxHeight = 250,
}: APlayerProps) {
const playlist = usePlaylist(Array.isArray(audio) ? audio : [audio], {
initialLoop,
Expand Down Expand Up @@ -208,6 +214,7 @@ export function APlayer({
audio={playlistAudioProp}
playingAudioUrl={playlist.currentSong.url}
onPlayAudio={handlePlayAudioFromList}
listMaxHeight={listMaxHeight}
/>
) : null}
</div>
Expand Down

1 comment on commit f771240

@vercel
Copy link

@vercel vercel bot commented on f771240 May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.