Skip to content

Commit

Permalink
feat: add country flags to production countries
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCatLady committed Nov 8, 2021
1 parent 18ca073 commit 6b27fbc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
19 changes: 14 additions & 5 deletions src/components/MovieDetails/index.tsx
Expand Up @@ -11,6 +11,8 @@ import {
ChevronDoubleDownIcon,
ChevronDoubleUpIcon,
} from '@heroicons/react/solid';
import { hasFlag } from 'country-flag-icons';
import 'country-flag-icons/3x2/flags.css';
import { uniqBy } from 'lodash';
import Link from 'next/link';
import { useRouter } from 'next/router';
Expand Down Expand Up @@ -609,13 +611,20 @@ const MovieDetails: React.FC<MovieDetailsProps> = ({ movie }) => {
{data.productionCountries.map((c) => {
return (
<span
className="block"
className="flex items-center justify-end"
key={`prodcountry-${c.iso_3166_1}`}
>
{intl.formatDisplayName(c.iso_3166_1, {
type: 'region',
fallback: 'none',
}) ?? c.name}
{hasFlag(c.iso_3166_1) && (
<span
className={`mr-1.5 text-xs leading-5 flag:${c.iso_3166_1}`}
/>
)}
<span>
{intl.formatDisplayName(c.iso_3166_1, {
type: 'region',
fallback: 'none',
}) ?? c.name}
</span>
</span>
);
})}
Expand Down
19 changes: 14 additions & 5 deletions src/components/TvDetails/index.tsx
Expand Up @@ -5,6 +5,8 @@ import {
FilmIcon,
PlayIcon,
} from '@heroicons/react/outline';
import { hasFlag } from 'country-flag-icons';
import 'country-flag-icons/3x2/flags.css';
import Link from 'next/link';
import { useRouter } from 'next/router';
import React, { useMemo, useState } from 'react';
Expand Down Expand Up @@ -546,13 +548,20 @@ const TvDetails: React.FC<TvDetailsProps> = ({ tv }) => {
{data.productionCountries.map((c) => {
return (
<span
className="block"
className="flex items-center justify-end"
key={`prodcountry-${c.iso_3166_1}`}
>
{intl.formatDisplayName(c.iso_3166_1, {
type: 'region',
fallback: 'none',
}) ?? c.name}
{hasFlag(c.iso_3166_1) && (
<span
className={`mr-1.5 text-xs leading-5 flag:${c.iso_3166_1}`}
/>
)}
<span>
{intl.formatDisplayName(c.iso_3166_1, {
type: 'region',
fallback: 'none',
}) ?? c.name}
</span>
</span>
);
})}
Expand Down

0 comments on commit 6b27fbc

Please sign in to comment.