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
+55 -47

No files matched your search

+3 -4
View File
@@ -12,15 +12,14 @@ export default function Container() {
return (
<>
<div className='gap-2 flex'>
<Button className='mb-2 p-2' onClick={previous} disabled={!hasPrevious} title='Previous movie'>
<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='p-2' onClick={previous} disabled={!hasPrevious} title='Previous movie'>
<ArrowLeft size={24} strokeWidth={1} />
</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} />
</Button>
</div>
<Movie key={movie?.id} movie={movie} />
<div className='w-full h-2' />
</>
+17 -11
View File
@@ -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>
);
+2 -2
View File
@@ -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!)}
>
+4 -3
View File
@@ -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 -3
View File
@@ -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) => {
+24 -24
View File
@@ -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;
}
}