Skip to content

Commit

Permalink
PhotoMessage width and height props added.
Browse files Browse the repository at this point in the history
  • Loading branch information
abdurrahmanekr committed Sep 5, 2017
1 parent 00f832c commit c74115d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ import { MessageBox } from 'react-chat-elements'
| onClick | none | function | message on click (message(object) is returned) |
| onOpen | none | function | message on open (file or photo) (message(object) is returned) |
| onDownload | none | function | message on download (file or photo) (message(object) is returned) |
| width | none | int | only photo width (optional) |
| height | none | int | only photo height (optional) |


## SystemMessage Component
Expand Down
2 changes: 2 additions & 0 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export class App extends Component {
position: (this.token() >= 1 ? 'right' : 'left'),
type: type,
text: loremIpsum({ count: 1, units: 'sentences' }),
width: 300,
height: 300,
data: {
uri: `data:image/png;base64,${this.photo(150)}`,
status: {
Expand Down
2 changes: 2 additions & 0 deletions src/MessageBox/MessageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export class MessageBox extends Component {
onOpen={this.props.onOpen}
onDownload={this.props.onDownload}
data={this.props.data}
width={this.props.width}
height={this.props.height}
text={this.props.text}/>
}
{
Expand Down
7 changes: 6 additions & 1 deletion src/PhotoMessage/PhotoMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ export class PhotoMessage extends Component {

return (
<div className="rce-mbox-photo">
<div className="rce-mbox-photo--img">
<div
className="rce-mbox-photo--img"
style={this.props.width && this.props.height && {
width: this.props.width,
height: this.props.height,
}}>
<img src={this.props.data.uri} alt={this.props.data.alt} onClick={this.props.onOpen}/>
{
this.props.data.status &&
Expand Down

0 comments on commit c74115d

Please sign in to comment.