Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): show-coherency-percencentage-instead-of-ratio #1739

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading