@react-youtube-jukebox/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -0
- package/dist/index.css +1345 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +649 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# @react-youtube-jukebox/core
|
|
2
|
+
|
|
3
|
+
YouTube jukebox component for React apps.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @react-youtube-jukebox/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import "@react-youtube-jukebox/core/styles.css";
|
|
15
|
+
import { Jukebox } from "@react-youtube-jukebox/core";
|
|
16
|
+
|
|
17
|
+
const tracks = [
|
|
18
|
+
{ videoId: "yTg4v2Cnfyo", title: "Soul Below", artist: "Ljones" },
|
|
19
|
+
{ videoId: "s4MQku9Mkwc", title: "Something About Us", artist: "Daft Punk" },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export function Page() {
|
|
23
|
+
return <Jukebox tracks={tracks} />;
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
패키지 스타일은 별도 CSS export로 제공됩니다. 앱 엔트리에서 `@react-youtube-jukebox/core/styles.css`를 함께 import 해야 합니다.
|
|
28
|
+
기본 테마는 `glass`이며, 필요하면 `theme="simple"`, `theme="sunset"`, `theme="ride"`를 전달할 수 있습니다.
|
|
29
|
+
쉘 형태는 `chrome` prop으로 제어하며 기본값은 `classic`입니다. `wallet`과 `ride` 프리셋으로 같은 로직 위에 다른 UI chrome을 적용할 수 있습니다.
|
|
30
|
+
|
|
31
|
+
## Custom Expanded Panel
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import {
|
|
35
|
+
Jukebox,
|
|
36
|
+
type JukeboxExpandedRenderProps,
|
|
37
|
+
} from "@react-youtube-jukebox/core";
|
|
38
|
+
|
|
39
|
+
function CustomExpandedPanel({
|
|
40
|
+
currentTrack,
|
|
41
|
+
isExpanded,
|
|
42
|
+
playerMountRef,
|
|
43
|
+
togglePlay,
|
|
44
|
+
}: JukeboxExpandedRenderProps) {
|
|
45
|
+
return (
|
|
46
|
+
<section data-open={isExpanded}>
|
|
47
|
+
<div ref={playerMountRef} style={{ aspectRatio: "16 / 9" }} />
|
|
48
|
+
<strong>{currentTrack.title}</strong>
|
|
49
|
+
<button onClick={togglePlay}>Toggle</button>
|
|
50
|
+
</section>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function Page() {
|
|
55
|
+
return (
|
|
56
|
+
<Jukebox
|
|
57
|
+
tracks={tracks}
|
|
58
|
+
renderExpandedContent={(props) => <CustomExpandedPanel {...props} />}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`renderExpandedContent`를 전달하면 기본 expanded 디자인 대신 사용자 렌더를 사용합니다. 토글 애니메이션과 컨테이너 visibility는 라이브러리가 계속 관리하고, 소비자는 내부 레이아웃과 컨트롤만 정의하면 됩니다.
|
|
65
|
+
|
|
66
|
+
## Props
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
type JukeboxTrack = {
|
|
70
|
+
videoId: string;
|
|
71
|
+
title: string;
|
|
72
|
+
artist?: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
type JukeboxTheme = "glass" | "simple" | "sunset" | "ride";
|
|
76
|
+
type JukeboxChrome = "classic" | "wallet" | "ride";
|
|
77
|
+
type JukeboxExpandedRenderProps = {
|
|
78
|
+
currentIndex: number;
|
|
79
|
+
currentTrack: JukeboxTrack;
|
|
80
|
+
isExpanded: boolean;
|
|
81
|
+
isMuted: boolean;
|
|
82
|
+
isPlaying: boolean;
|
|
83
|
+
nextTrack: JukeboxTrack | undefined;
|
|
84
|
+
playerMountRef: (node: HTMLDivElement | null) => void;
|
|
85
|
+
totalTracks: number;
|
|
86
|
+
volume: number;
|
|
87
|
+
setVolume: (nextVolume: number) => void;
|
|
88
|
+
toggleMute: () => void;
|
|
89
|
+
togglePlay: () => void;
|
|
90
|
+
playNext: () => void;
|
|
91
|
+
playPrev: () => void;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
type JukeboxProps = {
|
|
95
|
+
tracks: JukeboxTrack[];
|
|
96
|
+
autoplay?: boolean;
|
|
97
|
+
position?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
98
|
+
theme?: JukeboxTheme;
|
|
99
|
+
chrome?: JukeboxChrome;
|
|
100
|
+
offset?: number | { x: number; y: number };
|
|
101
|
+
portal?: boolean;
|
|
102
|
+
className?: string;
|
|
103
|
+
renderExpandedContent?: (
|
|
104
|
+
props: JukeboxExpandedRenderProps,
|
|
105
|
+
) => React.ReactNode;
|
|
106
|
+
};
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
기본 사용은 viewport 기준 포털 렌더링입니다. 레이아웃 안에서 직접 배치가 필요할 때만 `portal={false}`를 사용합니다.
|
|
110
|
+
`autoplay`는 기본값이 `true`이며, 첫 진입 시 무음 상태로 자동 재생합니다. 자동 재생을 끄려면 `autoplay={false}`를 전달합니다.
|