Skip to content

Commit 7bfbe00

Browse files
committed
feat(web): create ranked voting and binary voting miniguides
1 parent dbe008d commit 7bfbe00

File tree

11 files changed

+329
-13
lines changed

11 files changed

+329
-13
lines changed

web/src/assets/svgs/mini-guides/binary-voting/voting-module-dark-mode.svg

Lines changed: 12 additions & 0 deletions
Loading

web/src/assets/svgs/mini-guides/binary-voting/voting-module-light-mode.svg

Lines changed: 12 additions & 0 deletions
Loading

web/src/assets/svgs/mini-guides/ranked-voting/voting-module-dark-mode.svg

Lines changed: 66 additions & 0 deletions
Loading

web/src/assets/svgs/mini-guides/ranked-voting/voting-module-light-mode.svg

Lines changed: 66 additions & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from "react";
2+
import DarkModeVotingModuleImage from "tsx:assets/svgs/mini-guides/binary-voting/voting-module-dark-mode.svg";
3+
import LightModeVotingModuleImage from "tsx:assets/svgs/mini-guides/binary-voting/voting-module-light-mode.svg";
4+
import ImageRenderer from "../ImageRenderer";
5+
6+
const VotingModule: React.FC = () => (
7+
<ImageRenderer darkModeImage={DarkModeVotingModuleImage} lightModeImage={LightModeVotingModuleImage} />
8+
);
9+
10+
export default VotingModule;
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React, { useState } from "react";
2+
import JurorRewards from "../Staking/JurorRewards";
3+
import Template, { Title, ParagraphsContainer, LeftContentContainer } from "../Template";
4+
import VotingModule from "./VotingModule";
5+
6+
const leftPageContents = [
7+
{
8+
title: "Binary Voting",
9+
paragraphs: [
10+
"Jurors choose one option to vote. The option which receives the majority of votes is considered the winner.",
11+
"Refuse to Arbitrate is used when a dispute has been posted in the wrong court, has no clear outcome, or" +
12+
" evidence is immoral and/or illegal. In case the majority decides to Refuse to Arbitrate, that option" +
13+
" is considered the winner.",
14+
],
15+
},
16+
{
17+
title: "Juror Rewards",
18+
paragraphs: [
19+
"Jurors whose vote is coherent with the final jury decision (after all the appeal instances) receive the" +
20+
" Juror Rewards composed of arbitration fees (ETH) + PNK redistribution between jurors. Jurors whose vote" +
21+
" is not coherent with the final jury decision, lose their locked PNK.",
22+
],
23+
},
24+
];
25+
26+
const rightPageComponents = [() => <VotingModule />, () => <JurorRewards />];
27+
28+
const LeftContent: React.FC<{ currentPage: number }> = ({ currentPage }) => {
29+
const { title, paragraphs } = leftPageContents[currentPage - 1];
30+
31+
return (
32+
<LeftContentContainer>
33+
<Title>{title}</Title>
34+
<ParagraphsContainer>
35+
{paragraphs.map((paragraph, index) => (
36+
<label key={index}>{paragraph}</label>
37+
))}
38+
</ParagraphsContainer>
39+
</LeftContentContainer>
40+
);
41+
};
42+
43+
const RightContent: React.FC<{ currentPage: number }> = ({ currentPage }) => {
44+
const RightPageComponent = rightPageComponents[currentPage - 1];
45+
46+
return <RightPageComponent />;
47+
};
48+
49+
interface IBinaryVoting {
50+
toggleMiniGuide: () => void;
51+
}
52+
53+
const BinaryVoting: React.FC<IBinaryVoting> = ({ toggleMiniGuide }) => {
54+
const [currentPage, setCurrentPage] = useState(1);
55+
56+
return (
57+
<Template
58+
LeftContent={<LeftContent currentPage={currentPage} />}
59+
RightContent={<RightContent currentPage={currentPage} />}
60+
onClose={toggleMiniGuide}
61+
currentPage={currentPage}
62+
setCurrentPage={setCurrentPage}
63+
numPages={leftPageContents.length}
64+
isOnboarding={false}
65+
/>
66+
);
67+
};
68+
69+
export default BinaryVoting;

web/src/components/Popup/MiniGuides/Level.tsx renamed to web/src/components/Popup/MiniGuides/JurorLevels.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ const RightContent: React.FC<{ currentPage: number }> = ({ currentPage }) => {
117117
);
118118
};
119119

