2016-09-06 03:38:31 +09:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
|
|
|
|
|
|
|
const MediaGallery = React.createClass({
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
media: ImmutablePropTypes.list.isRequired
|
|
|
|
},
|
|
|
|
|
|
|
|
mixins: [PureRenderMixin],
|
|
|
|
|
|
|
|
render () {
|
2016-09-06 03:59:56 +09:00
|
|
|
var children = this.props.media.take(4);
|
|
|
|
var size = children.size;
|
|
|
|
|
|
|
|
children = children.map((attachment, i) => {
|
2016-09-06 07:23:27 +09:00
|
|
|
let width = 50;
|
|
|
|
let height = 100;
|
2016-09-06 03:59:56 +09:00
|
|
|
|
|
|
|
if (size == 4 || (size === 3 && i > 0)) {
|
2016-09-06 07:23:27 +09:00
|
|
|
height = 50;
|
2016-09-06 03:59:56 +09:00
|
|
|
}
|
|
|
|
|
2016-09-06 07:23:27 +09:00
|
|
|
return <a key={attachment.get('id')} href={attachment.get('url')} style={{ boxSizing: 'border-box', position: 'relative', float: 'left', textDecoration: 'none', border: 'none', display: 'block', width: `${width}%`, height: `${height}%`, background: `url(${attachment.get('preview_url')}) no-repeat`, backgroundSize: 'cover', cursor: 'zoom-in' }} />;
|
2016-09-06 03:38:31 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
2016-09-06 07:23:27 +09:00
|
|
|
<div style={{ marginTop: '8px', overflow: 'hidden', width: '100%', height: '110px', boxSizing: 'border-box', padding: '4px' }}>
|
2016-09-06 03:38:31 +09:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default MediaGallery;
|