Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | 'use client';
import { Icon } from '@/components/icon';
import { useModal } from '@/components/ui';
import { useLongText } from '@/hooks/use-chat/use-chat-longText';
import { LongTextModal } from '../chat-modal';
interface Props {
text: string;
className?: string;
}
export const ExpandableText = ({ text, className }: Props) => {
const { open } = useModal();
const { textRef, isLongText } = useLongText(text);
return (
<>
<span
ref={textRef}
className={`line-clamp-20 block whitespace-pre-line text-gray-800 ${className}`}
>
{text}
</span>
{isLongText && (
<button
className='text-text-xs-medium mt-2 flex items-center'
onClick={() => open(<LongTextModal text={text} />)}
>
<span className='text-text-xs-regular text-gray-500'>전체보기 </span>
<Icon id='chevron-right-1' className='w-4 text-gray-600' />
</button>
)}
</>
);
};
|