import React, { useRef, useState } from "react"; interface CollapsibleContentProps { content: string; maxHeight?: number; } const CollapsibleContent: React.FC = ({ content, maxHeight = 150, }) => { const contentWrapperRef = useRef(null); const [isExpanded, setIsExpanded] = useState(false); // Determine if content needs to be collapsed const shouldCollapse = contentWrapperRef.current ? contentWrapperRef.current.scrollHeight > maxHeight : false; return (
{/* Gradient overlay */} {shouldCollapse && !isExpanded && (
)}
{/* Expand/Collapse button */} {shouldCollapse && ( )}
); }; export default CollapsibleContent;