From c30ecc1b81f3b704e0e32b46d2b084d9fad8e0be Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Mon, 26 Dec 2022 13:54:35 +0600 Subject: [PATCH] fixed comment loader animation --- src/components/node/NodeNoComments/index.tsx | 17 ++++++---- .../node/NodeNoComments/styles.module.scss | 11 ++++++- src/containers/boris/BorisComments/index.tsx | 32 +++++++++---------- src/containers/node/NodeBottomBlock/index.tsx | 24 +++++++++++--- 4 files changed, 56 insertions(+), 28 deletions(-) diff --git a/src/components/node/NodeNoComments/index.tsx b/src/components/node/NodeNoComments/index.tsx index 3ae20562..11db8302 100644 --- a/src/components/node/NodeNoComments/index.tsx +++ b/src/components/node/NodeNoComments/index.tsx @@ -9,20 +9,25 @@ import { t } from '~/utils/trans'; import styles from './styles.module.scss'; interface IProps { - is_loading?: boolean; + loading?: boolean; count?: number; } -const NodeNoComments: FC = ({ is_loading = false, count = 3 }) => { +const NodeNoComments: FC = ({ loading = false, count = 3 }) => { const items = useMemo( - () => [...new Array(count)].map((_, i) =>
), - [count] + () => + [...new Array(count)].map((_, i) => ( +
+ )), + [count], ); return ( - + {items} - {!is_loading &&
{t(ERRORS.NO_COMMENTS)}
} + {!loading && ( +
{t(ERRORS.NO_COMMENTS)}
+ )}
); }; diff --git a/src/components/node/NodeNoComments/styles.module.scss b/src/components/node/NodeNoComments/styles.module.scss index cdae439c..3b350569 100644 --- a/src/components/node/NodeNoComments/styles.module.scss +++ b/src/components/node/NodeNoComments/styles.module.scss @@ -1,5 +1,14 @@ @import 'src/styles/variables'; +@keyframes fade { + from { + opacity: 1; + } + to { + opacity: 0.3; + } +} + .wrap { user-select: none; overflow: hidden; @@ -17,7 +26,7 @@ bottom: 0; } - &:global(.is_loading) { + &.loading { opacity: 1; .card { diff --git a/src/containers/boris/BorisComments/index.tsx b/src/containers/boris/BorisComments/index.tsx index b0052db2..7f17df1f 100644 --- a/src/containers/boris/BorisComments/index.tsx +++ b/src/containers/boris/BorisComments/index.tsx @@ -17,27 +17,27 @@ const BorisComments: FC = () => { const user = useUserContext(); const { isUser } = useAuth(); - const { - isLoading, - comments, - onSaveComment, - } = useCommentContext(); + const { isLoading, comments, onSaveComment } = useCommentContext(); const { node } = useNodeContext(); return ( - - {(isUser || isSSR) && ( - - )} + + {(isUser || isSSR) && ( + + )} - {isLoading || !comments?.length ? ( - - ) : ( - - )} + {isLoading || !comments?.length ? ( + + ) : ( + + )} -
- +
+ ); }; diff --git a/src/containers/node/NodeBottomBlock/index.tsx b/src/containers/node/NodeBottomBlock/index.tsx index 5532cf44..6553b7f7 100644 --- a/src/containers/node/NodeBottomBlock/index.tsx +++ b/src/containers/node/NodeBottomBlock/index.tsx @@ -26,7 +26,11 @@ interface IProps { const NodeBottomBlock: FC = ({ commentsOrder }) => { const user = useUserContext(); const { node, isLoading } = useNodeContext(); - const { comments, isLoading: isLoadingComments, onSaveComment } = useCommentContext(); + const { + comments, + isLoading: isLoadingComments, + onSaveComment, + } = useCommentContext(); const { related, isLoading: isLoadingRelated } = useNodeRelatedContext(); const { inline } = useNodeBlocks(node, isLoading); const { isUser } = useAuthProvider(); @@ -43,15 +47,21 @@ const NodeBottomBlock: FC = ({ commentsOrder }) => { {inline &&
{inline}
}
- {isLoading || isLoadingComments || (!comments.length && !inline) ? ( - + {isLoading || + isLoadingComments || + (!comments.length && !inline) ? ( + ) : ( )}
{isUser && !isLoading && ( - + )} @@ -66,7 +76,11 @@ const NodeBottomBlock: FC = ({ commentsOrder }) => {
- +