Skip to content

Commit 28d0268

Browse files
Gargronhiyuki2578
authored andcommitted
Make the "mark media as sensitive" button more obvious in web UI (mastodon#10673)
* Make the "mark media as sensitive" button more obvious in web UI * Use eye-slash icon instead of eye icon to mean "hide"
1 parent 44089e0 commit 28d0268

6 files changed

Lines changed: 19 additions & 35 deletions

File tree

app/javascript/mastodon/components/media_gallery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class MediaGallery extends React.PureComponent {
314314
}
315315

316316
if (visible) {
317-
spoilerButton = <IconButton title={intl.formatMessage(messages.toggle_visible)} icon={visible ? 'eye' : 'eye-slash'} overlay onClick={this.handleOpen} />;
317+
spoilerButton = <IconButton title={intl.formatMessage(messages.toggle_visible)} icon='eye-slash' overlay onClick={this.handleOpen} />;
318318
} else {
319319
spoilerButton = (
320320
<button type='button' onClick={this.handleOpen} className='spoiler-button__overlay'>

app/javascript/mastodon/features/compose/components/compose_form.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import UploadButtonContainer from '../containers/upload_button_container';
1010
import { defineMessages, injectIntl } from 'react-intl';
1111
import SpoilerButtonContainer from '../containers/spoiler_button_container';
1212
import PrivacyDropdownContainer from '../containers/privacy_dropdown_container';
13-
import SensitiveButtonContainer from '../containers/sensitive_button_container';
1413
import EmojiPickerDropdown from '../containers/emoji_picker_dropdown_container';
1514
import PollFormContainer from '../containers/poll_form_container';
1615
import UploadFormContainer from '../containers/upload_form_container';
@@ -220,7 +219,6 @@ class ComposeForm extends ImmutablePureComponent {
220219
<UploadButtonContainer />
221220
<PollButtonContainer />
222221
<PrivacyDropdownContainer />
223-
<SensitiveButtonContainer />
224222
<SpoilerButtonContainer />
225223
</div>
226224
<div className='character-counter__wrapper'><CharacterCounter max={1024} text={text} /></div>

app/javascript/mastodon/features/compose/components/upload_form.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
33
import UploadProgressContainer from '../containers/upload_progress_container';
44
import ImmutablePureComponent from 'react-immutable-pure-component';
55
import UploadContainer from '../containers/upload_container';
6+
import SensitiveButtonContainer from '../containers/sensitive_button_container';
67

78
export default class UploadForm extends ImmutablePureComponent {
89

@@ -22,6 +23,8 @@ export default class UploadForm extends ImmutablePureComponent {
2223
<UploadContainer id={id} key={id} />
2324
))}
2425
</div>
26+
27+
{!mediaIds.isEmpty() && <SensitiveButtonContainer />}
2528
</div>
2629
);
2730
}

app/javascript/mastodon/features/compose/containers/sensitive_button_container.js

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@ import React from 'react';
22
import { connect } from 'react-redux';
33
import PropTypes from 'prop-types';
44
import classNames from 'classnames';
5-
import IconButton from '../../../components/icon_button';
6-
import { changeComposeSensitivity } from '../../../actions/compose';
7-
import Motion from '../../ui/util/optional_motion';
8-
import spring from 'react-motion/lib/spring';
9-
import { injectIntl, defineMessages } from 'react-intl';
5+
import { changeComposeSensitivity } from 'mastodon/actions/compose';
6+
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
7+
import Icon from 'mastodon/components/icon';
108

119
const messages = defineMessages({
1210
marked: { id: 'compose_form.sensitive.marked', defaultMessage: 'Media is marked as sensitive' },
1311
unmarked: { id: 'compose_form.sensitive.unmarked', defaultMessage: 'Media is not marked as sensitive' },
1412
});
1513

1614
const mapStateToProps = state => ({
17-
visible: state.getIn(['compose', 'media_attachments']).size > 0,
1815
active: state.getIn(['compose', 'sensitive']),
1916
disabled: state.getIn(['compose', 'spoiler']),
2017
});
@@ -30,40 +27,21 @@ const mapDispatchToProps = dispatch => ({
3027
class SensitiveButton extends React.PureComponent {
3128

3229
static propTypes = {
33-
visible: PropTypes.bool,
3430
active: PropTypes.bool,
3531
disabled: PropTypes.bool,
3632
onClick: PropTypes.func.isRequired,
3733
intl: PropTypes.object.isRequired,
3834
};
3935

4036
render () {
41-
const { visible, active, disabled, onClick, intl } = this.props;
37+
const { active, disabled, onClick, intl } = this.props;
4238

4339
return (
44-
<Motion defaultStyle={{ scale: 0.87 }} style={{ scale: spring(visible ? 1 : 0.87, { stiffness: 200, damping: 3 }) }}>
45-
{({ scale }) => {
46-
const icon = active ? 'eye-slash' : 'eye';
47-
const className = classNames('compose-form__sensitive-button', {
48-
'compose-form__sensitive-button--visible': visible,
49-
});
50-
return (
51-
<div className={className} style={{ transform: `scale(${scale})` }}>
52-
<IconButton
53-
className='compose-form__sensitive-button__icon'
54-
title={intl.formatMessage(active ? messages.marked : messages.unmarked)}
55-
icon={icon}
56-
onClick={onClick}
57-
size={18}
58-
active={active}
59-
disabled={disabled}
60-
style={{ lineHeight: null, height: null }}
61-
inverted
62-
/>
63-
</div>
64-
);
65-
}}
66-
</Motion>
40+
<div className='compose-form__sensitive-button'>
41+
<button className={classNames('icon-button', { active })} onClick={onClick} disabled={disabled} title={intl.formatMessage(active ? messages.marked : messages.unmarked)}>
42+
<Icon id='eye-slash' /> <FormattedMessage id='compose_form.sensitive.hide' defaultMessage='Mark media as sensitive' />
43+
</button>
44+
</div>
6745
);
6846
}
6947

app/javascript/mastodon/features/video/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ class Video extends React.PureComponent {
472472
</div>
473473

474474
<div className='video-player__buttons right'>
475-
{!onCloseVideo && <button type='button' aria-label={intl.formatMessage(messages.hide)} onClick={this.toggleReveal}><Icon id='eye' fixedWidth /></button>}
475+
{!onCloseVideo && <button type='button' aria-label={intl.formatMessage(messages.hide)} onClick={this.toggleReveal}><Icon id='eye-slash' fixedWidth /></button>}
476476
{(!fullscreen && onOpenVideo) && <button type='button' aria-label={intl.formatMessage(messages.expand)} onClick={this.handleOpenVideo}><Icon id='expand' fixedWidth /></button>}
477477
{onCloseVideo && <button type='button' aria-label={intl.formatMessage(messages.close)} onClick={this.handleCloseVideo}><Icon id='compress' fixedWidth /></button>}
478478
<button type='button' aria-label={intl.formatMessage(fullscreen ? messages.exit_fullscreen : messages.fullscreen)} onClick={this.toggleFullscreen}><Icon id={fullscreen ? 'compress' : 'arrows-alt'} fixedWidth /></button>

app/javascript/styles/mastodon/components.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@
264264
.compose-form {
265265
padding: 10px;
266266

267+
&__sensitive-button {
268+
padding: 10px;
269+
padding-top: 0;
270+
}
271+
267272
.compose-form__warning {
268273
color: $inverted-text-color;
269274
margin-bottom: 10px;

0 commit comments

Comments
 (0)