2022-01-10 14:17:52 -08:00
|
|
|
import classNames from 'classnames';
|
2021-09-22 12:38:48 -07:00
|
|
|
import PropTypes from 'prop-types';
|
2022-01-10 14:17:52 -08:00
|
|
|
import React from 'react';
|
2021-09-22 12:38:48 -07:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import IconButton from '../../../components/icon_button';
|
2021-09-22 12:38:48 -07:00
|
|
|
|
|
|
|
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' },
|
|
|
|
});
|
|
|
|
|
|
|
|
export default @injectIntl
|
|
|
|
class SpoilerButton extends React.PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
active: PropTypes.bool,
|
|
|
|
onClick: PropTypes.func.isRequired,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
handleClick = () => {
|
|
|
|
this.props.onClick();
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { intl, active } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='compose-form__spoiler-button'>
|
|
|
|
<IconButton
|
|
|
|
className={classNames('compose-form__spoiler-button-icon', { active })}
|
|
|
|
src={require('@tabler/icons/icons/alert-triangle.svg')}
|
|
|
|
title={intl.formatMessage(active ? messages.marked : messages.unmarked)}
|
|
|
|
onClick={this.handleClick}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|