fix: improved card view
This commit is contained in:
1 parent
dae856be78
commit
c42d5a5298
6 files changed
+55
-47
No files matched your search
+17
-11
@@ -15,19 +15,25 @@ const Card: FC<Props> = ({ movie, className }) => {
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`${className} p-4 rounded-lg border bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-lg`}
|
||||
className={`${className} rounded-lg border bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-lg`}
|
||||
>
|
||||
<div className='max-w-[300px] w-full mx-auto'>
|
||||
<div className='grid items-center grid-cols-[1fr_50px]'>
|
||||
<Title title={movie.title} />
|
||||
{movie.release_date && (
|
||||
<span className='flex justify-end text-lg font-semibold'>{new Date(movie.release_date).getFullYear()}</span>
|
||||
)}
|
||||
</div>
|
||||
<Rating movie={movie} />
|
||||
</div>
|
||||
<div className='flex justify-center relative mt-1 grow'>
|
||||
<div className='flex justify-center relative grow overflow-hidden rounded-lg'>
|
||||
<Poster title={movie.title} width={300} height={450} size={100} poster={movie.poster_path} />
|
||||
<div className='absolute left-0 top-0 w-full h-20 bg-gradient-to-t from-transparent to-black opacity-80'>
|
||||
<div className='max-w-[300px] w-full mx-auto pt-1 px-3 text-white'>
|
||||
<div className='grid items-center grid-cols-[1fr_50px]'>
|
||||
<Title hideGradient title={movie.title} />
|
||||
{movie.release_date && (
|
||||
<span className='flex justify-end text-lg font-semibold'>
|
||||
{new Date(movie.release_date).getFullYear()}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='absolute left-0 bottom-0 w-full bg-gradient-to-t from-black to-transparent h-20 text-white p-3 pb-2 flex flex-col justify-end opacity-80'>
|
||||
<Rating movie={movie} iconsFillColor='fill-white' />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -37,13 +37,13 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage }) => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<ul className='flex gap-3 flex-wrap justify-between grow'>
|
||||
<ul className='flex gap-3 flex-wrap justify-center grow'>
|
||||
{pages.map((page) => (
|
||||
<Fragment key={page.page}>
|
||||
{filterUnknownMovies(page.results)?.map((movie, index, array) => (
|
||||
<li
|
||||
key={movie.id}
|
||||
className='flex grow basis-[300px] cursor-pointer'
|
||||
className='flex basis-[300px] cursor-pointer'
|
||||
onClick={() => setMovie(movie)}
|
||||
ref={array.length / 2 !== index ? undefined : (element) => setLoader(element!)}
|
||||
>
|
||||
|
||||
@@ -5,9 +5,10 @@ import useFavorites, { useFavoritesMutation } from '@/app/(site)/favorites/useFa
|
||||
|
||||
interface Props {
|
||||
movie: Movie;
|
||||
iconsFillColor?: string;
|
||||
}
|
||||
|
||||
const Rating: FC<Props> = ({ movie }) => {
|
||||
const Rating: FC<Props> = ({ movie, iconsFillColor = 'fill-accent-foreground' }) => {
|
||||
const { map } = useFavorites();
|
||||
const { add, remove } = useFavoritesMutation();
|
||||
|
||||
@@ -24,10 +25,10 @@ const Rating: FC<Props> = ({ movie }) => {
|
||||
className='z-[2] cursor-pointer'
|
||||
title={isFavorite ? 'Remove from favorites' : 'Add to favorite'}
|
||||
>
|
||||
<Heart className={isFavorite ? 'fill-accent-foreground' : ''} size={18} />
|
||||
<Heart className={isFavorite ? iconsFillColor : ''} size={20} />
|
||||
</span>
|
||||
<span className='flex items-center'>
|
||||
<Star size={18} className='fill-accent-foreground mr-1' />
|
||||
<Star size={18} className={`mr-1 ${iconsFillColor}`} />
|
||||
<span className='font-semibold'>{movie.vote_average?.toFixed(1)}</span>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
@@ -5,18 +5,20 @@ import { useTheme } from '@/hooks/useTheme';
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
hideGradient?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const Title: FC<Props> = ({ title }) => {
|
||||
const Title: FC<Props> = ({ title, hideGradient, className }) => {
|
||||
const [isScrollableTitle, setIsScrollableTitle] = useState(false);
|
||||
const [theme] = useTheme();
|
||||
return (
|
||||
<Marquee
|
||||
play={isScrollableTitle}
|
||||
gradient={isScrollableTitle}
|
||||
gradient={!hideGradient && isScrollableTitle}
|
||||
gradientWidth={10}
|
||||
gradientColor={theme === 'light' ? [255, 255, 255] : [2, 8, 23]}
|
||||
className='movie-title overflow-hidden h-[30px] text-lg font-semibold'
|
||||
className={`movie-title overflow-hidden h-[30px] text-lg font-semibold ${className}`}
|
||||
>
|
||||
<div
|
||||
ref={(element) => {
|
||||
|
||||
Reference in new issue
Block a user