Skip to content

Commit

Permalink
feat(project): add live and episode tag to card
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristiaanScheermeijer committed Jun 18, 2021
1 parent 345e04f commit fb28192
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/components/Card/Card.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ $aspects: ((1, 1), (2, 1), (2, 3), (4, 3), (5, 3), (16, 9), (9, 16));
border-radius: 4px;
}

.live {
background-color: variables.$red;
}

.progressContainer {
position: absolute;
right: 0;
Expand Down
15 changes: 13 additions & 2 deletions src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type CardProps = {
duration: number;
posterSource?: string;
seriesId?: string;
seasonNumber?: string;
episodeNumber?: string;
progress?: number;
posterAspect?: '1:1' | '2:1' | '2:3' | '4:3' | '5:3' | '16:9' | '9:16';
featured?: boolean;
Expand All @@ -29,6 +31,8 @@ function Card({
duration,
posterSource,
seriesId,
seasonNumber,
episodeNumber,
progress,
posterAspect = '16:9',
featured = false,
Expand All @@ -45,11 +49,18 @@ function Card({
const posterClassNames = classNames(styles.poster, styles[`aspect${posterAspect.replace(':', '')}`], {
[styles.current]: isCurrent,
});
const metaData = () => {

const renderTag = () => {
if (loading || disabled || !title) return null;

if (seriesId) {
return <div className={styles.tag}>Series</div>;
} else if (seasonNumber && episodeNumber) {
return <div className={styles.tag}>S{seasonNumber}:E{episodeNumber}</div>
} else if (duration) {
return <div className={styles.tag}>{formatDurationTag(duration)}</div>;
} else if (duration === 0) {
return <div className={classNames(styles.tag, styles.live)}>{t('live')}</div>;
}
};

Expand All @@ -71,7 +82,7 @@ function Card({
{featured && !disabled && (
<div className={classNames(styles.title, { [styles.loading]: loading })}>{title}</div>
)}
{!disabled && metaData()}
{renderTag()}
</div>
)}
{isCurrent && <div className={styles.currentLabel}>{currentLabel}</div>}
Expand Down
4 changes: 3 additions & 1 deletion src/components/CardGrid/CardGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function CardGrid({
if (!rows[rowIndex][columnIndex]) return;

const playlistItem: PlaylistItem = rows[rowIndex][columnIndex];
const { mediaid, title, duration, seriesId } = playlistItem;
const { mediaid, title, duration, seriesId, episodeNumber, seasonNumber } = playlistItem;

return (
<div className={styles.cell} style={style} key={mediaid} role="row">
Expand All @@ -56,6 +56,8 @@ function CardGrid({
duration={duration}
posterSource={findPlaylistImageForWidth(playlistItem, imageSourceWidth)}
seriesId={seriesId}
episodeNumber={episodeNumber}
seasonNumber={seasonNumber}
onClick={() => onCardClick(playlistItem)}
onHover={typeof onCardHover === 'function' ? () => onCardHover(playlistItem) : undefined}
loading={isLoading}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Shelf/Shelf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ const Shelf: React.FC<ShelfProps> = ({
progress={watchHistory ? watchHistory[item.mediaid] : undefined}
posterSource={findPlaylistImageForWidth(item, imageSourceWidth)}
seriesId={item.seriesId}
seasonNumber={item.seasonNumber}
episodeNumber={item.episodeNumber}
onClick={isInView ? () => onCardClick(item) : undefined}
onHover={typeof onCardHover === 'function' ? () => onCardHover(item) : undefined}
featured={featured}
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en_US/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"close_modal": "Close",
"filter_videos_by_genre": "Filter videos by genre",
"home": "Home",
"live": "LIVE",
"play_item": "Play {{ title }}",
"settings": "Settings",
"slide_left": "Slide left",
Expand Down
9 changes: 4 additions & 5 deletions src/i18n/locales/en_US/video.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"add_to_favorites": "Add to favorites",
"copied_url": "Copied url",
"current_episode": "Current episode",
"currently_playing": "Currently playing",
"episodes": "Episodes",
"favorite": "Favorite",
"remove_from_favorites": "Remove from favorites",
"share": "Share",
"start_watching": "Start watching",
"trailer": "Trailer",
"share_video": "Share this video",
"copied_url": "Copied url",
"watch_trailer": "Watch the trailer",
"currently_playing": "Currently playing",
"current_episode": "Current episode",
"episodes": "Episodes"
"share_video": "Share this video"
}
1 change: 1 addition & 0 deletions src/i18n/locales/nl_NL/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"close_modal": "",
"filter_videos_by_genre": "",
"home": "",
"live": "",
"play_item": "",
"settings": "",
"slide_left": "",
Expand Down
11 changes: 5 additions & 6 deletions src/i18n/locales/nl_NL/video.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"add_to_favorites": "",
"copied_url": "",
"current_episode": "",
"currently_playing": "",
"episodes": "",
"favorite": "",
"remove_from_favorites": "",
"share": "",
"start_watching": "",
"trailer": "",
"share_video": "",
"copied_url": "",
"watch_trailer": "",
"currently_playing": "",
"current_episode": "",
"episodes": ""
"watch_trailer": "",
"share_video": ""
}

0 comments on commit fb28192

Please sign in to comment.