degmods.com/src/components/comment/CommentContent.tsx

41 lines
944 B
TypeScript

import { NoteRender } from 'components/Notes/NoteRender'
import { useTextLimit } from 'hooks'
interface CommentContentProps {
content: string
isNsfw?: boolean
}
export const CommentContent = ({
content,
isNsfw = false
}: CommentContentProps) => {
const { text, isTextOverflowing, isExpanded, toggle } = useTextLimit(content)
return (
<>
{isExpanded && (
<div
className='IBMSMSMBSSCL_CBExpand IBMSMSMBSSCL_CBExpandAlt'
onClick={toggle}
>
<p>Hide full post</p>
</div>
)}
<p className='IBMSMSMBSSCL_CBText'>
<NoteRender content={text} />
</p>
{isTextOverflowing && !isExpanded && (
<div className='IBMSMSMBSSCL_CBExpand' onClick={toggle}>
<p>View full post</p>
</div>
)}
{isNsfw && (
<div className='IBMSMSMBSSCL_CommentNSWFTag'>
<p>NSFW</p>
</div>
)}
</>
)
}