fix: image aspect ration

This commit is contained in:
ner committed 2024-03-25 18:11:24 +02:00
1 parent 48f43afef2
commit 0357f23cae
7 files changed
+13 -23

No files matched your search

+5 -10
View File
@@ -27,18 +27,13 @@ const Card: FC<Props> = ({ movie, onClick, fit }) => {
<div
onDoubleClick={handleToggleFavorite}
className={cn(
'w-[300px] h-[450px] min-w-[300px] min-h-[450px] shrink-0 mx-auto',
fit ? 'w-full h-auto xs:w-[300px] xs:h-[450px]' : undefined
'w-[300px] h-[450px] shrink-0 mx-auto relative',
fit ? 'xs:w-[300px] xs:h-[450px] w-full h-full aspect-w-2 aspect-h-3' : undefined
)}
>
<motion.div className='flex flex-col w-full h-full mx-auto relative bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-lg overflow-hidden rounded-lg'>
<motion.div onTap={onClick} className='flex h-full'>
<Poster
title={movie.title}
size={100}
poster={movie.poster_path}
className={fit ? 'h-auto min-h-[450px] xs:h-full' : undefined}
/>
<motion.div className='absolute top-0 left-0 flex flex-col w-full h-full mx-auto bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-lg overflow-hidden rounded-lg'>
<motion.div onTap={onClick} className='flex w-full h-full'>
<Poster title={movie.title} size={100} poster={movie.poster_path} />
</motion.div>
<div className='absolute left-0 top-0 w-full h-20 bg-gradient-to-t from-transparent to-black opacity-75 rounded-t-lg'>
<div className='h-full w-full mx-auto pt-1 px-3 text-white'>
+1 -1
View File
@@ -69,7 +69,7 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage, withBottomGap = tr
<motion.li
key={movie.id}
variants={item}
className='flex cursor-pointer'
className='flex xs:w-auto w-full cursor-pointer'
ref={isAnchor ? (element) => setLoader(element!) : undefined}
>
<Card fit movie={movie} onClick={() => showPreviewModal({ movie, onClose: onPreviewClose })} />
+1 -1
View File
@@ -29,7 +29,7 @@ const Preview: FC<Props> = ({ movie, className, onClose, children, card, fit })
<div className='flex flex-col lg:flex-row max-w-[100%] gap-2'>
{card || <Card fit={fit} movie={movie} />}
<div className='flex flex-col grow'>
{children && <div className='flex hover-none:hidden w-full mb-2 gap-2'>{children}</div>}
{children && <div className='flex hover-none:hidden w-full max-sm:mb-0 mb-2 gap-2'>{children}</div>}
<div className='flex w-full gap-2'>
<Actions movie={movie} onClose={onClose} />
</div>
+2 -7
View File
@@ -1,21 +1,16 @@
import { FC } from 'react';
import { ImageOff } from 'lucide-react';
import { cn } from '@/lib/utils';
interface Props {
title: string;
poster: string;
size: number;
className?: string;
}
const Poster: FC<Props> = ({ title, poster, size = 250, className }) => {
const Poster: FC<Props> = ({ title, poster, size = 250 }) => {
return poster ? (
<img
className={cn('rounded-lg mx-auto w-auto h-full object-fill', className)}
height={750}
width={500}
className='rounded-lg w-full h-full object-fill'
src={`https://image.tmdb.org/t/p/w500/${poster}`}
alt={title}
/>