degmods.com/src/components/comment/CommentContent.tsx
en 2a0d727eb8
All checks were successful
Release to Staging / build_and_release (push) Successful in 1m11s
feat(notes): control q-repost depth rendering
2025-03-11 16:17:03 +00:00

42 lines
1.0 KiB
TypeScript

import { NoteRender } from 'components/Notes/NoteRender'
import { CommentDepthProvider } from 'contexts/CommentDepthContext'
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 (
<CommentDepthProvider>
{isExpanded && (
<div
className='IBMSMSMBSSCL_CBExpand IBMSMSMBSSCL_CBExpandAlt'
onClick={toggle}
>
<p>Hide full post</p>
</div>
)}
<div className='IBMSMSMBSSCL_CBText'>
<NoteRender content={text} />
</div>
{isTextOverflowing && !isExpanded && (
<div className='IBMSMSMBSSCL_CBExpand' onClick={toggle}>
<p>View full post</p>
</div>
)}
{isNsfw && (
<div className='IBMSMSMBSSCL_CommentNSWFTag'>
<p>NSFW</p>
</div>
)}
</CommentDepthProvider>
)
}