Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
Added upvote percentage to the popup for votes made
Browse files Browse the repository at this point in the history
The upvote percentage can be viewed when hovering over the vote count and seeing the voters and their vote reward value.
  • Loading branch information
KrNel committed May 6, 2019
1 parent 8d99bec commit fbabfea
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/src/actions/summaryPostActions.js
Expand Up @@ -64,7 +64,7 @@ export const getSummaryContent = (selectedFilter, query, page, action) => (dispa
if (posts.length && action === 'more') {
startAuthor = summaryPost.startAuthor;
startPermlink = summaryPost.startPermlink;
query.limit = query.limit+1;
query.limit = query.limit + 1;
}

let nextPost = false;
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/pages/Manage/ManageGroups.js
Expand Up @@ -34,7 +34,7 @@ class ManageGroups extends Component {
section: PropTypes.string.isRequired,
headerText: PropTypes.string.isRequired,
match: PropTypes.shape(PropTypes.object.isRequired),
groups: PropTypes.shape(PropTypes.object.isRequired),
groups: PropTypes.arrayOf(PropTypes.object.isRequired),
areGroupsLoading: PropTypes.bool,
onChangeOwnership: PropTypes.func.isRequired,
};
Expand Down
28 changes: 28 additions & 0 deletions client/src/components/pages/Steem/PercentDisplay.js
@@ -0,0 +1,28 @@
import React from 'react';
import PropTypes from 'prop-types';

/**
* Formats a number to a percentage with 2 decimal places.
*
* @param {number} value Number to be formatted
* @return {element} Span element containing formatted value
*/
const PercentDisplay = ({ value }) => {
const formatter = new Intl.NumberFormat('en-US', {
style: 'percent',
minimumFractionDigits: 2
})
return (
<span>{formatter.format(value)}</span>
)
}

PercentDisplay.propTypes = {
value: PropTypes.number,
};

PercentDisplay.defaultProps = {
value: 0,
};

export default PercentDisplay;
7 changes: 6 additions & 1 deletion client/src/components/pages/Steem/PostsSummary.css
Expand Up @@ -69,7 +69,7 @@
right: 0;
left: 0;
background: rgb(0, 0, 0);
background: rgba(0, 0, 0, 0.7);
background: rgba(0, 0, 0, 0.8);
color: #f1f1f1;
opacity:1;
font-size: 1.1rem;
Expand Down Expand Up @@ -100,6 +100,7 @@
position: relative;
display: block;
max-height: 6.2rem;
line-height: 1.7rem;
}

.infSummary .overlayImage a {
Expand All @@ -121,6 +122,10 @@
margin-top: 0.5rem;
}

.postBox .item {
line-height: inherit;
}

.postBox .timeago {
text-align: right;
}
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/pages/Steem/PostsSummaryGrid.js
Expand Up @@ -71,7 +71,6 @@ const PostsSummary = (props) => {
const reblogged_by = post.reblogged_by;

let isResteemed = false;
let isResteemedByUser = false;

if (page === 'blog') {
isResteemed = pageOwner !== author
Expand Down Expand Up @@ -183,7 +182,6 @@ const PostsSummary = (props) => {
pid={pid}
image={thumb}
handleResteem={handleResteem}
isResteemedByUser={isResteemedByUser}
resteemedPayload={resteemedPayload}
pageOwner={pageOwner}
/>
Expand Down
16 changes: 12 additions & 4 deletions client/src/components/pages/Steem/Vote.js
Expand Up @@ -4,6 +4,7 @@ import Slider from 'react-rangeslider';
import PropTypes from 'prop-types';

import DollarDisplay from './DollarDisplay';
import PercentDisplay from './PercentDisplay';
import UserLink from './UserLink';
import { getUpvotes, sortVotes } from '../../../utils/helpers';

Expand Down Expand Up @@ -202,14 +203,21 @@ class Vote extends Component {
if (votesCount) {
votersPopup = voters.slice(0, 14).map(vote => (
<div key={vote.voter}>
{<UserLink user={vote.voter} />}
{ <UserLink user={vote.voter} /> }

{vote.rshares * ratio > 0.01 && (
<span style={{ opacity: '0.5' }}>
{' '}
{ vote.rshares * ratio > 0.001 && (
<span>
{`\u00A0\u00A0`}
<DollarDisplay value={vote.rshares * ratio} />
</span>
)}

{
<span style={{ opacity: '0.7' }}>
{`\u00A0\u2022\u00A0`}
<PercentDisplay value={vote.percent / 10000} />
</span>
}
</div>
));
}else {
Expand Down

0 comments on commit fbabfea

Please sign in to comment.