54 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-02-08 01:12:01 -05:00
import { injectIntl, defineMessages } from 'react-intl'
import { changeComposeSpoilerness } from '../../../actions/compose'
import ComposeExtraButton from './compose_extra_button'
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' },
title: { id: 'compose_form.spoiler.title', defaultMessage: 'Warning' },
})
const mapStateToProps = (state) => ({
active: state.getIn(['compose', 'spoiler']),
})
2020-04-11 18:29:19 -04:00
const mapDispatchToProps = (dispatch) => ({
2020-02-08 01:12:01 -05:00
onClick () {
dispatch(changeComposeSpoilerness())
},
})
export default
@injectIntl
@connect(mapStateToProps, mapDispatchToProps)
class SpoilerButton extends PureComponent {
static propTypes = {
active: PropTypes.bool,
2020-03-24 00:39:12 -04:00
intl: PropTypes.object.isRequired,
2020-02-28 10:20:47 -05:00
small: PropTypes.bool,
2020-02-08 01:12:01 -05:00
}
handleClick = (e) => {
e.preventDefault()
this.props.onClick()
}
render () {
2020-02-28 10:20:47 -05:00
const { active, intl, small } = this.props
2020-02-08 01:12:01 -05:00
return (
<ComposeExtraButton
title={intl.formatMessage(messages.title)}
icon='warning'
onClick={this.handleClick}
2020-02-28 10:20:47 -05:00
small={small}
2020-03-06 23:53:28 -05:00
active={active}
2020-02-08 01:12:01 -05:00
/>
)
}
}