pleroma/app/soapbox/features/compose/components/spoiler_button.js

39 lines
995 B
JavaScript
Raw Normal View History

2021-09-22 12:38:48 -07:00
import PropTypes from 'prop-types';
import React from 'react';
2021-09-22 12:38:48 -07:00
import { defineMessages, injectIntl } from 'react-intl';
import ComposeFormButton from './compose_form_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 (
<ComposeFormButton
icon={require('@tabler/icons/icons/alert-triangle.svg')}
title={intl.formatMessage(active ? messages.marked : messages.unmarked)}
active={active}
onClick={this.handleClick}
/>
2021-09-22 12:38:48 -07:00
);
}
}