diff --git a/app/soapbox/features/compose/components/compose_form_button.tsx b/app/soapbox/features/compose/components/compose_form_button.tsx new file mode 100644 index 000000000..3f80c4b6a --- /dev/null +++ b/app/soapbox/features/compose/components/compose_form_button.tsx @@ -0,0 +1,34 @@ +import classNames from 'classnames'; +import React from 'react'; + +import { IconButton } from 'soapbox/components/ui'; + +interface IComposeFormButton { + icon: string, + title?: string, + active?: boolean, + disabled?: boolean, + onClick: () => void, +} + +const ComposeFormButton: React.FC = ({ + icon, + title, + active, + disabled, + onClick, +}) => { + return ( +
+ +
+ ); +}; + +export default ComposeFormButton; diff --git a/app/soapbox/features/compose/components/markdown_button.js b/app/soapbox/features/compose/components/markdown_button.js deleted file mode 100644 index 202bc0cf7..000000000 --- a/app/soapbox/features/compose/components/markdown_button.js +++ /dev/null @@ -1,41 +0,0 @@ -import classNames from 'classnames'; -import PropTypes from 'prop-types'; -import React from 'react'; -import { defineMessages, injectIntl } from 'react-intl'; - -import IconButton from '../../../components/icon_button'; - -const messages = defineMessages({ - marked: { id: 'compose_form.markdown.marked', defaultMessage: 'Post markdown enabled' }, - unmarked: { id: 'compose_form.markdown.unmarked', defaultMessage: 'Post markdown disabled' }, -}); - -export default @injectIntl -class MarkdownButton 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 ( -
- -
- ); - } - -} diff --git a/app/soapbox/features/compose/components/markdown_button.tsx b/app/soapbox/features/compose/components/markdown_button.tsx new file mode 100644 index 000000000..01b0620a0 --- /dev/null +++ b/app/soapbox/features/compose/components/markdown_button.tsx @@ -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 = ({ active, onClick }) => { + const intl = useIntl(); + + return ( + + ); + +}; + +export default MarkdownButton; diff --git a/app/soapbox/features/compose/components/poll_button.js b/app/soapbox/features/compose/components/poll_button.js deleted file mode 100644 index a9d607d04..000000000 --- a/app/soapbox/features/compose/components/poll_button.js +++ /dev/null @@ -1,48 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { defineMessages, injectIntl } from 'react-intl'; - -import IconButton from '../../../components/icon_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' }, -}); - -export default -@injectIntl -class PollButton extends React.PureComponent { - - static propTypes = { - disabled: PropTypes.bool, - unavailable: PropTypes.bool, - active: PropTypes.bool, - onClick: PropTypes.func.isRequired, - intl: PropTypes.object.isRequired, - }; - - handleClick = () => { - this.props.onClick(); - } - - render() { - const { intl, active, unavailable, disabled } = this.props; - - if (unavailable) { - return null; - } - - return ( -
- -
- ); - } - -} diff --git a/app/soapbox/features/compose/components/poll_button.tsx b/app/soapbox/features/compose/components/poll_button.tsx new file mode 100644 index 000000000..c59ae3151 --- /dev/null +++ b/app/soapbox/features/compose/components/poll_button.tsx @@ -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 = ({ active, unavailable, disabled, onClick }) => { + const intl = useIntl(); + + if (unavailable) { + return null; + } + + return ( + + ); +}; + +export default PollButton; diff --git a/app/soapbox/features/compose/components/privacy_dropdown.js b/app/soapbox/features/compose/components/privacy_dropdown.js index 3c7f011e1..415789ba5 100644 --- a/app/soapbox/features/compose/components/privacy_dropdown.js +++ b/app/soapbox/features/compose/components/privacy_dropdown.js @@ -8,7 +8,7 @@ import Overlay from 'react-overlays/lib/Overlay'; import Icon from 'soapbox/components/icon'; -import IconButton from '../../../components/icon_button'; +import { IconButton } from '../../../components/ui'; import Motion from '../../ui/util/optional_motion'; const messages = defineMessages({ @@ -253,7 +253,7 @@ class PrivacyDropdown extends React.PureComponent {
- -
+ ); } diff --git a/app/soapbox/features/compose/components/spoiler_button.js b/app/soapbox/features/compose/components/spoiler_button.js deleted file mode 100644 index 4a90a3336..000000000 --- a/app/soapbox/features/compose/components/spoiler_button.js +++ /dev/null @@ -1,41 +0,0 @@ -import classNames from 'classnames'; -import PropTypes from 'prop-types'; -import React from 'react'; -import { defineMessages, injectIntl } from 'react-intl'; - -import IconButton from '../../../components/icon_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' }, -}); - -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 ( -
- -
- ); - } - -} diff --git a/app/soapbox/features/compose/components/spoiler_button.tsx b/app/soapbox/features/compose/components/spoiler_button.tsx new file mode 100644 index 000000000..6d9c1aa76 --- /dev/null +++ b/app/soapbox/features/compose/components/spoiler_button.tsx @@ -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 = ({ active, onClick }) => { + const intl = useIntl(); + + return ( + + ); +}; + +export default SpoilerButton; diff --git a/app/soapbox/features/compose/containers/markdown_button_container.js b/app/soapbox/features/compose/containers/markdown_button_container.js index 4001f3c92..cab3fb4d4 100644 --- a/app/soapbox/features/compose/containers/markdown_button_container.js +++ b/app/soapbox/features/compose/containers/markdown_button_container.js @@ -12,7 +12,10 @@ const mapStateToProps = (state, { intl }) => { const mapDispatchToProps = dispatch => ({ onClick() { - dispatch(changeComposeContentType(this.active ? 'text/plain' : 'text/markdown')); + dispatch((_, getState) => { + const active = getState().getIn(['compose', 'content_type']) === 'text/markdown'; + dispatch(changeComposeContentType(active ? 'text/plain' : 'text/markdown')); + }); }, });