feat: aspect-ratio instead of width measurer
This commit is contained in:
1 parent
375ebf93d9
commit
279a61ddcd
15 files changed
+168
-313
No files matched your search
+24
-27
@@ -2,7 +2,6 @@ import { FC } from 'react';
|
||||
|
||||
import Poster from '@/components/Movie/components/Poster';
|
||||
import Rating from '@/components/Movie/components/Rating';
|
||||
import { AspectRatio } from '@/components/ui/aspect-ratio';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import Favorite from './components/Favorite';
|
||||
@@ -12,38 +11,36 @@ interface Props {
|
||||
movie?: Movie;
|
||||
onClick?: () => void;
|
||||
className?: string;
|
||||
containerProps?: unknown;
|
||||
}
|
||||
|
||||
const Card: FC<Props> = ({ movie, onClick, className }) => {
|
||||
const Card: FC<Props> = ({ movie, onClick, className, containerProps }) => {
|
||||
if (!movie) return null;
|
||||
|
||||
return (
|
||||
<div className='xs:w-[300px] xs:h-[450px] w-full h-full shrink-0'>
|
||||
<AspectRatio ratio={2 / 3}>
|
||||
<div
|
||||
className={cn(
|
||||
'h-full relative bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-lg overflow-hidden rounded-lg',
|
||||
className
|
||||
)}
|
||||
>
|
||||
<div className='flex w-full h-full'>
|
||||
<Poster title={movie.name || movie.title} poster={movie.poster_path} />
|
||||
</div>
|
||||
<div className='text-white absolute w-full h-full top-0 left-0 rounded-md flex flex-col justify-between p-2 card-gradient'>
|
||||
<Handlers movie={movie} onClick={onClick} />
|
||||
<div className='grid grid-cols-[1fr_auto] text-lg opacity-75 gap-2'>
|
||||
<span className='overflow-ellipsis overflow-hidden whitespace-nowrap'>{movie.name || movie.title}</span>
|
||||
{Boolean(movie.release_date) && <span>{new Date(movie.release_date).getFullYear()}</span>}
|
||||
</div>
|
||||
<div className='opacity-75 mb-[-5px]'>
|
||||
<span className='select-none flex w-full items-center ml-auto gap-1 mt-[-8px] justify-between z-[1]'>
|
||||
<Favorite movie={movie} />
|
||||
<Rating rating={movie.vote_average} />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
{...(containerProps || {})}
|
||||
className={cn(
|
||||
'card-aspect-ratio relative bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-lg overflow-hidden rounded-lg',
|
||||
className
|
||||
)}
|
||||
>
|
||||
<div className='flex w-full h-full'>
|
||||
<Poster title={movie.name || movie.title} poster={movie.poster_path} />
|
||||
</div>
|
||||
<div className='text-white absolute w-full h-full top-0 left-0 rounded-md flex flex-col justify-between p-2 card-gradient'>
|
||||
<Handlers movie={movie} onClick={onClick} />
|
||||
<div className='grid grid-cols-[1fr_auto] text-lg opacity-75 gap-2'>
|
||||
<span className='overflow-ellipsis overflow-hidden whitespace-nowrap'>{movie.name || movie.title}</span>
|
||||
{Boolean(movie.release_date) && <span>{new Date(movie.release_date).getFullYear()}</span>}
|
||||
</div>
|
||||
</AspectRatio>
|
||||
<div className='opacity-75 mb-[-5px]'>
|
||||
<span className='select-none flex w-full items-center ml-auto gap-1 mt-[-8px] justify-between z-[1]'>
|
||||
<Favorite movie={movie} />
|
||||
<Rating rating={movie.vote_average} />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user