diff --git a/app/soapbox/components/list.js b/app/soapbox/components/list.js index ed0210c68..02905efea 100644 --- a/app/soapbox/components/list.js +++ b/app/soapbox/components/list.js @@ -5,7 +5,6 @@ import { v4 as uuidv4 } from 'uuid'; import Icon from './icon'; - const List = ({ children }) => (
{children}
); diff --git a/app/soapbox/components/load_more.js b/app/soapbox/components/load_more.js deleted file mode 100644 index 80567aebc..000000000 --- a/app/soapbox/components/load_more.js +++ /dev/null @@ -1,33 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { FormattedMessage } from 'react-intl'; - -import { Button } from 'soapbox/components/ui'; - -export default class LoadMore extends React.PureComponent { - - static propTypes = { - onClick: PropTypes.func, - disabled: PropTypes.bool, - visible: PropTypes.bool, - } - - static defaultProps = { - visible: true, - } - - render() { - const { disabled, visible } = this.props; - - if (!visible) { - return null; - } - - return ( - - ); - } - -} diff --git a/app/soapbox/components/load_more.tsx b/app/soapbox/components/load_more.tsx new file mode 100644 index 000000000..90f05e588 --- /dev/null +++ b/app/soapbox/components/load_more.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { FormattedMessage } from 'react-intl'; + +import { Button } from 'soapbox/components/ui'; + +interface ILoadMore { + onClick: () => void, + disabled?: boolean, + visible?: Boolean, +} + +const LoadMore: React.FC = ({ onClick, disabled, visible = true }) => { + if (!visible) { + return null; + } + + return ( + + ); +}; + +export default LoadMore; diff --git a/app/soapbox/components/more_follows.js b/app/soapbox/components/more_follows.js deleted file mode 100644 index adfecb4ce..000000000 --- a/app/soapbox/components/more_follows.js +++ /dev/null @@ -1,68 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { defineMessages, injectIntl } from 'react-intl'; -import { connect } from 'react-redux'; - -import { getFeatures } from 'soapbox/utils/features'; - -const messages = defineMessages({ - following: { - id: 'morefollows.following_label', - defaultMessage: '…and {count} more {count, plural, one {follow} other {follows}} on remote sites.', - }, - followers: { - id: 'morefollows.followers_label', - defaultMessage: '…and {count} more {count, plural, one {follower} other {followers}} on remote sites.', - }, -}); - - -const mapStateToProps = state => { - const instance = state.get('instance'); - - return { - features: getFeatures(instance), - }; -}; - -export default @connect(mapStateToProps) -@injectIntl -class MoreFollows extends React.PureComponent { - - static propTypes = { - visible: PropTypes.bool, - count: PropTypes.number, - type: PropTypes.string, - intl: PropTypes.object.isRequired, - features: PropTypes.object.isRequired, - } - - static defaultProps = { - visible: true, - } - - getMessage = () => { - const { type, count, intl } = this.props; - return intl.formatMessage(messages[type], { count }); - } - - render() { - const { features } = this.props; - - // If the instance isn't federating, there are no remote followers - if (!features.federating) { - return null; - } - - return ( -
-
-
- {this.getMessage()} -
-
-
- ); - } - -} diff --git a/app/soapbox/components/more_follows.tsx b/app/soapbox/components/more_follows.tsx new file mode 100644 index 000000000..a99b4b5be --- /dev/null +++ b/app/soapbox/components/more_follows.tsx @@ -0,0 +1,49 @@ +import React from 'react'; +import { defineMessages, useIntl } from 'react-intl'; + +import { useAppSelector } from 'soapbox/hooks'; +import { getFeatures } from 'soapbox/utils/features'; + +const messages = defineMessages({ + following: { + id: 'morefollows.following_label', + defaultMessage: '…and {count} more {count, plural, one {follow} other {follows}} on remote sites.', + }, + followers: { + id: 'morefollows.followers_label', + defaultMessage: '…and {count} more {count, plural, one {follower} other {followers}} on remote sites.', + }, +}); + +interface IMoreFollows { + visible?: Boolean, + count?: number, + type: 'following' | 'followers', +} + +const MoreFollows: React.FC = ({ visible = true, count, type }) => { + const intl = useIntl(); + const features = useAppSelector((state) => getFeatures(state.instance)); + + const getMessage = () => { + return intl.formatMessage(messages[type], { count }); + }; + + + // If the instance isn't federating, there are no remote followers + if (!features.federating) { + return null; + } + + return ( +
+
+
+ {getMessage()} +
+
+
+ ); +}; + +export default MoreFollows; diff --git a/app/soapbox/components/progress_bar.js b/app/soapbox/components/progress_bar.js deleted file mode 100644 index d338bca9c..000000000 --- a/app/soapbox/components/progress_bar.js +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -import ImmutablePureComponent from 'react-immutable-pure-component'; - - -export default class ProgressBar extends ImmutablePureComponent { - - render() { - const { progress } = this.props; - - return ( -
-
-
- ); - } - -} diff --git a/app/soapbox/components/progress_bar.tsx b/app/soapbox/components/progress_bar.tsx new file mode 100644 index 000000000..414efe053 --- /dev/null +++ b/app/soapbox/components/progress_bar.tsx @@ -0,0 +1,13 @@ +import React from 'react'; + +interface IProgressBar { + progress: number, +} + +const ProgressBar: React.FC = ({ progress }) => ( +
+
+
+) + +export default ProgressBar; diff --git a/app/soapbox/components/progress_circle.js b/app/soapbox/components/progress_circle.js deleted file mode 100644 index 7cd3937a7..000000000 --- a/app/soapbox/components/progress_circle.js +++ /dev/null @@ -1,62 +0,0 @@ -import classNames from 'classnames'; -import PropTypes from 'prop-types'; -import React from 'react'; - -export default class ProgressCircle extends React.PureComponent { - - static propTypes = { - progress: PropTypes.number.isRequired, - radius: PropTypes.number, - stroke: PropTypes.number, - title: PropTypes.string, - }; - - static defaultProps = { - radius: 12, - stroke: 4, - } - - render() { - const { progress, radius, stroke, title } = this.props; - - const progressStroke = stroke + 0.5; - const actualRadius = radius + progressStroke; - const circumference = 2 * Math.PI * radius; - const dashoffset = circumference * (1 - Math.min(progress, 1)); - - return ( -
- - - 1, - })} - style={{ - strokeDashoffset: dashoffset, - strokeDasharray: circumference, - }} - cx={actualRadius} - cy={actualRadius} - r={radius} - fill='none' - strokeWidth={progressStroke} - strokeLinecap='round' - /> - -
- ); - } - -} diff --git a/app/soapbox/components/progress_circle.tsx b/app/soapbox/components/progress_circle.tsx new file mode 100644 index 000000000..aaa1fc4d0 --- /dev/null +++ b/app/soapbox/components/progress_circle.tsx @@ -0,0 +1,52 @@ +import classNames from 'classnames'; +import React from 'react'; + +interface IProgressCircle { + progress: number, + radius?: number, + stroke?: number, + title?: string, +} + +const ProgressCircle: React.FC = ({ progress, radius = 12, stroke = 4, title }) => { + const progressStroke = stroke + 0.5; + const actualRadius = radius + progressStroke; + const circumference = 2 * Math.PI * radius; + const dashoffset = circumference * (1 - Math.min(progress, 1)); + + return ( +
+ + + 1, + })} + style={{ + strokeDashoffset: dashoffset, + strokeDasharray: circumference, + }} + cx={actualRadius} + cy={actualRadius} + r={radius} + fill='none' + strokeWidth={progressStroke} + strokeLinecap='round' + /> + +
+ ); +}; + +export default ProgressCircle;