import { Play, Info } from 'lucide-react'; import { useState, useRef } from 'react'; import { formatImageUrl } from '../lib/image'; export default function TopTenCard({ movie, index }) { const [showPreview, setShowPreview] = useState(false); const hoverTimer = useRef(null); const handleMouseEnter = () => { hoverTimer.current = setTimeout(() => { setShowPreview(true); }, 400); // Mượt mà hơn với 400ms phản hồi }; const handleMouseLeave = () => { if (hoverTimer.current) clearTimeout(hoverTimer.current); setShowPreview(false); }; const year = movie.year || (movie.modified?.time ? new Date(movie.modified.time).getFullYear() : ''); const epCount = movie.episode_current?.match(/\d+/)?.[0] || '??'; // horizontal backdrop for preview const backdrop = formatImageUrl(movie.poster_url || movie.thumb_url); const poster = formatImageUrl(movie.thumb_url || movie.poster_url); return (
{/* Giant Netflix Outlined Number */}
{index + 1}
{/* Overlapping Poster Card */}
{movie.name}
{/* Episode Badge */}
TẬP {epCount}
{/* Info below aligned with poster */}

{movie.name}

{movie.origin_name}

{/* Premium Hover Preview Popup */} {showPreview && (
preview
{movie.name} {movie.origin_name}
{movie.quality || 'FHD'}

{movie.content?.replace(/<[^>]*>/g, '') || 'Đang cập nhật nội dung cốt truyện...'}

{year} {movie.episode_current}
)}
); }