app
controllers
helpers
javascript
fonts
images
mastodon
actions
components
containers
features
account
account_gallery
account_timeline
blocks
community_timeline
compose
components
containers
autosuggest_account_container.js
compose_form_container.js
emoji_picker_dropdown_container.js
navigation_container.js
privacy_dropdown_container.js
reply_indicator_container.js
search_container.js
search_results_container.js
sensitive_button_container.js
spoiler_button_container.js
upload_button_container.js
upload_container.js
upload_form_container.js
upload_progress_container.js
warning_container.js
util
index.js
emoji
favourited_statuses
favourites
follow_requests
followers
following
generic_not_found
getting_started
hashtag_timeline
home_timeline
mutes
notifications
pinned_statuses
public_timeline
reblogs
report
standalone
status
ui
video
locales
middleware
reducers
selectors
service_worker
store
.gitkeep
api.js
base_polyfills.js
extra_polyfills.js
initial_state.js
is_mobile.js
link_header.js
load_polyfills.js
main.js
performance.js
ready.js
rtl.js
scroll.js
stream.js
test_setup.js
uuid.js
web_push_subscription.js
packs
styles
lib
mailers
models
policies
presenters
serializers
services
validators
views
workers
bin
config
db
docs
lib
log
nanobox
public
spec
streaming
vendor
.babelrc
.buildpacks
.codeclimate.yml
.dockerignore
.editorconfig
.env.nanobox
.env.production.sample
.env.test
.env.vagrant
.eslintignore
.eslintrc.yml
.foreman
.gitattributes
.gitignore
.haml-lint.yml
.nanoignore
.nvmrc
.postcssrc.yml
.profile
.rspec
.rubocop.yml
.ruby-version
.scss-lint.yml
.slugignore
.travis.yml
.yarnclean
Aptfile
CODEOWNERS
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Capfile
Dockerfile
Gemfile
Gemfile.lock
ISSUE_TEMPLATE.md
LICENSE
Procfile
Procfile.dev
README.md
Rakefile
Vagrantfile
app.json
boxfile.yml
config.ru
docker-compose.yml
docker_entrypoint.sh
jest.config.js
package.json
scalingo.json
yarn.lock
72 lines
2.2 KiB
JavaScript
72 lines
2.2 KiB
JavaScript
import React from 'react';
|
|
import { connect } from 'react-redux';
|
|
import PropTypes from 'prop-types';
|
|
import classNames from 'classnames';
|
|
import IconButton from '../../../components/icon_button';
|
|
import { changeComposeSensitivity } from '../../../actions/compose';
|
|
import Motion from '../../ui/util/optional_motion';
|
|
import spring from 'react-motion/lib/spring';
|
|
import { injectIntl, defineMessages } from 'react-intl';
|
|
|
|
const messages = defineMessages({
|
|
title: { id: 'compose_form.sensitive', defaultMessage: 'Mark media as sensitive' },
|
|
});
|
|
|
|
const mapStateToProps = state => ({
|
|
visible: state.getIn(['compose', 'media_attachments']).size > 0,
|
|
active: state.getIn(['compose', 'sensitive']),
|
|
disabled: state.getIn(['compose', 'spoiler']),
|
|
});
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
onClick () {
|
|
dispatch(changeComposeSensitivity());
|
|
},
|
|
|
|
});
|
|
|
|
class SensitiveButton extends React.PureComponent {
|
|
|
|
static propTypes = {
|
|
visible: PropTypes.bool,
|
|
active: PropTypes.bool,
|
|
disabled: PropTypes.bool,
|
|
onClick: PropTypes.func.isRequired,
|
|
intl: PropTypes.object.isRequired,
|
|
};
|
|
|
|
render () {
|
|
const { visible, active, disabled, onClick, intl } = this.props;
|
|
|
|
return (
|
|
<Motion defaultStyle={{ scale: 0.87 }} style={{ scale: spring(visible ? 1 : 0.87, { stiffness: 200, damping: 3 }) }}>
|
|
{({ scale }) => {
|
|
const icon = active ? 'eye-slash' : 'eye';
|
|
const className = classNames('compose-form__sensitive-button', {
|
|
'compose-form__sensitive-button--visible': visible,
|
|
});
|
|
return (
|
|
<div className={className} style={{ transform: `scale(${scale})` }}>
|
|
<IconButton
|
|
className='compose-form__sensitive-button__icon'
|
|
title={intl.formatMessage(messages.title)}
|
|
icon={icon}
|
|
onClick={onClick}
|
|
size={18}
|
|
active={active}
|
|
disabled={disabled}
|
|
style={{ lineHeight: null, height: null }}
|
|
inverted
|
|
/>
|
|
</div>
|
|
);
|
|
}}
|
|
</Motion>
|
|
);
|
|
}
|
|
|
|
}
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(SensitiveButton));
|