0
0
instrumental/app/javascript/mastodon/features/compose/containers/spoiler_button_container.js

29 lines
912 B
JavaScript
Raw Normal View History

import { injectIntl, defineMessages } from 'react-intl';
2017-03-25 08:01:43 +09:00
import { connect } from 'react-redux';
2017-03-25 08:01:43 +09:00
import { changeComposeSpoilerness } from '../../../actions/compose';
import TextIconButton from '../components/text_icon_button';
2017-03-25 08:01:43 +09:00
const messages = defineMessages({
marked: { id: 'compose_form.spoiler.marked', defaultMessage: 'Text is hidden behind warning' },
unmarked: { id: 'compose_form.spoiler.unmarked', defaultMessage: 'Text is not hidden' },
2017-03-25 08:01:43 +09:00
});
const mapStateToProps = (state, { intl }) => ({
label: 'CW',
title: intl.formatMessage(state.getIn(['compose', 'spoiler']) ? messages.marked : messages.unmarked),
active: state.getIn(['compose', 'spoiler']),
ariaControls: 'cw-spoiler-input',
2017-03-25 08:01:43 +09:00
});
const mapDispatchToProps = dispatch => ({
onClick () {
dispatch(changeComposeSpoilerness());
},
2017-03-25 08:01:43 +09:00
});
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TextIconButton));