import React, { useState, useEffect, useRef } from ‘react’; import { Home, Film, PlusSquare, User, Heart, MessageCircle, Share2, Bookmark, MoreHorizontal, Play, Pause, VolumeX, Volume2, Send, X, Grid, Video } from ‘lucide-react’; // — INITIAL MOCK DATA — const CURRENT_USER = { name: ‘Demo User’, handle: ‘@demouser’, avatar: ‘https://i.pravatar.cc/150?u=demo_user’, followers: ‘1.2k’, following: ‘340’ }; const INITIAL_POSTS = [ { id: 1, user: { name: ‘Tech Insider’, handle: ‘@techinsider’, avatar: ‘https://i.pravatar.cc/150?u=tech’ }, type: ‘video_horizontal’, content: ‘The future of mobile displays is here. Check out this flexible screen concept! 📱✨ #Tech #Innovation’, mediaUrl: ‘https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4’, likes: 1240, comments: [], shares: 45, timestamp: ‘2h ago’, isLiked: false, isSaved: false }, { id: 2, user: { name: ‘Sarah Jenkins’, handle: ‘@sarahj_art’, avatar: ‘https://i.pravatar.cc/150?u=sarah’ }, type: ‘image’, content: ‘Just finished this digital painting. Inspired by cyberpunk aesthetics. Let me know what you think in the comments! 🎨🌃’, mediaUrl: ‘https://images.unsplash.com/photo-1605806616949-1e87b487bc2a?ixlib=rb-4.0.3&auto=format&fit=crop&w=800&q=80’, likes: 3450, comments: [ { id: 1, user: ‘ArtFan99’, text: ‘The colors are incredible!’ }, { id: 2, user: ‘CyberPunked’, text: ‘Major Blade Runner vibes. Love it.’ } ], shares: 12, timestamp: ‘5h ago’, isLiked: true, isSaved: true }, { id: 3, user: { name: ‘Dev Community’, handle: ‘@devs_rule’, avatar: ‘https://i.pravatar.cc/150?u=dev’ }, type: ‘text’, content: ‘Unpopular opinion: Sometimes a standard HTML page with Vanilla JS is better than a massive SPA framework. What are your thoughts on over-engineering simple websites? 👇💬’, likes: 892, comments: [], shares: 115, timestamp: ‘8h ago’, isLiked: false, isSaved: false } ]; const INITIAL_SHORTS = [ { id: 101, user: { name: ‘Nature Vibe’, handle: ‘@nature.vibe’ }, content: ‘Majestic waterfalls 🌊’, mediaUrl: ‘https://www.w3schools.com/html/mov_bbb.mp4’, likes: ‘1.2M’, comments: ‘4.5k’ }, { id: 102, user: { name: ‘Urban Explorer’, handle: ‘@urban_x’ }, content: ‘City lights fading into the night 🏙️’, mediaUrl: ‘https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4’, likes: ‘800k’, comments: ‘1.2k’ } ]; // — SUB-COMPONENTS — const FeedPost = ({ post, onLike, onSave, onAddComment }) => { const [showComments, setShowComments] = useState(false); const [commentText, setCommentText] = useState(”); const handleCommentSubmit = (e) => { e.preventDefault(); if (!commentText.trim()) return; onAddComment(post.id, commentText); setCommentText(”); }; return (
{/* Header */}
avatar

{post.user.name}

{post.user.handle} • {post.timestamp}

{/* Content */}

{post.content}

{/* Media */} {post.type === ‘image’ && (
Post media
)} {post.type === ‘video_horizontal’ && (
)} {/* Actions */}
{/* Comments Section */} {showComments && (
{/* Existing Comments */} {post.comments.length > 0 && (
{post.comments.map((c, i) => (
{c.user} {c.text}
))}
)} {/* Add Comment Input */}
my-avatar
setCommentText(e.target.value)} placeholder=”Add a comment…” className=”w-full bg-gray-800 text-sm text-white rounded-full py-2 pl-4 pr-10 focus:outline-none focus:ring-1 focus:ring-blue-500 transition-all” />
)}
); }; const ShortPlayer = ({ short }) => { const videoRef = useRef(null); const [isPlaying, setIsPlaying] = useState(false); const [isMuted, setIsMuted] = useState(true); useEffect(() => { const options = { root: null, rootMargin: ‘0px’, threshold: 0.6 }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { videoRef.current?.play().then(() => setIsPlaying(true)).catch(() => setIsPlaying(false)); } else { videoRef.current?.pause(); setIsPlaying(false); } }); }, options); if (videoRef.current) observer.observe(videoRef.current); return () => { if (videoRef.current) observer.unobserve(videoRef.current); }; }, []); const togglePlay = () => { if (videoRef.current.paused) { videoRef.current.play(); setIsPlaying(true); } else { videoRef.current.pause(); setIsPlaying(false); } }; return (