import { ChevronLeft, ChevronRight } from "lucide-react"; import ViewTransitionLink from "@/components/ViewTransitionLink"; import type { CastMember } from "@/api/types"; import { useCarouselEmbla } from "@/hooks/useCarouselEmbla"; import { buildPersonCatalogHref } from "@/pages/catalogSearchParams"; import { getInitials } from "@/lib/text"; import { cn } from "@/lib/utils"; interface CastCarouselProps { cast: CastMember[]; limit?: number; /** * When true, the carousel adds MediaCarousel-style edge padding so it can sit * at the top level of a page (outside `.page-shell`) and align with other * full-bleed rows. */ fullBleed?: boolean; } export default function CastCarousel({ cast, limit = 20, fullBleed = false }: CastCarouselProps) { const { emblaRef, canScrollPrev, canScrollNext, scrollPrev, scrollNext } = useCarouselEmbla(); if (cast.length === 0) return null; const visible = cast .slice() .sort((a, b) => a.order - b.order) .slice(0, limit); return (
{canScrollPrev && ( )}
{canScrollNext && ( )}
); } function CastCard({ member, href }: { member: CastMember; href: string | null }) { const inner = ( <>
{member.photo_url ? ( {member.name} ) : (
{getInitials(member.name)}
)}
{member.name}
{member.character ? (
{member.character}
) : null}
); if (href) { return ( {inner} ); } return
{inner}
; }