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