forked from namastedev/namaste-frontend-system-design
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08905fe
commit 9af1ca1
Showing
3 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const CommentBox = ({ data }) => { | ||
return data.map((comment, index) => ( | ||
<div className=" pl-10 border-l-2 border-black" key={index}> | ||
<div className="flex"> | ||
<div> | ||
<img | ||
className="w-16 p-2 rounded-full" | ||
src="https://www.redditstatic.com/avatars/defaults/v2/avatar_default_1.png" | ||
alt="user" | ||
/> | ||
</div> | ||
<div> | ||
<p className="font-bold px-2 py-4">{comment.username}</p> | ||
<p className="px-2">{comment.comment}</p> | ||
</div> | ||
</div> | ||
<div>{comment?.replies && <CommentBox data={comment.replies} />}</div> | ||
</div> | ||
)); | ||
}; | ||
export default CommentBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import CommentBox from "./CommentBox"; | ||
|
||
const data = [ | ||
{ | ||
username: "Akshay Saini", | ||
comment: "Lorem ipsum dolor sit amet consectetur adip occurence velit", | ||
replies: [ | ||
{ | ||
username: "Deepika Padukone", | ||
comment: "Lorem ipsum dolor sit amet consectetur adip occurence velit", | ||
}, | ||
], | ||
}, | ||
{ | ||
username: "Elon Musk", | ||
comment: "Lorem ipsum dolor sit amet consectetur adip occurence velit", | ||
replies: [ | ||
{ | ||
username: "Deepika Padukone", | ||
comment: "Lorem ipsum dolor sit amet consectetur adip occurence velit", | ||
replies: [ | ||
{ | ||
username: "Deepika Padukone", | ||
comment: | ||
"Lorem ipsum dolor sit amet consectetur adip occurence velit", | ||
replies: [ | ||
{ | ||
username: "Deepika Padukone", | ||
comment: | ||
"Lorem ipsum dolor sit amet consectetur adip occurence velit", | ||
replies: [ | ||
{ | ||
username: "Deepika Padukone", | ||
comment: | ||
"Lorem ipsum dolor sit amet consectetur adip occurence velit", | ||
replies: [ | ||
{ | ||
username: "Deepika Padukone", | ||
comment: | ||
"Lorem ipsum dolor sit amet consectetur adip occurence velit", | ||
replies: [ | ||
{ | ||
username: "Deepika Padukone", | ||
comment: | ||
"Lorem ipsum dolor sit amet consectetur adip occurence velit", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
username: "Deepika Padukone", | ||
comment: | ||
"Lorem ipsum dolor sit amet consectetur adip occurence velit", | ||
}, | ||
], | ||
}, | ||
{ | ||
username: "Deepika Padukone", | ||
comment: "Lorem ipsum dolor sit amet consectetur adip occurence velit", | ||
}, | ||
], | ||
}, | ||
{ | ||
username: "Sachin Tendulkar", | ||
comment: "Lorem ipsum dolor sit amet consectetur adip occurence velit", | ||
}, | ||
]; | ||
|
||
const Comments = () => { | ||
return ( | ||
<div> | ||
<CommentBox data={data} /> | ||
</div> | ||
); | ||
}; | ||
export default Comments; |