import ImmutablePropTypes from 'react-immutable-proptypes'; import PureRenderMixin from 'react-addons-pure-render-mixin'; import IconButton from './icon_button'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; const messages = defineMessages({ toggle_visible: { id: 'media_gallery.toggle_visible', defaultMessage: 'Toggle visibility' } }); const outerStyle = { marginTop: '8px', overflow: 'hidden', width: '100%', boxSizing: 'border-box', position: 'relative' }; const spoilerStyle = { textAlign: 'center', height: '100%', cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center', flexDirection: 'column' }; const spoilerSpanStyle = { display: 'block', fontSize: '14px', }; const spoilerSubSpanStyle = { display: 'block', fontSize: '11px', fontWeight: '500' }; const spoilerButtonStyle = { position: 'absolute', top: '6px', left: '8px', zIndex: '100' }; const MediaGallery = React.createClass({ getInitialState () { return { visible: !this.props.sensitive }; }, propTypes: { sensitive: React.PropTypes.bool, media: ImmutablePropTypes.list.isRequired, height: React.PropTypes.number.isRequired, onOpenMedia: React.PropTypes.func.isRequired, intl: React.PropTypes.object.isRequired }, mixins: [PureRenderMixin], handleClick (index, e) { if (e.button === 0) { e.preventDefault(); this.props.onOpenMedia(this.props.media, index); } e.stopPropagation(); }, handleOpen () { this.setState({ visible: !this.state.visible }); }, render () { const { media, intl, sensitive } = this.props; let children; if (!this.state.visible) { if (sensitive) { children = (