Change design of hide media button in web UI (#31807)
This commit is contained in:
parent
5260233b81
commit
3929e3c6d2
3 changed files with 51 additions and 43 deletions
|
@ -1,7 +1,7 @@
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { PureComponent } from 'react';
|
import { PureComponent } from 'react';
|
||||||
|
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
@ -10,17 +10,10 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
|
|
||||||
import VisibilityOffIcon from '@/material-icons/400-24px/visibility_off.svg?react';
|
|
||||||
import { Blurhash } from 'mastodon/components/blurhash';
|
import { Blurhash } from 'mastodon/components/blurhash';
|
||||||
|
|
||||||
import { autoPlayGif, displayMedia, useBlurhash } from '../initial_state';
|
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 {
|
class Item extends PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -215,7 +208,6 @@ class MediaGallery extends PureComponent {
|
||||||
size: PropTypes.object,
|
size: PropTypes.object,
|
||||||
height: PropTypes.number.isRequired,
|
height: PropTypes.number.isRequired,
|
||||||
onOpenMedia: PropTypes.func.isRequired,
|
onOpenMedia: PropTypes.func.isRequired,
|
||||||
intl: PropTypes.object.isRequired,
|
|
||||||
defaultWidth: PropTypes.number,
|
defaultWidth: PropTypes.number,
|
||||||
cacheWidth: PropTypes.func,
|
cacheWidth: PropTypes.func,
|
||||||
visible: PropTypes.bool,
|
visible: PropTypes.bool,
|
||||||
|
@ -291,7 +283,7 @@ class MediaGallery extends PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { media, lang, intl, sensitive, defaultWidth, autoplay } = this.props;
|
const { media, lang, sensitive, defaultWidth, autoplay } = this.props;
|
||||||
const { visible } = this.state;
|
const { visible } = this.state;
|
||||||
const width = this.state.width || defaultWidth;
|
const width = this.state.width || defaultWidth;
|
||||||
|
|
||||||
|
@ -323,9 +315,7 @@ class MediaGallery extends PureComponent {
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
} else if (visible) {
|
} else if (!visible) {
|
||||||
spoilerButton = <IconButton title={intl.formatMessage(messages.toggle_visible, { number: size })} icon='eye-slash' iconComponent={VisibilityOffIcon} overlay onClick={this.handleOpen} ariaHidden />;
|
|
||||||
} else {
|
|
||||||
spoilerButton = (
|
spoilerButton = (
|
||||||
<button type='button' onClick={this.handleOpen} className='spoiler-button__overlay'>
|
<button type='button' onClick={this.handleOpen} className='spoiler-button__overlay'>
|
||||||
<span className='spoiler-button__overlay__label'>
|
<span className='spoiler-button__overlay__label'>
|
||||||
|
@ -338,15 +328,23 @@ class MediaGallery extends PureComponent {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='media-gallery' style={style} ref={this.handleRef}>
|
<div className='media-gallery' style={style} ref={this.handleRef}>
|
||||||
<div className={classNames('spoiler-button', { 'spoiler-button--minified': visible && !uncached, 'spoiler-button--click-thru': uncached })}>
|
{(!visible || uncached) && (
|
||||||
|
<div className={classNames('spoiler-button', { 'spoiler-button--click-thru': uncached })}>
|
||||||
{spoilerButton}
|
{spoilerButton}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{children}
|
{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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default injectIntl(MediaGallery);
|
export default MediaGallery;
|
||||||
|
|
|
@ -457,7 +457,7 @@
|
||||||
"lists.subheading": "Your lists",
|
"lists.subheading": "Your lists",
|
||||||
"load_pending": "{count, plural, one {# new item} other {# new items}}",
|
"load_pending": "{count, plural, one {# new item} other {# new items}}",
|
||||||
"loading_indicator.label": "Loading…",
|
"loading_indicator.label": "Loading…",
|
||||||
"media_gallery.toggle_visible": "{number, plural, one {Hide image} other {Hide images}}",
|
"media_gallery.hide": "Hide",
|
||||||
"moved_to_account_banner.text": "Your account {disabledAccount} is currently disabled because you moved to {movedToAccount}.",
|
"moved_to_account_banner.text": "Your account {disabledAccount} is currently disabled because you moved to {movedToAccount}.",
|
||||||
"mute_modal.hide_from_notifications": "Hide from notifications",
|
"mute_modal.hide_from_notifications": "Hide from notifications",
|
||||||
"mute_modal.hide_options": "Hide options",
|
"mute_modal.hide_options": "Hide options",
|
||||||
|
|
|
@ -4718,22 +4718,14 @@ a.status-card {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
|
|
||||||
&--minified {
|
&--hidden {
|
||||||
display: block;
|
display: none;
|
||||||
inset-inline-start: 4px;
|
|
||||||
top: 4px;
|
|
||||||
width: auto;
|
|
||||||
height: auto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&--click-thru {
|
&--click-thru {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--hidden {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__overlay {
|
&__overlay {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -4745,19 +4737,20 @@ a.status-card {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
border: 0;
|
border: 0;
|
||||||
color: $white;
|
color: $white;
|
||||||
|
line-height: 20px;
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
&__label {
|
&__label {
|
||||||
background-color: rgba($black, 0.45);
|
background-color: rgba($black, 0.45);
|
||||||
backdrop-filter: blur(10px) saturate(180%) contrast(75%) brightness(70%);
|
backdrop-filter: blur(10px) saturate(180%) contrast(75%) brightness(70%);
|
||||||
border-radius: 6px;
|
border-radius: 8px;
|
||||||
padding: 10px 15px;
|
padding: 12px 16px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 8px;
|
gap: 4px;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
font-weight: 500;
|
font-weight: 600;
|
||||||
font-size: 14px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__action {
|
&__action {
|
||||||
|
@ -6838,10 +6831,32 @@ a.status-card {
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-gallery__item__badges {
|
.media-gallery__actions {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 6px;
|
bottom: 6px;
|
||||||
inset-inline-start: 6px;
|
inset-inline-end: 6px;
|
||||||
|
display: flex;
|
||||||
|
gap: 2px;
|
||||||
|
z-index: 2;
|
||||||
|
|
||||||
|
&__pill {
|
||||||
|
display: block;
|
||||||
|
color: $white;
|
||||||
|
border: 0;
|
||||||
|
background: rgba($black, 0.65);
|
||||||
|
backdrop-filter: blur(10px) saturate(180%) contrast(75%) brightness(70%);
|
||||||
|
padding: 3px 12px;
|
||||||
|
border-radius: 99px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.media-gallery__item__badges {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 8px;
|
||||||
|
inset-inline-start: 8px;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 2px;
|
gap: 2px;
|
||||||
}
|
}
|
||||||
|
@ -6854,18 +6869,13 @@ a.status-card {
|
||||||
color: $white;
|
color: $white;
|
||||||
background: rgba($black, 0.65);
|
background: rgba($black, 0.65);
|
||||||
backdrop-filter: blur(10px) saturate(180%) contrast(75%) brightness(70%);
|
backdrop-filter: blur(10px) saturate(180%) contrast(75%) brightness(70%);
|
||||||
padding: 2px 6px;
|
padding: 3px 8px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
font-size: 11px;
|
font-size: 12px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
line-height: 18px;
|
line-height: 20px;
|
||||||
|
|
||||||
.icon {
|
|
||||||
width: 15px;
|
|
||||||
height: 15px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.attachment-list {
|
.attachment-list {
|
||||||
|
|
Loading…
Reference in a new issue