lbry-desktop/ui/component/rewardTotal/view.jsx

27 lines
914 B
React
Raw Normal View History

2019-06-17 22:32:38 +02:00
// @flow
import React from 'react';
import TotalBackground from './total-background.png';
2019-09-27 20:56:15 +02:00
import useTween from 'effects/use-tween';
2020-09-02 22:08:37 +02:00
import I18nMessage from 'component/i18nMessage';
import LbcSymbol from 'component/common/lbc-symbol';
2019-06-17 22:32:38 +02:00
type Props = {
rewards: Array<Reward>,
};
function RewardTotal(props: Props) {
const { rewards } = props;
const rewardTotal = rewards.reduce((acc, val) => acc + val.reward_amount, 0);
2019-07-01 18:47:10 +02:00
const modifier = rewardTotal > 500 ? 1 : 15; // used to tweak the reward count speed
const total = useTween(rewardTotal * modifier);
2019-06-17 22:32:38 +02:00
const integer = Math.round(total * rewardTotal);
return (
<section className="card card--section card--reward-total" style={{ backgroundImage: `url(${TotalBackground})` }}>
2020-09-02 22:08:37 +02:00
<I18nMessage tokens={{ amount: integer, lbc: <LbcSymbol /> }}>%amount% %lbc% earned from rewards</I18nMessage>
2019-06-17 22:32:38 +02:00
</section>
);
}
export default RewardTotal;