|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import { PureComponent } from 'react';
|
|
|
|
|
|
|
|
|
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
|
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
|
|
|
|
@ -10,17 +10,10 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
|
|
|
|
|
|
import { debounce } from 'lodash';
|
|
|
|
|
|
|
|
|
|
import VisibilityOffIcon from '@/material-icons/400-24px/visibility_off.svg?react';
|
|
|
|
|
import { Blurhash } from 'mastodon/components/blurhash';
|
|
|
|
|
|
|
|
|
|
import { autoPlayGif, displayMedia, useBlurhash } from '../initial_state';
|
|
|
|
|
|
|
|
|
|
import { IconButton } from './icon_button';
|
|
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
|
toggle_visible: { id: 'media_gallery.toggle_visible', defaultMessage: '{number, plural, one {Hide image} other {Hide images}}' },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
class Item extends PureComponent {
|
|
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
@ -215,7 +208,6 @@ class MediaGallery extends PureComponent {
|
|
|
|
|
size: PropTypes.object,
|
|
|
|
|
height: PropTypes.number.isRequired,
|
|
|
|
|
onOpenMedia: PropTypes.func.isRequired,
|
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
|
defaultWidth: PropTypes.number,
|
|
|
|
|
cacheWidth: PropTypes.func,
|
|
|
|
|
visible: PropTypes.bool,
|
|
|
|
@ -291,7 +283,7 @@ class MediaGallery extends PureComponent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render () {
|
|
|
|
|
const { media, lang, intl, sensitive, defaultWidth, autoplay } = this.props;
|
|
|
|
|
const { media, lang, sensitive, defaultWidth, autoplay } = this.props;
|
|
|
|
|
const { visible } = this.state;
|
|
|
|
|
const width = this.state.width || defaultWidth;
|
|
|
|
|
|
|
|
|
@ -323,9 +315,7 @@ class MediaGallery extends PureComponent {
|
|
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
} else if (visible) {
|
|
|
|
|
spoilerButton = <IconButton title={intl.formatMessage(messages.toggle_visible, { number: size })} icon='eye-slash' iconComponent={VisibilityOffIcon} overlay onClick={this.handleOpen} ariaHidden />;
|
|
|
|
|
} else {
|
|
|
|
|
} else if (!visible) {
|
|
|
|
|
spoilerButton = (
|
|
|
|
|
<button type='button' onClick={this.handleOpen} className='spoiler-button__overlay'>
|
|
|
|
|
<span className='spoiler-button__overlay__label'>
|
|
|
|
@ -338,15 +328,23 @@ class MediaGallery extends PureComponent {
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className='media-gallery' style={style} ref={this.handleRef}>
|
|
|
|
|
<div className={classNames('spoiler-button', { 'spoiler-button--minified': visible && !uncached, 'spoiler-button--click-thru': uncached })}>
|
|
|
|
|
{spoilerButton}
|
|
|
|
|
</div>
|
|
|
|
|
{(!visible || uncached) && (
|
|
|
|
|
<div className={classNames('spoiler-button', { 'spoiler-button--click-thru': uncached })}>
|
|
|
|
|
{spoilerButton}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{children}
|
|
|
|
|
|
|
|
|
|
{(visible && !uncached) && (
|
|
|
|
|
<div className='media-gallery__actions'>
|
|
|
|
|
<button className='media-gallery__actions__pill' onClick={this.handleOpen}><FormattedMessage id='media_gallery.hide' defaultMessage='Hide' /></button>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default injectIntl(MediaGallery);
|
|
|
|
|
export default MediaGallery;
|
|
|
|
|