From c42d5a5298ee2974a63256e4a3681551b173fe58 Mon Sep 17 00:00:00 2001 From: ner Date: Fri, 18 Aug 2023 17:37:02 +0300 Subject: [PATCH] fix: improved card view --- app/(site)/container.tsx | 7 ++- components/Movie/Card.tsx | 28 +++++++----- components/Movie/List.tsx | 4 +- components/Movie/components/Rating/index.tsx | 7 +-- components/Movie/components/Title/index.tsx | 8 ++-- styles/index.css | 48 ++++++++++---------- 6 files changed, 55 insertions(+), 47 deletions(-) diff --git a/app/(site)/container.tsx b/app/(site)/container.tsx index 86197cf..164b973 100644 --- a/app/(site)/container.tsx +++ b/app/(site)/container.tsx @@ -12,15 +12,14 @@ export default function Container() { return ( <> -
- -
-
diff --git a/components/Movie/Card.tsx b/components/Movie/Card.tsx index 6d9ad64..771f704 100644 --- a/components/Movie/Card.tsx +++ b/components/Movie/Card.tsx @@ -15,19 +15,25 @@ const Card: FC = ({ movie, className }) => { return (
-
-
- - {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> ); diff --git a/components/Movie/List.tsx b/components/Movie/List.tsx index 23057e1..014822b 100644 --- a/components/Movie/List.tsx +++ b/components/Movie/List.tsx @@ -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!)} > diff --git a/components/Movie/components/Rating/index.tsx b/components/Movie/components/Rating/index.tsx index 4fecfa7..e0477a1 100644 --- a/components/Movie/components/Rating/index.tsx +++ b/components/Movie/components/Rating/index.tsx @@ -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> diff --git a/components/Movie/components/Title/index.tsx b/components/Movie/components/Title/index.tsx index 17a2ff0..fe45702 100644 --- a/components/Movie/components/Title/index.tsx +++ b/components/Movie/components/Title/index.tsx @@ -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) => { diff --git a/styles/index.css b/styles/index.css index fd35c4d..669a31c 100644 --- a/styles/index.css +++ b/styles/index.css @@ -1,75 +1,75 @@ @tailwind base; @tailwind components; @tailwind utilities; - + @layer base { :root { --background: 0 0% 100%; --gradient-color: 0 0% 100%, 0 0% 0%; --foreground: 222.2 84% 4.9%; - + --muted: 210 40% 96.1%; --muted-foreground: 215.4 16.3% 46.9%; - + --popover: 0 0% 100%; --popover-foreground: 222.2 84% 4.9%; - + --card: 0 0% 100%; --card-foreground: 222.2 84% 4.9%; - + --border: 214.3 31.8% 91.4%; --input: 214.3 31.8% 91.4%; - + --primary: 222.2 47.4% 11.2%; --primary-foreground: 210 40% 98%; - + --secondary: 210 40% 96.1%; --secondary-foreground: 222.2 47.4% 11.2%; - + --accent: 210 40% 96.1%; --accent-foreground: 222.2 47.4% 11.2%; - + --destructive: 0 84.2% 60.2%; --destructive-foreground: 210 40% 98%; - + --ring: 215 20.2% 65.1%; - + --radius: 0.5rem; } - + .dark { --background: 222.2 84% 4.9%; --gradient-color: 222.2 84% 4.9%, 0 0% 0%; --foreground: 210 40% 98%; - + --muted: 217.2 32.6% 17.5%; --muted-foreground: 215 20.2% 65.1%; - + --popover: 222.2 84% 4.9%; --popover-foreground: 210 40% 98%; - + --card: 222.2 84% 4.9%; --card-foreground: 210 40% 98%; - + --border: 217.2 32.6% 17.5%; --input: 217.2 32.6% 17.5%; - + --primary: 210 40% 98%; --primary-foreground: 222.2 47.4% 11.2%; - + --secondary: 217.2 32.6% 17.5%; --secondary-foreground: 210 40% 98%; - + --accent: 217.2 32.6% 17.5%; --accent-foreground: 210 40% 98%; - + --destructive: 0 62.8% 30.6%; --destructive-foreground: 0 85.7% 97.3%; - + --ring: 217.2 32.6% 17.5%; } } - + @layer base { * { @apply border-border; @@ -81,7 +81,7 @@ main, header { - max-width: 1050px; + max-width: 1260px; margin: 0 auto; padding: 0 12px; -} \ No newline at end of file +}