import { FC, useCallback, useEffect, useRef, useState } from 'react' import classNames from 'classnames' import { Button } from 'react-bootstrap' import { useTranslation } from 'react-i18next' export const ExpandableContent: FC<{ className?: string }> = ({ children, className, }) => { const { t } = useTranslation() const contentRef = useRef(null) const [isExpanded, setIsExpanded] = useState(false) const [isOverflowing, setIsOverflowing] = useState(false) useEffect(() => { if (contentRef.current) { setIsOverflowing( contentRef.current.scrollHeight > contentRef.current.clientHeight ) } }, []) const handleShowMore = useCallback(() => { setIsExpanded(true) contentRef.current?.dispatchEvent( new CustomEvent('review-panel:position', { bubbles: true }) ) }, []) const handleShowLess = useCallback(() => { setIsExpanded(false) contentRef.current?.dispatchEvent( new CustomEvent('review-panel:position', { bubbles: true }) ) }, []) return (
{children}
{isExpanded ? ( ) : ( isOverflowing && ( ) )}
) }