diff --git a/app/soapbox/components/status_action_bar.js b/app/soapbox/components/status_action_bar.js index 45331fb38..e098713df 100644 --- a/app/soapbox/components/status_action_bar.js +++ b/app/soapbox/components/status_action_bar.js @@ -6,11 +6,15 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { defineMessages, injectIntl } from 'react-intl'; import { connect } from 'react-redux'; -import { Link, withRouter } from 'react-router-dom'; +import { withRouter } from 'react-router-dom'; import { simpleEmojiReact } from 'soapbox/actions/emoji_reacts'; import EmojiSelector from 'soapbox/components/emoji_selector'; -import { StatusAction, StatusActionButton } from 'soapbox/components/status-action-button'; +import { + StatusAction, + StatusActionButton, + StatusActionCounter, +} from 'soapbox/components/ui/status/status-action-button'; import DropdownMenuContainer from 'soapbox/containers/dropdown_menu_container'; import { isUserTouching } from 'soapbox/is_mobile'; import { isStaff, isAdmin } from 'soapbox/utils/accounts'; @@ -20,7 +24,7 @@ import SoapboxPropTypes from 'soapbox/utils/soapbox_prop_types'; import { openModal } from '../actions/modals'; -import { IconButton, Text, Hoverable } from './ui'; +import { IconButton, Hoverable } from './ui'; const messages = defineMessages({ @@ -345,11 +349,9 @@ class StatusActionBar extends ImmutablePureComponent { this.props.onToggleStatusSensitivity(this.props.status); } - handleOpenReblogsModal = (event) => { + handleOpenReblogsModal = () => { const { me, status, onOpenUnauthorizedModal, onOpenReblogsModal } = this.props; - event.stopPropagation(); - if (!me) onOpenUnauthorizedModal(); else onOpenReblogsModal(status.getIn(['account', 'acct']), status.get('id')); } @@ -631,17 +633,6 @@ class StatusActionBar extends ImmutablePureComponent { const canShare = ('share' in navigator) && status.get('visibility') === 'public'; - const shareButton = canShare && ( -
- -
- ); - return (
{reblogButton} - {reblogCount !== 0 && {reblogCount}} + {reblogCount > 0 && ( + + )}
- {emojiReactCount !== 0 && ( + {emojiReactCount > 0 && ( (features.exposableReactions && !features.emojiReacts) ? ( - - {emojiReactCount} - + ) : ( - {emojiReactCount} + ) )}
- {shareButton} + {canShare && ( + + )} diff --git a/app/soapbox/components/status-action-button.tsx b/app/soapbox/components/ui/status/status-action-button.tsx similarity index 81% rename from app/soapbox/components/status-action-button.tsx rename to app/soapbox/components/ui/status/status-action-button.tsx index 826df3f62..79a7bedba 100644 --- a/app/soapbox/components/status-action-button.tsx +++ b/app/soapbox/components/ui/status/status-action-button.tsx @@ -6,13 +6,26 @@ import { IconButton, Text } from 'soapbox/components/ui'; interface IStatusActionCounter { count: number, + onClick?: () => void, to?: string, } /** Action button numerical counter, eg "5" likes */ -const StatusActionCounter: React.FC = ({ to, count = 0 }): JSX.Element => { - const text = {count}; - return to ? {text} : text; +const StatusActionCounter: React.FC = ({ to = '#', onClick, count = 0 }): JSX.Element => { + + const handleClick: React.EventHandler = e => { + if (onClick) { + onClick(); + e.preventDefault(); + e.stopPropagation(); + } + }; + + return ( + + {count} + + ); }; interface IStatusActionButton { @@ -61,4 +74,3 @@ const StatusActionButton: React.FC = ({ icon, title, to, ac }; export { StatusAction, StatusActionButton, StatusActionCounter }; -export default StatusActionButton;