You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
910 B

  1. import { connect } from 'react-redux';
  2. import TextIconButton from '../components/text_icon_button';
  3. import { changeComposeSpoilerness } from '../../../actions/compose';
  4. import { injectIntl, defineMessages } from 'react-intl';
  5. const messages = defineMessages({
  6. marked: { id: 'compose_form.spoiler.marked', defaultMessage: 'Text is hidden behind warning' },
  7. unmarked: { id: 'compose_form.spoiler.unmarked', defaultMessage: 'Text is not hidden' },
  8. });
  9. const mapStateToProps = (state, { intl }) => ({
  10. label: 'CW',
  11. title: intl.formatMessage(state.getIn(['compose', 'spoiler']) ? messages.marked : messages.unmarked),
  12. active: state.getIn(['compose', 'spoiler']),
  13. ariaControls: 'cw-spoiler-input',
  14. });
  15. const mapDispatchToProps = dispatch => ({
  16. onClick () {
  17. dispatch(changeComposeSpoilerness());
  18. },
  19. });
  20. export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TextIconButton));