Skip to content

Commit

Permalink
onReplyClick and onReplyMessageClick added
Browse files Browse the repository at this point in the history
replyButton feat added
  • Loading branch information
abdurrahmanekr committed Apr 27, 2020
1 parent 3a3531d commit 6b09f88
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ import { MessageBox } from 'react-chat-elements'
| onPhotoError | none | function | message on error photo |
| onTitleClick | none | function | message title on click event |
| onForwardClick | none | function | message forward on click event |
| onReplyClick | none | function | message reply on click event |
| onReplyMessageClick | none | function | reply message on click event |
| onContextMenu | none | function | message contextmenu click event |
| forwarded | none | boolean | message forward icon |
| replyButton | none | boolean | message reply icon |
| status | none | string | message status info (waiting, sent, received, read) |
| notch | true | boolean | message box notch |
| avatar | none | url | message box avatar url |
Expand Down Expand Up @@ -225,6 +228,8 @@ import { MessageList } from 'react-chat-elements'
| onDownload | none | function | message list item on download (file or photo) (message(object) is returned) |
| onScroll | none | function | message list onScroll event |
| onForwardClick | none | function | message list item onForwardClick event |
| onReplyClick | none | function | message list item onReplyClick event |
| onReplyMessageClick | none | function | message list item onReplyMessageClick event |
| downButton | true | boolean | message list scroll to bottom button |
| downButtonBadge | none | boolean | message list downButton badge content |
| onDownButtonClick | none | function | message list onDownButtonClick |
Expand Down
1 change: 1 addition & 0 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class App extends Component {
return {
position: (this.token() >= 1 ? 'right' : 'left'),
forwarded: true,
replyButton: true,
reply: this.token() >= 1 ? ({
photoURL: this.token() >= 1 ? `data:image/png;base64,${this.photo(150)}` : null,
title: loremIpsum({ count: 2, units: 'words' }),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-chat-elements",
"version": "10.9.0",
"version": "10.9.1",
"description": "Reactjs chat components",
"author": "Avare Kodcu <[email protected]>",
"main": "dist/main.js",
Expand Down
26 changes: 25 additions & 1 deletion src/MessageBox/MessageBox.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@
right: -50px;
}

.rce-mbox-reply-btn-left {
display: flex;
opacity: 0;
visibility: hidden;
left: -85px;
}

.rce-mbox-reply-btn-right {
display: flex;
opacity: 0;
visibility: hidden;
right: -85px;
}

.rce-container-mbox:hover .rce-mbox-forward-left {
opacity: 1;
visibility: visible;
Expand All @@ -48,6 +62,16 @@
visibility: visible;
}

.rce-container-mbox:hover .rce-mbox-reply-btn-left {
opacity: 1;
visibility: visible;
}

.rce-container-mbox:hover .rce-mbox-reply-btn-right {
opacity: 1;
visibility: visible;
}

.rce-mbox {
position: relative;
background: white;
Expand Down Expand Up @@ -222,4 +246,4 @@

.rce-mbox-title > .rce-avatar-container {
margin-right: 5px;
}
}
20 changes: 19 additions & 1 deletion src/MessageBox/MessageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import ReplyMessage from '../ReplyMessage/ReplyMessage';
import Avatar from '../Avatar/Avatar';

import FaForward from 'react-icons/lib/fa/mail-forward';
import FaReply from 'react-icons/lib/fa/mail-reply';

import IoDoneAll from 'react-icons/lib/io/android-done-all';
import MdIosTime from 'react-icons/lib/md/access-time';
import MdCheck from 'react-icons/lib/md/check';
import MdMessage from 'react-icons/lib/md/message';

import {
format,
Expand Down Expand Up @@ -84,6 +84,23 @@ export class MessageBox extends Component {
</div>
}

{
this.props.replyButton === true &&
<div
className={this.props.forwarded !== true ? classNames(
'rce-mbox-forward',
{ 'rce-mbox-forward-right': this.props.position === 'left' },
{ 'rce-mbox-forward-left': this.props.position === 'right' }
) : classNames(
'rce-mbox-forward',
{ 'rce-mbox-reply-btn-right': this.props.position === 'left' },
{ 'rce-mbox-reply-btn-left': this.props.position === 'right' }
)}
onClick={this.props.onReplyClick}>
<MdMessage />
</div>
}

{
(this.props.title || this.props.avatar) &&
<div
Expand Down Expand Up @@ -254,6 +271,7 @@ MessageBox.defaultProps = {
titleColor: null,
onTitleClick: null,
onForwardClick: null,
onReplyClick: null,
onReplyMessageClick: null,
date: new Date(),
data: {},
Expand Down
14 changes: 14 additions & 0 deletions src/MessageList/MessageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ export class MessageList extends Component {
this.props.onForwardClick(item, i, e);
}

onReplyClick(item, i, e) {
if (this.props.onReplyClick instanceof Function)
this.props.onReplyClick(item, i, e);
}

onReplyMessageClick(item, i, e) {
if (this.props.onReplyMessageClick instanceof Function)
this.props.onReplyMessageClick(item, i, e);
}

onContextMenu(item, i, e) {
if (this.props.onContextMenu instanceof Function)
this.props.onContextMenu(item, i, e);
Expand Down Expand Up @@ -148,6 +158,8 @@ export class MessageList extends Component {
onDownload={this.props.onDownload && ((e) => this.onDownload(x, i, e))}
onTitleClick={this.props.onTitleClick && ((e) => this.onTitleClick(x, i, e))}
onForwardClick={this.props.onForwardClick && ((e) => this.onForwardClick(x, i, e))}
onReplyClick={this.props.onReplyClick && ((e) => this.onReplyClick(x, i, e))}
onReplyMessageClick={this.props.onReplyMessageClick && ((e) => this.onReplyMessageClick(x, i, e))}
onClick={this.props.onClick && ((e) => this.onClick(x, i, e))}
onContextMenu={this.props.onContextMenu && ((e) => this.onContextMenu(x, i, e))}
onMessageFocused={this.props.onMessageFocused && ((e) => this.onMessageFocused(x, i, e))}
Expand Down Expand Up @@ -181,6 +193,8 @@ MessageList.defaultProps = {
onClick: null,
onTitleClick: null,
onForwardClick: null,
onReplyClick: null,
onReplyMessageClick: null,
onDownButtonClick: null,
onOpen: null,
onPhotoError: null,
Expand Down

0 comments on commit 6b09f88

Please sign in to comment.