From d7b2499c13bcafa26bb657afd98b5fe89e4b2724 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Tue, 26 Apr 2022 10:41:03 +0300 Subject: [PATCH] feat: comment with replies component, convertCommentsToTree helper method, comments section component, add comment input component, useAutoResizableText area, update mocks with comments data --- .../Comments/AddComment/AddComment.tsx | 33 +++++++++++++++++++ .../Comments/Comment/Comment.stories.tsx | 28 ++++++++++++++++ .../Components/Comments/Comment/Comment.tsx | 22 +++++++++++++ .../CommentCard/CommentCard.stories.tsx | 6 ++-- .../CommentCard/CommentCard.tsx | 12 ++----- .../CommentsSection.stories.tsx | 22 +++++++++++++ .../CommentsSection/CommentsSection.tsx | 27 +++++++++++++++ .../Posts/Components/Comments/helpers.tsx | 19 +++++++++++ .../Posts/Components/Comments/index.tsx | 1 + .../Posts/Components/Comments/types.ts | 15 +++++++++ src/mocks/data.ts | 5 +-- src/mocks/data/posts.ts | 6 ++-- src/utils/hooks/index.ts | 1 + src/utils/hooks/useAutoResizableTextArea.ts | 20 +++++++++++ 14 files changed, 201 insertions(+), 16 deletions(-) create mode 100644 src/features/Posts/Components/Comments/AddComment/AddComment.tsx create mode 100644 src/features/Posts/Components/Comments/Comment/Comment.stories.tsx create mode 100644 src/features/Posts/Components/Comments/Comment/Comment.tsx rename src/features/Posts/Components/{ => Comments}/CommentCard/CommentCard.stories.tsx (80%) rename src/features/Posts/Components/{ => Comments}/CommentCard/CommentCard.tsx (77%) create mode 100644 src/features/Posts/Components/Comments/CommentsSection/CommentsSection.stories.tsx create mode 100644 src/features/Posts/Components/Comments/CommentsSection/CommentsSection.tsx create mode 100644 src/features/Posts/Components/Comments/helpers.tsx create mode 100644 src/features/Posts/Components/Comments/index.tsx create mode 100644 src/features/Posts/Components/Comments/types.ts create mode 100644 src/utils/hooks/useAutoResizableTextArea.ts diff --git a/src/features/Posts/Components/Comments/AddComment/AddComment.tsx b/src/features/Posts/Components/Comments/AddComment/AddComment.tsx new file mode 100644 index 0000000..669cbd5 --- /dev/null +++ b/src/features/Posts/Components/Comments/AddComment/AddComment.tsx @@ -0,0 +1,33 @@ +import { FormEvent } from "react"; +import Button from "src/Components/Button/Button"; +import Avatar from "src/features/Profiles/Components/Avatar/Avatar"; +import { useAutoResizableTextArea } from "src/utils/hooks"; + + + +export default function AddComment() { + + const textAreaRef = useAutoResizableTextArea(); + + const submitComment = (e: FormEvent) => { + e.preventDefault(); + alert('submitted') + } + + return ( +
+
+ +