2017-03-25 00:01:43 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import TextIconButton from '../components/text_icon_button';
|
|
|
|
import { changeComposeSpoilerness } from '../../../actions/compose';
|
|
|
|
import { injectIntl, defineMessages } from 'react-intl';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
2018-03-13 07:58:13 +01:00
|
|
|
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 00:01:43 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
const mapStateToProps = (state, { intl }) => ({
|
|
|
|
label: 'CW',
|
2018-03-13 07:58:13 +01:00
|
|
|
title: intl.formatMessage(state.getIn(['compose', 'spoiler']) ? messages.marked : messages.unmarked),
|
2017-04-23 20:33:44 +02:00
|
|
|
active: state.getIn(['compose', 'spoiler']),
|
2017-05-20 17:31:47 +02:00
|
|
|
ariaControls: 'cw-spoiler-input',
|
2017-03-25 00:01:43 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
|
|
|
|
onClick () {
|
|
|
|
dispatch(changeComposeSpoilerness());
|
2017-05-20 17:31:47 +02:00
|
|
|
},
|
2017-03-25 00:01:43 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TextIconButton));
|