import React, { useState, useRef } from 'react'; import { Post, CurrentView } from '../types'; import { PlayIcon, PauseIcon } from './icons'; import { UI_TEXTS } from '../constants'; import { ViewMode } from './FilterSortBar'; interface PostCardProps { post: Post; isFeatured?: boolean; setCurrentView: (view: CurrentView) => void; setSelectedItemId: (id: string | null) => void; viewMode?: ViewMode; } const PostCard: React.FC = ({ post, isFeatured = false, setCurrentView, setSelectedItemId, viewMode = 'grid' }) => { const [isVideoPlaying, setIsVideoPlaying] = useState(false); const videoRef = useRef(null); const toggleVideoPlay = (e: React.MouseEvent) => { e.stopPropagation(); // Prevent card click event when clicking video button if (videoRef.current) { if (videoRef.current.paused) { videoRef.current.play(); setIsVideoPlaying(true); } else { videoRef.current.pause(); setIsVideoPlaying(false); } } }; const handleCardClick = () => { setCurrentView('blogPostDetail'); setSelectedItemId(post.id); }; if (viewMode === 'list' && !isFeatured) { return (
{post.title}

{post.title}

{post.category} {(post.date || post.readTime) && } {post.date && {post.date}} {post.date && post.readTime && } {post.readTime && {post.readTime}}
{post.description && (

{post.description}

)}
); } // Grid View (or Featured Card) const imageAspectRatio = isFeatured ? "aspect-[4/5] md:aspect-[16/9]" : "aspect-[1/1]"; const titleSize = isFeatured ? "text-2xl md:text-3xl lg:text-4xl" : "text-xl md:text-lg"; const scaleEffect = isFeatured ? "group-hover:scale-[1.0125]" : "group-hover:scale-[1.025]"; return (
{post.videoUrl && !isFeatured ? ( <> ) : ( {post.title} )}

{post.title}

{isFeatured && post.description && (

{post.description}

)} {!isFeatured && post.description && (

{post.description}

)}
{post.category} {(post.date || post.readTime) && } {post.date && {post.date}} {post.date && post.readTime && } {post.readTime && {post.readTime}}
); }; export default PostCard;