2023-05-24 00:15:17 +09:00
|
|
|
import { injectIntl, defineMessages } from 'react-intl';
|
|
|
|
|
2017-03-25 08:01:43 +09:00
|
|
|
import { connect } from 'react-redux';
|
2023-05-24 00:15:17 +09:00
|
|
|
|
2024-02-24 00:32:13 +09:00
|
|
|
import WarningIcon from '@/material-icons/400-20px/warning.svg?react';
|
2024-01-26 00:41:31 +09:00
|
|
|
import { IconButton } from 'mastodon/components/icon_button';
|
|
|
|
|
2017-03-25 08:01:43 +09:00
|
|
|
import { changeComposeSpoilerness } from '../../../actions/compose';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
2018-03-13 15:58:13 +09:00
|
|
|
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 08:01:43 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
const mapStateToProps = (state, { intl }) => ({
|
2024-01-26 00:41:31 +09:00
|
|
|
iconComponent: WarningIcon,
|
2018-03-13 15:58:13 +09:00
|
|
|
title: intl.formatMessage(state.getIn(['compose', 'spoiler']) ? messages.marked : messages.unmarked),
|
2017-04-24 03:33:44 +09:00
|
|
|
active: state.getIn(['compose', 'spoiler']),
|
2017-05-21 00:31:47 +09:00
|
|
|
ariaControls: 'cw-spoiler-input',
|
2024-01-26 00:41:31 +09:00
|
|
|
size: 18,
|
|
|
|
inverted: true,
|
2017-03-25 08:01:43 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
|
|
|
|
onClick () {
|
|
|
|
dispatch(changeComposeSpoilerness());
|
2017-05-21 00:31:47 +09:00
|
|
|
},
|
2017-03-25 08:01:43 +09:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2024-01-26 00:41:31 +09:00
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(IconButton));
|