Created
April 25, 2018 13:08
-
-
Save gladchinda/26e41edc687a578f56c893863c5d0995 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
class ChatMessage extends Component { | |
render() { | |
const { position = 'left', message } = this.props; | |
const isRight = position.toLowerCase() === 'right'; | |
const align = isRight ? 'text-right' : 'text-left'; | |
const justify = isRight ? 'justify-content-end' : 'justify-content-start'; | |
const messageBoxStyles = { | |
maxWidth: '70%', | |
flexGrow: 0 | |
}; | |
const messageStyles = { | |
fontWeight: 500, | |
lineHeight: 1.4, | |
whiteSpace: 'pre-wrap' | |
}; | |
return <div className={`w-100 my-1 d-flex ${justify}`}> | |
<div className="bg-light rounded border border-gray p-2" style={messageBoxStyles}> | |
<span className={`d-block text-secondary ${align}`} style={messageStyles}>{message}</span> | |
</div> | |
</div> | |
} | |
} | |
export default ChatMessage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment