import { useRef, useState } from 'react'; import { motion } from 'framer-motion'; import { ChevronLeft, ChevronRight } from 'lucide-react'; import { Scene } from '../pages/script-overview'; import Image from 'next/image'; interface SceneFilmstripProps { scenes: Scene[]; selectedSceneId?: string; onSceneSelect: (sceneId: string) => void; } export function SceneFilmstrip({ scenes, selectedSceneId, onSceneSelect }: SceneFilmstripProps) { const [selectedSceneIdState, setSelectedSceneIdState] = useState(null); const scrollContainerRef = useRef(null); // 处理滚动 const handleScroll = (direction: 'left' | 'right') => { if (!scrollContainerRef.current) return; const scrollAmount = 300; const container = scrollContainerRef.current; container.scrollTo({ left: container.scrollLeft + (direction === 'left' ? -scrollAmount : scrollAmount), behavior: 'smooth' }); }; // 处理场景选择 const handleSceneSelect = (sceneId: string) => { setSelectedSceneIdState(sceneId); onSceneSelect(sceneId); // 滚动到对应的场景卡片 const sceneCard = document.getElementById(`scene-card-${sceneId}`); if (sceneCard) { sceneCard.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' }); } }; return (
{/* 滚动按钮 */} {/* 胶片打孔效果 */}
{Array.from({ length: 20 }).map((_, i) => (
))}
{Array.from({ length: 20 }).map((_, i) => (
))}
{/* 场景缩略图 */}
{scenes.map((scene, index) => ( handleSceneSelect(scene.id)} className={` relative flex-shrink-0 w-32 h-20 rounded-lg overflow-hidden cursor-pointer ${selectedSceneId === scene.id ? 'ring-2 ring-purple-500' : 'hover:ring-1 hover:ring-white/20'} transition-shadow duration-200 `} > {scene.name}
{scene.name}
))}
{/* 胶片装饰线 */}
); }