Skip to content

Commit 6b09f88

Browse files
onReplyClick and onReplyMessageClick added
replyButton feat added
1 parent 3a3531d commit 6b09f88

6 files changed

Lines changed: 65 additions & 3 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,11 @@ import { MessageBox } from 'react-chat-elements'
140140
| onPhotoError | none | function | message on error photo |
141141
| onTitleClick | none | function | message title on click event |
142142
| onForwardClick | none | function | message forward on click event |
143+
| onReplyClick | none | function | message reply on click event |
144+
| onReplyMessageClick | none | function | reply message on click event |
143145
| onContextMenu | none | function | message contextmenu click event |
144146
| forwarded | none | boolean | message forward icon |
147+
| replyButton | none | boolean | message reply icon |
145148
| status | none | string | message status info (waiting, sent, received, read) |
146149
| notch | true | boolean | message box notch |
147150
| avatar | none | url | message box avatar url |
@@ -225,6 +228,8 @@ import { MessageList } from 'react-chat-elements'
225228
| onDownload | none | function | message list item on download (file or photo) (message(object) is returned) |
226229
| onScroll | none | function | message list onScroll event |
227230
| onForwardClick | none | function | message list item onForwardClick event |
231+
| onReplyClick | none | function | message list item onReplyClick event |
232+
| onReplyMessageClick | none | function | message list item onReplyMessageClick event |
228233
| downButton | true | boolean | message list scroll to bottom button |
229234
| downButtonBadge | none | boolean | message list downButton badge content |
230235
| onDownButtonClick | none | function | message list onDownButtonClick |

example/App.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export class App extends Component {
9595
return {
9696
position: (this.token() >= 1 ? 'right' : 'left'),
9797
forwarded: true,
98+
replyButton: true,
9899
reply: this.token() >= 1 ? ({
99100
photoURL: this.token() >= 1 ? `data:image/png;base64,${this.photo(150)}` : null,
100101
title: loremIpsum({ count: 2, units: 'words' }),

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-chat-elements",
3-
"version": "10.9.0",
3+
"version": "10.9.1",
44
"description": "Reactjs chat components",
55
"author": "Avare Kodcu <abdurrahmaneker58@gmail.com>",
66
"main": "dist/main.js",

src/MessageBox/MessageBox.css

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@
3838
right: -50px;
3939
}
4040

41+
.rce-mbox-reply-btn-left {
42+
display: flex;
43+
opacity: 0;
44+
visibility: hidden;
45+
left: -85px;
46+
}
47+
48+
.rce-mbox-reply-btn-right {
49+
display: flex;
50+
opacity: 0;
51+
visibility: hidden;
52+
right: -85px;
53+
}
54+
4155
.rce-container-mbox:hover .rce-mbox-forward-left {
4256
opacity: 1;
4357
visibility: visible;
@@ -48,6 +62,16 @@
4862
visibility: visible;
4963
}
5064

65+
.rce-container-mbox:hover .rce-mbox-reply-btn-left {
66+
opacity: 1;
67+
visibility: visible;
68+
}
69+
70+
.rce-container-mbox:hover .rce-mbox-reply-btn-right {
71+
opacity: 1;
72+
visibility: visible;
73+
}
74+
5175
.rce-mbox {
5276
position: relative;
5377
background: white;
@@ -222,4 +246,4 @@
222246

223247
.rce-mbox-title > .rce-avatar-container {
224248
margin-right: 5px;
225-
}
249+
}

src/MessageBox/MessageBox.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import ReplyMessage from '../ReplyMessage/ReplyMessage';
1111
import Avatar from '../Avatar/Avatar';
1212

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

1615
import IoDoneAll from 'react-icons/lib/io/android-done-all';
1716
import MdIosTime from 'react-icons/lib/md/access-time';
1817
import MdCheck from 'react-icons/lib/md/check';
18+
import MdMessage from 'react-icons/lib/md/message';
1919

2020
import {
2121
format,
@@ -84,6 +84,23 @@ export class MessageBox extends Component {
8484
</div>
8585
}
8686

87+
{
88+
this.props.replyButton === true &&
89+
<div
90+
className={this.props.forwarded !== true ? classNames(
91+
'rce-mbox-forward',
92+
{ 'rce-mbox-forward-right': this.props.position === 'left' },
93+
{ 'rce-mbox-forward-left': this.props.position === 'right' }
94+
) : classNames(
95+
'rce-mbox-forward',
96+
{ 'rce-mbox-reply-btn-right': this.props.position === 'left' },
97+
{ 'rce-mbox-reply-btn-left': this.props.position === 'right' }
98+
)}
99+
onClick={this.props.onReplyClick}>
100+
<MdMessage />
101+
</div>
102+
}
103+
87104
{
88105
(this.props.title || this.props.avatar) &&
89106
<div
@@ -254,6 +271,7 @@ MessageBox.defaultProps = {
254271
titleColor: null,
255272
onTitleClick: null,
256273
onForwardClick: null,
274+
onReplyClick: null,
257275
onReplyMessageClick: null,
258276
date: new Date(),
259277
data: {},

src/MessageList/MessageList.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ export class MessageList extends Component {
7979
this.props.onForwardClick(item, i, e);
8080
}
8181

82+
onReplyClick(item, i, e) {
83+
if (this.props.onReplyClick instanceof Function)
84+
this.props.onReplyClick(item, i, e);
85+
}
86+
87+
onReplyMessageClick(item, i, e) {
88+
if (this.props.onReplyMessageClick instanceof Function)
89+
this.props.onReplyMessageClick(item, i, e);
90+
}
91+
8292
onContextMenu(item, i, e) {
8393
if (this.props.onContextMenu instanceof Function)
8494
this.props.onContextMenu(item, i, e);
@@ -148,6 +158,8 @@ export class MessageList extends Component {
148158
onDownload={this.props.onDownload && ((e) => this.onDownload(x, i, e))}
149159
onTitleClick={this.props.onTitleClick && ((e) => this.onTitleClick(x, i, e))}
150160
onForwardClick={this.props.onForwardClick && ((e) => this.onForwardClick(x, i, e))}
161+
onReplyClick={this.props.onReplyClick && ((e) => this.onReplyClick(x, i, e))}
162+
onReplyMessageClick={this.props.onReplyMessageClick && ((e) => this.onReplyMessageClick(x, i, e))}
151163
onClick={this.props.onClick && ((e) => this.onClick(x, i, e))}
152164
onContextMenu={this.props.onContextMenu && ((e) => this.onContextMenu(x, i, e))}
153165
onMessageFocused={this.props.onMessageFocused && ((e) => this.onMessageFocused(x, i, e))}
@@ -181,6 +193,8 @@ MessageList.defaultProps = {
181193
onClick: null,
182194
onTitleClick: null,
183195
onForwardClick: null,
196+
onReplyClick: null,
197+
onReplyMessageClick: null,
184198
onDownButtonClick: null,
185199
onOpen: null,
186200
onPhotoError: null,

0 commit comments

Comments
 (0)