dispatch/client/src/js/components/pages/Chat/Message.js

34 lines
872 B
JavaScript
Raw Normal View History

import React, { PureComponent } from 'react';
import classnames from 'classnames';
2015-12-28 23:34:32 +00:00
export default class Message extends PureComponent {
handleNickClick = () => this.props.onNickClick(this.props.message.from);
2017-05-06 21:02:45 +00:00
2015-12-28 23:34:32 +00:00
render() {
const { message } = this.props;
const className = classnames('message', {
[`message-${message.type}`]: message.type
});
2016-02-16 21:43:25 +00:00
const style = {
paddingLeft: `${window.messageIndent + 15}px`,
2017-03-23 19:38:27 +00:00
textIndent: `-${window.messageIndent}px`,
...this.props.style
2016-02-16 21:43:25 +00:00
};
2015-12-28 23:34:32 +00:00
return (
<p className={className} style={style}>
<span className="message-time">{message.time}</span>
2018-04-05 23:46:22 +00:00
{message.from && (
<span className="message-sender" onClick={this.handleNickClick}>
2018-04-05 23:46:22 +00:00
{' '}
{message.from}
</span>
2018-04-05 23:46:22 +00:00
)}{' '}
{message.content}
2015-12-28 23:34:32 +00:00
</p>
);
}
}