120-
interface ILevel {
120+
interface IJurorLevels {
121121
toggleMiniGuide: () => void;
122122
}
123123

124-
const Level: React.FC<ILevel> = ({ toggleMiniGuide }) => {
124+
const JurorLevels: React.FC<IJurorLevels> = ({ toggleMiniGuide }) => {
125125
const [currentPage, setCurrentPage] = useState(1);
126126

127127
return (
@@ -137,4 +137,4 @@ const Level: React.FC<ILevel> = ({ toggleMiniGuide }) => {
137137
);
138138
};
139139

140-
export default Level;
140+
export default JurorLevels;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from "react";
2+
import DarkModeVotingModuleImage from "tsx:assets/svgs/mini-guides/ranked-voting/voting-module-dark-mode.svg";
3+
import LightModeVotingModuleImage from "tsx:assets/svgs/mini-guides/ranked-voting/voting-module-light-mode.svg";
4+
import ImageRenderer from "../ImageRenderer";
5+
6+
const VotingModule: React.FC = () => (
7+
<ImageRenderer darkModeImage={DarkModeVotingModuleImage} lightModeImage={LightModeVotingModuleImage} />
8+
);
9+
10+
export default VotingModule;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React, { useState } from "react";
2+
import JurorRewards from "../Staking/JurorRewards";
3+
import Template, { Title, ParagraphsContainer, LeftContentContainer } from "../Template";
4+
import VotingModule from "./VotingModule";
5+
6+
const leftPageContents = [
7+
{
8+
title: "Ranked Voting",
9+
paragraphs: [
10+
"Jurors rank the options in order of preference. The number of options you rank doesn’t affect the rewards" +
11+
" you may win as long as you rank the winning option. Note it’s also possible to reject some options you" +
12+
" consider inadequate.",
13+
"Refuse to Arbitrate is used when a dispute has been posted in the wrong court, has no clear outcome, or" +
14+
" evidence is immoral and/or illegal. In case the majority decides to Refuse to Arbitrate, that option is" +
15+
" considered the winner.",
16+
],
17+
},
18+
{
19+
title: "Juror Rewards",
20+
paragraphs: [
21+
"Jurors whose vote is coherent with the final jury decision (after all the appeal instances) receive the" +
22+
" Juror Rewards composed of arbitration fees (ETH) + PNK redistribution between jurors. Jurors whose vote" +
23+
" is not coherent with the final jury decision, lose their locked PNK.",
24+
],
25+
},
26+
];
27+
28+
const rightPageComponents = [() => <VotingModule />, () => <JurorRewards />];
29+
30+
const LeftContent: React.FC<{ currentPage: number }> = ({ currentPage }) => {
31+
const { title, paragraphs } = leftPageContents[currentPage - 1];
32+
33+
return (
34+
<LeftContentContainer>
35+
<Title>{title}</Title>
36+
<ParagraphsContainer>
37+
{paragraphs.map((paragraph, index) => (
38+
<label key={index}>{paragraph}</label>
39+
))}
40+
</ParagraphsContainer>
41+
</LeftContentContainer>
42+
);
43+
};
44+
45+
const RightContent: React.FC<{ currentPage: number }> = ({ currentPage }) => {
46+
const RightPageComponent = rightPageComponents[currentPage - 1];
47+
48+
return <RightPageComponent />;
49+
};
50+
51+
interface IRankedVoting {
52+
toggleMiniGuide: () => void;
53+
}
54+
55+
const RankedVoting: React.FC<IRankedVoting> = ({ toggleMiniGuide }) => {
56+
const [currentPage, setCurrentPage] = useState(1);
57+
58+
return (
59+
<Template
60+
LeftContent={<LeftContent currentPage={currentPage} />}
61+
RightContent={<RightContent currentPage={currentPage} />}
62+
onClose={toggleMiniGuide}
63+
currentPage={currentPage}
64+
setCurrentPage={setCurrentPage}
65+
numPages={leftPageContents.length}
66+
isOnboarding={false}
67+
/>
68+
);
69+
};
70+
71+
export default RankedVoting;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { landscapeStyle } from "styles/landscapeStyle";
44
import { useToggle } from "react-use";
55
import XIcon from "svgs/socialmedia/x.svg";
66
import HowItWorks from "components/HowItWorks";
7-
import Level from "components/Popup/MiniGuides/Level";
7+
import JurorLevels from "components/Popup/MiniGuides/JurorLevels";
88

99
const Container = styled.div`
1010
display: flex;
@@ -63,7 +63,7 @@ interface IHeader {
6363
}
6464

6565
const Header: React.FC<IHeader> = ({ levelTitle, levelNumber, totalCoherent, totalResolvedDisputes }) => {
66-
const [isLevelMiniGuideOpen, toggleLevelMiniGuide] = useToggle(false);
66+
const [isJurorLevelsMiniGuideOpen, toggleJurorLevelsMiniGuide] = useToggle(false);
6767

6868
const coherencePercentage = parseFloat(((totalCoherent / Math.max(totalResolvedDisputes, 1)) * 100).toFixed(2));
6969
const courtUrl = window.location.origin;
@@ -75,9 +75,9 @@ const Header: React.FC<IHeader> = ({ levelTitle, levelNumber, totalCoherent, tot
7575
<StyledTitle>Juror Dashboard</StyledTitle>
7676
<LinksContainer>
7777
<HowItWorks
78-
isMiniGuideOpen={isLevelMiniGuideOpen}
79-
toggleMiniGuide={toggleLevelMiniGuide}
80-
MiniGuideComponent={Level}
78+
isMiniGuideOpen={isJurorLevelsMiniGuideOpen}
79+
toggleMiniGuide={toggleJurorLevelsMiniGuide}
80+
MiniGuideComponent={JurorLevels}
8181
/>
8282
{totalResolvedDisputes > 0 ? (
8383
<StyledLink href={xShareUrl} target="_blank" rel="noreferrer">

0 commit comments

Comments
 (0)