Skip to content
Snippets Groups Projects
Commit 5f36d882 authored by Eugen Rochko's avatar Eugen Rochko
Browse files

Better layout for attachments in <MediaGallery>

parent fc222dfa
Branches
Tags
No related merge requests found
......@@ -10,8 +10,23 @@ const MediaGallery = React.createClass({
mixins: [PureRenderMixin],
render () {
var children = this.props.media.take(4).map((attachment, i) => {
return <a key={attachment.get('id')} href={attachment.get('url')} style={{ float: 'left', marginRight: (i % 2 == 0 ? '5px' : '0'), marginBottom: '5px', textDecoration: 'none', border: 'none', display: 'block', width: '142px', height: '110px', background: `url(${attachment.get('preview_url')}) no-repeat`, backgroundSize: 'cover', cursor: 'zoom-in' }} />;
var children = this.props.media.take(4);
var size = children.size;
children = children.map((attachment, i) => {
let width = 142;
let height = 110;
let marginRight = 0;
if (size == 4 || (size === 3 && i > 0)) {
height = 52.5;
}
if ((size === 3 && i === 0) || (size === 4 && i % 2 === 0)) {
marginRight = 5;
}
return <a key={attachment.get('id')} href={attachment.get('url')} style={{ position: 'relative', float: 'left', marginRight: `${marginRight}px`, marginBottom: '5px', textDecoration: 'none', border: 'none', display: 'block', width: `${width}px`, height: `${height}px`, background: `url(${attachment.get('preview_url')}) no-repeat`, backgroundSize: 'cover', cursor: 'zoom-in' }} />;
});
return (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment