Skip to content

Commit

Permalink
feat(videodetail): add series metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
royschut committed Jun 17, 2021
1 parent b6ea99e commit 0c2ffaf
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 21 deletions.
6 changes: 5 additions & 1 deletion src/components/Modal/Modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import Modal from './Modal';

describe('<Modal>', () => {
test('renders and matches snapshot', () => {
const { container } = render(<Modal />);
const { container } = render(
<Modal onClose={jest.fn()}>
<p>Test modal</p>
</Modal>,
);

expect(container).toMatchSnapshot();
});
Expand Down
3 changes: 3 additions & 0 deletions src/components/Modal/__snapshots__/Modal.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ exports[`<Modal> renders and matches snapshot 1`] = `
</g>
</svg>
</div>
<p>
Test modal
</p>
</div>
</div>
</div>
Expand Down
23 changes: 23 additions & 0 deletions src/components/Video/Video.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,35 @@
line-height: 36px;
letter-spacing: 0.25px;
margin: 8px 0px;
@include responsive.mobile-only() {
margin: 0px;
}
}
.metaContainer {
display: flex;
flex-direction: column;
}
.meta {
line-height: 18px;
font-size: 16px;
letter-spacing: 0.15px;
margin-bottom: 8px;
@include responsive.mobile-only() {
font-size: 14px;
order: 2;
}
}
.seriesMeta {
font-size: 20px;
line-height: 20px;
letter-spacing: 0.5px;
margin-bottom: 8px;
margin-top: 24px;
@include responsive.mobile-only() {
font-size: 18px;
margin: 4px 0px;
order: 1;
}
}
.description {
font-size: 18px;
Expand Down
6 changes: 5 additions & 1 deletion src/components/Video/Video.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ describe('<Video>', () => {
} as PlaylistItem;
const { container } = render(
<Video
title="Test video"
play
item={item}
startPlay={jest.fn()}
goBack={jest.fn()}
poster="fading"
play
hasShared={false}
onShareClick={jest.fn()}
enableSharing
isFavorited={false}
onFavoriteButtonClick={jest.fn()}
playTrailer={false}
onTrailerClick={jest.fn()}
onTrailerClose={jest.fn()}
/>,
);

Expand Down
36 changes: 26 additions & 10 deletions src/components/Video/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import styles from './Video.module.scss';
type Poster = 'fading' | 'normal';

type Props = {
title: string;
item: PlaylistItem;
trailerItem?: PlaylistItem;
play: boolean;
Expand All @@ -37,10 +38,12 @@ type Props = {
playTrailer: boolean;
onTrailerClick: () => void;
onTrailerClose: () => void;
isSeries?: boolean;
children?: JSX.Element;
};

const Video: React.FC<Props> = ({
title,
item,
trailerItem,
play,
Expand All @@ -52,11 +55,11 @@ const Video: React.FC<Props> = ({
onShareClick,
isFavorited,
onFavoriteButtonClick,

children,
playTrailer,
onTrailerClick,
onTrailerClose,
isSeries = false,
}: Props) => {
const [isPlaying, setIsPlaying] = useState<boolean>(false);
const [mouseActive, setMouseActive] = useState(false);
Expand All @@ -74,13 +77,32 @@ const Video: React.FC<Props> = ({
if (item.rating) metaData.push(item.rating);
const metaString = metaData.join(' • ');

const seriesMeta = isSeries ? `S${item.seasonNumber}:E${item.episodeNumber}` : null;

let timeout: NodeJS.Timeout;
const mouseActivity = () => {
setMouseActive(true);
clearTimeout(timeout);
timeout = setTimeout(() => setMouseActive(false), 2000);
};

const metaContent = (
<>
<h2 className={styles.title}>{title}</h2>
<div className={styles.metaContainer}>
<div className={styles.meta}>{metaString}</div>
{isSeries && (
<div className={styles.seriesMeta}>
<strong>{seriesMeta}</strong>
{' - '}
{item.title}
</div>
)}
</div>
<CollapsibleText text={item.description} className={styles.description} maxHeight={isMobile ? 50 : 'none'} />
</>
);

return (
<div className={styles.video}>
<div
Expand All @@ -90,9 +112,7 @@ const Video: React.FC<Props> = ({
})}
>
<div className={styles.info}>
<h2 className={styles.title}>{item.title}</h2>
<div className={styles.meta}>{metaString}</div>
<CollapsibleText text={item.description} className={styles.description} maxHeight={isMobile ? 50 : 'none'} />
{metaContent}
<div className={styles.playButton}>
<Button
color="primary"
Expand Down Expand Up @@ -147,11 +167,7 @@ const Video: React.FC<Props> = ({
<IconButton aria-label={t('common:back')} onClick={goBack}>
<ArrowLeft />
</IconButton>
<div className={styles.playerInfo}>
<h2 className={styles.title}>{item.title}</h2>
<div className={styles.meta}>{metaString}</div>
<div className={styles.description}>{item.description}</div>
</div>
<div className={styles.playerInfo}>{metaContent}</div>
</div>
</div>
)}
Expand All @@ -161,7 +177,7 @@ const Video: React.FC<Props> = ({
<Cinema item={trailerItem} onComplete={onTrailerClose} isTrailer />
<div
className={classNames(styles.trailerMeta, styles.title, { [styles.hidden]: !mouseActive })}
>{`${item.title} - Trailer`}</div>
>{`${title} - Trailer`}</div>
</div>
</Modal>
)}
Expand Down
29 changes: 21 additions & 8 deletions src/components/Video/__snapshots__/Video.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ exports[`<Video> renders and matches snapshot 1`] = `
<h2
class="title"
>
Test item title
Test video
</h2>
<div
class="meta"
class="metaContainer"
>
1970 • 6m • Tester • CC_CC
<div
class="meta"
>
1970 • 6m • Tester • CC_CC
</div>
</div>
<div
class="collapsibleText"
Expand Down Expand Up @@ -158,17 +162,26 @@ exports[`<Video> renders and matches snapshot 1`] = `
<h2
class="title"
>
Test item title
Test video
</h2>
<div
class="meta"
class="metaContainer"
>
1970 • 6m • Tester • CC_CC
<div
class="meta"
>
1970 • 6m • Tester • CC_CC
</div>
</div>
<div
class="description"
class="collapsibleText"
>
Test item description
<div
class="textContainer description"
style="max-height: none;"
>
Test item description
</div>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/screens/Movie/Movie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const Movie = ({
))}
</Helmet>
<VideoComponent
title={item.title}
item={item}
trailerItem={trailerItem}
play={play}
Expand Down
2 changes: 2 additions & 0 deletions src/screens/Series/Series.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const Series = ({
))}
</Helmet>
<VideoComponent
title={seriesPlaylist.title}
item={item}
trailerItem={trailerItem}
play={play}
Expand All @@ -119,6 +120,7 @@ const Series = ({
onTrailerClose={() => setPlayTrailer(false)}
isFavorited={isFavorited}
onFavoriteButtonClick={() => (isFavorited ? removeItem(item) : saveItem(item))}
isSeries
>
<PlaylistContainer playlistId={id}>
{() => (
Expand Down
3 changes: 2 additions & 1 deletion src/utils/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ const cardUrl = (item: PlaylistItem, playlistId?: string | null) =>

const videoUrl = (item: PlaylistItem, playlistId?: string | null, play: boolean = false) => {
const url = item.seriesId ? seriesURL(item, playlistId) : movieURL(item, playlistId);
const playParam = play ? `${playlistId ? '&' : '?'}play=1` : '';

return `${url}${play ? '&play=1' : ''}`;
return `${url}${playParam}`;
};

export { formatDurationTag, formatDuration, cardUrl, movieURL, seriesURL, videoUrl, episodeURL };
2 changes: 2 additions & 0 deletions types/playlist.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type Track = {
export type PlaylistItem = {
description: string;
duration: number;
episodeNumber?: string;
feedid: string;
image: string;
images: Image[];
Expand All @@ -26,6 +27,7 @@ export type PlaylistItem = {
mediaid: string;
pubdate: number;
rating: string;
seasonNumber?: string;
sources: Source[];
seriesId?: string;
tags: string;
Expand Down

0 comments on commit 0c2ffaf

Please sign in to comment.