Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Comment Section UI with Redesigned User Icon and Styling #10458

Merged
Merged
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1d6cded
icon desing changed
modamaan Feb 6, 2025
551c9e6
Merge remote-tracking branch 'upstream/develop' into issues/10428/com…
modamaan Feb 7, 2025
ad38525
updated the ui of comment section and latest comment should be first
modamaan Feb 7, 2025
044a345
ReactMarkdown added
modamaan Feb 9, 2025
ce9618b
ReactMarkdown installed
modamaan Feb 9, 2025
97f2843
lock file
modamaan Feb 9, 2025
d13dc4b
Merge remote-tracking branch 'upstream/develop' into issues/10428/com…
modamaan Feb 9, 2025
761fc50
shadcn markdown added
modamaan Feb 9, 2025
16adc14
Merge branch 'issues/10428/comment-section' of https://github.com/mod…
modamaan Feb 9, 2025
936d644
Remove package-lock.json from the branch
modamaan Feb 9, 2025
23eacc3
Remove package.json from the branch
modamaan Feb 9, 2025
03ffd07
Merge branch 'develop' into issues/10428/comment-section
modamaan Feb 9, 2025
fdc71ce
Merge remote-tracking branch 'upstream/develop' into issues/10428/com…
modamaan Feb 9, 2025
e012ac1
try to solve lint issue
modamaan Feb 9, 2025
a27a755
Merge branch 'issues/10428/comment-section' of https://github.com/mod…
modamaan Feb 9, 2025
209a464
Merge remote-tracking branch 'upstream/develop' into issues/10428/com…
modamaan Feb 10, 2025
7c84b89
text removed
modamaan Feb 10, 2025
837f8f4
Reverted package-lock.json to match develop branch
modamaan Feb 10, 2025
07668e3
Reverted package.json to match develop branch
modamaan Feb 10, 2025
e3937d1
cypress issue
modamaan Feb 10, 2025
30b6ab0
Merge remote-tracking branch 'upstream/develop' into issues/10428/com…
modamaan Feb 10, 2025
ccbdd6b
try to resolve cypress issue
modamaan Feb 10, 2025
8137562
Merge remote-tracking branch 'upstream/develop' into issues/10428/com…
modamaan Feb 11, 2025
9108b39
Merge branch 'develop' into issues/10428/comment-section
modamaan Feb 11, 2025
90c3fa9
TooltipComponent added
modamaan Feb 11, 2025
1a8a988
Merge branch 'issues/10428/comment-section' of https://github.com/mod…
modamaan Feb 11, 2025
31e43f5
avatar, username and time added in a single row
modamaan Feb 11, 2025
2d20ce6
Merge remote-tracking branch 'upstream/develop' into issues/10428/com…
modamaan Feb 11, 2025
e640ead
Merge branch 'develop' into issues/10428/comment-section
modamaan Feb 11, 2025
142e421
Merge remote-tracking branch 'upstream/develop' into issues/10428/com…
modamaan Feb 17, 2025
d215e51
slice() updated with spread operator
modamaan Feb 17, 2025
9054b07
Merge branch 'issues/10428/comment-section' of https://github.com/mod…
modamaan Feb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 41 additions & 22 deletions src/components/Resource/ResourceCommentSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { toast } from "sonner";
import { cn } from "@/lib/utils";

import { Button } from "@/components/ui/button";
import { Markdown } from "@/components/ui/markdown";
import { Textarea } from "@/components/ui/textarea";
import { TooltipComponent } from "@/components/ui/tooltip";

import { Avatar } from "@/components/Common/Avatar";
import PaginationComponent from "@/components/Common/Pagination";
Expand All @@ -18,7 +20,7 @@ import { RESULTS_PER_PAGE_LIMIT } from "@/common/constants";
import routes from "@/Utils/request/api";
import mutate from "@/Utils/request/mutate";
import query from "@/Utils/request/query";
import { formatName, relativeTime } from "@/Utils/utils";
import { formatDateTime, formatName, relativeTime } from "@/Utils/utils";
import { CommentModel } from "@/types/resourceRequest/resourceRequest";

const CommentSection = (props: { id: string }) => {
Expand Down Expand Up @@ -91,11 +93,14 @@ const CommentSection = (props: { id: string }) => {
</div>
) : (
<ul>
{resourceComments?.results?.map((comment) => (
<li key={comment.id} className="w-full">
<Comment {...comment} />
</li>
))}
{resourceComments?.results
?.slice()
.reverse()
.map((comment) => (
<li key={comment.id} className="w-full">
<Comment {...comment} />
</li>
))}
<div className="flex w-full items-center justify-center">
<div
className={cn(
Expand Down Expand Up @@ -130,23 +135,37 @@ export const Comment = ({
created_by,
created_date,
}: CommentModel) => (
<div className="mt-4 flex w-full flex-col rounded-lg border border-secondary-300 bg-white p-4 text-secondary-800">
<div className="w-full">
<p className="break-words whitespace-pre-wrap">
{comment.replace(/\n+/g, "\n")}
</p>
</div>
<div className="flex w-full items-center">
<div className="mr-auto flex items-center rounded-md border bg-secondary-100 py-1 pl-2 pr-3">
<Avatar
name={`${created_by.first_name} ${created_by.last_name}`}
className="h-8 w-8 "
/>
<span className="pl-2 text-sm text-secondary-700">
{formatName(created_by)}
</span>
<div
className={cn(
"mt-4 flex w-full flex-col rounded-lg border border-secondary-300 bg-white p-4 text-secondary-800",
)}
>
<div className="flex items-start gap-3">
<TooltipComponent content={formatName(created_by)}>
<div className="flex">
<Avatar
name={`${created_by.first_name} ${created_by.last_name}`}
className="w-8 h-8 rounded-full object-cover"
/>
</div>
</TooltipComponent>
<div className="flex flex-col flex-grow mt-1">
<div className="flex items-center justify-between w-full">
<span className="text-gray-700 font-medium text-xs md:text-sm">
{formatName(created_by)}
</span>
<time
className="text-gray-500 text-xs"
dateTime={created_date}
title={formatDateTime(created_date)}
>
{relativeTime(created_date)}
</time>
</div>
<div className="break-words whitespace-pre-wrap mt-1">
<Markdown content={comment} />
</div>
</div>
<div className="text-xs">{relativeTime(created_date)}</div>
</div>
</div>
);
Loading