|
|
|
|
@ -1,3 +1,5 @@ |
|
|
|
|
import { RefObject } from 'react' |
|
|
|
|
|
|
|
|
|
import map from 'lodash/map' |
|
|
|
|
|
|
|
|
|
import type { Chapter } from '../../types' |
|
|
|
|
@ -16,24 +18,25 @@ type ChapterWithStyles = Chapter & { |
|
|
|
|
|
|
|
|
|
type Props = { |
|
|
|
|
chapters: Array<ChapterWithStyles>, |
|
|
|
|
videoRef?: RefObject<HTMLVideoElement>, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const Chapters = ({ chapters }: Props) => ( |
|
|
|
|
<ChapterList> |
|
|
|
|
{ |
|
|
|
|
map( |
|
|
|
|
chapters, |
|
|
|
|
({ |
|
|
|
|
loaded, |
|
|
|
|
played, |
|
|
|
|
width, |
|
|
|
|
}, index) => ( |
|
|
|
|
<ChapterContainer key={index} style={{ width: `${width}%` }}> |
|
|
|
|
<LoadedProgress style={{ width: `${loaded}%` }} /> |
|
|
|
|
<PlayedProgress style={{ width: `${played}%` }} /> |
|
|
|
|
</ChapterContainer> |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
</ChapterList> |
|
|
|
|
) |
|
|
|
|
export const Chapters = ({ chapters, videoRef }: Props) => { |
|
|
|
|
const maxWidthProgressBar = videoRef?.current?.offsetWidth |
|
|
|
|
return ( |
|
|
|
|
<ChapterList> |
|
|
|
|
{map(chapters, ({ |
|
|
|
|
loaded, |
|
|
|
|
played, |
|
|
|
|
width, |
|
|
|
|
}, index) => ( |
|
|
|
|
<ChapterContainer key={index} style={{ width: `${width}%` }}> |
|
|
|
|
<LoadedProgress style={{ width: `${loaded}%` }} /> |
|
|
|
|
<PlayedProgress |
|
|
|
|
style={{ maxWidth: `${maxWidthProgressBar ? `${maxWidthProgressBar - 30}px` : '100%'}`, width: `${played}%` }} |
|
|
|
|
/> |
|
|
|
|
</ChapterContainer> |
|
|
|
|
))} |
|
|
|
|
</ChapterList> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|