Skip to content

Commit

Permalink
extract image class
Browse files Browse the repository at this point in the history
  • Loading branch information
James Moriarty committed Jul 12, 2017
1 parent 1a83b2f commit 0e728a6
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,24 @@
}
});

var Image = React.createClass({
render: function() {
<div className="image">
<a target="_blank" href={this.props.href}>
<img key={this.props.key} src={this.props.src} />
</a>
<div className="desc">{this.props.name}</div>
</div>
}
})

var ImageList = React.createClass({
render: function() {
var images = this.props.images.map(function (image) {
return (
<div className="image">
<a target="_blank" href={image.href}>
<img key={image.src} src={image.src} />
</a>
<div className="desc">{image.name}</div>
</div>
);
});
return (
<div className="imageList">
{images}
{this.props.images.map(function(image, i){
return <Image href=image.href key=i src=image.src name=image.name />
})}
</div>
);
}
Expand Down

0 comments on commit 0e728a6

Please sign in to comment.