Skip to content

Commit 2377ebd

Browse files
MessageBox title features edited.
1 parent 4aa57cd commit 2377ebd

5 files changed

Lines changed: 43 additions & 16 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,14 @@ import { MessageBox } from 'react-chat-elements'
7676
| position | left | string | message box position |
7777
| type | text | string | message type (text, photo, file) |
7878
| text | none | string | message text |
79+
| title | none | string | message title |
80+
| titleColor | none | string(color) | message title color |
7981
| data | {} | object | message data |
8082
| date | new Date() | Date | message date |
8183
| onClick | none | function | message on click (message(object) is returned) |
8284
| onOpen | none | function | message on open (file or photo) (message(object) is returned) |
8385
| onDownload | none | function | message on download (file or photo) (message(object) is returned) |
86+
| onTitleClick | none | function | message title on click event |
8487

8588

8689
## SystemMessage Component

example/App.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ export class App extends Component {
3636
// setInterval(this.addMessage.bind(this), 3000);
3737
}
3838

39+
getRandomColor() {
40+
var letters = '0123456789ABCDEF';
41+
var color = '#';
42+
for (var i = 0; i < 6; i++) {
43+
color += letters[Math.floor(Math.random() * 16)];
44+
}
45+
return color;
46+
}
47+
3948
token() {
4049
return (parseInt(Math.random() * 10 % 3));
4150
}
@@ -61,6 +70,8 @@ export class App extends Component {
6170
return {
6271
position: (this.token() >= 1 ? 'right' : 'left'),
6372
type: type,
73+
title: loremIpsum({ count: 2, units: 'words' }),
74+
titleColor: this.getRandomColor(),
6475
text: loremIpsum({ count: 1, units: 'sentences' }),
6576
data: {
6677
uri: `data:image/png;base64,${this.photo(150)}`,
@@ -162,10 +173,13 @@ export class App extends Component {
162173
<MessageList
163174
className='message-list'
164175
onDownload={() => {
165-
debugger;
176+
console.log('onDownload');
177+
}}
178+
onTitleClick={() => {
179+
console.log('onTitleClick');
166180
}}
167181
onOpen={() => {
168-
debugger;
182+
console.log('onOpen');
169183
}}
170184
lockable={true}
171185
dataSource={this.state.messageList} />
@@ -176,16 +190,9 @@ export class App extends Component {
176190
multiline={true}
177191
// buttonsFloat='left'
178192
rightButtons={
179-
<Dropdown
180-
items={[
181-
'asdasd',
182-
'Lorem ipsum dolor sit amet.',
183-
]}
184-
buttonProps={{
185-
text: 'Boşu Boşuna'
186-
}}
187-
onSelect={this.addMessage.bind(this)}
188-
animationPosition='southeast'/>
193+
<Button
194+
text='Gönder'
195+
onClick={this.addMessage.bind(this)}/>
189196
}/>
190197
</div>
191198

src/MessageBox/MessageBox.css

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,16 @@
6060
fill: white;
6161
}
6262

63-
.rce-mbox-title{
63+
.rce-mbox-title {
6464
margin: 0;
65-
font-size: 10px;
66-
color:#4f81a1;
65+
margin-bottom: 8px;
66+
font-weight: 500;
67+
font-size: 13px;
68+
color: #4f81a1;
69+
user-select: none;
70+
cursor: pointer;
71+
}
72+
73+
.rce-mbox-title:hover {
74+
text-decoration: underline;
6775
}

src/MessageBox/MessageBox.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class MessageBox extends Component {
2020
className={positionCls}>
2121
{
2222
this.props.title &&
23-
<p className="rce-mbox-title">{this.props.title}</p>
23+
<p style={this.props.titleColor && {color: this.props.titleColor}} onClick={this.props.onTitleClick} className="rce-mbox-title">{this.props.title}</p>
2424
}
2525

2626
{
@@ -83,6 +83,8 @@ MessageBox.defaultProps = {
8383
type: 'text',
8484
text: '',
8585
title: null,
86+
titleColor: null,
87+
onTitleClick: null,
8688
date: new Date(),
8789
data: {},
8890
onClick: null,

src/MessageList/MessageList.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ export class MessageList extends Component {
5252
this.props.onClick(item, i);
5353
}
5454

55+
onTitleClick(item, i) {
56+
if (this.props.onTitleClick instanceof Function)
57+
this.props.onTitleClick(item, i);
58+
}
59+
5560
render() {
5661
return (
5762
<div
@@ -64,6 +69,7 @@ export class MessageList extends Component {
6469
{...x}
6570
onOpen={() => this.onOpen(x, i)}
6671
onDownload={() => this.onDownload(x, i)}
72+
onTitleClick={() => this.onTitleClick(x, i)}
6773
onClick={() => this.onClick(x, i)} />
6874
))
6975
}
@@ -74,6 +80,7 @@ export class MessageList extends Component {
7480

7581
MessageList.defaultProps = {
7682
onClick: null,
83+
onTitleClick: null,
7784
onOpen: null,
7885
onDownload: null,
7986
dataSource: [],

0 commit comments

Comments
 (0)