From eea7095e6588c753e924c0e6164d44f653d4ef84 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Sun, 19 Nov 2023 18:07:28 +0600 Subject: [PATCH] refactor comment components --- .../LocalCommentFormTextarea/index.tsx | 36 --------------- .../Authorized/index.tsx | 0 .../CommentFormAttachButtons/index.tsx | 0 .../components}/CommentFormAttaches/index.tsx | 0 .../CommentFormAttaches/styles.module.scss | 0 .../CommentFormFormatButtons/index.tsx | 0 .../styles.module.scss | 0 .../components/CommentFormTextarea/index.tsx | 44 +++++++++++++++++++ .../{comment => common}/CommentForm/index.tsx | 14 +++--- .../CommentForm/styles.module.scss | 0 src/components/common/CornerMenu/index.tsx | 10 ++++- src/constants/comment.ts | 9 ---- src/containers/boris/BorisComments/index.tsx | 4 +- .../components}/CommentAvatar/index.tsx | 0 .../CommentAvatar/styles.module.scss | 0 .../comments}/CommentWrapper/index.tsx | 2 +- .../CommentWrapper/styles.module.scss | 0 .../NodeCommentForm/index.tsx | 5 ++- .../{node => comments}/NodeCommentForm/ssr.ts | 0 .../components}/CommentEditingForm/index.tsx | 2 +- .../components}/CommentEmbedBlock/index.tsx | 0 .../CommentEmbedBlock/styles.module.scss | 0 .../components}/CommentImageGrid/index.tsx | 0 .../CommentImageGrid/styles.module.scss | 0 .../components}/CommentLike/index.tsx | 0 .../CommentLike/styles.module.scss | 0 .../components}/CommentMenu/index.tsx | 0 .../CommentMenu/styles.module.scss | 0 .../components}/CommentTextBlock/index.tsx | 0 .../CommentTextBlock/styles.module.scss | 0 .../CommentContent/constants/index.ts | 10 +++++ .../components}/CommentContent/index.tsx | 11 +++-- .../CommentContent/styles.module.scss | 0 .../components}/CommentDistance/index.tsx | 0 .../CommentDistance/styles.module.scss | 0 .../components}/Comment/index.tsx | 8 ++-- .../components}/Comment/styles.module.scss | 0 .../{node => comments}/NodeComments/index.tsx | 2 +- .../NodeComments/styles.module.scss | 0 src/containers/main/Header/index.tsx | 2 +- src/containers/main/SubmitBarRouter/index.tsx | 2 +- src/containers/node/NodeBottomBlock/index.tsx | 4 +- 42 files changed, 89 insertions(+), 76 deletions(-) delete mode 100644 src/components/comment/LocalCommentFormTextarea/index.tsx rename src/components/{containers => common}/Authorized/index.tsx (100%) rename src/components/{comment => common/CommentForm/components}/CommentFormAttachButtons/index.tsx (100%) rename src/components/{comment => common/CommentForm/components}/CommentFormAttaches/index.tsx (100%) rename src/components/{comment => common/CommentForm/components}/CommentFormAttaches/styles.module.scss (100%) rename src/components/{comment => common/CommentForm/components}/CommentFormFormatButtons/index.tsx (100%) rename src/components/{comment => common/CommentForm/components}/CommentFormFormatButtons/styles.module.scss (100%) create mode 100644 src/components/common/CommentForm/components/CommentFormTextarea/index.tsx rename src/components/{comment => common}/CommentForm/index.tsx (86%) rename src/components/{comment => common}/CommentForm/styles.module.scss (100%) rename src/{components/comment => containers/comments/CommentWrapper/components}/CommentAvatar/index.tsx (100%) rename src/{components/comment => containers/comments/CommentWrapper/components}/CommentAvatar/styles.module.scss (100%) rename src/{components/containers => containers/comments}/CommentWrapper/index.tsx (93%) rename src/{components/containers => containers/comments}/CommentWrapper/styles.module.scss (100%) rename src/containers/{node => comments}/NodeCommentForm/index.tsx (91%) rename src/containers/{node => comments}/NodeCommentForm/ssr.ts (100%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components/CommentContent/components}/CommentEditingForm/index.tsx (94%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components/CommentContent/components}/CommentEmbedBlock/index.tsx (100%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components/CommentContent/components}/CommentEmbedBlock/styles.module.scss (100%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components/CommentContent/components}/CommentImageGrid/index.tsx (100%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components/CommentContent/components}/CommentImageGrid/styles.module.scss (100%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components/CommentContent/components}/CommentLike/index.tsx (100%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components/CommentContent/components}/CommentLike/styles.module.scss (100%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components/CommentContent/components}/CommentMenu/index.tsx (100%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components/CommentContent/components}/CommentMenu/styles.module.scss (100%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components/CommentContent/components}/CommentTextBlock/index.tsx (100%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components/CommentContent/components}/CommentTextBlock/styles.module.scss (100%) create mode 100644 src/containers/comments/NodeComments/components/Comment/components/CommentContent/constants/index.ts rename src/{components/comment => containers/comments/NodeComments/components/Comment/components}/CommentContent/index.tsx (93%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components}/CommentContent/styles.module.scss (100%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components}/CommentDistance/index.tsx (100%) rename src/{components/comment => containers/comments/NodeComments/components/Comment/components}/CommentDistance/styles.module.scss (100%) rename src/{components/comment => containers/comments/NodeComments/components}/Comment/index.tsx (90%) rename src/{components/comment => containers/comments/NodeComments/components}/Comment/styles.module.scss (100%) rename src/containers/{node => comments}/NodeComments/index.tsx (96%) rename src/containers/{node => comments}/NodeComments/styles.module.scss (100%) diff --git a/src/components/comment/LocalCommentFormTextarea/index.tsx b/src/components/comment/LocalCommentFormTextarea/index.tsx deleted file mode 100644 index d901d241..00000000 --- a/src/components/comment/LocalCommentFormTextarea/index.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import React, { forwardRef, KeyboardEventHandler, TextareaHTMLAttributes, useCallback } from 'react'; - -import { Textarea } from '~/components/input/Textarea'; -import { useRandomPhrase } from '~/constants/phrases'; -import { useCommentFormContext } from '~/hooks/comments/useCommentFormFormik'; - -interface IProps extends TextareaHTMLAttributes { - isLoading?: boolean; -} - -const LocalCommentFormTextarea = forwardRef(({ ...rest }, ref) => { - const { values, handleChange, handleSubmit, isSubmitting } = useCommentFormContext(); - - const onKeyDown = useCallback>( - ({ ctrlKey, key, metaKey }) => { - if ((ctrlKey || metaKey) && key === 'Enter') handleSubmit(undefined); - }, - [handleSubmit] - ); - - const placeholder = useRandomPhrase('SIMPLE'); - - return ( -