forked from treehouse/mastodon
Make hidden media clickable in account media gallery
parent
d82c495c0f
commit
a9e8f98a9d
|
@ -12,12 +12,20 @@ export default class Permalink extends React.PureComponent {
|
||||||
href: PropTypes.string.isRequired,
|
href: PropTypes.string.isRequired,
|
||||||
to: PropTypes.string.isRequired,
|
to: PropTypes.string.isRequired,
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
|
onInterceptClick: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
handleClick = (e) => {
|
handleClick = (e) => {
|
||||||
if (this.context.router && e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
||||||
e.preventDefault();
|
if (this.props.onInterceptClick && this.props.onInterceptClick()) {
|
||||||
this.context.router.history.push(this.props.to);
|
e.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.context.router) {
|
||||||
|
e.preventDefault();
|
||||||
|
this.context.router.history.push(this.props.to);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +35,7 @@ export default class Permalink extends React.PureComponent {
|
||||||
className,
|
className,
|
||||||
href,
|
href,
|
||||||
to,
|
to,
|
||||||
|
onInterceptClick,
|
||||||
...other
|
...other
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,15 @@ export default class MediaItem extends ImmutablePureComponent {
|
||||||
visible: displayMedia !== 'hide_all' && !this.props.media.getIn(['status', 'sensitive']) || displayMedia === 'show_all',
|
visible: displayMedia !== 'hide_all' && !this.props.media.getIn(['status', 'sensitive']) || displayMedia === 'show_all',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleClick = () => {
|
||||||
|
if (!this.state.visible) {
|
||||||
|
this.setState({ visible: true });
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { media } = this.props;
|
const { media } = this.props;
|
||||||
const { visible } = this.state;
|
const { visible } = this.state;
|
||||||
|
@ -50,6 +59,7 @@ export default class MediaItem extends ImmutablePureComponent {
|
||||||
href={status.get('url')}
|
href={status.get('url')}
|
||||||
style={style}
|
style={style}
|
||||||
title={title}
|
title={title}
|
||||||
|
onInterceptClick={this.handleClick}
|
||||||
>
|
>
|
||||||
{icon}
|
{icon}
|
||||||
{label}
|
{label}
|
||||||
|
|
|
@ -423,6 +423,7 @@
|
||||||
&:active,
|
&:active,
|
||||||
&:focus {
|
&:focus {
|
||||||
outline: 0;
|
outline: 0;
|
||||||
|
color: $ui-secondary-color;
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
content: "";
|
content: "";
|
||||||
|
|
Loading…
Reference in New Issue