feat: scroll navigation

This commit is contained in:
ner committed 2024-10-10 15:55:25 +03:00
1 parent eaaf46082c
commit 058ecd452f
7 files changed
+238 -132

No files matched your search

+41 -34
View File
@@ -5,6 +5,8 @@ import { User2 } from 'lucide-react';
import Image from 'next/image';
import Link from 'next/link';
import ScrollNavigation from '@/components/ScrollNavigation';
import useCredits from './useCredits';
interface Props {
@@ -18,42 +20,47 @@ const Credits: FC<Props> = ({ showId, showType = 'movie', onPersonClick }) => {
return (
Boolean(credits?.length) && (
<ul className='no-scrollbar flex animate-fade-aside-slide-in snap-x snap-mandatory gap-2 overflow-auto rounded-lg opacity-0'>
{credits?.map((actor) => (
<li
key={`${actor.id}_${actor.cast_id}`}
title={actor.name}
className='relative w-full max-w-[120px] shrink-0 cursor-pointer snap-start self-end bg-card text-card-foreground transition-shadow hover:shadow-lg'
<ScrollNavigation<HTMLUListElement>>
{(setRef) => (
<ul
ref={setRef}
className='no-scrollbar flex animate-fade-aside-slide-in snap-x snap-mandatory gap-2 overflow-auto rounded-lg opacity-0'
>
<Link
href={`/starring?actorId=${actor.id}&title=${encodeURIComponent(actor.name)}`}
onClick={() => onPersonClick?.(actor.id.toString())}
>
<div className='overflow-hidden rounded-lg'>
{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='flex h-[180px] w-[120px] items-center justify-center rounded-lg'>
<User2 size={120} strokeWidth={1} />
{credits?.map((actor) => (
<li
key={`${actor.id}_${actor.cast_id}`}
title={actor.name}
className='relative w-full max-w-[120px] shrink-0 cursor-pointer snap-start self-end bg-card text-card-foreground transition-shadow hover:shadow-lg'
>
<Link
href={`/starring?actorId=${actor.id}&title=${encodeURIComponent(actor.name)}`}
onClick={() => onPersonClick?.(actor.id.toString())}
>
<div className='overflow-hidden rounded-lg'>
{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='flex h-[180px] w-[120px] items-center justify-center rounded-lg'>
<User2 size={120} strokeWidth={1} />
</div>
)}
</div>
)}
</div>
<div className='absolute left-0 top-0 flex size-full flex-col justify-between rounded-md bg-vignette p-2 py-1 text-sm text-white'>
<p className=' truncate'>{actor.name}</p>
{Boolean(actor.character) && (
<p className='truncate'>{actor.character}</p>
)}
</div>
</Link>
</li>
))}
</ul>
<div className='absolute left-0 top-0 flex size-full flex-col justify-between rounded-md bg-vignette p-2 py-1 text-sm text-white'>
<p className=' truncate'>{actor.name}</p>
{Boolean(actor.character) && <p className='truncate'>{actor.character}</p>}
</div>
</Link>
</li>
))}
</ul>
)}
</ScrollNavigation>
)
);
};