fix: improved card view
This commit is contained in:
1 parent
dae856be78
commit
c42d5a5298
6 files changed
+55
-47
No files matched your search
@@ -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
@@ -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>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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!)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -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,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) => {
|
||||||
|
|||||||
+24
-24
@@ -1,75 +1,75 @@
|
|||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
|
||||||
@layer base {
|
@layer base {
|
||||||
:root {
|
:root {
|
||||||
--background: 0 0% 100%;
|
--background: 0 0% 100%;
|
||||||
--gradient-color: 0 0% 100%, 0 0% 0%;
|
--gradient-color: 0 0% 100%, 0 0% 0%;
|
||||||
--foreground: 222.2 84% 4.9%;
|
--foreground: 222.2 84% 4.9%;
|
||||||
|
|
||||||
--muted: 210 40% 96.1%;
|
--muted: 210 40% 96.1%;
|
||||||
--muted-foreground: 215.4 16.3% 46.9%;
|
--muted-foreground: 215.4 16.3% 46.9%;
|
||||||
|
|
||||||
--popover: 0 0% 100%;
|
--popover: 0 0% 100%;
|
||||||
--popover-foreground: 222.2 84% 4.9%;
|
--popover-foreground: 222.2 84% 4.9%;
|
||||||
|
|
||||||
--card: 0 0% 100%;
|
--card: 0 0% 100%;
|
||||||
--card-foreground: 222.2 84% 4.9%;
|
--card-foreground: 222.2 84% 4.9%;
|
||||||
|
|
||||||
--border: 214.3 31.8% 91.4%;
|
--border: 214.3 31.8% 91.4%;
|
||||||
--input: 214.3 31.8% 91.4%;
|
--input: 214.3 31.8% 91.4%;
|
||||||
|
|
||||||
--primary: 222.2 47.4% 11.2%;
|
--primary: 222.2 47.4% 11.2%;
|
||||||
--primary-foreground: 210 40% 98%;
|
--primary-foreground: 210 40% 98%;
|
||||||
|
|
||||||
--secondary: 210 40% 96.1%;
|
--secondary: 210 40% 96.1%;
|
||||||
--secondary-foreground: 222.2 47.4% 11.2%;
|
--secondary-foreground: 222.2 47.4% 11.2%;
|
||||||
|
|
||||||
--accent: 210 40% 96.1%;
|
--accent: 210 40% 96.1%;
|
||||||
--accent-foreground: 222.2 47.4% 11.2%;
|
--accent-foreground: 222.2 47.4% 11.2%;
|
||||||
|
|
||||||
--destructive: 0 84.2% 60.2%;
|
--destructive: 0 84.2% 60.2%;
|
||||||
--destructive-foreground: 210 40% 98%;
|
--destructive-foreground: 210 40% 98%;
|
||||||
|
|
||||||
--ring: 215 20.2% 65.1%;
|
--ring: 215 20.2% 65.1%;
|
||||||
|
|
||||||
--radius: 0.5rem;
|
--radius: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark {
|
.dark {
|
||||||
--background: 222.2 84% 4.9%;
|
--background: 222.2 84% 4.9%;
|
||||||
--gradient-color: 222.2 84% 4.9%, 0 0% 0%;
|
--gradient-color: 222.2 84% 4.9%, 0 0% 0%;
|
||||||
--foreground: 210 40% 98%;
|
--foreground: 210 40% 98%;
|
||||||
|
|
||||||
--muted: 217.2 32.6% 17.5%;
|
--muted: 217.2 32.6% 17.5%;
|
||||||
--muted-foreground: 215 20.2% 65.1%;
|
--muted-foreground: 215 20.2% 65.1%;
|
||||||
|
|
||||||
--popover: 222.2 84% 4.9%;
|
--popover: 222.2 84% 4.9%;
|
||||||
--popover-foreground: 210 40% 98%;
|
--popover-foreground: 210 40% 98%;
|
||||||
|
|
||||||
--card: 222.2 84% 4.9%;
|
--card: 222.2 84% 4.9%;
|
||||||
--card-foreground: 210 40% 98%;
|
--card-foreground: 210 40% 98%;
|
||||||
|
|
||||||
--border: 217.2 32.6% 17.5%;
|
--border: 217.2 32.6% 17.5%;
|
||||||
--input: 217.2 32.6% 17.5%;
|
--input: 217.2 32.6% 17.5%;
|
||||||
|
|
||||||
--primary: 210 40% 98%;
|
--primary: 210 40% 98%;
|
||||||
--primary-foreground: 222.2 47.4% 11.2%;
|
--primary-foreground: 222.2 47.4% 11.2%;
|
||||||
|
|
||||||
--secondary: 217.2 32.6% 17.5%;
|
--secondary: 217.2 32.6% 17.5%;
|
||||||
--secondary-foreground: 210 40% 98%;
|
--secondary-foreground: 210 40% 98%;
|
||||||
|
|
||||||
--accent: 217.2 32.6% 17.5%;
|
--accent: 217.2 32.6% 17.5%;
|
||||||
--accent-foreground: 210 40% 98%;
|
--accent-foreground: 210 40% 98%;
|
||||||
|
|
||||||
--destructive: 0 62.8% 30.6%;
|
--destructive: 0 62.8% 30.6%;
|
||||||
--destructive-foreground: 0 85.7% 97.3%;
|
--destructive-foreground: 0 85.7% 97.3%;
|
||||||
|
|
||||||
--ring: 217.2 32.6% 17.5%;
|
--ring: 217.2 32.6% 17.5%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@layer base {
|
@layer base {
|
||||||
* {
|
* {
|
||||||
@apply border-border;
|
@apply border-border;
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user