From 8473a104ca22ede89041d37990b178af8d0b4799 Mon Sep 17 00:00:00 2001 From: ner Date: Mon, 21 Oct 2024 21:03:32 +0300 Subject: [PATCH] fix: retina images --- api/dto/Show.ts | 10 ++++++++-- components/Poster/index.tsx | 16 ++++++++++------ components/ui/nav.tsx | 17 ++++++++++------- types.d.ts | 2 +- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/api/dto/Show.ts b/api/dto/Show.ts index 33962a4..88d1a69 100644 --- a/api/dto/Show.ts +++ b/api/dto/Show.ts @@ -7,8 +7,14 @@ export const mapMovieSeriesToShow = ( overview, rating: vote_average, votes: vote_count, - backdrop: backdrop_path ? `https://image.tmdb.org/t/p/w1280/${backdrop_path}` : '', - poster: poster_path ? `https://image.tmdb.org/t/p/w342/${poster_path}` : '', + backdrop: backdrop_path ? `https://image.tmdb.org/t/p/w1280${backdrop_path}` : '', + poster: poster_path + ? { + '1x': `https://image.tmdb.org/t/p/w342${poster_path}`, + '1.5x': `https://image.tmdb.org/t/p/w500${poster_path}`, + '2x': `https://image.tmdb.org/t/p/w780${poster_path}` + } + : { '1x': '', '1.5x': '', '2x': '' }, release: 'release_date' in item ? item.release_date : item.first_air_date, title: 'release_date' in item ? item.title : item.name }); diff --git a/components/Poster/index.tsx b/components/Poster/index.tsx index a1a3418..df089de 100644 --- a/components/Poster/index.tsx +++ b/components/Poster/index.tsx @@ -22,12 +22,16 @@ const Poster: FC = ({ show, onClick, className, rounded, containerProps, className={cn('card-aspect-ratio relative bg-black overflow-hidden rounded-lg text-lg', className, rounded)} >
- {show.title} + + + + {show.title} +
void }; -const Cursor: FC = ({ width, left, opacity }) => ( +const Cursor: FC = ({ width, left, opacity, onTransitionEnd }) => (
  • ); @@ -23,12 +24,14 @@ export type NavProps = { function Nav({ tabs, active, className, children, onChange }: NavProps) { const [cursor, setCursor] = useState({ left: 0, width: 0, opacity: 0 }); + const [transitionEnded, setTransitionEnded] = useState(false); const currentRef = useRef(null); useLayoutEffect(() => { const link = currentRef.current; setCursor({ width: link?.clientWidth || 0, left: link?.offsetLeft || 0, opacity: link ? 1 : 0 }); + setTransitionEnded(false); }, [active?.title]); return ( @@ -43,16 +46,16 @@ function Nav({ tabs, active, className, children, onChange }: Nav key={title} ref={isActive ? currentRef : undefined} onClick={() => onChange?.(tab)} - className={cn( - 'mix-blend-difference text-white z-10 px-2.5 py-0.5 font-normal cursor-default', - !isActive && 'cursor-pointer' - )} + className={cn('z-10 px-2.5 py-0.5 font-normal cursor-pointer', { + 'cursor-default text-secondary': isActive, + 'mix-blend-difference text-white': !transitionEnded + })} > {children?.(tab) ||
    {title}
    }
  • ); })} - + setTransitionEnded(true)} /> ); } diff --git a/types.d.ts b/types.d.ts index a89205b..605b9f9 100644 --- a/types.d.ts +++ b/types.d.ts @@ -60,7 +60,7 @@ interface Show { title: string; overview: string; backdrop: string; - poster: string; + poster: { '1x': string; '1.5x': string; '2x': string }; release: Date; rating: number; votes: number;