Skip to content

Commit 8c41958

Browse files
authored
Merge pull request #1760 from kleros/feat/make-cases-cards-links
feat: UX improvements
2 parents a79e377 + 8437b2e commit 8c41958

File tree

16 files changed

+105
-87
lines changed

16 files changed

+105
-87
lines changed

web/src/components/CasesDisplay/index.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react";
22
import styled from "styled-components";
33

4-
import { useLocation, useNavigate } from "react-router-dom";
4+
import { Link, useLocation } from "react-router-dom";
55

66
import ArrowIcon from "svgs/icons/arrow.svg";
77

@@ -53,14 +53,15 @@ const CasesDisplay: React.FC<ICasesDisplay> = ({
5353
className,
5454
totalPages,
5555
}) => {
56-
const navigate = useNavigate();
5756
const location = useLocation();
5857
return (
5958
<div {...{ className }}>
6059
<TitleContainer className="title">
6160
<StyledTitle>{title}</StyledTitle>
6261
{location.pathname.startsWith("/cases/display/1/desc/all") ? (
63-
<StyledButton onClick={() => navigate(`/resolver`)} text="Create a case" Icon={ArrowIcon} />
62+
<Link to={"/resolver"}>
63+
<StyledButton text="Create a case" Icon={ArrowIcon} />
64+
</Link>
6465
) : null}
6566
</TitleContainer>
6667
<Search />

web/src/components/DisputeView/DisputeCardView.tsx

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react";
22
import styled from "styled-components";
33

4-
import { useNavigate } from "react-router-dom";
4+
import { Link } from "react-router-dom";
55

66
import { Card } from "@kleros/ui-components-library";
77

@@ -54,15 +54,16 @@ interface IDisputeCardView {
5454
}
5555

5656
const DisputeCardView: React.FC<IDisputeCardView> = ({ isLoading, ...props }) => {
57-
const navigate = useNavigate();
5857
return (
59-
<StyledCard hover onClick={() => navigate(`/cases/${props?.disputeID?.toString()}`)}>
60-
<PeriodBanner id={parseInt(props?.disputeID)} period={props?.period} />
61-
<CardContainer>
62-
{isLoading ? <StyledCaseCardTitleSkeleton /> : <TruncatedTitle text={props?.title} maxLength={100} />}
63-
<DisputeInfo {...props} />
64-
</CardContainer>
65-
</StyledCard>
58+
<Link to={`/cases/${props?.disputeID?.toString()}`}>
59+
<StyledCard hover>
60+
<PeriodBanner id={parseInt(props?.disputeID)} period={props?.period} />
61+
<CardContainer>
62+
{isLoading ? <StyledCaseCardTitleSkeleton /> : <TruncatedTitle text={props?.title} maxLength={100} />}
63+
<DisputeInfo {...props} />
64+
</CardContainer>
65+
</StyledCard>
66+
</Link>
6667
);
6768
};
6869

web/src/components/DisputeView/DisputeListView.tsx

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react";
22
import styled from "styled-components";
33

4-
import { useNavigate } from "react-router-dom";
4+
import { Link } from "react-router-dom";
55
import { useAccount } from "wagmi";
66

77
import { Card } from "@kleros/ui-components-library";
@@ -56,17 +56,18 @@ interface IDisputeListView {
5656
}
5757
const DisputeListView: React.FC<IDisputeListView> = (props) => {
5858
const { isDisconnected } = useAccount();
59-
const navigate = useNavigate();
6059
return (
61-
<StyledListItem hover onClick={() => navigate(`/cases/${props?.disputeID?.toString()}`)}>
62-
<PeriodBanner isCard={false} id={parseInt(props?.disputeID ?? "0")} period={props.period} />
63-
<ListContainer>
64-
<TitleContainer isLabel={!isDisconnected}>
65-
<TruncatedTitle text={props?.title} maxLength={50} />
66-
</TitleContainer>
67-
<DisputeInfo {...props} />
68-
</ListContainer>
69-
</StyledListItem>
60+
<Link to={`/cases/${props?.disputeID?.toString()}`}>
61+
<StyledListItem hover>
62+
<PeriodBanner isCard={false} id={parseInt(props?.disputeID ?? "0")} period={props.period} />
63+
<ListContainer>
64+
<TitleContainer isLabel={!isDisconnected}>
65+
<TruncatedTitle text={props?.title} maxLength={50} />
66+
</TitleContainer>
67+
<DisputeInfo {...props} />
68+
</ListContainer>
69+
</StyledListItem>
70+
</Link>
7071
);
7172
};
7273

web/src/components/Field.tsx

-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { landscapeStyle } from "styles/landscapeStyle";
44

55
import { Link } from "react-router-dom";
66

7-
import { useScrollTop } from "hooks/useScrollTop";
8-
97
const FieldContainer = styled.div<FieldContainerProps>`
108
display: flex;
119
align-items: center;
@@ -96,8 +94,6 @@ const Field: React.FC<IField> = ({
9694
isJurorBalance,
9795
className,
9896
}) => {
99-
const scrollTop = useScrollTop();
100-
10197
return (
10298
<FieldContainer isList={displayAsList} {...{ isOverview, isJurorBalance, width, className }}>
10399
<Icon />
@@ -108,7 +104,6 @@ const Field: React.FC<IField> = ({
108104
to={link}
109105
onClick={(event) => {
110106
event.stopPropagation();
111-
scrollTop();
112107
}}
113108
>
114109
{value}

web/src/components/ScrollTop.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React, { useEffect } from "react";
2+
3+
import { useScrollTop } from "hooks/useScrollTop";
4+
5+
const ScrollTop: React.FC = () => {
6+
const scrollTop = useScrollTop();
7+
8+
useEffect(() => {
9+
scrollTop();
10+
}, []);
11+
12+
return <></>;
13+
};
14+
export default ScrollTop;

web/src/pages/Cases/AttachmentDisplay/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useSearchParams } from "react-router-dom";
66
import NewTabIcon from "svgs/icons/new-tab.svg";
77

88
import Loader from "components/Loader";
9+
import ScrollTop from "components/ScrollTop";
910

1011
import Header from "./Header";
1112

@@ -39,8 +40,8 @@ const StyledNewTabIcon = styled(NewTabIcon)`
3940

4041
const AttachmentDisplay: React.FC = () => {
4142
const [searchParams] = useSearchParams();
42-
4343
const url = searchParams.get("url");
44+
4445
return (
4546
<Container>
4647
<Header />
@@ -60,6 +61,7 @@ const AttachmentDisplay: React.FC = () => {
6061
</Suspense>
6162
</>
6263
) : null}
64+
<ScrollTop />
6365
</Container>
6466
);
6567
};

web/src/pages/Cases/CaseDetails/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import Overview from "./Overview";
1919
import Tabs from "./Tabs";
2020
import Timeline from "./Timeline";
2121
import Voting from "./Voting";
22+
import ScrollTop from "components/ScrollTop";
2223

2324
const Container = styled.div``;
2425

@@ -70,6 +71,7 @@ const CaseDetails: React.FC = () => {
7071
<Route path="*" element={<Navigate to="overview" replace />} />
7172
</Routes>
7273
</StyledCard>
74+
<ScrollTop />
7375
</Container>
7476
</VotingContextProvider>
7577
);

web/src/pages/Cases/CasesFetcher.tsx

+13-9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { useCourtDetails, CourtDetailsQuery } from "queries/useCourtDetails";
1313
import { DisputeDetailsFragment, Dispute_Filter, OrderDirection } from "src/graphql/graphql";
1414

1515
import CasesDisplay from "components/CasesDisplay";
16+
import ScrollTop from "components/ScrollTop";
1617

1718
const calculateStats = (
1819
isCourtFilter: boolean,
@@ -70,15 +71,18 @@ const CasesFetcher: React.FC = () => {
7071
);
7172

7273
return (
73-
<CasesDisplay
74-
disputes={data?.disputes as DisputeDetailsFragment[]}
75-
numberDisputes={totalCases}
76-
numberClosedDisputes={ruledCases}
77-
currentPage={pageNumber}
78-
setCurrentPage={(newPage: number) => navigate(`${location}/${newPage}/${order}/${filter}`)}
79-
totalPages={totalPages}
80-
{...{ casesPerPage }}
81-
/>
74+
<>
75+
<CasesDisplay
76+
disputes={data?.disputes as DisputeDetailsFragment[]}
77+
numberDisputes={totalCases}
78+
numberClosedDisputes={ruledCases}
79+
currentPage={pageNumber}
80+
setCurrentPage={(newPage: number) => navigate(`${location}/${newPage}/${order}/${filter}`)}
81+
totalPages={totalPages}
82+
{...{ casesPerPage }}
83+
/>
84+
<ScrollTop />
85+
</>
8286
);
8387
};
8488

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

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import LatestCases from "components/LatestCases";
2121
import Staking from "components/Popup/MiniGuides/Staking";
2222
import { StyledSkeleton } from "components/StyledSkeleton";
2323
import { Divider } from "components/Divider";
24+
import ScrollTop from "components/ScrollTop";
2425

2526
import Description from "./Description";
2627
import StakePanel from "./StakePanel";
@@ -119,6 +120,7 @@ const CourtDetails: React.FC = () => {
119120
<Description />
120121
</StyledCard>
121122
<LatestCases filters={{ court: id }} />
123+
<ScrollTop />
122124
</Container>
123125
);
124126
};

