Skip to content

Commit

Permalink
Merge pull request #1739 from kleros/feat/coherency-percentage
Browse files Browse the repository at this point in the history
feat(web): show-coherency-percencentage-instead-of-ratio
  • Loading branch information
jaybuidl authored Nov 7, 2024
2 parents 1c54fec + a709812 commit 1165d3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 3 additions & 5 deletions web/src/pages/Home/TopJurors/Header/Coherency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Container = styled.div`
display: flex;
font-size: 12px !important;
&::before {
content: "Votes";
content: "Coherency";
}
color: ${({ theme }) => theme.secondaryText};
align-items: center;
Expand All @@ -21,15 +21,13 @@ const Container = styled.div`
css`
font-size: 14px !important;
justify-content: center;
&::before {
content: "Coherent Votes";
}
`
)}
`;

const coherentVotesTooltipMsg =
"This is the ratio of coherent votes made by a juror: " +
"This is the percentage of coherent votes made by a juror." +
" Hover to see the ratio of coherent votes: " +
"the number in the left is the number of times where the juror " +
"voted coherently and the number in the right is the total number of times " +
"the juror voted";
Expand Down
9 changes: 8 additions & 1 deletion web/src/pages/Home/TopJurors/JurorCard/Coherency.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Tooltip } from "@kleros/ui-components-library";
import React from "react";
import styled from "styled-components";

Expand All @@ -18,7 +19,13 @@ interface ICoherency {
const Coherency: React.FC<ICoherency> = ({ totalCoherentVotes, totalResolvedVotes }) => {
const coherenceRatio = `${totalCoherentVotes}/${totalResolvedVotes}`;

return <Container>{coherenceRatio}</Container>;
return (
<Container>
<Tooltip text={coherenceRatio}>{getPercent(totalCoherentVotes, totalResolvedVotes)}</Tooltip>
</Container>
);
};

const getPercent = (num: number, den: number): string => `${Math.floor((num * 100) / den)}%`;

export default Coherency;

0 comments on commit 1165d3b

Please sign in to comment.