Skip to content

Commit 81a3412

Browse files
committed
fix: layout shift if there is no rank, hide pagination if searching
1 parent 22e54d7 commit 81a3412

File tree

5 files changed

+45
-36
lines changed

5 files changed

+45
-36
lines changed

web/src/pages/Home/TopJurors/Header/DesktopHeader.tsx

+21-14
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,42 @@ import React from "react";
22
import styled, { css } from "styled-components";
33

44
import { useToggle } from "react-use";
5+
import { useParams } from "react-router-dom";
56

67
import { landscapeStyle } from "styles/landscapeStyle";
78
import { responsiveSize } from "styles/responsiveSize";
89

910
import RankingIcon from "svgs/icons/ranking.svg";
1011

12+
import { decodeURIFilter } from "utils/uri";
13+
1114
import HowItWorks from "components/HowItWorks";
1215
import JurorLevels from "components/Popup/MiniGuides/JurorLevels";
1316

1417
import Coherence from "./Coherence";
1518
import Rewards from "./Rewards";
1619

17-
const Container = styled.div`
20+
const Container = styled.div<{ renderIcon?: boolean }>`
1821
display: none;
1922
width: 100%;
2023
background-color: ${({ theme }) => theme.lightBlue};
21-
border 1px solid ${({ theme }) => theme.stroke};
24+
border: 1px solid ${({ theme }) => theme.stroke};
2225
border-top-left-radius: 3px;
2326
border-top-right-radius: 3px;
2427
border-bottom: 1px solid ${({ theme }) => theme.stroke};
2528
padding: 18.6px 32px;
2629
27-
${landscapeStyle(
28-
() => css`
29-
display: grid;
30-
grid-template-columns:
31-
min-content repeat(3, ${responsiveSize(160, 180, 900)})
32-
auto;
33-
column-gap: ${responsiveSize(12, 28, 900)};
34-
align-items: center;
35-
`
36-
)}
30+
${({ renderIcon }) =>
31+
landscapeStyle(
32+
() => css`
33+
display: grid;
34+
grid-template-columns: ${renderIcon
35+
? `min-content repeat(3, ${responsiveSize(160, 180, 900)}) auto`
36+
: `repeat(3, ${responsiveSize(160, 180, 900)}) auto`};
37+
column-gap: ${responsiveSize(12, 28, 900)};
38+
align-items: center;
39+
`
40+
)}
3741
`;
3842

3943
const StyledRankingIcon = styled(RankingIcon)`
@@ -53,10 +57,13 @@ const HowItWorksContainer = styled.div`
5357

5458
export const DesktopHeader: React.FC = () => {
5559
const [isJurorLevelsMiniGuideOpen, toggleJurorLevelsMiniGuide] = useToggle(false);
60+
const { filter } = useParams();
61+
const { id: searchValue } = decodeURIFilter(filter ?? "all");
62+
const renderIcon = !searchValue;
5663

5764
return (
58-
<Container>
59-
<StyledRankingIcon />
65+
<Container renderIcon={renderIcon}>
66+
{renderIcon ? <StyledRankingIcon /> : null}
6067
<StyledLabel>Juror</StyledLabel>
6168
<Rewards />
6269
<Coherence />

web/src/pages/Home/TopJurors/JurorCard/DesktopCard.tsx

+17-15
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import JurorTitle from "./JurorTitle";
1111
import Rank from "./Rank";
1212
import Rewards from "./Rewards";
1313

14-
const Container = styled.div`
14+
const Container = styled.div<{ renderRank?: boolean }>`
1515
${hoverShortTransitionTiming}
1616
display: none;
1717
width: 100%;
@@ -21,28 +21,28 @@ const Container = styled.div`
2121
align-items: center;
2222
padding: 15.55px 32px;
2323
24-
${landscapeStyle(
25-
() => css`
26-
display: grid;
27-
grid-template-columns:
28-
min-content repeat(3, ${responsiveSize(160, 180, 900)})
29-
auto;
30-
column-gap: ${responsiveSize(12, 28, 900)};
31-
`
32-
)}
24+
${({ renderRank }) =>
25+
landscapeStyle(
26+
() => css`
27+
display: grid;
28+
grid-template-columns: ${renderRank
29+
? `min-content repeat(3, ${responsiveSize(160, 180, 900)}) auto`
30+
: `repeat(3, ${responsiveSize(160, 180, 900)}) auto`};
31+
column-gap: ${responsiveSize(12, 28, 900)};
32+
`
33+
)}
3334
3435
:hover {
3536
background-color: ${({ theme }) => theme.lightGrey}BB;
3637
}
3738
`;
3839

3940
interface IDesktopCard {
40-
rank: number;
41+
rank?: number;
4142
address: string;
4243
totalCoherentVotes: string;
4344
totalResolvedVotes: string;
4445
totalResolvedDisputes: string;
45-
coherenceScore: string;
4646
}
4747

4848
const DesktopCard: React.FC<IDesktopCard> = ({
@@ -51,16 +51,18 @@ const DesktopCard: React.FC<IDesktopCard> = ({
5151
totalCoherentVotes,
5252
totalResolvedVotes,
5353
totalResolvedDisputes,
54-
coherenceScore,
5554
}) => {
55+
const renderRank = !!rank;
56+
5657
return (
57-
<Container>
58-
<Rank rank={rank} />
58+
<Container renderRank={renderRank}>
59+
{renderRank && <Rank rank={rank} />}
5960
<JurorTitle address={address} />
6061
<Rewards address={address} />
6162
<Coherence {...{ totalCoherentVotes, totalResolvedVotes }} />
6263
<JurorLevel {...{ totalCoherentVotes, totalResolvedVotes, totalResolvedDisputes }} />
6364
</Container>
6465
);
6566
};
67+
6668
export default DesktopCard;

web/src/pages/Home/TopJurors/JurorCard/MobileCard.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ const HeaderCoherenceAndCoherence = styled.div`
8080
interface IMobileCard {
8181
rank: number;
8282
address: string;
83-
coherenceScore: string;
8483
totalCoherentVotes: string;
8584
totalResolvedVotes: string;
8685
totalResolvedDisputes: string;
@@ -89,7 +88,6 @@ interface IMobileCard {
8988
const MobileCard: React.FC<IMobileCard> = ({
9089
rank,
9190
address,
92-
coherenceScore,
9391
totalCoherentVotes,
9492
totalResolvedVotes,
9593
totalResolvedDisputes,

web/src/pages/Home/TopJurors/JurorCard/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import MobileCard from "./MobileCard";
66
interface IJurorCard {
77
rank: number;
88
address: `0x${string}`;
9-
coherenceScore: string;
109
totalCoherentVotes: string;
1110
totalResolvedVotes: string;
1211
totalResolvedDisputes: string;
@@ -15,12 +14,11 @@ interface IJurorCard {
1514
const JurorCard: React.FC<IJurorCard> = ({
1615
rank,
1716
address,
18-
coherenceScore,
1917
totalCoherentVotes,
2018
totalResolvedVotes,
2119
totalResolvedDisputes,
2220
}) => {
23-
const allProps = { rank, address, coherenceScore, totalCoherentVotes, totalResolvedVotes, totalResolvedDisputes };
21+
const allProps = { rank, address, totalCoherentVotes, totalResolvedVotes, totalResolvedDisputes };
2422

2523
return (
2624
<>

web/src/pages/Jurors/DisplayJurors.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ const DisplayJurors: React.FC<IDisplayJurors> = ({ totalLeaderboardJurors }) =>
7575
<SkeletonDisputeListItem key={i} />
7676
))}
7777
</ListContainer>
78-
<StyledPagination currentPage={currentPage} numPages={totalPages} callback={handlePageChange} />
78+
{!searchValue && (
79+
<StyledPagination currentPage={currentPage} numPages={totalPages} callback={handlePageChange} />
80+
)}
7981
</>
8082
) : (
8183
<>
@@ -88,10 +90,12 @@ const DisplayJurors: React.FC<IDisplayJurors> = ({ totalLeaderboardJurors }) =>
8890
{!isUndefined(jurors)
8991
? jurors.map((juror) => <JurorCard key={juror.id} address={juror.id} {...juror} />)
9092
: [...Array(jurorsPerPage)].map((_, i) => <SkeletonDisputeListItem key={i} />)}
93+
{!searchValue && (
94+
<StyledPagination currentPage={currentPage} numPages={totalPages} callback={handlePageChange} />
95+
)}
9196
</>
9297
)}
9398
</ListContainer>
94-
<StyledPagination currentPage={currentPage} numPages={totalPages} callback={handlePageChange} />
9599
</>
96100
)}
97101
</>

0 commit comments

Comments
 (0)