diff --git a/apps/portal/src/components/resumes/comments/comment/CommentBody.tsx b/apps/portal/src/components/resumes/comments/comment/CommentBody.tsx index e10e3a4b..abf24b88 100644 --- a/apps/portal/src/components/resumes/comments/comment/CommentBody.tsx +++ b/apps/portal/src/components/resumes/comments/comment/CommentBody.tsx @@ -4,6 +4,8 @@ import { } from '@heroicons/react/20/solid'; import { FaceSmileIcon } from '@heroicons/react/24/outline'; +import CommentDescription from './CommentDescription'; + import type { ResumeComment } from '~/types/resume-comments'; type CommentBodyProps = { @@ -49,7 +51,7 @@ export default function CommentBody({ {/* Description */} -
{comment.description}
+ {comment.description} {/* Upvote and edit */}
diff --git a/apps/portal/src/components/resumes/comments/comment/CommentDescription.tsx b/apps/portal/src/components/resumes/comments/comment/CommentDescription.tsx new file mode 100644 index 00000000..8f1eff21 --- /dev/null +++ b/apps/portal/src/components/resumes/comments/comment/CommentDescription.tsx @@ -0,0 +1,48 @@ +import clsx from 'clsx'; +import type { ReactNode } from 'react'; +import { useLayoutEffect, useRef, useState } from 'react'; + +type CommentDescriptionProps = Readonly<{ + children: ReactNode; +}>; + +export default function CommentDescription({ + children, +}: CommentDescriptionProps) { + const ref = useRef(null); + const [descriptionExpanded, setDescriptionExpanded] = useState(false); + const [descriptionOverflow, setDescriptionOverflow] = useState(false); + + useLayoutEffect(() => { + if (ref.current && ref.current.clientHeight < ref.current.scrollHeight) { + setDescriptionOverflow(true); + } + }, [ref]); + + const onSeeActionClicked = () => { + setDescriptionExpanded(!descriptionExpanded); + }; + + return ( + <> + + {children} + + {descriptionOverflow && ( +
+
+ {descriptionExpanded ? 'See Less' : 'See More'} +
+
+ )} + + ); +}