import type { BoxProps } from "@chakra-ui/react"; import { Box, Button, Text } from "@chakra-ui/react"; import React, { forwardRef, useState } from "react"; interface Props extends BoxProps { children: React.ReactNode; noOfLines: number; } export const ExpandableText = forwardRef( ({ children, noOfLines, ...rest }, ref) => { const [expandedCount, setExpandedCount] = useState( noOfLines, ); const [isClicked, setIsClicked] = useState(false); const handleToggle = () => { setIsClicked(true); setExpandedCount(expandedCount ? undefined : noOfLines); }; const inputRef = React.useRef(null); const isTextClamped = (inputRef.current?.scrollHeight as number) > (inputRef.current?.clientHeight as number) || isClicked; return ( {children} ); }, ); ExpandableText.displayName = "ExpandableText";