From 278d9dcef9b1c66546f8961413485f225cebd2c3 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 19 Jun 2023 22:55:19 +0100 Subject: [PATCH] feat: comment loading skeleton --- src/components/site/PostFooter.tsx | 36 +++++++++++++++++++++--------- src/components/ui/CodeMirror.tsx | 2 +- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/components/site/PostFooter.tsx b/src/components/site/PostFooter.tsx index e779a86f..d8ad284e 100644 --- a/src/components/site/PostFooter.tsx +++ b/src/components/site/PostFooter.tsx @@ -10,16 +10,34 @@ import { ReactionLike } from "~/components/common/ReactionLike" import { ReactionTip } from "~/components/common/ReactionTip" import { ExpandedCharacter, ExpandedNote } from "~/lib/types" +import { Skeleton } from "../ui/Skeleton" + const key = ["PostFooterInView"] +const CommentSkeleton = () => ( +
+ + <> +
+ +
+
+ +
+ +
+ + +
+
+
+ +
+
+) + const DynamicComment = dynamic(() => import("~/components/common/Comment"), { - // TODO Skeleton - loading: () => ( -
-

Loading comments...

-
- ), - ssr: false, + loading: CommentSkeleton, }) export const usePostFooterInView = () => { @@ -69,9 +87,7 @@ export const PostFooter = ({ {inited || isInView ? ( ) : ( -
-

Loading comments...

-
+ )} ) diff --git a/src/components/ui/CodeMirror.tsx b/src/components/ui/CodeMirror.tsx index 49eb8c7f..499011a3 100644 --- a/src/components/ui/CodeMirror.tsx +++ b/src/components/ui/CodeMirror.tsx @@ -255,7 +255,7 @@ const LazyCodeMirrorEditor = forwardRef< data-cm-editor ref={editorElementRef} onMouseEnter={onMouseEnter} - className={loading ? "" : props.className} + className={loading ? "hidden" : props.className} /> {loading && (props.LoadingComponent ? (