chinwagsocial/app/javascript/mastodon/features/compose/containers/spoiler_button_container.js

33 lines
1 KiB
JavaScript
Raw Normal View History

import { injectIntl, defineMessages } from 'react-intl';
2017-03-25 10:01:43 +11:00
import { connect } from 'react-redux';
import WarningIcon from 'mastodon/../material-icons/400-24px/warning.svg?react';
import { IconButton } from 'mastodon/components/icon_button';
2017-03-25 10:01:43 +11:00
import { changeComposeSpoilerness } from '../../../actions/compose';
const messages = defineMessages({
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 }) => ({
iconComponent: WarningIcon,
title: intl.formatMessage(state.getIn(['compose', 'spoiler']) ? messages.marked : messages.unmarked),
active: state.getIn(['compose', 'spoiler']),
ariaControls: 'cw-spoiler-input',
size: 18,
inverted: true,
2017-03-25 10:01:43 +11:00
});
const mapDispatchToProps = dispatch => ({
onClick () {
dispatch(changeComposeSpoilerness());
},
2017-03-25 10:01:43 +11:00
});
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(IconButton));