Add colored nicks
This commit is contained in:
parent
937987da82
commit
b3f2b53a6f
6 changed files with 46 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
|||
import React, { PureComponent } from 'react';
|
||||
import classnames from 'classnames';
|
||||
import stringToHSL from 'utils/color';
|
||||
|
||||
export default class Message extends PureComponent {
|
||||
handleNickClick = () => this.props.onNickClick(this.props.message.from);
|
||||
|
@ -17,11 +18,16 @@ export default class Message extends PureComponent {
|
|||
...this.props.style
|
||||
};
|
||||
|
||||
const senderStyle = {};
|
||||
if (message.from) {
|
||||
senderStyle.color = stringToHSL(message.from);
|
||||
}
|
||||
|
||||
return (
|
||||
<p className={className} style={style}>
|
||||
<span className="message-time">{message.time}</span>
|
||||
{message.from && (
|
||||
<span className="message-sender" onClick={this.handleNickClick}>
|
||||
<span className="message-sender" style={senderStyle} onClick={this.handleNickClick}>
|
||||
{' '}
|
||||
{message.from}
|
||||
</span>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue