fix: retina images

This commit is contained in:
ner committed 2024-10-21 21:03:32 +03:00
1 parent 0cface89bf
commit 8473a104ca
4 files changed
+29 -16

No files matched your search

+8 -2
View File
@@ -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
});
+10 -6
View File
@@ -22,12 +22,16 @@ const Poster: FC<Props> = ({ show, onClick, className, rounded, containerProps,
className={cn('card-aspect-ratio relative bg-black overflow-hidden rounded-lg text-lg', className, rounded)}
>
<div className='flex size-full'>
<img
className={cn('size-full rounded-lg object-cover', rounded)}
loading={lazy ? 'lazy' : 'eager'}
src={show.poster}
alt={show.title}
/>
<picture>
<source srcSet={show.poster['1x']} media='(min-width: 601px)' />
<source srcSet={show.poster['2x']} media='(max-width: 600px)' />
<img
className={cn('size-full rounded-lg object-cover', rounded)}
loading={lazy ? 'lazy' : 'eager'}
src={show.poster['1x']}
alt={show.title}
/>
</picture>
</div>
<div
className={cn(
+10 -7
View File
@@ -4,11 +4,12 @@ import { cn } from '@/lib/utils';
type Tab = { title: string };
type CursorProps = { left: number; width: number; opacity: number };
type CursorProps = { left: number; width: number; opacity: number; onTransitionEnd: () => void };
const Cursor: FC<CursorProps> = ({ width, left, opacity }) => (
const Cursor: FC<CursorProps> = ({ width, left, opacity, onTransitionEnd }) => (
<li
className='pointer-events-none absolute z-0 h-full rounded-2xl bg-primary transition-all'
onTransitionEnd={onTransitionEnd}
style={{ width, left, opacity }}
/>
);
@@ -23,12 +24,14 @@ export type NavProps<T extends Tab> = {
function Nav<T extends Tab>({ tabs, active, className, children, onChange }: NavProps<T>) {
const [cursor, setCursor] = useState({ left: 0, width: 0, opacity: 0 });
const [transitionEnded, setTransitionEnded] = useState(false);
const currentRef = useRef<HTMLLIElement>(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<T extends Tab>({ 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) || <div>{title}</div>}
</li>
);
})}
<Cursor {...cursor} />
<Cursor {...cursor} onTransitionEnd={() => setTransitionEnded(true)} />
</ul>
);
}
Vendored
+1 -1
View File
@@ -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;