spoiler_button_container.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. import { injectIntl, defineMessages } from 'react-intl';
  2. import { connect } from 'react-redux';
  3. import WarningIcon from 'mastodon/../material-icons/400-24px/warning.svg?react';
  4. import { IconButton } from 'mastodon/components/icon_button';
  5. import { changeComposeSpoilerness } from '../../../actions/compose';
  6. const messages = defineMessages({
  7. marked: { id: 'compose_form.spoiler.marked', defaultMessage: 'Text is hidden behind warning' },
  8. unmarked: { id: 'compose_form.spoiler.unmarked', defaultMessage: 'Text is not hidden' },
  9. });
  10. const mapStateToProps = (state, { intl }) => ({
  11. iconComponent: WarningIcon,
  12. title: intl.formatMessage(state.getIn(['compose', 'spoiler']) ? messages.marked : messages.unmarked),
  13. active: state.getIn(['compose', 'spoiler']),
  14. ariaControls: 'cw-spoiler-input',
  15. size: 18,
  16. inverted: true,
  17. });
  18. const mapDispatchToProps = dispatch => ({
  19. onClick () {
  20. dispatch(changeComposeSpoilerness());
  21. },
  22. });
  23. export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(IconButton));