fix: improved card view

This commit is contained in:
ner committed 2023-08-18 17:37:02 +03:00
1 parent dae856be78
commit c42d5a5298
6 files changed
+32 -24

No files matched your search

+3 -4
View File
@@ -12,15 +12,14 @@ export default function Container() {
return ( return (
<> <>
<div className='gap-2 flex'> <div className='gap-2 flex bg-background mb-2 lg:static max-sm:z-10 max-sm:fixed max-sm:bottom-0 max-sm:left-0 max-sm:w-full max-sm:p-2 max-sm:mb-0'>
<Button className='mb-2 p-2' onClick={previous} disabled={!hasPrevious} title='Previous movie'> <Button className='p-2' onClick={previous} disabled={!hasPrevious} title='Previous movie'>
<ArrowLeft size={24} strokeWidth={1} /> <ArrowLeft size={24} strokeWidth={1} />
</Button> </Button>
<Button className='w-full mb-2 p-2 grow' onClick={next} title='Next movie'> <Button className='w-full p-2 grow' onClick={next} title='Next movie'>
<ArrowRight size={24} strokeWidth={1} /> <ArrowRight size={24} strokeWidth={1} />
</Button> </Button>
</div> </div>
<Movie key={movie?.id} movie={movie} /> <Movie key={movie?.id} movie={movie} />
<div className='w-full h-2' /> <div className='w-full h-2' />
</> </>
+17 -11
View File
@@ -15,19 +15,25 @@ const Card: FC<Props> = ({ movie, className }) => {
return ( return (
<div <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='flex justify-center relative grow overflow-hidden rounded-lg'>
<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'>
<Poster title={movie.title} width={300} height={450} size={100} poster={movie.poster_path} /> <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>
</div> </div>
); );
+2 -2
View File
@@ -37,13 +37,13 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage }) => {
return ( return (
<> <>
<ul className='flex gap-3 flex-wrap justify-between grow'> <ul className='flex gap-3 flex-wrap justify-center grow'>
{pages.map((page) => ( {pages.map((page) => (
<Fragment key={page.page}> <Fragment key={page.page}>
{filterUnknownMovies(page.results)?.map((movie, index, array) => ( {filterUnknownMovies(page.results)?.map((movie, index, array) => (
<li <li
key={movie.id} key={movie.id}
className='flex grow basis-[300px] cursor-pointer' className='flex basis-[300px] cursor-pointer'
onClick={() => setMovie(movie)} onClick={() => setMovie(movie)}
ref={array.length / 2 !== index ? undefined : (element) => setLoader(element!)} ref={array.length / 2 !== index ? undefined : (element) => setLoader(element!)}
> >
+4 -3
View File
@@ -5,9 +5,10 @@ import useFavorites, { useFavoritesMutation } from '@/app/(site)/favorites/useFa
interface Props { interface Props {
movie: Movie; movie: Movie;
iconsFillColor?: string;
} }
const Rating: FC<Props> = ({ movie }) => { const Rating: FC<Props> = ({ movie, iconsFillColor = 'fill-accent-foreground' }) => {
const { map } = useFavorites(); const { map } = useFavorites();
const { add, remove } = useFavoritesMutation(); const { add, remove } = useFavoritesMutation();
@@ -24,10 +25,10 @@ const Rating: FC<Props> = ({ movie }) => {
className='z-[2] cursor-pointer' className='z-[2] cursor-pointer'
title={isFavorite ? 'Remove from favorites' : 'Add to favorite'} title={isFavorite ? 'Remove from favorites' : 'Add to favorite'}
> >
<Heart className={isFavorite ? 'fill-accent-foreground' : ''} size={18} /> <Heart className={isFavorite ? iconsFillColor : ''} size={20} />
</span> </span>
<span className='flex items-center'> <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 className='font-semibold'>{movie.vote_average?.toFixed(1)}</span>
</span> </span>
</span> </span>
+5 -3
View File
@@ -5,18 +5,20 @@ import { useTheme } from '@/hooks/useTheme';
interface Props { interface Props {
title: string; title: string;
hideGradient?: boolean;
className?: string;
} }
const Title: FC<Props> = ({ title }) => { const Title: FC<Props> = ({ title, hideGradient, className }) => {
const [isScrollableTitle, setIsScrollableTitle] = useState(false); const [isScrollableTitle, setIsScrollableTitle] = useState(false);
const [theme] = useTheme(); const [theme] = useTheme();
return ( return (
<Marquee <Marquee
play={isScrollableTitle} play={isScrollableTitle}
gradient={isScrollableTitle} gradient={!hideGradient && isScrollableTitle}
gradientWidth={10} gradientWidth={10}
gradientColor={theme === 'light' ? [255, 255, 255] : [2, 8, 23]} 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 <div
ref={(element) => { ref={(element) => {
+1 -1
View File
@@ -81,7 +81,7 @@
main, main,
header { header {
max-width: 1050px; max-width: 1260px;
margin: 0 auto; margin: 0 auto;
padding: 0 12px; padding: 0 12px;
} }