Skip to content

Commit 0b75799

Browse files
authored
Merge pull request #2022 from kleros/feat/new-overview-design
feat: new overview design
2 parents 4adedb5 + f5f2530 commit 0b75799

File tree

8 files changed

+190
-148
lines changed

8 files changed

+190
-148
lines changed
Lines changed: 11 additions & 0 deletions
Loading

web/src/components/DisputePreview/DisputeContext.tsx

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
1-
import React from "react";
1+
import React, { useMemo } from "react";
22
import styled from "styled-components";
33

44
import { DisputeDetails } from "@kleros/kleros-sdk/src/dataMappings/utils/disputeDetailsTypes";
5+
import { useAccount } from "wagmi";
56

67
import { INVALID_DISPUTE_DATA_ERROR, RPC_ERROR } from "consts/index";
78
import { Answer as IAnswer } from "context/NewDisputeContext";
89
import { isUndefined } from "utils/index";
910

1011
import { responsiveSize } from "styles/responsiveSize";
1112

13+
import { DisputeDetailsQuery, VotingHistoryQuery } from "src/graphql/graphql";
14+
1215
import ReactMarkdown from "components/ReactMarkdown";
1316
import { StyledSkeleton } from "components/StyledSkeleton";
1417

1518
import { Divider } from "../Divider";
1619
import { ExternalLink } from "../ExternalLink";
1720

1821
import AliasDisplay from "./Alias";
22+
import RulingAndRewardsIndicators from "../Verdict/RulingAndRewardsIndicators";
23+
import CardLabel from "../DisputeView/CardLabels";
1924

2025
const StyledH1 = styled.h1`
2126
margin: 0;
2227
word-wrap: break-word;
23-
font-size: ${responsiveSize(18, 24)};
28+
font-size: ${responsiveSize(20, 26)};
2429
line-height: 24px;
2530
`;
2631

