Skip to content
This repository has been archived by the owner on Feb 17, 2025. It is now read-only.

Commit

Permalink
feat: styling added to tagged people in conversation (#135)
Browse files Browse the repository at this point in the history
* feat: styling added to tagged people in conversation

* fix: no index key
  • Loading branch information
arian-garshi authored Sep 18, 2023
1 parent fed4a5a commit 57acf71
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
8 changes: 0 additions & 8 deletions src/Components/SideSheet/Comments/Components/CommentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,6 @@ const CommentView: React.FC<CommentViewProps> = ({
}
}

useEffect(() => {
console.log("newMessage: ", newMessage)
}, [newMessage])

useEffect(() => {
console.log("taggedUsers: ", taggedUsers)
}, [taggedUsers])

return (
<Container>
<ConversationDiv>
Expand Down
20 changes: 19 additions & 1 deletion src/Components/SideSheet/Comments/Components/RenderComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,29 @@ import { unescapeHtmlEntities } from "../../../../utils/helpers"

const CommentText = styled(Typography)`
margin: 10px 0;
span {
color: #3aadb6;
font-weight: 500;
}
`

const SubmitEditButton = styled(Button)`
margin-right: 15px;
`
function wrapInSpan(inputString: string): (string | JSX.Element)[] {
const parts = inputString.split(/{{(.*?)}}/)

let isNextSpan = false
return parts.map((part, index) => {
if (isNextSpan) {
isNextSpan = false
return <span key={`${part}-${index}`}>{part}</span>
}
isNextSpan = true
return part
})
}

interface RenderCommentProps {
comment: Message,
Expand Down Expand Up @@ -161,7 +179,7 @@ const RenderComment: FC<RenderCommentProps> = ({
onMouseOut={handleClose}
>
{
comment.softDeleted ? "Message deleted by user" : unescapeHtmlEntities(comment.text || "")
comment.softDeleted ? "Message deleted by user" : wrapInSpan(unescapeHtmlEntities(comment.text || ""))
}
</CommentText>
<Popover
Expand Down

0 comments on commit 57acf71

Please sign in to comment.