Skip to content

Commit 1a60a77

Browse files
committed
feat: enhance comment mentions with reply styling in Comment and ViewMarkdown components
1 parent d923258 commit 1a60a77

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/components/Comment/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@ const Comment: React.FC<IComment> = ({
4242
`<span className="mention">@${currentUser}</span>`
4343
);
4444

45-
return newContent;
45+
const reply = newContent.replace(/@(\w+)/g, (match, username) => {
46+
if (username === currentUser) return match;
47+
return `<span className="reply">@${username}</span>`;
48+
});
49+
50+
return reply;
51+
52+
/* return newContent; */
4653
},
4754
[currentUser]
4855
);

src/components/CommentsList/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const list: ICommentData[] = [
5454
},
5555
{
5656
id: 6,
57-
comment: "~~Strikethrough~~ for deprecated features",
57+
comment: "@Maria ~~Strikethrough~~ for deprecated features",
5858
user: {
5959
name: "Mike",
6060
avatar: "https://avatar.iran.liara.run/public/55",

src/components/ViewMarkdown/styles.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export const Span = styled.span`
3737
padding: 2px;
3838
height: fit-content;
3939
}
40+
41+
&.reply {
42+
text-decoration: underline;
43+
color: ${({ theme }) => theme.colors.primary};
44+
}
4045
`;
4146

4247
export const Link = styled.a`

0 commit comments

Comments
 (0)