From 4b504130d86346554323feb12ba93e91db05b6b1 Mon Sep 17 00:00:00 2001 From: James Morris Date: Tue, 19 Jul 2022 15:24:55 +0100 Subject: [PATCH] Working progress of the button when sending reporting refs https://github.com/TryGhost/Team/issues/1685 --- .../components/modals/NotAuthorContextMenu.js | 32 +++++++++++++++---- .../src/components/modals/ReportDialog.js | 30 +++++++++++++++-- apps/comments-ui/src/images/icons/spinner.svg | 1 + apps/comments-ui/src/images/icons/success.svg | 5 +++ 4 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 apps/comments-ui/src/images/icons/spinner.svg create mode 100644 apps/comments-ui/src/images/icons/success.svg diff --git a/apps/comments-ui/src/components/modals/NotAuthorContextMenu.js b/apps/comments-ui/src/components/modals/NotAuthorContextMenu.js index 8374083c6f..0438502e0d 100644 --- a/apps/comments-ui/src/components/modals/NotAuthorContextMenu.js +++ b/apps/comments-ui/src/components/modals/NotAuthorContextMenu.js @@ -5,23 +5,41 @@ import ReportDialog from './ReportDialog'; const NotAuthorContextMenu = (props) => { // const {dispatchAction} = useContext(AppContext); - let [isOpen, setIsOpen] = useState(false); + let [isOpen, setOpen] = useState(false); + let [reportProgress, setProgress] = useState('default'); // states for button: default, sending, sent - const reportComment = (event) => { - // dispatchAction('reportComment', props.comment); - setIsOpen(true); + const openModal = () => { + setProgress('default'); + setOpen(true); }; const closeModal = () => { - setIsOpen(false); + setProgress('default'); + setOpen(false); + }; + + const reportComment = (event) => { + event.stopPropagation(); + + setProgress('sending'); + + // faked timing of the report being sent for user feedback purposes + setTimeout(() => { + setProgress('sent'); + // dispatchAction('reportComment', props.comment); + + setTimeout(() => { + setOpen(false); + }, 750); + }, 1000); }; return (
- - +
); }; diff --git a/apps/comments-ui/src/components/modals/ReportDialog.js b/apps/comments-ui/src/components/modals/ReportDialog.js index 7dd09de5e9..0181fcf6d1 100644 --- a/apps/comments-ui/src/components/modals/ReportDialog.js +++ b/apps/comments-ui/src/components/modals/ReportDialog.js @@ -1,13 +1,39 @@ import React from 'react'; import GenericDialog from './GenericDialog'; +import {ReactComponent as SpinnerIcon} from '../../images/icons/spinner.svg'; +import {ReactComponent as SuccessIcon} from '../../images/icons/success.svg'; const ReportDialog = (props) => { + let buttonColor = 'bg-red-600'; + if (props.progress === 'sent') { + buttonColor = 'bg-green-600'; + } + + let buttonText = 'Yes'; + if (props.progress === 'sending') { + buttonText = 'Sending'; + } else if (props.progress === 'sent') { + buttonText = 'Sent'; + } + + let buttonIcon = null; + if (props.progress === 'sending') { + buttonIcon = ; + } else if (props.progress === 'sent') { + buttonIcon = ; + } + return ( - +

You sure you want to report?

You request will be sent to the owner of this site.

- +

No,

diff --git a/apps/comments-ui/src/images/icons/spinner.svg b/apps/comments-ui/src/images/icons/spinner.svg new file mode 100644 index 0000000000..a348b523aa --- /dev/null +++ b/apps/comments-ui/src/images/icons/spinner.svg @@ -0,0 +1 @@ + diff --git a/apps/comments-ui/src/images/icons/success.svg b/apps/comments-ui/src/images/icons/success.svg new file mode 100644 index 0000000000..8c8d68a370 --- /dev/null +++ b/apps/comments-ui/src/images/icons/success.svg @@ -0,0 +1,5 @@ + + + + +