feat: native carousel

This commit is contained in:
ner committed 2024-08-25 21:48:03 +03:00
1 parent 4ddaa89032
commit 5733bc0af0
20 files changed
+961 -534

No files matched your search

+41 -35
View File
@@ -37,42 +37,48 @@ const Credits: FC<Props> = ({ movieId, onPersonClick, type = 'movie' }) => {
return (
Boolean(credits?.length) && (
<div className='overflow-auto no-scrollbar max-w-[100%] py-2 pb-3 mb-[-0.75rem]'>
<motion.ul className='flex gap-3' variants={container} initial='hidden' animate='visible' whileInView='visible'>
{credits?.map((actor) => (
<motion.li
variants={item}
key={`${actor.id}_${actor.cast_id}`}
title={actor.name}
onTap={() => {
router.push(`/starring?actorId=${actor.id}&title=${encodeURIComponent(actor.name)}`);
onPersonClick?.(actor.id.toString());
}}
className='p-2 rounded-lg border bg-card text-card-foreground self-end max-w-[150px] w-full shrink-0 cursor-pointer transition-shadow hover:shadow-lg'
>
{Boolean(actor.character) && (
<p className='pb-2 overflow-ellipsis whitespace-nowrap overflow-hidden'>{actor.character}</p>
<motion.ul
className='flex gap-2 no-scrollbar overflow-auto rounded-lg snap-mandatory snap-x'
variants={container}
initial='hidden'
animate='visible'
whileInView='visible'
>
{credits?.map((actor) => (
<motion.li
variants={item}
key={`${actor.id}_${actor.cast_id}`}
title={actor.name}
onTap={() => {
router.push(`/starring?actorId=${actor.id}&title=${encodeURIComponent(actor.name)}`);
onPersonClick?.(actor.id.toString());
}}
className='bg-card text-card-foreground self-end max-w-[120px] w-full shrink-0 cursor-pointer transition-shadow hover:shadow-lg relative snap-start'
>
<div className='rounded-lg overflow-hidden'>
{actor.profile_path ? (
<Image
unoptimized
height={180}
width={120}
src={`https://image.tmdb.org/t/p/w500/${actor.profile_path}`}
alt={actor.name}
/>
) : (
<div className='h-[180px] w-[120px] flex items-center justify-center rounded-lg'>
<User2 size={120} strokeWidth={1} />
</div>
)}
<div className='rounded-md overflow-hidden'>
{actor.profile_path ? (
<Image
unoptimized
height={225}
width={150}
src={`https://image.tmdb.org/t/p/w500/${actor.profile_path}`}
alt={actor.name}
/>
) : (
<div className='w-[132px] h-[198px] flex items-center justify-center rounded-lg border'>
<User2 size={120} strokeWidth={1} />
</div>
)}
</div>
<p className='pt-2 overflow-ellipsis whitespace-nowrap overflow-hidden'>{actor.name}</p>
</motion.li>
))}
</motion.ul>
</div>
</div>
<div className='text-white text-sm absolute w-full h-full top-0 left-0 rounded-md flex flex-col justify-between p-2 py-1 card-gradient'>
<p className=' overflow-ellipsis whitespace-nowrap overflow-hidden'>{actor.name}</p>
{Boolean(actor.character) && (
<p className='overflow-ellipsis whitespace-nowrap overflow-hidden'>{actor.character}</p>
)}
</div>
</motion.li>
))}
</motion.ul>
)
);
};
+3 -4
View File
@@ -4,19 +4,18 @@ import { ImageOff } from 'lucide-react';
interface Props {
title: string;
poster: string;
size: number;
}
const Poster: FC<Props> = ({ title, poster, size = 250 }) => {
const Poster: FC<Props> = ({ title, poster }) => {
return poster ? (
<img
className='rounded-lg w-full h-full object-fill'
className='rounded-lg w-full h-full object-cover'
src={`https://image.tmdb.org/t/p/w500/${poster}`}
alt={title}
/>
) : (
<div className={'w-full flex items-center justify-center rounded-lg grow'}>
<ImageOff size={size} strokeWidth={1} color='hsl(215.4 16.3% 46.9%)' />
<ImageOff size={100} strokeWidth={1} color='hsl(215.4 16.3% 46.9%)' />
</div>
);
};
+1 -1
View File
@@ -26,7 +26,7 @@ const Rating: FC<Props> = ({ isFavorite, rating, toggleFavorite, iconsFillColor
</motion.span>
<span className='flex items-center'>
<Star size={18} className={`mr-1 ${iconsFillColor}`} />
<span className='font-semibold'>{rating?.toFixed(1)}</span>
<p className='mt-[3px]'>{rating?.toFixed(1)}</p>
</span>
</span>
);