Skip to content

Commit 4172322

Browse files
committed
feat: build vote cards and stylings
1 parent 6908af8 commit 4172322

File tree

12 files changed

+326
-12
lines changed

12 files changed

+326
-12
lines changed

web/src/components/DisputeView/PeriodBanner.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,14 @@ const StyledLabel = styled.label<{ frontColor: string; withDot?: boolean; isCard
5858
`
5959
: null}
6060
`;
61+
6162
export interface IPeriodBanner {
6263
id: number;
6364
period: Periods;
6465
isCard?: boolean;
6566
}
6667

67-
const getPeriodColors = (period: Periods, theme: Theme): [string, string] => {
68+
export const getPeriodColors = (period: Periods, theme: Theme): [string, string] => {
6869
switch (period) {
6970
case Periods.appeal:
7071
return [theme.tint, theme.tintMedium];

web/src/pages/Profile/Stakes/CurrentStakes/index.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,33 @@ const Container = styled.div`
1919

2020
const NoCurrentStakesLabel = styled.label`
2121
font-size: ${responsiveSize(14, 16)};
22-
margin-bottom: 12px;
2322
`;
2423

2524
interface ICurrentStakes {
2625
totalStake: string;
2726
lockedStake: string;
2827
currentStakeData: JurorStakeDetailsQuery | undefined;
29-
isLoading: boolean;
28+
isCurrentStakeLoading: boolean;
3029
}
3130

32-
const CurrentStakes: React.FC<ICurrentStakes> = ({ totalStake, lockedStake, currentStakeData, isLoading }) => {
31+
const CurrentStakes: React.FC<ICurrentStakes> = ({
32+
totalStake,
33+
lockedStake,
34+
currentStakeData,
35+
isCurrentStakeLoading,
36+
}) => {
3337
const stakedCourts = currentStakeData?.jurorTokensPerCourts?.filter(({ staked }) => staked > 0);
3438
const isStaked = stakedCourts && stakedCourts.length > 0;
3539

3640
return (
3741
<Container>
3842
<Header {...{ totalStake, lockedStake }} />
39-
{!isStaked && !isLoading ? (
43+
{!isStaked && !isCurrentStakeLoading ? (
4044
<NoCurrentStakesLabel>No stakes found</NoCurrentStakesLabel>
41-
) : isLoading ? (
45+
) : isCurrentStakeLoading ? (
4246
<Skeleton />
4347
) : null}
44-
{isStaked && !isLoading ? (
48+
{isStaked && !isCurrentStakeLoading ? (
4549
<CourtCardsContainer>
4650
{currentStakeData?.jurorTokensPerCourts
4751
?.filter(({ staked }) => staked > 0)

web/src/pages/Profile/Stakes/StakingHistory.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ const StyledTitle = styled.h1`
2727
margin-bottom: 20px;
2828
`;
2929

30+
const NoHistoryLabel = styled.label`
31+
font-size: ${responsiveSize(14, 16)};
32+
`;
33+
3034
interface IStakingHistory {
3135
searchParamAddress: `0x${string}`;
3236
totalNumberStakingEvents: number;
@@ -38,7 +42,6 @@ const StakingHistory: React.FC<IStakingHistory> = ({ searchParamAddress, totalNu
3842
const eventsPerPage = 10;
3943
const currentPage = parseInt(page ?? "1");
4044
const skip = (currentPage - 1) * eventsPerPage;
41-
4245
const { data: stakingHistoryData, isLoading: isLoadingStakingHistory } = useStakingHistory(eventsPerPage, skip);
4346
const { data: courtTreeData, isLoading: isLoadingCourtTree } = useCourtTree();
4447
const stakingEvents = stakingHistoryData?.data?.userStakingEvents?.edges ?? [];
@@ -52,7 +55,9 @@ const StakingHistory: React.FC<IStakingHistory> = ({ searchParamAddress, totalNu
5255
<Container>
5356
<StyledTitle>Staking History</StyledTitle>
5457
<CourtCardsContainer>
55-
{isLoadingStakingHistory || isLoadingCourtTree ? (
58+
{!isLoadingStakingHistory && totalNumberStakingEvents === 0 ? (
59+
<NoHistoryLabel>No history found</NoHistoryLabel>
60+
) : isLoadingStakingHistory || isLoadingCourtTree ? (
5661
Array.from({ length: 10 }).map((_, index) => <Skeleton height={64} key={index} />)
5762
) : (
5863
<>

web/src/pages/Profile/Stakes/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ interface IStakes {
3636
}
3737

3838
const Stakes: React.FC<IStakes> = ({ searchParamAddress }) => {
39-
const { data: currentStakeData, isLoading } = useJurorStakeDetailsQuery(searchParamAddress);
39+
const { data: currentStakeData, isLoading: isCurrentStakeLoading } = useJurorStakeDetailsQuery(searchParamAddress);
4040
const { data: stakingHistoryData } = useStakingHistory(1, 0);
4141
const totalStake = currentStakeData?.jurorTokensPerCourts?.[0]?.effectiveStake ?? "0";
4242
const lockedStake = currentStakeData?.jurorTokensPerCourts?.[0]?.locked ?? "0";
4343
const totalNumberStakingEvents = stakingHistoryData?.data?.userStakingEvents?.count ?? 0;
4444

4545
return (
4646
<Container>
47-
<CurrentStakes {...{ totalStake, lockedStake, currentStakeData, isLoading }} />
47+
<CurrentStakes {...{ totalStake, lockedStake, currentStakeData, isCurrentStakeLoading }} />
4848
<StakingHistory {...{ searchParamAddress, totalNumberStakingEvents }} />
4949
</Container>
5050
);

web/src/pages/Profile/Votes/StatsAndFilters/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const Container = styled.div`
1010
display: flex;
1111
flex-wrap: wrap;
1212
gap: 8px;
13-
margin-bottom: ${responsiveSize(16, 32)};
13+
margin-bottom: ${responsiveSize(4, 12)};
1414
justify-content: space-between;
1515
`;
1616

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React from "react";
2+
import styled, { css } from "styled-components";
3+
4+
import { landscapeStyle } from "styles/landscapeStyle";
5+
6+
import { InternalLink } from "components/InternalLink";
7+
8+
const Container = styled.div`
9+
display: flex;
10+
width: 100%;
11+
flex-direction: row;
12+
gap: 8px 16px;
13+
align-items: center;
14+
justify-content: space-between;
15+
flex-wrap: wrap;
16+
17+
small {
18+
height: 100%;
19+
font-weight: 600;
20+
}
21+
22+
${landscapeStyle(
23+
() => css`
24+
justify-content: flex-start;
25+
width: auto;
26+
`
27+
)}
28+
`;
29+
30+
const StyledInternalLink = styled(InternalLink)`
31+
font-weight: 600;
32+
`;
33+
34+
interface ICaseNumber {
35+
id: string;
36+
}
37+
38+
const CaseNumber: React.FC<ICaseNumber> = ({ id }) => {
39+
return (
40+
<Container>
41+
<StyledInternalLink to={`/cases/${id?.toString()}`}>Case {id}</StyledInternalLink>
42+
</Container>
43+
);
44+
};
45+
export default CaseNumber;
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React, { useMemo } from "react";
2+
import styled, { css, useTheme } from "styled-components";
3+
4+
import { Periods } from "consts/periods";
5+
6+
import { getPeriodColors } from "components/DisputeView/PeriodBanner";
7+
8+
interface ICaseStatus {}
9+
10+
const StyledLabel = styled.label<{ frontColor: string; withDot?: boolean }>`
11+
display: flex;
12+
align-items: center;
13+
width: auto;
14+
color: ${({ frontColor }) => frontColor};
15+
${({ withDot, frontColor }) =>
16+
withDot
17+
? css`
18+
::before {
19+
content: "";
20+
display: inline-block;
21+
height: 8px;
22+
width: 8px;
23+
border-radius: 50%;
24+
margin-right: 8px;
25+
background-color: ${frontColor};
26+
flex-shrink: 0;
27+
}
28+
`
29+
: null}
30+
`;
31+
32+
const getPeriodLabel = (period: Periods): string => {
33+
switch (period) {
34+
case Periods.evidence:
35+
return "In Progress";
36+
case Periods.commit:
37+
return "In Progress";
38+
case Periods.vote:
39+
return "Voting";
40+
case Periods.appeal:
41+
return "Crowdfunding Appeal";
42+
case Periods.execution:
43+
return "Closed";
44+
default:
45+
return "In Progress";
46+
}
47+
};
48+
49+
const CaseStatus: React.FC<ICaseStatus> = ({}) => {
50+
const theme = useTheme();
51+
const [frontColor, backgroundColor] = useMemo(
52+
() => getPeriodColors(Periods.evidence, theme),
53+
[theme, Periods.evidence]
54+
);
55+
56+
return (
57+
<StyledLabel frontColor={frontColor} withDot>
58+
{getPeriodLabel(Periods.evidence)}
59+
</StyledLabel>
60+
);
61+
};
62+
export default CaseStatus;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from "react";
2+
import styled, { css } from "styled-components";
3+
4+
import { landscapeStyle } from "styles/landscapeStyle";
5+
6+
const Container = styled.div`
7+
display: flex;
8+
width: 100%;
9+
flex-direction: row;
10+
gap: 8px 16px;
11+
align-items: center;
12+
justify-content: space-between;
13+
flex-wrap: wrap;
14+
15+
small {
16+
height: 100%;
17+
font-weight: 400;
18+
}
19+
20+
${landscapeStyle(
21+
() => css`
22+
justify-content: flex-start;
23+
width: auto;
24+
`
25+
)}
26+
`;
27+
28+
interface ICourtName {
29+
name: string;
30+
}
31+
32+
const CourtName: React.FC<ICourtName> = ({ name }) => {
33+
return (
34+
<Container>
35+
<small>{name}</small>
36+
</Container>
37+
);
38+
};
39+
export default CourtName;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from "react";
2+
import styled from "styled-components";
3+
4+
import RoundIcon from "svgs/icons/round.svg";
5+
6+
const Container = styled.div`
7+
display: flex;
8+
gap: 8px;
9+
10+
small {
11+
font-weight: 400;
12+
}
13+
`;
14+
15+
interface IRound {
16+
number: string;
17+
}
18+
19+
const Round: React.FC<IRound> = ({ number }) => {
20+
return (
21+
<Container>
22+
<RoundIcon />
23+
<small>Round {number}</small>
24+
</Container>
25+
);
26+
};
27+
export default Round;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from "react";
2+
import styled from "styled-components";
3+
4+
import VotedIcon from "svgs/icons/voted-ballot.svg";
5+
6+
const Container = styled.div`
7+
display: flex;
8+
flex-direction: row;
9+
gap: 8px;
10+
11+
small {
12+
font-weight: 400;
13+
}
14+
`;
15+
16+
const StyledVotedIcon = styled(VotedIcon)`
17+
path {
18+
fill: ${({ theme }) => theme.primaryBlue};
19+
}
20+
`;
21+
22+
const BlueSmall = styled.small`
23+
color: ${({ theme }) => theme.primaryBlue};
24+
`;
25+
26+
interface IVote {
27+
choice: string;
28+
}
29+
30+
const Vote: React.FC<IVote> = ({ choice }) => {
31+
return (
32+
<Container>
33+
<StyledVotedIcon />
34+
<BlueSmall>Vote: </BlueSmall>
35+
<small>{choice}</small>
36+
</Container>
37+
);
38+
};
39+
export default Vote;

0 commit comments

Comments
 (0)