fix: list animation

This commit is contained in:
ner committed 2023-12-29 18:49:31 +02:00
1 parent 345e7cfc90
commit 5f0dac673d
3 files changed
+12 -10

No files matched your search

+8 -4
View File
@@ -1,4 +1,5 @@
import { FC, ReactNode } from 'react'; import { FC, ReactNode } from 'react';
import { motion } from 'framer-motion';
import Poster from '@/components/Movie/components/Poster'; import Poster from '@/components/Movie/components/Poster';
import Rating from '@/components/Movie/components/Rating'; import Rating from '@/components/Movie/components/Rating';
@@ -8,14 +9,17 @@ interface Props {
movie?: Movie; movie?: Movie;
className?: string; className?: string;
children?: ReactNode; children?: ReactNode;
onClick?: () => void;
} }
const Card: FC<Props> = ({ movie, className, children }) => { const Card: FC<Props> = ({ movie, className, children, onClick }) => {
if (!movie) return null; if (!movie) return null;
return ( return (
<div className={`${className} rounded-lg bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-lg`}> <div
<div className='flex justify-center relative grow overflow-hidden rounded-lg'> className={`${className} rounded-lg relative bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-lg overflow-hidden rounded-lg`}
>
<motion.div className='flex justify-center grow' onTap={onClick}>
<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} />
{children} {children}
<div className='absolute left-0 top-0 w-full h-20 bg-gradient-to-t from-transparent to-black opacity-80'> <div className='absolute left-0 top-0 w-full h-20 bg-gradient-to-t from-transparent to-black opacity-80'>
@@ -30,11 +34,11 @@ const Card: FC<Props> = ({ movie, className, children }) => {
</div> </div>
</div> </div>
</div> </div>
</motion.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'> <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' /> <Rating movie={movie} iconsFillColor='fill-white' />
</div> </div>
</div> </div>
</div>
); );
}; };
+2 -4
View File
@@ -59,9 +59,8 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage, withBottomGap = tr
<motion.ul <motion.ul
className='flex gap-3 flex-wrap justify-center grow' className='flex gap-3 flex-wrap justify-center grow'
variants={container} variants={container}
initial='hidden' initial={pages.length === 1 ? 'hidden' : false}
animate='visible' animate='visible'
layout
> >
{pages.map((page) => ( {pages.map((page) => (
<Fragment key={page.page}> <Fragment key={page.page}>
@@ -70,10 +69,9 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage, withBottomGap = tr
key={movie.id} key={movie.id}
variants={item} variants={item}
className='flex basis-[300px] cursor-pointer' className='flex basis-[300px] cursor-pointer'
onTap={() => setMovie(movie)}
ref={array.length / 2 !== index ? undefined : (element) => setLoader(element!)} ref={array.length / 2 !== index ? undefined : (element) => setLoader(element!)}
> >
<Card movie={movie} className='grow flex flex-col' /> <Card movie={movie} className='grow flex flex-col' onClick={() => setMovie(movie)} />
</motion.li> </motion.li>
))} ))}
</Fragment> </Fragment>
+2 -2
View File
@@ -48,11 +48,11 @@ const DialogContent = React.forwardRef<
animate={{ top: '20vh' }} animate={{ top: '20vh' }}
exit={{ top: '100vh' }} exit={{ top: '100vh' }}
drag='y' drag='y'
dragConstraints={{ top: 0, bottom: 300 }} dragConstraints={{ top: 0, bottom: 0 }}
onDragEnd={(_, info) => info.offset.y > 100 && props.onClose?.()} onDragEnd={(_, info) => info.offset.y > 100 && props.onClose?.()}
dragListener={false} dragListener={false}
dragControls={controls} dragControls={controls}
dragElastic={0.5} dragElastic={0.8}
> >
<DialogPrimitive.Content <DialogPrimitive.Content
ref={ref} ref={ref}