32+
const TitleSection = styled.div`
33+
display: flex;
34+
flex-direction: column;
35+
gap: 12px;
36+
`;
37+
2738
const ReactMarkdownWrapper = styled.div`
2839
& p:first-of-type {
2940
margin: 0;
@@ -66,19 +77,59 @@ const AliasesContainer = styled.div`
6677
gap: ${responsiveSize(8, 20)};
6778
`;
6879

80+
const RulingAndRewardsAndLabels = styled.div`
81+
display: flex;
82+
flex-direction: row;
83+
flex-wrap: wrap;
84+
gap: 8px;
85+
`;
86+
6987
interface IDisputeContext {
7088
disputeDetails?: DisputeDetails;
7189
isRpcError?: boolean;
90+
dispute?: DisputeDetailsQuery | undefined;
91+
92+
disputeId?: string;
93+
votingHistory?: VotingHistoryQuery | undefined;
7294
}
7395

74-
export const DisputeContext: React.FC<IDisputeContext> = ({ disputeDetails, isRpcError = false }) => {
96+
export const DisputeContext: React.FC<IDisputeContext> = ({
97+
disputeDetails,
98+
isRpcError = false,
99+
dispute,
100+
disputeId,
101+
votingHistory,
102+
}) => {
103+
const { isDisconnected } = useAccount();
75104
const errMsg = isRpcError ? RPC_ERROR : INVALID_DISPUTE_DATA_ERROR;
105+
const rounds = votingHistory?.dispute?.rounds;
106+
const jurorRewardsDispersed = useMemo(() => Boolean(rounds?.every((round) => round.jurorRewardsDispersed)), [rounds]);
107+
console.log({ jurorRewardsDispersed }, disputeDetails);
76108

77109
return (
78110
<>
79-
<StyledH1 dir="auto">
80-
{isUndefined(disputeDetails) ? <StyledSkeleton /> : (disputeDetails?.title ?? errMsg)}
81-
</StyledH1>
111+
<TitleSection>
112+
<StyledH1 dir="auto">
113+
{isUndefined(disputeDetails) ? <StyledSkeleton /> : (disputeDetails?.title ?? errMsg)}
114+
</StyledH1>
115+
{!isUndefined(disputeDetails) &&
116+
!isUndefined(dispute) &&
117+
!isUndefined(disputeId) &&
118+
!isUndefined(votingHistory) ? (
119+
<RulingAndRewardsAndLabels>
120+
{!isUndefined(Boolean(dispute?.dispute?.ruled)) || jurorRewardsDispersed ? (
121+
<RulingAndRewardsIndicators
122+
ruled={Boolean(dispute?.dispute?.ruled)}
123+
jurorRewardsDispersed={jurorRewardsDispersed}
124+
/>
125+
) : null}
126+
{!isDisconnected ? (
127+
<CardLabel {...{ disputeId }} round={rounds?.length - 1} isList={false} isOverview={true} />
128+
) : null}
129+
</RulingAndRewardsAndLabels>
130+
) : null}
131+
<Divider />
132+
</TitleSection>
82133
{disputeDetails?.question?.trim() || disputeDetails?.description?.trim() ? (
83134
<div>
84135
{disputeDetails?.question?.trim() ? (

web/src/components/DisputeView/CardLabels/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ import { ClassicContribution } from "src/graphql/graphql";
2222
import Label, { IColors } from "./Label";
2323
import RewardsAndFundLabel from "./RewardsAndFundLabel";
2424

25-
const Container = styled.div<{ isList: boolean }>`
25+
const Container = styled.div<{ isList: boolean; isOverview: boolean }>`
2626
display: flex;
2727
gap: 8px;
2828
flex-direction: column;
2929
align-items: end;
30+
3031
${({ isList }) =>
3132
!isList &&
3233
css`
@@ -36,7 +37,16 @@ const Container = styled.div<{ isList: boolean }>`
3637
flex-direction: row;
3738
align-items: center;
3839
`}
40+
41+
${({ isOverview }) =>
42+
isOverview &&
43+
css`
44+
margin-top: 0;
45+
flex-direction: row;
46+
width: auto;
47+
`}
3948
`;
49+
4050
const RewardsContainer = styled.div`
4151
display: flex;
4252
gap: 4px 8px;
@@ -47,6 +57,7 @@ interface ICardLabels {
4757
disputeId: string;
4858
round: number;
4959
isList: boolean;
60+
isOverview?: boolean;
5061
}
5162

5263
const LabelArgs: Record<string, { text: string; icon: React.FC<React.SVGAttributes<SVGElement>>; color: IColors }> = {
@@ -73,7 +84,7 @@ const getFundingRewards = (contributions: ClassicContribution[], closed: boolean
7384
return Number(formatUnits(BigInt(contribution), 18));
7485
};
7586

76-
const CardLabel: React.FC<ICardLabels> = ({ disputeId, round, isList }) => {
87+
const CardLabel: React.FC<ICardLabels> = ({ disputeId, round, isList, isOverview = false }) => {
7788
const { address } = useAccount();
7889
const { data: labelInfo, isLoading } = useLabelInfoQuery(address?.toLowerCase(), disputeId);
7990
const localRounds = getLocalRounds(labelInfo?.dispute?.disputeKitDispute);
@@ -139,7 +150,7 @@ const CardLabel: React.FC<ICardLabels> = ({ disputeId, round, isList }) => {
139150
}, [contributionRewards, shifts]);
140151

141152
return (
142-
<Container {...{ isList }}>
153+
<Container {...{ isList, isOverview }}>
143154
{isLoading ? (
144155
<Skeleton width={130} height={14} />
145156
) : (

web/src/components/DisputeView/DisputeInfo/DisputeInfoCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const DisputeInfoCard: React.FC<IDisputeInfoCard> = ({ isOverview, showLabels, f
6060
item.display ? <StyledField key={item.name} {...(item as IField)} {...{ isOverview }} /> : null
6161
)}
6262
</RestOfFieldsContainer>
63-
{showLabels ? <CardLabel disputeId={disputeID} round={round - 1} /> : null}
63+
{showLabels ? <CardLabel disputeId={disputeID} round={round - 1} isList={false} /> : null}
6464
</Container>
6565
);
6666
};

0 commit comments

Comments
 (0)