From 84016e362db18f471d79d92de2ab0d2e4e1ddb2b Mon Sep 17 00:00:00 2001 From: Benjamin Goering Date: Wed, 26 Apr 2017 12:37:33 -0500 Subject: [PATCH] Delete Comment UI --- client/coral-embed-stream/src/Comment.css | 47 ++++++++++- client/coral-embed-stream/src/Comment.js | 83 +++++++++++++++++-- .../src/IgnoreUserWizard.css | 14 ---- .../src/IgnoreUserWizard.js | 4 +- 4 files changed, 121 insertions(+), 27 deletions(-) delete mode 100644 client/coral-embed-stream/src/IgnoreUserWizard.css diff --git a/client/coral-embed-stream/src/Comment.css b/client/coral-embed-stream/src/Comment.css index 8d7c7ebf9..5fe5401fe 100644 --- a/client/coral-embed-stream/src/Comment.css +++ b/client/coral-embed-stream/src/Comment.css @@ -13,13 +13,54 @@ pointer-events: none; } -.topRightMenu { +/* element in the top right of the Comment */ +.topRight { float: right; + margin-top: 10px; text-align: right; +} + +.topRight > * { + text-align: initial; +} + +.topRight .popover { + margin-top: 1em; + right: 0px; +} + +.topRight .popoverMenuOpen .link { + padding-bottom: 0.125em; + border-bottom: 2px solid currentColor; +} + +.topRightMenu { cursor: pointer; margin-top: 5px; } -.topRightMenu > * { - text-align: initial; +.link { + color: #2376D8; + cursor: pointer; +} + +.popover { + position: absolute; + z-index: 1; +} + +/* Wizard used for Ignore User, Delete Comment confirmations */ +.Wizard { + background-color: #2E343B; + color: white; + padding: 1em; + max-width: 220px; /* consider moving to better class */ +} + +.Wizard header { + font-weight: bold; +} + +.Wizard .textAlignRight { + text-align: right; } diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index 63b3ef8dc..b5a7dfeb3 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -23,6 +23,8 @@ import Slot from 'coral-framework/components/Slot'; import IgnoredCommentTombstone from './IgnoredCommentTombstone'; import {TopRightMenu} from './TopRightMenu'; import {getActionSummary, getTotalActionCount, iPerformedThisAction} from 'coral-framework/utils'; +import {Button} from 'coral-ui'; +import classnames from 'classnames'; import styles from './Comment.css'; @@ -161,6 +163,55 @@ class Comment extends React.Component { tag: BEST_TAG, }), () => 'Failed to remove best comment tag'); + class PopoverMenu extends React.Component { + static propTypes = { + children: PropTypes.node, + Popover: PropTypes.oneOfType([PropTypes.element, PropTypes.func]), + openClassName: PropTypes.string, + } + constructor(props) { + super(props); + this.toggle = this.toggle.bind(this); + this.close = this.close.bind(this); + this.state = { + isOpen: false + }; + } + toggle() { + this.setState({isOpen: ! this.state.isOpen}); + } + close() { + this.setState({isOpen: false}); + } + render() { + const {isOpen} = this.state; + const {children, Popover, openClassName} = this.props; + return ( + + + { children } + + + { isOpen ? : null } + + + ); + } + } + + const DeleteCommentConfirmation = ({cancel, deleteComment}) => { + return ( +
+
Delete a comment
+

Are you sure you want to delete that comment

+
+ + +
+
+ ); + }; + return (
- { (currentUser && (comment.user.id !== currentUser.id)) - ? - - - : null + { (currentUser && + (comment.user.id === currentUser.id)) + + /* User can edit/delete their own comment for a short window after posting */ + ? + + { /*console.log('delete comment', comment)*/ }} + /> }> + Delete + + + + /* TopRightMenu allows currentUser to ignore other users' comments */ + : + + } diff --git a/client/coral-embed-stream/src/IgnoreUserWizard.css b/client/coral-embed-stream/src/IgnoreUserWizard.css deleted file mode 100644 index 838f2f76a..000000000 --- a/client/coral-embed-stream/src/IgnoreUserWizard.css +++ /dev/null @@ -1,14 +0,0 @@ -.IgnoreUserWizard { - background-color: #2E343B; - color: white; - padding: 1em; - max-width: 220px; -} - -.IgnoreUserWizard header { - font-weight: bold; -} - -.IgnoreUserWizard .textAlignRight { - text-align: right; -} diff --git a/client/coral-embed-stream/src/IgnoreUserWizard.js b/client/coral-embed-stream/src/IgnoreUserWizard.js index 371e6d48b..7e72bb924 100644 --- a/client/coral-embed-stream/src/IgnoreUserWizard.js +++ b/client/coral-embed-stream/src/IgnoreUserWizard.js @@ -1,5 +1,5 @@ import React, {PropTypes} from 'react'; -import styles from './IgnoreUserWizard.css'; +import styles from './Comment.css'; import {Button} from 'coral-ui'; // Guides the user through ignoring another user, including confirming their decision @@ -58,7 +58,7 @@ export class IgnoreUserWizard extends React.Component { const {step} = this.state; const elForThisStep = elsForStep[step - 1]; return ( -
+
{ elForThisStep }
);