3034f4ce6c
* bring in ody styles; modify; cleanup * workflow * workflow * v0.52.6-alpha.teststyles.1 * fix hook * v0.52.6-alpha.teststyles.2 * style fixes * fix pagination styling * v0.52.6-alpha.teststyles.3 * wallet icon was bad * restore deploy script * fixes * fix player close button * modal inputs * cleanup * cleanup * fix staked indicator * fix profile menu button skel delay * fix view-all-playlists hover * fix overlay buttons on collection page * fix header buttons
82 lines
2.3 KiB
JavaScript
82 lines
2.3 KiB
JavaScript
// @flow
|
|
import * as REACTION_TYPES from 'constants/reactions';
|
|
import * as ICONS from 'constants/icons';
|
|
import React from 'react';
|
|
import classnames from 'classnames';
|
|
import Button from 'component/button';
|
|
import { formatNumberWithCommas } from 'util/number';
|
|
import NudgeFloating from 'component/nudgeFloating';
|
|
type Props = {
|
|
claim: StreamClaim,
|
|
doFetchReactions: (string) => void,
|
|
doReactionLike: (string) => void,
|
|
doReactionDislike: (string) => void,
|
|
uri: string,
|
|
likeCount: number,
|
|
dislikeCount: number,
|
|
myReaction: ?string,
|
|
};
|
|
|
|
function FileReactions(props: Props) {
|
|
const {
|
|
claim,
|
|
uri,
|
|
doFetchReactions,
|
|
doReactionLike,
|
|
doReactionDislike,
|
|
myReaction,
|
|
likeCount,
|
|
dislikeCount,
|
|
} = props;
|
|
|
|
const claimId = claim && claim.claim_id;
|
|
const channel = claim && claim.signing_channel && claim.signing_channel.name;
|
|
const isCollection = claim && claim.value_type === 'collection'; // hack because nudge gets cut off by card on cols.
|
|
const likeIcon = ICONS.UPVOTE;
|
|
const dislikeIcon = ICONS.DOWNVOTE;
|
|
React.useEffect(() => {
|
|
function fetchReactions() {
|
|
doFetchReactions(claimId);
|
|
}
|
|
|
|
if (claimId) {
|
|
fetchReactions();
|
|
}
|
|
}, [claimId, doFetchReactions]);
|
|
|
|
return (
|
|
<>
|
|
{channel && !isCollection && (
|
|
<NudgeFloating
|
|
name="nudge:support-acknowledge"
|
|
text={__('Let %channel% know you enjoyed this!', { channel })}
|
|
/>
|
|
)}
|
|
|
|
<Button
|
|
title={__('I like this')}
|
|
authSrc="filereaction_like"
|
|
className={classnames('button--file-action button-like', {
|
|
'button--file-action-active': myReaction === REACTION_TYPES.LIKE,
|
|
})}
|
|
label={<>{formatNumberWithCommas(likeCount, 0)}</>}
|
|
iconSize={18}
|
|
icon={likeIcon}
|
|
onClick={() => doReactionLike(uri)}
|
|
/>
|
|
<Button
|
|
authSrc={'filereaction_dislike'}
|
|
title={__('I dislike this')}
|
|
className={classnames('button--file-action button-dislike', {
|
|
'button--file-action-active': myReaction === REACTION_TYPES.DISLIKE,
|
|
})}
|
|
label={<>{formatNumberWithCommas(dislikeCount, 0)}</>}
|
|
iconSize={18}
|
|
icon={dislikeIcon}
|
|
onClick={() => doReactionDislike(uri)}
|
|
/>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default FileReactions;
|