From 5f36d8828a08859262a0520a07f103fecbdfc7c3 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 5 Sep 2016 20:59:56 +0200 Subject: Better layout for attachments in --- .../components/components/media_gallery.jsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/components/components/media_gallery.jsx b/app/assets/javascripts/components/components/media_gallery.jsx index 403c68202..eb2288ae5 100644 --- a/app/assets/javascripts/components/components/media_gallery.jsx +++ b/app/assets/javascripts/components/components/media_gallery.jsx @@ -10,8 +10,23 @@ const MediaGallery = React.createClass({ mixins: [PureRenderMixin], render () { - var children = this.props.media.take(4).map((attachment, i) => { - return ; + 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 ; }); return ( -- cgit