Skip to content

Commit a0024a0

Browse files
committed
feat(frontend): add external links to movie and tv detail pages
1 parent 8408e19 commit a0024a0

File tree

7 files changed

+79
-1
lines changed

7 files changed

+79
-1
lines changed

src/assets/services/imdb.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/services/rt.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/services/tmdb.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import React from 'react';
2+
import TmdbLogo from '../../assets/services/tmdb.svg';
3+
import ImdbLogo from '../../assets/services/imdb.svg';
4+
import RTLogo from '../../assets/services/rt.svg';
5+
6+
interface ExternalLinkBlockProps {
7+
mediaType: 'movie' | 'tv';
8+
imdbId?: string;
9+
tmdbId?: number;
10+
rtUrl?: string;
11+
}
12+
13+
const ExternalLinkBlock: React.FC<ExternalLinkBlockProps> = ({
14+
imdbId,
15+
tmdbId,
16+
rtUrl,
17+
mediaType,
18+
}) => {
19+
return (
20+
<div className="flex justify-end items-center">
21+
{tmdbId && (
22+
<a
23+
href={`https://www.themoviedb.org/${mediaType}/${tmdbId}`}
24+
className="w-8 mx-2 opacity-50 hover:opacity-100 transition duration-300"
25+
target="_blank"
26+
rel="noreferrer"
27+
>
28+
<TmdbLogo />
29+
</a>
30+
)}
31+
{imdbId && (
32+
<a
33+
href={`https://www.imdb.com/title/${imdbId}`}
34+
className="w-8 mx-2 opacity-50 hover:opacity-100 transition duration-300"
35+
target="_blank"
36+
rel="noreferrer"
37+
>
38+
<ImdbLogo />
39+
</a>
40+
)}
41+
{rtUrl && (
42+
<a
43+
href={`${rtUrl}`}
44+
className="w-14 mx-2 opacity-50 hover:opacity-100 transition duration-300"
45+
target="_blank"
46+
rel="noreferrer"
47+
>
48+
<RTLogo />
49+
</a>
50+
)}
51+
</div>
52+
);
53+
};
54+
55+
export default ExternalLinkBlock;

src/components/MovieDetails/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import type { RTRating } from '../../../server/api/rottentomatoes';
3737
import Error from '../../pages/_error';
3838
import Head from 'next/head';
3939
import globalMessages from '../../i18n/globalMessages';
40+
import ExternalLinkBlock from '../ExternalLinkBlock';
4041

4142
const messages = defineMessages({
4243
releasedate: 'Release Date',
@@ -512,6 +513,14 @@ const MovieDetails: React.FC<MovieDetailsProps> = ({ movie }) => {
512513
</div>
513514
)}
514515
</div>
516+
<div className="mt-4">
517+
<ExternalLinkBlock
518+
mediaType="movie"
519+
tmdbId={data.id}
520+
imdbId={data.externalIds.imdbId}
521+
rtUrl={ratingData?.url}
522+
/>
523+
</div>
515524
</div>
516525
</div>
517526
<div className="md:flex md:items-center md:justify-between mb-4 mt-6">

src/components/TvDetails/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import type { RTRating } from '../../../server/api/rottentomatoes';
2929
import Head from 'next/head';
3030
import globalMessages from '../../i18n/globalMessages';
3131
import { ANIME_KEYWORD_ID } from '../../../server/api/themoviedb';
32+
import ExternalLinkBlock from '../ExternalLinkBlock';
3233

3334
const messages = defineMessages({
3435
userrating: 'User Rating',
@@ -482,6 +483,14 @@ const TvDetails: React.FC<TvDetailsProps> = ({ tv }) => {
482483
</div>
483484
)}
484485
</div>
486+
<div className="mt-4">
487+
<ExternalLinkBlock
488+
mediaType="tv"
489+
tmdbId={data.id}
490+
imdbId={data.externalIds.imdbId}
491+
rtUrl={ratingData?.url}
492+
/>
493+
</div>
485494
</div>
486495
</div>
487496
<div className="md:flex md:items-center md:justify-between mb-4 mt-6">

tailwind.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
borderWidth: ['first', 'last'],
1616
margin: ['first', 'last', 'responsive'],
1717
boxShadow: ['group-focus'],
18-
opacity: ['disabled'],
18+
opacity: ['disabled', 'hover'],
1919
},
2020
plugins: [
2121
require('@tailwindcss/forms'),

0 commit comments

Comments
 (0)