mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
fixed comment loader animation
This commit is contained in:
parent
85f3de775a
commit
c30ecc1b81
4 changed files with 56 additions and 28 deletions
|
@ -9,20 +9,25 @@ import { t } from '~/utils/trans';
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
is_loading?: boolean;
|
loading?: boolean;
|
||||||
count?: number;
|
count?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NodeNoComments: FC<IProps> = ({ is_loading = false, count = 3 }) => {
|
const NodeNoComments: FC<IProps> = ({ loading = false, count = 3 }) => {
|
||||||
const items = useMemo(
|
const items = useMemo(
|
||||||
() => [...new Array(count)].map((_, i) => <div className={styles.card} key={i} />),
|
() =>
|
||||||
[count]
|
[...new Array(count)].map((_, i) => (
|
||||||
|
<div className={styles.card} key={i} />
|
||||||
|
)),
|
||||||
|
[count],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group className={classNames(styles.wrap, { is_loading })}>
|
<Group className={classNames(styles.wrap, { [styles.loading]: loading })}>
|
||||||
{items}
|
{items}
|
||||||
{!is_loading && <div className={styles.nothing}>{t(ERRORS.NO_COMMENTS)}</div>}
|
{!loading && (
|
||||||
|
<div className={styles.nothing}>{t(ERRORS.NO_COMMENTS)}</div>
|
||||||
|
)}
|
||||||
</Group>
|
</Group>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
@import 'src/styles/variables';
|
@import 'src/styles/variables';
|
||||||
|
|
||||||
|
@keyframes fade {
|
||||||
|
from {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 0.3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.wrap {
|
.wrap {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -17,7 +26,7 @@
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:global(.is_loading) {
|
&.loading {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
|
|
|
@ -17,21 +17,21 @@ const BorisComments: FC<IProps> = () => {
|
||||||
const user = useUserContext();
|
const user = useUserContext();
|
||||||
const { isUser } = useAuth();
|
const { isUser } = useAuth();
|
||||||
|
|
||||||
const {
|
const { isLoading, comments, onSaveComment } = useCommentContext();
|
||||||
isLoading,
|
|
||||||
comments,
|
|
||||||
onSaveComment,
|
|
||||||
} = useCommentContext();
|
|
||||||
const { node } = useNodeContext();
|
const { node } = useNodeContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group>
|
<Group>
|
||||||
{(isUser || isSSR) && (
|
{(isUser || isSSR) && (
|
||||||
<NodeCommentFormSSR user={user} nodeId={node.id} saveComment={onSaveComment} />
|
<NodeCommentFormSSR
|
||||||
|
user={user}
|
||||||
|
nodeId={node.id}
|
||||||
|
saveComment={onSaveComment}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isLoading || !comments?.length ? (
|
{isLoading || !comments?.length ? (
|
||||||
<NodeNoComments is_loading count={7} />
|
<NodeNoComments loading count={7} />
|
||||||
) : (
|
) : (
|
||||||
<NodeComments order="ASC" />
|
<NodeComments order="ASC" />
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -26,7 +26,11 @@ interface IProps {
|
||||||
const NodeBottomBlock: FC<IProps> = ({ commentsOrder }) => {
|
const NodeBottomBlock: FC<IProps> = ({ commentsOrder }) => {
|
||||||
const user = useUserContext();
|
const user = useUserContext();
|
||||||
const { node, isLoading } = useNodeContext();
|
const { node, isLoading } = useNodeContext();
|
||||||
const { comments, isLoading: isLoadingComments, onSaveComment } = useCommentContext();
|
const {
|
||||||
|
comments,
|
||||||
|
isLoading: isLoadingComments,
|
||||||
|
onSaveComment,
|
||||||
|
} = useCommentContext();
|
||||||
const { related, isLoading: isLoadingRelated } = useNodeRelatedContext();
|
const { related, isLoading: isLoadingRelated } = useNodeRelatedContext();
|
||||||
const { inline } = useNodeBlocks(node, isLoading);
|
const { inline } = useNodeBlocks(node, isLoading);
|
||||||
const { isUser } = useAuthProvider();
|
const { isUser } = useAuthProvider();
|
||||||
|
@ -43,15 +47,21 @@ const NodeBottomBlock: FC<IProps> = ({ commentsOrder }) => {
|
||||||
{inline && <div className={styles.inline}>{inline}</div>}
|
{inline && <div className={styles.inline}>{inline}</div>}
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
{isLoading || isLoadingComments || (!comments.length && !inline) ? (
|
{isLoading ||
|
||||||
<NodeNoComments is_loading={isLoadingComments || isLoading} />
|
isLoadingComments ||
|
||||||
|
(!comments.length && !inline) ? (
|
||||||
|
<NodeNoComments loading={isLoadingComments || isLoading} />
|
||||||
) : (
|
) : (
|
||||||
<NodeComments order={commentsOrder} />
|
<NodeComments order={commentsOrder} />
|
||||||
)}
|
)}
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
{isUser && !isLoading && (
|
{isUser && !isLoading && (
|
||||||
<NodeCommentFormSSR nodeId={node.id} saveComment={onSaveComment} user={user} />
|
<NodeCommentFormSSR
|
||||||
|
nodeId={node.id}
|
||||||
|
saveComment={onSaveComment}
|
||||||
|
user={user}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
|
@ -66,7 +76,11 @@ const NodeBottomBlock: FC<IProps> = ({ commentsOrder }) => {
|
||||||
<NodeTagsBlock />
|
<NodeTagsBlock />
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.left_item}>
|
<div className={styles.left_item}>
|
||||||
<NodeRelatedBlock isLoading={isLoadingRelated} node={node} related={related} />
|
<NodeRelatedBlock
|
||||||
|
isLoading={isLoadingRelated}
|
||||||
|
node={node}
|
||||||
|
related={related}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Sticky>
|
</Sticky>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue