Skip to content

Commit f771240

Browse files
authored
Merge pull request #19 from birdgg/feat/list-max-height
feat: add listMaxHeight prop
2 parents 69db2b9 + 5b74e88 commit f771240

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

docs/pages/docs/api.mdx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
## Props
22

3-
| Prop | Default | Description |
4-
| ------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------ |
5-
| audio | | Songs' information. Could be a single object or an array of objects |
6-
| audio.name | `"Audio name"` | Title of the song |
7-
| audio.artist | `"Audio artist"` | Artist name of the song |
8-
| audio.url | | Url of the media source to play |
9-
| audio.cover | | Url of the album cover image |
10-
| audio.lrc | | Lyrics of the song in raw LRC format |
11-
| audio.theme | | Override theme color for this song. See `theme` prop for theme color explanation |
12-
| theme | `"#ebd0c2"` | Theme color of the player that applies to progress bar, volume control bar and playlist marker. |
13-
| autoPlay | | [See `autoplay` attribute of `<audio>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio#attr-autoplay) |
14-
| volume | `0.7` | Initial volume of the player. |
15-
| initialLoop | `"all"` | Initial loop mode of the player |
16-
| initialOrder | `"list"` | Initial playlist order of the player |
3+
| Prop | Default | Description |
4+
| ------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------ |
5+
| audio | | Songs' information. Could be a single object or an array of objects |
6+
| audio.name | `"Audio name"` | Title of the song |
7+
| audio.artist | `"Audio artist"` | Artist name of the song |
8+
| audio.url | | Url of the media source to play |
9+
| audio.cover | | Url of the album cover image |
10+
| audio.lrc | | Lyrics of the song in raw LRC format |
11+
| audio.theme | | Override theme color for this song. See `theme` prop for theme color explanation |
12+
| theme | `"#ebd0c2"` | Theme color of the player that applies to progress bar, volume control bar and playlist marker. |
13+
| autoPlay | | [See `autoplay` attribute of `<audio>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio#attr-autoplay) |
14+
| volume | `0.7` | Initial volume of the player. |
15+
| initialLoop | `"all"` | Initial loop mode of the player |
16+
| initialOrder | `"list"` | Initial playlist order of the player |
17+
| listMaxHeight | `250` | Playerlist max height |

src/components/list.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,25 @@ type PlaylistProps = {
88
playingAudioUrl?: string;
99
onPlayAudio?: (audio: AudioInfo) => void;
1010
themeColor?: string;
11+
listMaxHeight?: number;
1112
};
1213

1314
export function Playlist({
1415
open,
1516
audio,
1617
playingAudioUrl,
1718
onPlayAudio,
19+
listMaxHeight,
1820
themeColor = defaultThemeColor,
1921
}: PlaylistProps) {
22+
const olStyle = listMaxHeight ? { maxHeight: listMaxHeight } : undefined;
2023
return (
2124
<div
2225
className={clsx("aplayer-list", {
2326
"aplayer-list-hide": !open,
2427
})}
2528
>
26-
<ol>
29+
<ol style={olStyle}>
2730
{audio.map((audioInfo, index) => (
2831
<li
2932
key={index}

src/components/player.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ type APlayerProps = {
4242
initialOrder?: PlaylistOrder;
4343

4444
autoPlay?: boolean;
45+
46+
/**
47+
* @default 250
48+
*/
49+
listMaxHeight?: number;
4550
};
4651

4752
export function APlayer({
@@ -51,6 +56,7 @@ export function APlayer({
5156
initialLoop,
5257
initialOrder,
5358
autoPlay = false,
59+
listMaxHeight = 250,
5460
}: APlayerProps) {
5561
const playlist = usePlaylist(Array.isArray(audio) ? audio : [audio], {
5662
initialLoop,
@@ -208,6 +214,7 @@ export function APlayer({
208214
audio={playlistAudioProp}
209215
playingAudioUrl={playlist.currentSong.url}
210216
onPlayAudio={handlePlayAudioFromList}
217+
listMaxHeight={listMaxHeight}
211218
/>
212219
) : null}
213220
</div>

0 commit comments

Comments
 (0)