File tree Expand file tree Collapse file tree
ChatItem/__tests__/__snapshots__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -149,6 +149,27 @@ import { MessageBox } from 'react-chat-elements'
149149| copiableDate | false | boolean | message box date text copiable |
150150| focus | false | boolean | used in message focus feature in MessageList component, makes style of the component focused |
151151| onMessageFocused | none | function | makes focus value false after the message becomes focus |
152+ | reply | none | object | reply data |
153+
154+ ## Reply Message Component
155+
156+ ``` javascript
157+ import { MessageBox } from ' react-chat-elements'
158+
159+ < MessageBox
160+ reply= {{
161+ photoURL: ' https://facebook.github.io/react/img/logo.svg' ,
162+ title: ' elit magna' ,
163+ titleColor: ' #8717ae' ,
164+ message: ' Aliqua amet incididunt id nostrud' ,
165+ }}
166+ onReplyMessageClick= {() => console .log (' reply clicked!' )}
167+ position= {' left' }
168+ type= {' text' }
169+ text= {' Tempor duis do voluptate enim duis velit veniam aute ullamco dolore duis irure.' }/ >
170+ ```
171+
172+ ![ reply-message] ( https://user-images.githubusercontent.com/15075759/80224625-9dbbeb00-8652-11ea-994f-022be0cffe30.png )
152173
153174
154175## SystemMessage Component
Original file line number Diff line number Diff line change @@ -95,6 +95,12 @@ export class App extends Component {
9595 return {
9696 position : ( this . token ( ) >= 1 ? 'right' : 'left' ) ,
9797 forwarded : true ,
98+ reply : this . token ( ) >= 1 ? ( {
99+ photoURL : this . token ( ) >= 1 ? `data:image/png;base64,${ this . photo ( 150 ) } ` : null ,
100+ title : loremIpsum ( { count : 2 , units : 'words' } ) ,
101+ titleColor : this . getRandomColor ( ) ,
102+ message : loremIpsum ( { count : 1 , units : 'sentences' } ) ,
103+ } ) : null ,
98104 type : type ,
99105 theme : 'white' ,
100106 view : 'list' ,
@@ -119,6 +125,9 @@ export class App extends Component {
119125 } ,
120126 status : status ,
121127 date : + new Date ( ) ,
128+ onReplyMessageClick : ( ) => {
129+ console . log ( 'onReplyMessageClick' ) ;
130+ } ,
122131 avatar : `data:image/png;base64,${ this . photo ( ) } ` ,
123132 } ;
124133 case 'chat' :
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ exports[`ChatItem component should render without issues 1`] = `
1313 >
1414 <Avatar
1515 alt = " "
16+ className = " "
1617 onError = { [Function ]}
1718 sideElement = { null }
1819 size = " large"
@@ -32,7 +33,7 @@ exports[`ChatItem component should render without issues 1`] = `
3233 <div
3334 className = " rce-citem-body--top-time"
3435 >
35- right now
36+ just now
3637 </div >
3738 </div >
3839 <div
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import FileMessage from '../FileMessage/FileMessage';
66import SystemMessage from '../SystemMessage/SystemMessage' ;
77import LocationMessage from '../LocationMessage/LocationMessage' ;
88import SpotifyMessage from '../SpotifyMessage/SpotifyMessage' ;
9+ import ReplyMessage from '../ReplyMessage/ReplyMessage' ;
910
1011import Avatar from '../Avatar/Avatar' ;
1112
@@ -104,6 +105,16 @@ export class MessageBox extends Component {
104105 </ div >
105106 }
106107
108+ {
109+ this . props . reply &&
110+ < ReplyMessage
111+ photoURL = { this . props . reply . photoURL }
112+ title = { this . props . reply . title }
113+ titleColor = { this . props . reply . titleColor }
114+ message = { this . props . reply . message }
115+ onClick = { this . props . onReplyMessageClick } />
116+ }
117+
107118 {
108119 this . props . type === 'text' &&
109120 < div className = "rce-mbox-text" >
@@ -243,6 +254,7 @@ MessageBox.defaultProps = {
243254 titleColor : null ,
244255 onTitleClick : null ,
245256 onForwardClick : null ,
257+ onReplyMessageClick : null ,
246258 date : new Date ( ) ,
247259 data : { } ,
248260 onClick : null ,
@@ -251,6 +263,7 @@ MessageBox.defaultProps = {
251263 onLoad : null ,
252264 onPhotoError : null ,
253265 forwarded : false ,
266+ reply : false ,
254267 status : null ,
255268 dateString : null ,
256269 notch : true ,
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ exports[`MessageBox component should render without issues 1`] = `
1717 />
1818 <div
1919 className = " rce-mbox-time non-copiable"
20- data-text = " right now"
20+ data-text = " just now"
2121 >
2222 <span
2323 className = " rce-mbox-status"
Original file line number Diff line number Diff line change 1+ .rce-mbox-reply {
2+ position : relative;
3+ overflow : hidden;
4+ display : flex;
5+ margin-top : -3px ;
6+ margin-bottom : 6px ;
7+ margin-right : -6px ;
8+ margin-left : -6px ;
9+ border-radius : 5px ;
10+ background : # ececec ;
11+ padding : 0 5px ;
12+ padding-right : 0 ;
13+ font-size : 12px ;
14+ cursor : pointer;
15+ transition : 200ms ;
16+ user-select : none;
17+ }
18+
19+ .rce-mbox-reply .rce-mbox-reply-border {
20+ border-left : 5px solid;
21+ }
22+
23+ .rce-mbox-reply : hover {
24+ opacity : 0.85 ;
25+ }
26+
27+ .rce-mbox-reply-left {
28+ display : flex;
29+ flex-direction : column;
30+ justify-content : space-between;
31+ padding : 3px 0 ;
32+ flex : 1 ;
33+ }
34+
35+ .rce-mbox-reply-owner {
36+ font-size : 13px ;
37+ }
38+
39+ .rce-mbox-reply-message {
40+ color : # 5a5a5a ;
41+ overflow : hidden;
42+ white-space : nowrap;
43+ text-overflow : ellipsis;
44+ max-width : 150px ;
45+ }
46+
47+ .rce-mbox-reply-right {
48+ width : 40px ;
49+ height : 40px ;
50+ }
51+
52+ .rce-mbox-reply-right img {
53+ width : 100% ;
54+ }
55+
56+ .rce-mbox-reply-text {
57+ padding : 5px 0 ;
58+ width : 250px ;
59+ margin-left : -6px ;
60+ margin-right : -6px ;
61+ }
Original file line number Diff line number Diff line change 1+ import React , { Component } from 'react' ;
2+ import './ReplyMessage.css' ;
3+
4+ const classNames = require ( 'classnames' ) ;
5+
6+ export class ReplyMessage extends Component {
7+ constructor ( props ) {
8+ super ( props ) ;
9+ }
10+
11+ render ( ) {
12+ const {
13+ photoURL,
14+ title,
15+ titleColor,
16+ message,
17+ onClick,
18+ } = this . props ;
19+
20+ return (
21+ < div
22+ className = { classNames ( "rce-mbox-reply" , {
23+ 'rce-mbox-reply-border' : ! ! titleColor
24+ } ) }
25+ style = { titleColor && { borderColor : titleColor } }
26+ onClick = { onClick } >
27+ < div className = "rce-mbox-reply-left" >
28+ < div
29+ style = { titleColor && { color : titleColor } }
30+ className = "rce-mbox-reply-owner" >
31+ { title || 'Unknown' }
32+ </ div >
33+ < div className = "rce-mbox-reply-message" >
34+ { message || '...' }
35+ </ div >
36+ </ div >
37+ {
38+ photoURL &&
39+ < div className = "rce-mbox-reply-right" >
40+ < img src = { photoURL } alt = "" />
41+ </ div >
42+ }
43+ </ div >
44+ ) ;
45+ }
46+ }
47+
48+ ReplyMessage . defaultProps = {
49+ photoURL : null ,
50+ title : null ,
51+ titleColor : null ,
52+ message : null ,
53+ onClick : ( ) => void ( 0 ) ,
54+ }
55+
56+ export default ReplyMessage ;
Original file line number Diff line number Diff line change 1+ import React , { Component } from 'react' ;
2+ import { shallow } from 'enzyme' ;
3+ import toJson from 'enzyme-to-json' ;
4+ import ReplyMessage from '../ReplyMessage' ;
5+
6+ describe ( 'ReplyMessage component' , ( ) => {
7+ it ( 'should render without issues' , ( ) => {
8+ const component = shallow ( < ReplyMessage /> ) ;
9+ expect ( component . length ) . toBe ( 1 ) ;
10+ expect ( toJson ( component ) ) . toMatchSnapshot ( ) ;
11+ } ) ;
12+ } ) ;
Original file line number Diff line number Diff line change 1+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+ exports [` ReplyMessage component should render without issues 1` ] = `
4+ <div
5+ className = " rce-mbox-reply"
6+ onClick = { [Function ]}
7+ style = { null }
8+ >
9+ <div
10+ className = " rce-mbox-reply-left"
11+ >
12+ <div
13+ className = " rce-mbox-reply-owner"
14+ style = { null }
15+ >
16+ Unknown
17+ </div >
18+ <div
19+ className = " rce-mbox-reply-message"
20+ >
21+ ...
22+ </div >
23+ </div >
24+ </div >
25+ ` ;
You can’t perform that action at this time.
0 commit comments