"use client"; import { useEffect, useRef, useState } from "preact/hooks"; import { ComWhtwndBlogEntry } from "npm:@atcute/client/whitewind"; import { cx } from "../lib/cx.ts"; import { PostInfo } from "./post-info.tsx"; import { Title } from "./typography.tsx"; export function PostListItem({ post, rkey, }: { post: ComWhtwndBlogEntry.Record; rkey: string; }) { const [isHovered, setIsHovered] = useState(false); const [isLeaving, setIsLeaving] = useState(false); const timeoutRef = useRef | null>(null); // Clean up any timeouts on unmount useEffect(() => { return () => { if (timeoutRef.current) { clearTimeout(timeoutRef.current); } }; }, []); const handleMouseEnter = () => { if (timeoutRef.current) { clearTimeout(timeoutRef.current); } setIsLeaving(false); setIsHovered(true); }; const handleMouseLeave = () => { setIsLeaving(true); timeoutRef.current = setTimeout(() => { setIsHovered(false); setIsLeaving(false); }, 300); // Match the animation duration }; return ( <> {isHovered && (
{Array(10).fill(post.title).join(" ยท ")}
)}
{post.title}
); }