Skip to content

Commit cee02b7

Browse files
committed
feat: add links to courts in extrastats, style adjustments
1 parent c85d330 commit cee02b7

File tree

7 files changed

+47
-49
lines changed

7 files changed

+47
-49
lines changed

web/src/components/DisputePreview/DisputeContext.tsx

+17-31
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,20 @@ import { StyledSkeleton } from "components/StyledSkeleton";
1414

1515
import AliasDisplay from "./Alias";
1616
import { Divider } from "../Divider";
17+
import { ExternalLink } from "../ExternalLink";
1718

1819
const StyledH1 = styled.h1`
1920
margin: 0;
2021
word-wrap: break-word;
2122
`;
2223

23-
const QuestionAndDescription = styled.div`
24-
display: flex;
25-
flex-direction: column;
26-
word-wrap: break-word;
27-
div:first-child p:first-of-type {
28-
font-size: 16px;
29-
font-weight: 400;
24+
const ReactMarkdownWrapper = styled.div`
25+
& p:first-of-type {
3026
margin: 0;
3127
}
3228
`;
3329

34-
const VotingOptions = styled(QuestionAndDescription)`
30+
const VotingOptions = styled.div`
3531
display: flex;
3632
flex-direction: column;
3733
gap: 8px;
@@ -51,19 +47,6 @@ const Answer = styled.div`
5147
display: flex;
5248
flex-wrap: wrap;
5349
gap: 6px;
54-
> label {
55-
max-width: 100%;
56-
}
57-
`;
58-
59-
const StyledSmall = styled.small`
60-
color: ${({ theme }) => theme.secondaryText};
61-
font-weight: 400;
62-
`;
63-
64-
const StyledLabel = styled.label`
65-
color: ${({ theme }) => theme.primaryText};
66-
font-weight: 600;
6750
`;
6851

6952
const AliasesContainer = styled.div`
@@ -83,26 +66,29 @@ export const DisputeContext: React.FC<IDisputeContext> = ({ disputeDetails, isRp
8366
<>
8467
<StyledH1>{isUndefined(disputeDetails) ? <StyledSkeleton /> : (disputeDetails?.title ?? errMsg)}</StyledH1>
8568
{!isUndefined(disputeDetails) && (
86-
<QuestionAndDescription>
87-
<ReactMarkdown>{disputeDetails?.question}</ReactMarkdown>
88-
<ReactMarkdown>{disputeDetails?.description}</ReactMarkdown>
89-
</QuestionAndDescription>
69+
<>
70+
<ReactMarkdownWrapper>
71+
<ReactMarkdown>{disputeDetails?.question}</ReactMarkdown>
72+
</ReactMarkdownWrapper>
73+
<ReactMarkdownWrapper>
74+
<ReactMarkdown>{disputeDetails?.description}</ReactMarkdown>
75+
</ReactMarkdownWrapper>
76+
</>
9077
)}
9178
{isUndefined(disputeDetails?.frontendUrl) ? null : (
92-
<a href={disputeDetails?.frontendUrl} target="_blank" rel="noreferrer">
79+
<ExternalLink href={disputeDetails?.frontendUrl} target="_blank" rel="noreferrer">
9380
Go to arbitrable
94-
</a>
81+
</ExternalLink>
9582
)}
9683
<VotingOptions>
9784
{isUndefined(disputeDetails) ? null : <AnswersHeader>Voting Options</AnswersHeader>}
9885
<AnswersContainer>
9986
{disputeDetails?.answers?.map((answer: IAnswer, i: number) => (
10087
<Answer key={answer.title}>
101-
<StyledSmall>{i + 1 + `.`}</StyledSmall>
102-
<StyledLabel>
103-
{answer.title}
88+
<small>
89+
<label>{i + 1}.</label> {answer.title}
10490
{answer.description.trim() ? ` - ${answer.description}` : null}
105-
</StyledLabel>
91+
</small>
10692
</Answer>
10793
))}
10894
</AnswersContainer>

web/src/components/ExtraStatsDisplay.tsx

+11-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import styled from "styled-components";
33

44
import { StyledSkeleton } from "components/StyledSkeleton";
55
import { isUndefined } from "utils/index";
6+
import { InternalLink } from "./InternalLink";
67

78
const Container = styled.div`
89
display: flex;
@@ -30,10 +31,8 @@ const TextContainer = styled.div`
3031
justify-content: center;
3132
`;
3233

33-
const StyledP = styled.p`
34-
font-size: 14px;
34+
const StyledInternalLink = styled(InternalLink)`
3535
font-weight: 600;
36-
margin: 0;
3736
`;
3837

3938
const StyledExtraStatTitleSkeleton = styled(StyledSkeleton)`
@@ -42,18 +41,25 @@ const StyledExtraStatTitleSkeleton = styled(StyledSkeleton)`
4241

4342
export interface IExtraStatsDisplay {
4443
title: string;
44+
courtId?: string;
4545
icon: React.FunctionComponent<React.SVGAttributes<SVGElement>>;
4646
content?: React.ReactNode;
4747
text?: string;
4848
}
4949

50-
const ExtraStatsDisplay: React.FC<IExtraStatsDisplay> = ({ title, text, content, icon: Icon, ...props }) => {
50+
const ExtraStatsDisplay: React.FC<IExtraStatsDisplay> = ({ title, courtId, text, content, icon: Icon, ...props }) => {
5151
return (
5252
<Container {...props}>
5353
<SVGContainer>{<Icon />}</SVGContainer>
5454
<TextContainer>
5555
<label>{title}:</label>
56-
{content ? content : <StyledP>{!isUndefined(text) ? text : <StyledExtraStatTitleSkeleton />}</StyledP>}
56+
{content ? (
57+
content
58+
) : (
59+
<StyledInternalLink to={`/courts/${courtId?.toString()}`}>
60+
{!isUndefined(text) ? text : <StyledExtraStatTitleSkeleton />}
61+
</StyledInternalLink>
62+
)}
5763
</TextContainer>
5864
</Container>
5965
);

web/src/hooks/queries/usePopulatedDisputeData.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { DisputeDetails } from "@kleros/kleros-sdk/src/dataMappings/utils/disput
66
import { populateTemplate } from "@kleros/kleros-sdk/src/dataMappings/utils/populateTemplate";
77

88
import { useGraphqlBatcher } from "context/GraphqlBatcher";
9+
import { DEFAULT_CHAIN } from "consts/chains";
910
import { debounceErrorToast } from "utils/debounceErrorToast";
1011
import { isUndefined } from "utils/index";
1112

@@ -47,6 +48,7 @@ export const usePopulatedDisputeData = (disputeID?: string, arbitrableAddress?:
4748
document: disputeTemplateQuery,
4849
variables: { id: disputeData.dispute?.templateId.toString() },
4950
isDisputeTemplate: true,
51+
chainId: DEFAULT_CHAIN,
5052
});
5153

5254
const templateData = disputeTemplate?.templateData;

web/src/pages/Cases/CaseDetails/Evidence/EvidenceSearch.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const EvidenceSearch: React.FC<IEvidenceSearch> = ({ search, setSearch, evidence
4848

4949
<SearchContainer>
5050
<StyledSearchBar
51-
placeholder="Search evidence by number, word, or submitter."
51+
placeholder="Search evidence by number, word, or submitter"
5252
onChange={(e) => setSearch(e.target.value)}
5353
value={search}
5454
/>

web/src/pages/Courts/CourtDetails/StakePanel/Simulator/Header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Container = styled.div`
1414

1515
const PNKLogoAndTitle = styled.div`
1616
display: flex;
17-
gap: 0 16px;
17+
gap: 0 12px;
1818
align-items: center;
1919
`;
2020

web/src/pages/Courts/CourtDetails/StakePanel/index.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,32 @@ const Container = styled.div`
1515
position: relative;
1616
display: flex;
1717
flex-direction: column;
18-
gap: 28px;
18+
gap: 16px;
1919
2020
${landscapeStyle(
2121
() => css`
22+
gap: 24px;
2223
flex-direction: column;
2324
`
2425
)};
2526
`;
2627

27-
const LeftArea = styled.div`
28+
const StakingArea = styled.div`
2829
display: flex;
2930
flex-direction: column;
31+
gap: 24px;
3032
`;
3133

3234
const TagArea = styled.div`
3335
display: flex;
3436
gap: 10px;
3537
`;
3638

37-
const StakeArea = styled(TagArea)`
38-
margin-top: 28px;
39+
const InputArea = styled(TagArea)`
3940
flex-direction: column;
4041
`;
4142

4243
const TextArea = styled.div`
43-
margin-top: 32px;
4444
color: ${({ theme }) => theme.primaryText};
4545
`;
4646

@@ -57,7 +57,7 @@ const StakePanel: React.FC<{ courtName: string }> = ({ courtName = "General Cour
5757
const isStaking = action === ActionType.stake;
5858
return (
5959
<Container>
60-
<LeftArea>
60+
<StakingArea>
6161
<TagArea>
6262
<Tag text="Stake" active={isActive} onClick={() => handleClick(ActionType.stake)} />
6363
<Tag text="Withdraw" active={!isActive} onClick={() => handleClick(ActionType.withdraw)} />
@@ -67,10 +67,10 @@ const StakePanel: React.FC<{ courtName: string }> = ({ courtName = "General Cour
6767
{courtName}
6868
{courtName.toLowerCase().endsWith("court") || courtName.toLowerCase().startsWith("corte") ? null : " Court"}
6969
</TextArea>
70-
<StakeArea>
70+
<InputArea>
7171
<InputDisplay {...{ action, amount, setAmount }} />
72-
</StakeArea>
73-
</LeftArea>
72+
</InputArea>
73+
</StakingArea>
7474
<Simulator amountToStake={amount ? Number(uncommify(amount)) : 0} {...{ isStaking }} />
7575
</Container>
7676
);

web/src/pages/Home/CourtOverview/ExtraStats.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,27 @@ const StyledLabel = styled.label`
2626
interface IStat {
2727
title: string;
2828
getText: (data) => string;
29+
getCourtId: (data) => string;
2930
icon: React.FC<React.SVGAttributes<SVGElement>>;
3031
}
3132

3233
const stats: IStat[] = [
3334
{
3435
title: "Most Cases",
3536
getText: ({ data }) => data?.mostDisputedCourt?.name,
37+
getCourtId: ({ data }) => data?.mostDisputedCourt?.id,
3638
icon: LongArrowUp,
3739
},
3840
{
3941
title: "Highest drawing chance",
4042
getText: ({ data }) => data?.bestDrawingChancesCourt?.name,
43+
getCourtId: ({ data }) => data?.bestDrawingChancesCourt?.id,
4144
icon: LongArrowUp,
4245
},
4346
{
4447
title: "Highest rewards chance",
4548
getText: ({ data }) => data?.bestExpectedRewardCourt?.name,
49+
getCourtId: ({ data }) => data?.bestExpectedRewardCourt?.id,
4650
icon: LongArrowUp,
4751
},
4852
];
@@ -83,8 +87,8 @@ const ExtraStats = () => {
8387
{data.data?.mostDisputedCourt?.numberDisputes === 0 ? (
8488
<StyledLabel>No activity in this period</StyledLabel>
8589
) : (
86-
stats.map(({ title, getText, icon }) => (
87-
<ExtraStatsDisplay key={title} {...{ title, icon }} text={getText(data)} />
90+
stats.map(({ title, getCourtId, getText, icon }) => (
91+
<ExtraStatsDisplay key={title} courtId={getCourtId(data)} {...{ title, icon }} text={getText(data)} />
8892
))
8993
)}
9094
</StyledCard>

0 commit comments

Comments
 (0)