Skip to content

Commit

Permalink
message-box status prop added.
Browse files Browse the repository at this point in the history
forwarded title deleted.
version update v0.4.26
  • Loading branch information
abdurrahmanekr committed Sep 27, 2017
1 parent 1fd7c47 commit c0d3d06
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 14 deletions.
33 changes: 23 additions & 10 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,28 @@ export class App extends Component {
switch (type) {
case 'message':
var type = this.token();
if (type === 0)
type = 'photo';
else if (type === 1)
type = 'file';
else if (type === 2)
type = 'system';
else if (type === 3)
type = 'location';
else
type = 'text';
var statu = 'waiting';
switch(type) {
case 0:
type = 'photo';
statu = 'sent';
break;
case 1:
type = 'file';
statu = 'sent';
break;
case 2:
type = 'system';
statu = 'received';
break;
case 3:
type = 'location';
break;
default:
type = 'text';
statu = 'read';
break;
}

return {
position: (this.token() >= 1 ? 'right' : 'left'),
Expand All @@ -89,6 +101,7 @@ export class App extends Component {
latitude: '37.773972',
longitude: '-122.431297',
},
statu: statu,
date: new Date(),
};
case 'chat':
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": "0.4.25",
"version": "0.4.26",
"description": "Reactjs chat components",
"author": "Avare Kodcu <[email protected]>",
"main": "dist/main.js",
Expand Down
5 changes: 5 additions & 0 deletions src/MessageBox/MessageBox.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,8 @@
.rce-mbox-title:hover {
text-decoration: underline;
}

.rce-mbox-statu {
margin-left: 3px;
font-size: 15px;
}
30 changes: 29 additions & 1 deletion src/MessageBox/MessageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import LocationMessage from '../LocationMessage/LocationMessage';
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';

const moment = require('moment');

const classNames = require('classnames');
Expand All @@ -31,7 +35,6 @@ export class MessageBox extends Component {
{
this.props.forwarded === true &&
<div
title="Mesajı İlet"
className={classNames(
'rce-mbox-forward',
{ 'rce-mbox-forward-right': this.props.position === 'left' },
Expand Down Expand Up @@ -89,6 +92,30 @@ export class MessageBox extends Component {
!isNaN(this.props.date) &&
moment(this.props.date).fromNow()
}
{
this.props.statu &&
<span className='rce-mbox-statu'>
{
this.props.statu === 'waiting' &&
<MdIosTime />
}

{
this.props.statu === 'sent' &&
<MdCheck />
}

{
this.props.statu === 'received' &&
<IoDoneAll />
}

{
this.props.statu === 'read' &&
<IoDoneAll color='#4FC3F7'/>
}
</span>
}
</div>

{
Expand Down Expand Up @@ -131,6 +158,7 @@ MessageBox.defaultProps = {
onOpen: null,
onDownload: null,
forwarded: false,
statu: null,
};


Expand Down
4 changes: 2 additions & 2 deletions src/MessageBox/__tests__/MessageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import MessageBox from '../MessageBox';

describe('MessageBox component', () => {
it('should render without issues', () => {
const component = shallow(<MessageBox />);
const component = shallow(<MessageBox statu='read'/>);

expect(component.length).toBe(1);
expect(toJson(component)).toMatchSnapshot();
});
});
});
7 changes: 7 additions & 0 deletions src/MessageBox/__tests__/__snapshots__/MessageBox.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ exports[`MessageBox component should render without issues 1`] = `
className="rce-mbox-time"
>
a few seconds ago
<span
className="rce-mbox-statu"
>
<IoAndroidDoneAll
color="#4FC3F7"
/>
</span>
</div>
<div>
<svg
Expand Down

0 comments on commit c0d3d06

Please sign in to comment.