import React from "react"; import clsx from "clsx"; import { TimelinePostInfo } from "@/services/timeline"; import TimelineItem from "./TimelineItem"; import TimelineTop from "./TimelineTop"; export interface TimelinePostInfoEx extends TimelinePostInfo { onDelete?: () => void; } export type TimelineDeleteCallback = (index: number, id: number) => void; export interface TimelineProps { className?: string; style?: React.CSSProperties; posts: TimelinePostInfoEx[]; onResize?: () => void; containerRef?: React.Ref; } const Timeline: React.FC = (props) => { const { posts, onResize } = props; const [showMoreIndex, setShowMoreIndex] = React.useState(-1); return (
{(() => { const length = posts.length; return posts.map((post, index) => { return ( setShowMoreIndex((old) => (old === index ? -1 : index)), onDelete: post.onDelete, } : undefined } onClick={() => setShowMoreIndex(-1)} onResize={onResize} /> ); }); })()}
); }; export default Timeline;