logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

spoiler_button_container.js (910B)


  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));