Skip to content

Commit 95af337

Browse files
committed
Flux - 31 - Rendering an Image Detail
1 parent b573cb7 commit 95af337

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

imgur-client/src/components/image-detail.jsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,33 @@ module.exports = React.createClass({
1717
},
1818
render: function() {
1919
return <div>
20-
{this.state.image}
20+
{this.state.image ? this.renderContent() : null}
2121
</div>
2222
},
23+
renderContent: function() {
24+
return <div>
25+
<div className="panel panel-default">
26+
<div className="panel-heading">
27+
<h4>{this.state.image.title}</h4>
28+
</div>
29+
<div className="panel-body">
30+
{this.renderImage()}
31+
</div>
32+
<div className="panel-footer">
33+
<h5>{this.state.image.description}</h5>
34+
</div>
35+
</div>
36+
</div>
37+
},
38+
renderImage: function() {
39+
if(this.state.image.animated) {
40+
return <video preload="auto" autoPlay="autoplay" loop="loop" webkit-playsinline>
41+
<source src={this.state.image.mp4} type="video/mp4"></source>
42+
</video>
43+
} else {
44+
return <img src={this.state.image.link} />
45+
}
46+
},
2347
onChange: function() {
2448
this.setState({
2549
image: ImageStore.find(this.props.params.id)

0 commit comments

Comments
 (0)