From 2521653ba27187c2b7b11046c4a402f2e91c2d02 Mon Sep 17 00:00:00 2001 From: Kechicode <186776112+Kechicode@users.noreply.github.com> Date: Fri, 6 Dec 2024 17:48:02 +0800 Subject: [PATCH 1/6] feat(ArticleCommentForm): add slide down fade animation --- src/components/Comment/FooterActions/index.tsx | 1 + .../Forms/ArticleCommentForm/index.tsx | 10 +++++++++- .../Forms/ArticleCommentForm/styles.module.css | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/components/Comment/FooterActions/index.tsx b/src/components/Comment/FooterActions/index.tsx index 290d4cb443..be629286da 100644 --- a/src/components/Comment/FooterActions/index.tsx +++ b/src/components/Comment/FooterActions/index.tsx @@ -283,6 +283,7 @@ const BaseFooterActions = ({ }} isInCommentDetail={isInCommentDetail} defaultContent={defaultContent} + playAnimation /> )} diff --git a/src/components/Forms/ArticleCommentForm/index.tsx b/src/components/Forms/ArticleCommentForm/index.tsx index 7fbf4c381b..18cf2e8c5e 100644 --- a/src/components/Forms/ArticleCommentForm/index.tsx +++ b/src/components/Forms/ArticleCommentForm/index.tsx @@ -1,4 +1,5 @@ import { Editor } from '@matters/matters-editor' +import classNames from 'classnames' import { useContext, useState } from 'react' import { FormattedMessage, useIntl } from 'react-intl' @@ -38,6 +39,7 @@ export interface ArticleCommentFormProps { showClear?: boolean placeholder?: string + playAnimation?: boolean isFallbackEditor?: boolean setEditor?: (editor: Editor | null) => void } @@ -54,6 +56,7 @@ export const ArticleCommentForm: React.FC = ({ showClear, placeholder, isFallbackEditor, + playAnimation, setEditor: propsSetEditor, }) => { const intl = useIntl() @@ -178,9 +181,14 @@ export const ArticleCommentForm: React.FC = ({ handleSubmit() }) + const formClasses = classNames({ + [styles.form]: true, + [styles.playAnimation]: playAnimation, + }) + return (
Date: Fri, 6 Dec 2024 18:31:57 +0800 Subject: [PATCH 2/6] feat(ArticleCommentForm): add smooth hide animation for comment forms --- .../Comment/FooterActions/index.tsx | 41 +++++++++++++------ .../Forms/ArticleCommentForm/index.tsx | 12 +++++- .../ArticleCommentForm/styles.module.css | 23 +++++++++-- 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/src/components/Comment/FooterActions/index.tsx b/src/components/Comment/FooterActions/index.tsx index be629286da..f9e0984f91 100644 --- a/src/components/Comment/FooterActions/index.tsx +++ b/src/components/Comment/FooterActions/index.tsx @@ -189,6 +189,31 @@ const BaseFooterActions = ({ )} ` : '' + const [isHiding, setIsHiding] = useState(false) + + const handleHideForm = () => { + // Start hide animation + setIsHiding(true) + } + + const handleHideComplete = () => { + // End hide animation + setIsHiding(false) + + if (editor === activeEditor) { + setActiveEditor(null) + } + setShowForm(false) + } + + const handleReplyButtonClick = () => { + if (showForm) { + handleHideForm() + } else { + toggleShowForm() + } + } + return ( <>