Skip to content

Commit

Permalink
Flux - 31 - Rendering an Image Detail
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGrider committed Jul 5, 2015
1 parent b573cb7 commit 95af337
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion imgur-client/src/components/image-detail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,33 @@ module.exports = React.createClass({
},
render: function() {
return <div>
{this.state.image}
{this.state.image ? this.renderContent() : null}
</div>
},
renderContent: function() {
return <div>
<div className="panel panel-default">
<div className="panel-heading">
<h4>{this.state.image.title}</h4>
</div>
<div className="panel-body">
{this.renderImage()}
</div>
<div className="panel-footer">
<h5>{this.state.image.description}</h5>
</div>
</div>
</div>
},
renderImage: function() {
if(this.state.image.animated) {
return <video preload="auto" autoPlay="autoplay" loop="loop" webkit-playsinline>
<source src={this.state.image.mp4} type="video/mp4"></source>
</video>
} else {
return <img src={this.state.image.link} />
}
},
onChange: function() {
this.setState({
image: ImageStore.find(this.props.params.id)
Expand Down

0 comments on commit 95af337

Please sign in to comment.