Skip to content

Commit 74235df

Browse files
authored
Merge pull request #1297 from kleros/feat(web)/x-share-juror-score
feat(web): share juror score on x
2 parents 5a72ba1 + 79fa3ea commit 74235df

File tree

2 files changed

+71
-5
lines changed

2 files changed

+71
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import React from "react";
2+
import styled from "styled-components";
3+
import XIcon from "svgs/socialmedia/x.svg";
4+
5+
const Container = styled.div`
6+
display: flex;
7+
flex-direction: row;
8+
align-items: center;
9+
justify-content: space-between;
10+
`;
11+
12+
const StyledTitle = styled.h1`
13+
margin-bottom: calc(16px + (48 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
14+
`;
15+
16+
const XLinkContainer = styled.div`
17+
display: flex;
18+
color: ${({ theme }) => theme.primaryBlue};
19+
margin-bottom: calc(16px + (48 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
20+
`;
21+
22+
const StyledXIcon = styled(XIcon)`
23+
fill: ${({ theme }) => theme.primaryBlue};
24+
width: 16px;
25+
height: 16px;
26+
`;
27+
28+
const StyledLink = styled.a`
29+
display: flex;
30+
border: 0px;
31+
align-items: center;
32+
gap: 8px;
33+
34+
&:hover {
35+
text-decoration: underline;
36+
}
37+
`;
38+
39+
interface IHeader {
40+
levelTitle: string;
41+
levelNumber: number;
42+
totalCoherent: number;
43+
totalResolvedDisputes: number;
44+
}
45+
46+
const Header: React.FC<IHeader> = ({ levelTitle, levelNumber, totalCoherent, totalResolvedDisputes }) => {
47+
const coherencePercentage = parseFloat(((totalCoherent / Math.max(totalResolvedDisputes, 1)) * 100).toFixed(2));
48+
const courtUrl = window.location.origin;
49+
const xPostText = `Hey I've been busy as a Juror on the Kleros court, check out my score: \n\nLevel: ${levelNumber} (${levelTitle})\nCoherence Percentage: ${coherencePercentage}%\nCoherent Votes: ${totalCoherent}/${totalResolvedDisputes}\n\nBe a juror with me! ➡️ ${courtUrl}`;
50+
const xShareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(xPostText)}`;
51+
52+
return (
53+
<Container>
54+
<StyledTitle>Juror Dashboard</StyledTitle>
55+
<XLinkContainer>
56+
<StyledLink href={xShareUrl} target="_blank" rel="noreferrer">
57+
<StyledXIcon /> <span>Share your juror score</span>
58+
</StyledLink>
59+
</XLinkContainer>
60+
</Container>
61+
);
62+
};
63+
64+
export default Header;

web/src/pages/Dashboard/JurorInfo/index.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import styled, { css } from "styled-components";
33
import { landscapeStyle } from "styles/landscapeStyle";
44
import { Card as _Card } from "@kleros/ui-components-library";
5+
import Header from "./Header";
56
import Coherency from "./Coherency";
67
import JurorRewards from "./JurorRewards";
78
import PixelArt from "./PixelArt";
@@ -12,10 +13,6 @@ import { getUserLevelData } from "utils/userLevelCalculation";
1213

1314
const Container = styled.div``;
1415

15-
const Header = styled.h1`
16-
margin-bottom: calc(16px + (48 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
17-
`;
18-
1916
const Card = styled(_Card)`
2017
display: flex;
2118
flex-direction: column;
@@ -47,7 +44,12 @@ const JurorInfo: React.FC = () => {
4744

4845
return (
4946
<Container>
50-
<Header>Juror Dashboard</Header>
47+
<Header
48+
levelTitle={userLevelData.title}
49+
levelNumber={userLevelData.level}
50+
totalCoherent={totalCoherent}
51+
totalResolvedDisputes={totalResolvedDisputes}
52+
/>
5153
<Card>
5254
<PixelArt level={userLevelData.level} width="189px" height="189px" />
5355
<Coherency

0 commit comments

Comments
 (0)