mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: add comment tip (#5854)
This commit is contained in:
parent
87e950733f
commit
0cd5af5ffa
@ -31,8 +31,8 @@ const InfoSnackbar = forwardRef<HTMLDivElement, InfoSnackbarProps>(
|
||||
};
|
||||
|
||||
return (
|
||||
<SnackbarContent ref={ref}>
|
||||
<Paper className={`relative flex flex-col gap-4 border p-4 ${getBorderColor(type)}`}>
|
||||
<SnackbarContent ref={ref} className={'flex items-center justify-center'}>
|
||||
<Paper className={`relative flex flex-col gap-4 border p-5 ${getBorderColor(type)}`}>
|
||||
<div className={'flex w-full items-center justify-between text-base font-medium'}>
|
||||
<div className={'flex flex-1 items-center gap-2 text-left font-semibold'}>
|
||||
{getIcon(type)}
|
||||
@ -45,7 +45,7 @@ const InfoSnackbar = forwardRef<HTMLDivElement, InfoSnackbarProps>(
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 pr-10'}>{message}</div>
|
||||
<div className={'mx-8 flex-1'}>{message}</div>
|
||||
{showActions && (
|
||||
<div className={'flex w-full justify-end gap-4'}>
|
||||
<Button
|
||||
|
@ -16,9 +16,10 @@ interface AddCommentProps {
|
||||
setContent: (content: string) => void;
|
||||
focus: boolean;
|
||||
setFocus: (focus: boolean) => void;
|
||||
fixed: boolean;
|
||||
}
|
||||
|
||||
function AddComment({ content, setContent, focus, setFocus }: AddCommentProps) {
|
||||
function AddComment({ content, setContent, focus, setFocus, fixed }: AddCommentProps) {
|
||||
const { reload, replyCommentId, replyComment: setReplyCommentId } = useGlobalCommentContext();
|
||||
|
||||
const { t } = useTranslation();
|
||||
@ -50,24 +51,37 @@ function AddComment({ content, setContent, focus, setFocus }: AddCommentProps) {
|
||||
setContent('');
|
||||
|
||||
setReplyCommentId(null);
|
||||
notify.info({
|
||||
type: 'success',
|
||||
title: t('globalComment.commentAddedSuccessfully'),
|
||||
message: t('globalComment.askForViewComment'),
|
||||
okText: t('button.yes'),
|
||||
onOk: () => {
|
||||
const element = document.getElementById('addComment') as HTMLElement;
|
||||
if (fixed) {
|
||||
notify.info({
|
||||
type: 'success',
|
||||
title: t('globalComment.commentAddedSuccessfully'),
|
||||
message: t('globalComment.commentAddedSuccessTip'),
|
||||
okText: t('button.yes'),
|
||||
onOk: () => {
|
||||
const element = document.getElementById('addComment') as HTMLElement;
|
||||
|
||||
if (!element) return;
|
||||
void smoothScrollIntoViewIfNeeded(element, { behavior: 'smooth', scrollMode: 'if-needed', block: 'start' });
|
||||
},
|
||||
});
|
||||
if (!element) return;
|
||||
void smoothScrollIntoViewIfNeeded(element, { behavior: 'smooth', scrollMode: 'if-needed', block: 'start' });
|
||||
},
|
||||
});
|
||||
}
|
||||
} catch (_e) {
|
||||
notify.error(t('globalComment.failedToAddComment'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [createCommentOnPublishView, viewId, loading, content, replyCommentId, reload, setReplyCommentId, t, setContent]);
|
||||
}, [
|
||||
fixed,
|
||||
createCommentOnPublishView,
|
||||
viewId,
|
||||
loading,
|
||||
content,
|
||||
replyCommentId,
|
||||
reload,
|
||||
setReplyCommentId,
|
||||
t,
|
||||
setContent,
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className={'flex flex-col gap-2'}>
|
||||
|
@ -50,13 +50,14 @@ export function AddCommentWrapper() {
|
||||
setContent={setContent}
|
||||
focus={focus && !showFixedAddComment}
|
||||
setFocus={setFocus}
|
||||
fixed={false}
|
||||
/>
|
||||
</div>
|
||||
{showFixedAddComment && (
|
||||
<Portal container={document.body}>
|
||||
<div className={'fixed top-[48px] flex w-full justify-center'}>
|
||||
<div className={'w-[964px] min-w-0 max-w-full px-16 max-sm:px-4'}>
|
||||
<AddComment content={content} setContent={setContent} focus={focus} setFocus={setFocus} />
|
||||
<AddComment fixed content={content} setContent={setContent} focus={focus} setFocus={setFocus} />
|
||||
</div>
|
||||
</div>
|
||||
</Portal>
|
||||
|
@ -2365,6 +2365,6 @@
|
||||
"readMore": "Read more",
|
||||
"failedToAddComment": "Failed to add comment",
|
||||
"commentAddedSuccessfully": "Comment added successfully.",
|
||||
"askForViewComment": "Do you want to view the comment?"
|
||||
"commentAddedSuccessTip": "You've just added or replied to a comment. Would you like to jump to the top to see the latest comments?"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user