web/src/pages/Dashboard/Courts/CourtCard/CourtName.tsx

+9-19
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import React from "react";
22
import styled, { css } from "styled-components";
33

44
import { landscapeStyle } from "styles/landscapeStyle";
5-
import LightButton from "components/LightButton";
65

76
import ArrowIcon from "svgs/icons/arrow.svg";
8-
import { useNavigateAndScrollTop } from "hooks/useNavigateAndScrollTop";
7+
import { Link } from "react-router-dom";
98

109
const Container = styled.div`
1110
display: flex;
@@ -29,17 +28,13 @@ const Container = styled.div`
2928
)}
3029
`;
3130

32-
const StyledButton = styled(LightButton)`
31+
const StyledLink = styled(Link)`
3332
display: flex;
34-
flex-direction: row-reverse;
3533
gap: 8px;
36-
padding: 0px;
37-
> .button-text {
38-
color: ${({ theme }) => theme.primaryBlue};
39-
font-size: 14px;
40-
}
41-
> .button-svg {
42-
margin-right: 0;
34+
align-items: center;
35+
> svg {
36+
height: 15px;
37+
width: 15px;
4338
path {
4439
fill: ${({ theme }) => theme.primaryBlue};
4540
}
@@ -52,17 +47,12 @@ interface ICourtName {
5247
}
5348

5449
const CourtName: React.FC<ICourtName> = ({ name, id }) => {
55-
const navigate = useNavigateAndScrollTop();
56-
5750
return (
5851
<Container>
5952
<small>{name}</small>
60-
<StyledButton
61-
onClick={() => navigate(`/courts/${id?.toString()}`)}
62-
text="Open Court"
63-
Icon={ArrowIcon}
64-
className="reverse-button"
65-
/>
53+
<StyledLink to={`/courts/${id?.toString()}`}>
54+
Open Court <ArrowIcon />
55+
</StyledLink>
6656
</Container>
6757
);
6858
};

web/src/pages/Dashboard/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { responsiveSize } from "styles/responsiveSize";
1616

1717
import CasesDisplay from "components/CasesDisplay";
1818
import ConnectWallet from "components/ConnectWallet";
19+
import ScrollTop from "components/ScrollTop";
1920

2021
import Courts from "./Courts";
2122
import JurorInfo from "./JurorInfo";
@@ -92,6 +93,7 @@ const Dashboard: React.FC = () => {
9293
<ConnectWallet />
9394
</ConnectWalletContainer>
9495
)}
96+
<ScrollTop />
9597
</Container>
9698
);
9799
};

web/src/pages/GetPnk/index.tsx

+11-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { responsiveSize } from "styles/responsiveSize";
77

88
import ClaimPnkButton from "components/ClaimPnkButton";
99
import HeroImage from "components/HeroImage";
10+
import ScrollTop from "components/ScrollTop";
1011

1112
import { Widget } from "./Widget";
1213

@@ -27,16 +28,14 @@ const Container = styled.div`
2728
gap: 24px;
2829
`;
2930

30-
const GetPnk: React.FC = () => {
31-
return (
32-
<Wrapper>
33-
<HeroImage />
34-
<Container>
35-
{!isProductionDeployment() && <ClaimPnkButton />}
36-
<Widget />
37-
</Container>
38-
</Wrapper>
39-
);
40-
};
41-
31+
const GetPnk: React.FC = () => (
32+
<Wrapper>
33+
<HeroImage />
34+
<Container>
35+
{!isProductionDeployment() && <ClaimPnkButton />}
36+
<Widget />
37+
</Container>
38+
<ScrollTop />
39+
</Wrapper>
40+
);
4241
export default GetPnk;

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

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

44
import { responsiveSize } from "styles/responsiveSize";
55

6-
import { useNavigate } from "react-router-dom";
6+
import { Link } from "react-router-dom";
77

88
import { Button } from "@kleros/ui-components-library";
99

@@ -22,11 +22,12 @@ const StyledH1 = styled.h1`
2222
`;
2323

2424
const Header: React.FC = () => {
25-
const navigate = useNavigate();
2625
return (
2726
<StyledHeader>
2827
<StyledH1>Court Overview</StyledH1>
29-
<Button small Icon={Bookmark} text="Create a Case" onClick={() => navigate("/resolver")} />
28+
<Link to={"/resolver"}>
29+
<Button small Icon={Bookmark} text="Create a Case" />
30+
</Link>
3031
</StyledHeader>
3132
);
3233
};

0 commit comments

Comments
 (0)