ComposeForm: convert some buttons into TSX

This commit is contained in:
Alex Gleason 2022-03-21 17:28:57 -05:00
parent 890299ead0
commit 61fd48204b
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
7 changed files with 95 additions and 0 deletions

View file

@ -0,0 +1,30 @@
import React from 'react';
import { defineMessages, useIntl } from 'react-intl';
import ComposeFormButton from './compose_form_button';
const messages = defineMessages({
marked: { id: 'compose_form.markdown.marked', defaultMessage: 'Post markdown enabled' },
unmarked: { id: 'compose_form.markdown.unmarked', defaultMessage: 'Post markdown disabled' },
});
interface IMarkdownButton {
active?: boolean,
onClick: () => void,
}
const MarkdownButton: React.FC<IMarkdownButton> = ({ active, onClick }) => {
const intl = useIntl();
return (
<ComposeFormButton
icon={require('@tabler/icons/icons/markdown.svg')}
title={intl.formatMessage(active ? messages.marked : messages.unmarked)}
active={active}
onClick={onClick}
/>
);
};
export default MarkdownButton;

View file

@ -0,0 +1,36 @@
import React from 'react';
import { defineMessages, useIntl } from 'react-intl';
import ComposeFormButton from './compose_form_button';
const messages = defineMessages({
add_poll: { id: 'poll_button.add_poll', defaultMessage: 'Add a poll' },
remove_poll: { id: 'poll_button.remove_poll', defaultMessage: 'Remove poll' },
});
interface IPollButton {
disabled?: boolean,
unavailable?: boolean,
active?: boolean,
onClick: () => void,
}
const PollButton: React.FC<IPollButton> = ({ active, unavailable, disabled, onClick }) => {
const intl = useIntl();
if (unavailable) {
return null;
}
return (
<ComposeFormButton
icon={require('@tabler/icons/icons/chart-bar.svg')}
title={intl.formatMessage(active ? messages.remove_poll : messages.add_poll)}
active={active}
disabled={disabled}
onClick={onClick}
/>
);
};
export default PollButton;

View file

@ -0,0 +1,29 @@
import React from 'react';
import { defineMessages, useIntl } from 'react-intl';
import ComposeFormButton from './compose_form_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' },
});
interface ISpoilerButton {
active?: boolean,
onClick: () => void,
}
const SpoilerButton: React.FC<ISpoilerButton> = ({ active, onClick }) => {
const intl = useIntl();
return (
<ComposeFormButton
icon={require('@tabler/icons/icons/alert-triangle.svg')}
title={intl.formatMessage(active ? messages.marked : messages.unmarked)}
active={active}
onClick={onClick}
/>
);
};
export default SpoilerButton;