mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
boris: highlight announce comments
This commit is contained in:
parent
2ecda12513
commit
6230a769e0
5 changed files with 41 additions and 18 deletions
|
@ -20,6 +20,7 @@ type IProps = HTMLAttributes<HTMLDivElement> & {
|
||||||
group: ICommentGroup;
|
group: ICommentGroup;
|
||||||
isSame?: boolean;
|
isSame?: boolean;
|
||||||
canEdit?: boolean;
|
canEdit?: boolean;
|
||||||
|
highlighted?: boolean;
|
||||||
saveComment: (data: IComment) => Promise<unknown>;
|
saveComment: (data: IComment) => Promise<unknown>;
|
||||||
onDelete: (id: IComment['id'], isLocked: boolean) => void;
|
onDelete: (id: IComment['id'], isLocked: boolean) => void;
|
||||||
onShowImageModal: (images: IFile[], index: number) => void;
|
onShowImageModal: (images: IFile[], index: number) => void;
|
||||||
|
@ -33,6 +34,7 @@ const Comment: FC<IProps> = memo(
|
||||||
isSame,
|
isSame,
|
||||||
isLoading,
|
isLoading,
|
||||||
className,
|
className,
|
||||||
|
highlighted,
|
||||||
canEdit,
|
canEdit,
|
||||||
onDelete,
|
onDelete,
|
||||||
onShowImageModal,
|
onShowImageModal,
|
||||||
|
@ -41,8 +43,9 @@ const Comment: FC<IProps> = memo(
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<CommentWrapper
|
<CommentWrapper
|
||||||
className={classNames(className, {
|
className={classNames(styles.container, className, {
|
||||||
[NEW_COMMENT_CLASSNAME]: group.hasNew,
|
[NEW_COMMENT_CLASSNAME]: group.hasNew,
|
||||||
|
[styles.highlighted]: highlighted,
|
||||||
})}
|
})}
|
||||||
isEmpty={isEmpty}
|
isEmpty={isEmpty}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
|
@ -53,23 +56,31 @@ const Comment: FC<IProps> = memo(
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
{group.comments.map((comment, index) => {
|
{group.comments.map((comment, index) => {
|
||||||
if (comment.deleted_at) {
|
if (comment.deleted_at) {
|
||||||
return <CommendDeleted id={comment.id} onDelete={onDelete} key={comment.id} />;
|
return (
|
||||||
|
<CommendDeleted
|
||||||
|
id={comment.id}
|
||||||
|
onDelete={onDelete}
|
||||||
|
key={comment.id}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const prefix = Math.abs(group.distancesInDays[index]) > 14 && (
|
||||||
|
<CommentDistance
|
||||||
|
firstDate={
|
||||||
|
comment?.created_at ? parseISO(comment.created_at) : undefined
|
||||||
|
}
|
||||||
|
secondDate={
|
||||||
|
index > 0 && group.comments[index - 1]?.created_at
|
||||||
|
? parseISO(group.comments[index - 1].created_at!)
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CommentContent
|
<CommentContent
|
||||||
prefix={
|
prefix={prefix}
|
||||||
Math.abs(group.distancesInDays[index]) > 14 && (
|
|
||||||
<CommentDistance
|
|
||||||
firstDate={comment?.created_at ? parseISO(comment.created_at) : undefined}
|
|
||||||
secondDate={
|
|
||||||
index > 0 && group.comments[index - 1]?.created_at
|
|
||||||
? parseISO(group.comments[index - 1].created_at!)
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
saveComment={saveComment}
|
saveComment={saveComment}
|
||||||
nodeId={nodeId}
|
nodeId={nodeId}
|
||||||
comment={comment}
|
comment={comment}
|
||||||
|
@ -83,7 +94,7 @@ const Comment: FC<IProps> = memo(
|
||||||
</div>
|
</div>
|
||||||
</CommentWrapper>
|
</CommentWrapper>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export { Comment };
|
export { Comment };
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@import "src/styles/variables";
|
@import 'src/styles/variables';
|
||||||
|
|
||||||
@keyframes appear {
|
@keyframes appear {
|
||||||
from {
|
from {
|
||||||
|
@ -11,3 +11,7 @@
|
||||||
.wrap {
|
.wrap {
|
||||||
animation: appear 1s;
|
animation: appear 1s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.highlighted {
|
||||||
|
box-shadow: $color_primary 0 0 0px 2px;
|
||||||
|
}
|
||||||
|
|
|
@ -24,3 +24,6 @@ export const initialBackendStats: StatBackend = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const foundationDate = '2009-07-21 12:28:58';
|
export const foundationDate = '2009-07-21 12:28:58';
|
||||||
|
|
||||||
|
export const ANNOUNCE_USER_ID = 1;
|
||||||
|
export const BORIS_NODE_ID = 696;
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React, { FC, memo, useMemo } from 'react';
|
||||||
|
|
||||||
import { Comment } from '~/components/comment/Comment';
|
import { Comment } from '~/components/comment/Comment';
|
||||||
import { LoadMoreButton } from '~/components/input/LoadMoreButton';
|
import { LoadMoreButton } from '~/components/input/LoadMoreButton';
|
||||||
|
import { ANNOUNCE_USER_ID, BORIS_NODE_ID } from '~/constants/boris/constants';
|
||||||
import { useGrouppedComments } from '~/hooks/node/useGrouppedComments';
|
import { useGrouppedComments } from '~/hooks/node/useGrouppedComments';
|
||||||
import { ICommentGroup } from '~/types';
|
import { ICommentGroup } from '~/types';
|
||||||
import { useCommentContext } from '~/utils/context/CommentContextProvider';
|
import { useCommentContext } from '~/utils/context/CommentContextProvider';
|
||||||
|
@ -64,6 +65,9 @@ const NodeComments: FC<IProps> = memo(({ order }) => {
|
||||||
nodeId={node.id!}
|
nodeId={node.id!}
|
||||||
key={group.ids.join()}
|
key={group.ids.join()}
|
||||||
group={group}
|
group={group}
|
||||||
|
highlighted={
|
||||||
|
node.id === BORIS_NODE_ID && group.user.id === ANNOUNCE_USER_ID
|
||||||
|
}
|
||||||
canEdit={canEditComment(group, user)}
|
canEdit={canEditComment(group, user)}
|
||||||
onDelete={onDeleteComment}
|
onDelete={onDeleteComment}
|
||||||
onShowImageModal={onShowImageModal}
|
onShowImageModal={onShowImageModal}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import React, { VFC } from 'react';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
|
|
||||||
import { PageTitle } from '~/components/common/PageTitle';
|
import { PageTitle } from '~/components/common/PageTitle';
|
||||||
|
import { BORIS_NODE_ID } from '~/constants/boris/constants';
|
||||||
import { useBoris } from '~/hooks/boris/useBoris';
|
import { useBoris } from '~/hooks/boris/useBoris';
|
||||||
import { useNodeComments } from '~/hooks/comments/useNodeComments';
|
import { useNodeComments } from '~/hooks/comments/useNodeComments';
|
||||||
import { useImageModal } from '~/hooks/navigation/useImageModal';
|
import { useImageModal } from '~/hooks/navigation/useImageModal';
|
||||||
|
@ -13,7 +14,7 @@ import { NodeContextProvider } from '~/utils/context/NodeContextProvider';
|
||||||
import { getPageTitle } from '~/utils/ssr/getPageTitle';
|
import { getPageTitle } from '~/utils/ssr/getPageTitle';
|
||||||
|
|
||||||
const BorisPage: VFC = observer(() => {
|
const BorisPage: VFC = observer(() => {
|
||||||
const { node, isLoading, update } = useLoadNode(696);
|
const { node, isLoading, update } = useLoadNode(BORIS_NODE_ID);
|
||||||
|
|
||||||
const onShowImageModal = useImageModal();
|
const onShowImageModal = useImageModal();
|
||||||
const {
|
const {
|
||||||
|
@ -24,7 +25,7 @@ const BorisPage: VFC = observer(() => {
|
||||||
hasMore,
|
hasMore,
|
||||||
isLoading: isLoadingComments,
|
isLoading: isLoadingComments,
|
||||||
isLoadingMore,
|
isLoadingMore,
|
||||||
} = useNodeComments(696);
|
} = useNodeComments(BORIS_NODE_ID);
|
||||||
const { title, stats, isLoadingStats } = useBoris(comments);
|
const { title, stats, isLoadingStats } = useBoris(comments);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue