ComposeForm: convert some buttons into TSX
This commit is contained in:
parent
890299ead0
commit
61fd48204b
7 changed files with 95 additions and 0 deletions
Binary file not shown.
30
app/soapbox/features/compose/components/markdown_button.tsx
Normal file
30
app/soapbox/features/compose/components/markdown_button.tsx
Normal 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;
|
Binary file not shown.
36
app/soapbox/features/compose/components/poll_button.tsx
Normal file
36
app/soapbox/features/compose/components/poll_button.tsx
Normal 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;
|
Binary file not shown.
29
app/soapbox/features/compose/components/spoiler_button.tsx
Normal file
29
app/soapbox/features/compose/components/spoiler_button.tsx
Normal 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;
|
Binary file not shown.
Loading…
Reference in a new issue