Skip to content

Commit

Permalink
feat(route): add name route
Browse files Browse the repository at this point in the history
  • Loading branch information
zyachel committed Apr 15, 2023
1 parent 18ca98f commit 75732e0
Show file tree
Hide file tree
Showing 21 changed files with 2,150 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Inspired by projects like [teddit](https://codeberg.org/teddit/teddit), [nitter]

- [ ] lists
- [ ] moviemeter
- [ ] person info(includes directors and actors)
- [x] person info(includes directors and actors)
- [ ] company info
- [ ] user info

Expand Down
57 changes: 57 additions & 0 deletions src/components/name/Basic.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { CardBasic } from 'src/components/card';
import { Basic as BasicType } from 'src/interfaces/shared/name';
import { formatNumber } from 'src/utils/helpers';
import styles from 'src/styles/modules/components/name/basic.module.scss';

type Props = {
className: string;
data: BasicType;
};

const Basic = ({ data, className }: Props) => {
return (
<CardBasic className={className} image={data.poster.url} title={data.name}>
<div className={styles.ratings}>
{data.ranking && (
<p className={styles.rating}>
<span className={styles.rating__num}>{formatNumber(data.ranking.position)}</span>
<svg className={styles.rating__icon}>
<use href='/svg/sprite.svg#icon-graph-rising'></use>
</svg>
<span className={styles.rating__text}>
{' '}
Popularity (
<span className={styles.rating__sub}>{getRankingStats(data.ranking)}</span>)
</span>
</p>
)}
</div>

{!!data.primaryProfessions.length && (
<p className={styles.genres}>
<span className={styles.heading}>Profession: </span>
{data.primaryProfessions.join(', ')}
</p>
)}
{
<p className={styles.overview}>
<span className={styles.heading}>About: </span>
{data.bio.short}...
</p>
}
<p className={styles.genres}>
<span className={styles.heading}>Known for: </span>
{data.knownFor.title} ({data.knownFor.role})
</p>
</CardBasic>
);
};

const getRankingStats = (ranking: NonNullable<Props['data']['ranking']>) => {
if (ranking.direction === 'FLAT') return '\u2192';

const change = formatNumber(ranking.change);
return (ranking.direction === 'UP' ? '\u2191' : '\u2193') + change;
};

export default Basic;
12 changes: 12 additions & 0 deletions src/components/name/Bio.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import styles from 'src/styles/modules/components/name/did-you-know.module.scss';

type Props = { bio: string };

const Bio = ({ bio }: Props) => (
<section className={styles.bio}>
<h2 className='heading heading__secondary'>About</h2>
<div dangerouslySetInnerHTML={{ __html: bio }} />
</section>
);

export default Bio;
73 changes: 73 additions & 0 deletions src/components/name/Credits.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { Credits } from 'src/interfaces/shared/name';
import { CardTitle } from 'src/components/card';
import styles from 'src/styles/modules/components/name/credits.module.scss';

type Props = {
className: string;
data: Credits;
};

const Credits = ({ className, data }: Props) => {
if (!data.total) return null;

return (
<section className={`${className} ${styles.credits}`}>
<h2 className='heading heading__secondary'>Credits</h2>
<section>
<h3 className='heading heading__tertiary'>Released</h3>
{data.released.map(
(item, i) =>
!!item.total && (
<details open={i === 0} key={item.category.id}>
<summary>
{item.category.text} ({item.total})
</summary>
<ul className={styles.container} key={item.category.id}>
{item.titles.map(title => (
<CardTitle
key={title.id}
link={`/title/${title.id}`}
name={title.title}
titleType={title.type.text}
image={title.poster?.url}
year={title.releaseYear}
ratings={title.ratings}
/>
))}
</ul>
</details>
)
)}
</section>
<section>
<h3 className='heading heading__tertiary'>Unreleased</h3>
{data.unreleased.map(
(item, i) =>
!!item.total && (
<details open={i === 0} key={item.category.id}>
<summary>
{item.category.text} ({item.total})
</summary>
<ul className={styles.container}>
{item.titles.map(title => (
<CardTitle
key={title.id}
link={`/title/${title.id}`}
name={title.title}
titleType={title.type.text}
image={title.poster?.url}
year={title.releaseYear}
>
<p>{title.productionStatus}</p>
</CardTitle>
))}
</ul>
</details>
)
)}
</section>
</section>
);
};

export default Credits;
53 changes: 53 additions & 0 deletions src/components/name/DidYouKnow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import Link from 'next/link';
import { DidYouKnow } from 'src/interfaces/shared/name';
import styles from 'src/styles/modules/components/name/did-you-know.module.scss';

type Props = {
data: DidYouKnow;
};

const DidYouKnow = ({ data }: Props) => (
<section className={styles.didYouKnow}>
<h2 className='heading heading__secondary'>Did you know</h2>
<div className={styles.container}>
{!!data.trivia?.total && (
<section>
<h3 className='heading heading__tertiary'>Trivia</h3>
<div dangerouslySetInnerHTML={{ __html: data.trivia.html }}></div>
</section>
)}
{!!data.quotes?.total && (
<section>
<h3 className='heading heading__tertiary'>Quotes</h3>
<div dangerouslySetInnerHTML={{ __html: data.quotes.html }}></div>
</section>
)}
{!!data.trademark?.total && (
<section>
<h3 className='heading heading__tertiary'>Trademark</h3>
<div dangerouslySetInnerHTML={{ __html: data.trademark.html }}></div>
</section>
)}
{!!data.nicknames.length && (
<section>
<h3 className='heading heading__tertiary'>Nicknames</h3>
<p>{data.nicknames.join(', ')}</p>
</section>
)}
{!!data.salary?.total && (
<section>
<h3 className='heading heading__tertiary'>Salary</h3>
<p>
<span>{data.salary.value} in </span>
<Link href={`/title/${data.salary.title.id}`}>
<a className={'link'}>{data.salary.title.text}</a>
</Link>
<span> ({data.salary.title.year})</span>
</p>
</section>
)}
</div>
</section>
);

export default DidYouKnow;

0 comments on commit 75732e0

Please sign in to comment.