From f83993154859b2afc2ff4665132e3b39c47dc7c1 Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Tue, 5 Jul 2022 17:32:43 +0200 Subject: [PATCH] Added wip context menu --- apps/comments-ui/src/components/Comment.js | 66 +++++++++++++------ .../components/modals/AuthorContextMenu.js | 32 +++++++++ apps/comments-ui/src/images/icons/more.svg | 5 ++ 3 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 apps/comments-ui/src/components/modals/AuthorContextMenu.js create mode 100644 apps/comments-ui/src/images/icons/more.svg diff --git a/apps/comments-ui/src/components/Comment.js b/apps/comments-ui/src/components/Comment.js index e7a2d63850..335f279dde 100644 --- a/apps/comments-ui/src/components/Comment.js +++ b/apps/comments-ui/src/components/Comment.js @@ -1,32 +1,58 @@ import Avatar from './Avatar'; import {formatRelativeTime} from '../utils/helpers'; +import {ReactComponent as MoreIcon} from '../images/icons/more.svg'; +import React from 'react'; +import AppContext from '../AppContext'; +import AuthorContextMenu from './modals/AuthorContextMenu'; -function Comment(props) { - const comment = props.comment; +class Comment extends React.Component { + static contextType = AppContext; - const html = {__html: comment.html}; + constructor(props) { + super(props); + this.state = { + isContextMenuOpen: false + }; - return ( -
-
-
- + this.toggleContextMenu = this.toggleContextMenu.bind(this); + } -
-

{comment.member.name}

-
{formatRelativeTime(comment.created_at)}
+ toggleContextMenu() { + this.setState(state => ({ + isContextMenuOpen: !state.isContextMenuOpen + })); + } + + render() { + const comment = this.props.comment; + + const html = {__html: comment.html}; + + return ( +
+
+
+ + +
+

{comment.member.name}

+
{formatRelativeTime(comment.created_at)}
+
+ {/*
{comment.member.bio}
*/} + {/*
+ {formatRelativeTime(comment.created_at)} +
*/}
- {/*
{comment.member.bio}
*/} - {/*
- {formatRelativeTime(comment.created_at)} -
*/} -
-
-

+
+

+
+ + {/*
button> + {this.state.isContextMenuOpen ? : null}*/}
-
- ); + ); + } } export default Comment; diff --git a/apps/comments-ui/src/components/modals/AuthorContextMenu.js b/apps/comments-ui/src/components/modals/AuthorContextMenu.js new file mode 100644 index 0000000000..728fde1c53 --- /dev/null +++ b/apps/comments-ui/src/components/modals/AuthorContextMenu.js @@ -0,0 +1,32 @@ +import React from 'react'; +import AppContext from '../../AppContext'; + +class Form extends React.Component { + static contextType = AppContext; + + constructor(props) { + super(props); + this.state = {}; + + this.deleteComment = this.deleteComment.bind(this); + } + + deleteComment(event) { + // todo + } + + render() { + return ( +
+ + +
+ ); + } +} + +export default Form; diff --git a/apps/comments-ui/src/images/icons/more.svg b/apps/comments-ui/src/images/icons/more.svg new file mode 100644 index 0000000000..bc70fbb31a --- /dev/null +++ b/apps/comments-ui/src/images/icons/more.svg @@ -0,0 +1,5 @@ + + + + +