Skip to content

Commit 45bc1fb

Browse files
committed
feat: setup new profile page structure, new juror card style, add tabs, style tweaks, refactors
1 parent 2730163 commit 45bc1fb

File tree

21 files changed

+235
-113
lines changed

21 files changed

+235
-113
lines changed

web/src/pages/Home/TopJurors/JurorCard/JurorTitle.tsx renamed to web/src/components/JurorLink.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
import React from "react";
1+
import React, { useMemo } from "react";
22
import styled from "styled-components";
33

4+
import { useAccount } from "wagmi";
5+
6+
import { DEFAULT_CHAIN, getChain } from "consts/chains";
7+
48
import ArrowIcon from "svgs/icons/arrow.svg";
9+
import NewTabIcon from "svgs/icons/new-tab.svg";
510

611
import { IdenticonOrAvatar, AddressOrName } from "components/ConnectWallet/AccountDisplay";
712
import { StyledArrowLink } from "components/StyledArrowLink";
8-
import { useAccount } from "wagmi";
913

1014
const Container = styled.div`
1115
display: flex;
@@ -36,26 +40,34 @@ export const ReStyledArrowLink = styled(StyledArrowLink)`
3640
}
3741
`;
3842

39-
interface IJurorTitle {
43+
interface IJurorLink {
4044
address: string;
45+
isInternalLink?: boolean;
4146
}
4247

43-
const JurorTitle: React.FC<IJurorTitle> = ({ address }) => {
48+
const JurorLink: React.FC<IJurorLink> = ({ address, isInternalLink = true }) => {
4449
const { isConnected, address: connectedAddress } = useAccount();
4550
const profileLink =
4651
isConnected && connectedAddress?.toLowerCase() === address.toLowerCase()
4752
? "/profile/1/desc/all"
4853
: `/profile/1/desc/all?address=${address}`;
54+
const addressExplorerLink = useMemo(() => {
55+
return `${getChain(DEFAULT_CHAIN)?.blockExplorers?.default.url}/address/${address}`;
56+
}, [address]);
4957

5058
return (
5159
<Container>
5260
<IdenticonOrAvatar address={address} />
53-
<ReStyledArrowLink to={profileLink}>
61+
<ReStyledArrowLink
62+
to={isInternalLink ? profileLink : addressExplorerLink}
63+
rel={`${isInternalLink ? "" : "noopener noreferrer"}`}
64+
target={`${isInternalLink ? "" : "_blank"}`}
65+
>
5466
<AddressOrName address={address} />
55-
<ArrowIcon />
67+
{isInternalLink ? <ArrowIcon /> : <NewTabIcon />}
5668
</ReStyledArrowLink>
5769
</Container>
5870
);
5971
};
6072

61-
export default JurorTitle;
73+
export default JurorLink;

web/src/components/Popup/MiniGuides/JurorLevels.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { Card as _Card } from "@kleros/ui-components-library";
55

66
import { landscapeStyle } from "styles/landscapeStyle";
77

8-
import Coherence from "pages/Profile/JurorInfo/Coherence";
9-
import PixelArt from "pages/Profile/JurorInfo/PixelArt";
8+
import Coherence from "pages/Profile/JurorInfo/BottomContent/Coherence";
9+
import PixelArt from "pages/Profile/JurorInfo/BottomContent/PixelArt";
1010

1111
import Template from "./MainStructureTemplate";
1212
import { Title, ParagraphsContainer, LeftContentContainer } from "./PageContentsTemplate";

web/src/pages/Cases/CaseDetails/Voting/VotesDetails/AccordionTitle.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { getVoteChoice } from "utils/getVoteChoice";
88
import { isUndefined } from "utils/index";
99

1010
import { InternalLink } from "components/InternalLink";
11-
import JurorTitle from "pages/Home/TopJurors/JurorCard/JurorTitle";
11+
import JurorLink from "components/JurorLink";
1212

1313
const TitleContainer = styled.div`
1414
display: flex;
@@ -92,7 +92,7 @@ const AccordionTitle: React.FC<{
9292
<TitleContainer>
9393
<AddressContainer>
9494
<StyledInternalLink to={profileLink}>
95-
<JurorTitle address={juror} />
95+
<JurorLink address={juror} />
9696
</StyledInternalLink>
9797
</AddressContainer>
9898
<VoteStatus {...{ choice, period, answers, isActiveRound, commited, hiddenVotes }} />

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { hoverShortTransitionTiming } from "styles/commonStyles";
77

88
import Coherence from "./Coherence";
99
import JurorLevel from "./JurorLevel";
10-
import JurorTitle from "./JurorTitle";
1110
import Rank from "./Rank";
1211
import Rewards from "./Rewards";
12+
import JurorLink from "components/JurorLink";
1313

1414
const Container = styled.div<{ renderRank?: boolean }>`
1515
${hoverShortTransitionTiming}
@@ -57,7 +57,7 @@ const DesktopCard: React.FC<IDesktopCard> = ({
5757
return (
5858
<Container renderRank={renderRank}>
5959
{renderRank && <Rank rank={rank} />}
60-
<JurorTitle address={address} />
60+
<JurorLink address={address} />
6161
<Rewards address={address} />
6262
<Coherence {...{ totalCoherentVotes, totalResolvedVotes }} />
6363
<JurorLevel {...{ totalCoherentVotes, totalResolvedVotes, totalResolvedDisputes }} />

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { landscapeStyle } from "styles/landscapeStyle";
66
import { getUserLevelData } from "utils/userLevelCalculation";
77
import { getCoherencePercent } from "utils/getCoherencePercent";
88

9-
import PixelArt from "pages/Profile/JurorInfo/PixelArt";
9+
import PixelArt from "pages/Profile/JurorInfo/BottomContent/PixelArt";
1010

1111
const Container = styled.div`
1212
display: flex;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import HeaderRewards from "../Header/Rewards";
99

1010
import Coherence from "./Coherence";
1111
import JurorLevel from "./JurorLevel";
12-
import JurorTitle from "./JurorTitle";
1312
import Rank from "./Rank";
1413
import Rewards from "./Rewards";
14+
import JurorLink from "components/JurorLink";
1515

1616
const Container = styled.div`
1717
${hoverShortTransitionTiming}
@@ -97,7 +97,7 @@ const MobileCard: React.FC<IMobileCard> = ({
9797
<TopSide>
9898
<RankAndTitle>
9999
{rank ? <Rank rank={rank} /> : null}
100-
<JurorTitle address={address} />
100+
<JurorLink address={address} />
101101
</RankAndTitle>
102102
<JurorLevel {...{ totalCoherentVotes, totalResolvedVotes, totalResolvedDisputes }} />
103103
</TopSide>

web/src/pages/Profile/JurorInfo/Coherence.tsx renamed to web/src/pages/Profile/JurorInfo/BottomContent/Coherence.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import React from "react";
22
import styled, { css } from "styled-components";
33

4+
import { landscapeStyle } from "styles/landscapeStyle";
5+
46
import { CircularProgress } from "@kleros/ui-components-library";
57

6-
import { landscapeStyle } from "styles/landscapeStyle";
8+
import { ILevelCriteria } from "utils/userLevelCalculation";
79

810
import WithHelpTooltip from "components/WithHelpTooltip";
911

@@ -26,10 +28,7 @@ const tooltipMsg =
2628
" the majority of jurors it's considered a Coherent Vote.";
2729

2830
interface ICoherence {
29-
userLevelData: {
30-
level: number;
31-
title: string;
32-
};
31+
userLevelData: ILevelCriteria;
3332
totalCoherentVotes: number;
3433
totalResolvedVotes: number;
3534
isMiniGuide: boolean;

web/src/pages/Profile/JurorInfo/JurorRewards.tsx renamed to web/src/pages/Profile/JurorInfo/BottomContent/JurorRewards.tsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react";
2-
import styled from "styled-components";
2+
import styled, { css } from "styled-components";
33

4-
import { useAccount } from "wagmi";
4+
import { landscapeStyle } from "styles/landscapeStyle";
55

66
import { CoinIds } from "consts/coingecko";
77
import { useCoinPrice } from "hooks/useCoinPrice";
@@ -10,14 +10,27 @@ import { getFormattedRewards } from "utils/jurorRewardConfig";
1010
import { useUserQuery } from "queries/useUser";
1111

1212
import WithHelpTooltip from "components/WithHelpTooltip";
13-
14-
import TokenRewards from "./TokenRewards";
13+
import TokenRewards from "../TokenRewards";
1514

1615
const Container = styled.div`
1716
display: flex;
1817
flex-direction: column;
19-
align-items: flex-start;
18+
align-items: center;
2019
width: auto;
20+
gap: 24px;
21+
22+
${landscapeStyle(
23+
() => css`
24+
align-items: flex-start;
25+
`
26+
)}
27+
`;
28+
29+
const TokenRewardsContainer = styled.div`
30+
display: flex;
31+
flex-direction: column;
32+
align-items: start;
33+
gap: 16px;
2134
`;
2235

2336
const tooltipMsg =
@@ -42,9 +55,11 @@ const JurorRewards: React.FC<IJurorRewards> = ({ addressToQuery }) => {
4255
<WithHelpTooltip place="bottom" {...{ tooltipMsg }}>
4356
<label> Juror Rewards </label>
4457
</WithHelpTooltip>
45-
{formattedRewards.map(({ token, amount, value }) => (
46-
<TokenRewards key={token} {...{ token }} amount={amount} value={value} />
47-
))}
58+
<TokenRewardsContainer>
59+
{formattedRewards.map(({ token, amount, value }) => (
60+
<TokenRewards key={token} {...{ token }} amount={amount} value={value} />
61+
))}
62+
</TokenRewardsContainer>
4863
</Container>
4964
);
5065
};

web/src/pages/Profile/JurorInfo/PixelArt.tsx renamed to web/src/pages/Profile/JurorInfo/BottomContent/PixelArt.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import platoImage from "assets/pngs/dashboard/plato.png";
99
import pythagorasImage from "assets/pngs/dashboard/pythagoras.png";
1010
import socratesImage from "assets/pngs/dashboard/socrates.png";
1111

12+
const Container = styled.div`
13+
display: flex;
14+
justify-content: center;
15+
`;
16+
1217
interface IStyledImage {
1318
show: boolean;
1419
width: number | string;
@@ -42,7 +47,7 @@ interface IPixelArt {
4247
const PixelArt: React.FC<IPixelArt> = ({ level, width, height }) => {
4348
const [imageLoaded, setImageLoaded] = useState(false);
4449
return (
45-
<div>
50+
<Container>
4651
{!imageLoaded && <StyledSkeleton width={width} height={height} />}
4752
<StyledImage
4853
src={images[level]}
@@ -52,7 +57,7 @@ const PixelArt: React.FC<IPixelArt> = ({ level, width, height }) => {
5257
width={width}
5358
height={height}
5459
/>
55-
</div>
60+
</Container>
5661
);
5762
};
5863

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React from "react";
2+
import styled, { css } from "styled-components";
3+
4+
import { landscapeStyle } from "styles/landscapeStyle";
5+
6+
import { ILevelCriteria } from "utils/userLevelCalculation";
7+
8+
import PixelArt from "./PixelArt";
9+
import Coherence from "./Coherence";
10+
import JurorRewards from "./JurorRewards";
11+
import StakingRewards from "../StakingRewards";
12+
13+
const Container = styled.div`
14+
display: flex;
15+
flex-direction: column;
16+
flex-wrap: wrap;
17+
justify-content: space-between;
18+
align-items: center;
19+
20+
gap: 32px;
21+
width: 100%;
22+
height: auto;
23+
24+
${landscapeStyle(
25+
() => css`
26+
flex-direction: row;
27+
align-items: flex-start;
28+
`
29+
)}
30+
`;
31+
32+
const LeftContent = styled.div`
33+
display: flex;
34+
flex-direction: row;
35+
gap: 48px;
36+
flex-direction: column;
37+
38+
${landscapeStyle(
39+
() => css`
40+
flex-direction: row;
41+
`
42+
)}
43+
`;
44+
45+
interface IBottomContent {
46+
userLevelData: ILevelCriteria;
47+
totalCoherentVotes: number;
48+
totalResolvedVotes: number;
49+
addressToQuery: `0x${string}`;
50+
}
51+
52+
const BottomContent: React.FC<IBottomContent> = ({
53+
userLevelData,
54+
totalCoherentVotes,
55+
totalResolvedVotes,
56+
addressToQuery,
57+
}) => {
58+
return (
59+
<Container>
60+
<LeftContent>
61+
<PixelArt level={userLevelData.level} width="189px" height="189px" />
62+
<Coherence isMiniGuide={false} {...{ userLevelData, totalCoherentVotes, totalResolvedVotes }} />
63+
<JurorRewards {...{ addressToQuery }} />
64+
</LeftContent>
65+
<StakingRewards />
66+
</Container>
67+
);
68+
};
69+
export default BottomContent;

web/src/pages/Profile/JurorInfo/Header.tsx

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
import React, { useMemo } from "react";
1+
import React from "react";
22
import styled from "styled-components";
33

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

66
import { useToggle } from "react-use";
77
import { useSearchParams } from "react-router-dom";
8-
import { Copiable } from "@kleros/ui-components-library";
98

109
import XIcon from "svgs/socialmedia/x.svg";
1110

12-
import { DEFAULT_CHAIN, getChain } from "consts/chains";
13-
import { shortenAddress } from "utils/shortenAddress";
14-
1511
import HowItWorks from "components/HowItWorks";
1612
import JurorLevels from "components/Popup/MiniGuides/JurorLevels";
1713
import { ExternalLink } from "components/ExternalLink";
@@ -51,12 +47,6 @@ const StyledLink = styled(ExternalLink)`
5147
gap: 8px;
5248
`;
5349

54-
const StyledExternalLink = styled(ExternalLink)`
55-
font-size: ${responsiveSize(18, 22)};
56-
margin-left: ${responsiveSize(4, 8)};
57-
font-weight: 600;
58-
`;
59-
6050
interface IHeader {
6151
levelTitle: string;
6252
levelNumber: number;
@@ -81,20 +71,9 @@ const Header: React.FC<IHeader> = ({
8171
const xShareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(xPostText)}`;
8272
const searchParamAddress = searchParams.get("address")?.toLowerCase();
8373

84-
const addressExplorerLink = useMemo(() => {
85-
return `${getChain(DEFAULT_CHAIN)?.blockExplorers?.default.url}/address/${addressToQuery}`;
86-
}, [addressToQuery]);
87-
8874
return (
8975
<Container>
90-
<StyledTitle>
91-
Juror Profile -
92-
<Copiable copiableContent={addressToQuery} info="Copy Address">
93-
<StyledExternalLink to={addressExplorerLink} target="_blank" rel="noopener noreferrer">
94-
{shortenAddress(addressToQuery)}
95-
</StyledExternalLink>
96-
</Copiable>
97-
</StyledTitle>
76+
<StyledTitle>Juror Profile</StyledTitle>
9877
<LinksContainer>
9978
<JurorsLeaderboardButton />
10079
<HowItWorks

0 commit comments

Comments
 (0)