Skip to content

Commit

Permalink
feat(web): mobile version top jurors + bunch of code refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
kemuru committed Oct 25, 2023
1 parent 8e45aa7 commit 38f61bc
Show file tree
Hide file tree
Showing 16 changed files with 308 additions and 137 deletions.
4 changes: 2 additions & 2 deletions web/src/assets/svgs/menu-icons/help.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions web/src/pages/Dashboard/WithHelpTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import styled from "styled-components";
import styled, { css } from "styled-components";
import { landscapeStyle } from "styles/landscapeStyle";
import { Tooltip } from "@kleros/ui-components-library";
import _HelpIcon from "svgs/menu-icons/help.svg";

Expand All @@ -9,8 +10,17 @@ const Container = styled.div`
`;

const HelpIcon = styled(_HelpIcon)`
height: 12px;
width: 12px;
fill: ${({ theme }) => theme.secondaryText};
margin: 4px;
margin: 4px 4px 6px 8px;
${landscapeStyle(
() => css`
height: 14px;
width: 14px;
`
)}
`;

interface IWithHelpTooltip {
Expand Down
44 changes: 35 additions & 9 deletions web/src/pages/Home/TopJurors/Header/Coherency.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
import React from "react";
import styled from "styled-components";
import styled, { css } from "styled-components";
import { BREAKPOINT_LANDSCAPE, landscapeStyle } from "styles/landscapeStyle";
import { useWindowSize } from "react-use";
import WithHelpTooltip from "pages/Dashboard/WithHelpTooltip";

const Container = styled.div``;
const Container = styled.div`
label {
font-size: 12px !important;
&::before {
content: "Votes";
}
}
${landscapeStyle(
() =>
css`
display: flex;
label {
font-size: 14px !important;
&::before {
content: "Coherent Votes";
}
}
`
)}
`;

const coherentVotesTooltipMsg =
"This is the ratio of coherent votes made by a juror: " +
"the number in the left is the number of times where the juror " +
"voted coherently and the number in the right is the total number of times " +
"the juror voted";

const Coherency: React.FC = () => (
<Container>
<WithHelpTooltip place="top" tooltipMsg={coherentVotesTooltipMsg}>
<label> Coherent Votes </label>
</WithHelpTooltip>
</Container>
);
const Coherency: React.FC = () => {
const { width } = useWindowSize();
return (
<Container>
<WithHelpTooltip place={width > BREAKPOINT_LANDSCAPE ? "top" : "left"} tooltipMsg={coherentVotesTooltipMsg}>
<label></label>
</WithHelpTooltip>
</Container>
);
};
export default Coherency;
14 changes: 3 additions & 11 deletions web/src/pages/Home/TopJurors/Header/JurorTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
import React from "react";
import styled, { css } from "styled-components";
import { landscapeStyle } from "styles/landscapeStyle";
import styled from "styled-components";

const Container = styled.div`
display: flex;
gap: 16px;
align-items: center;
width: calc(40px + (220 - 40) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
gap: 36px;
label {
font-weight: 400;
font-size: 14px;
line-height: 19px;
color: ${({ theme }) => theme.secondaryText} !important;
}
${landscapeStyle(
() =>
css`
width: calc(40px + (220 - 40) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
gap: 36px;
`
)}
`;

const JurorTitle: React.FC = () => (
Expand Down
21 changes: 3 additions & 18 deletions web/src/pages/Home/TopJurors/Header/Rank.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
import React from "react";
import styled, { css } from "styled-components";
import { landscapeStyle } from "styles/landscapeStyle";
import styled from "styled-components";

const Container = styled.div`
width: 50%;
width: calc(16px + (24 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
label {
&::before {
content: "Ranking";
visibility: visible;
content: "#";
}
}
${landscapeStyle(
() =>
css`
width: calc(16px + (24 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
label {
&::before {
content: "#";
}
}
`
)}
`;

const Rank: React.FC = () => (
Expand Down
17 changes: 16 additions & 1 deletion web/src/pages/Home/TopJurors/Header/Rewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,25 @@ import { landscapeStyle } from "styles/landscapeStyle";
import WithHelpTooltip from "pages/Dashboard/WithHelpTooltip";

const Container = styled.div`
label {
font-size: 12px !important;
&::before {
content: "Rewards";
}
}
${landscapeStyle(
() =>
css`
display: flex;
width: calc(60px + (240 - 60) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
label {
font-size: 14px !important;
&::before {
content: "Total Rewards";
}
}
`
)}
`;
Expand All @@ -21,7 +36,7 @@ const totalRewardsTooltipMsg =
const Rewards: React.FC = () => (
<Container>
<WithHelpTooltip place="top" tooltipMsg={totalRewardsTooltipMsg}>
<label> Total Rewards </label>
<label></label>
</WithHelpTooltip>
</Container>
);
Expand Down
22 changes: 15 additions & 7 deletions web/src/pages/Home/TopJurors/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,49 @@ const Container = styled.div`
display: flex;
justify-content: space-between;
width: 100%;
height: 100%;
background-color: ${({ theme }) => theme.lightBlue};
padding: 24px;
border 1px solid ${({ theme }) => theme.stroke};
border-top-left-radius: 3px;
border-top-right-radius: 3px;
border-bottom: none;
flex-wrap: wrap;
${landscapeStyle(
() =>
css`
flex-wrap: nowrap;
gap: 0px;
border-bottom: 1px solid ${({ theme }) => theme.stroke};
padding: 18.6px 32px;
`
)}
`;

const PlaceAndTitleAndRewardsAndCoherency = styled.div`
display: flex;
flex-direction: column;
gap: 8px;
display: none;
${landscapeStyle(
() =>
css`
display: flex;
flex-direction: row;
gap: 32px;
gap: calc(20px + (28 - 20) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
`
)}
`;

const StyledLabel = styled.label`
${landscapeStyle(
() =>
css`
display: none;
`
)}
`;

const Header: React.FC = () => {
return (
<Container>
<StyledLabel>Ranking</StyledLabel>
<PlaceAndTitleAndRewardsAndCoherency>
<Rank />
<JurorTitle />
Expand Down
1 change: 1 addition & 0 deletions web/src/pages/Home/TopJurors/JurorCard/Coherency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const Container = styled.div`
align-items: center;
label {
font-weight: 600;
color: ${({ theme }) => theme.primaryText};
}
flex-wrap: wrap;
`;
Expand Down
66 changes: 66 additions & 0 deletions web/src/pages/Home/TopJurors/JurorCard/DesktopCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from "react";
import { landscapeStyle } from "styles/landscapeStyle";
import styled, { css } from "styled-components";
import Rank from "./Rank";
import JurorTitle from "./JurorTitle";
import Rewards from "./Rewards";
import Coherency from "./Coherency";
import HowItWorks from "./HowItWorks";

const Container = styled.div`
display: none;
justify-content: space-between;
flex-wrap: wrap;
width: 100%;
background-color: ${({ theme }) => theme.whiteBackground};
border: 1px solid ${({ theme }) => theme.stroke};
border-top: none;
align-items: center;
padding: 15.55px 32px;
label {
font-size: 16px;
}
${landscapeStyle(
() => css`
display: flex;
`
)}
`;

const PlaceAndTitleAndRewardsAndCoherency = styled.div`
display: flex;
flex-direction: row;
gap: calc(20px + (28 - 20) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
`;

interface IDesktopCard {
rank: number;
address: string;
totalCoherent: number;
totalResolvedDisputes: number;
coherenceScore: number;
}

const DesktopCard: React.FC<IDesktopCard> = ({
rank,
address,
totalCoherent,
totalResolvedDisputes,
coherenceScore,
}) => {
return (
<Container>
<PlaceAndTitleAndRewardsAndCoherency>
<Rank rank={rank} />
<JurorTitle address={address} />
<Rewards address={address} />
<Coherency totalCoherent={totalCoherent} totalResolvedDisputes={totalResolvedDisputes} />
</PlaceAndTitleAndRewardsAndCoherency>
<HowItWorks coherenceScore={coherenceScore} />
</Container>
);
};
export default DesktopCard;
28 changes: 25 additions & 3 deletions web/src/pages/Home/TopJurors/JurorCard/HowItWorks.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
import React from "react";
import styled from "styled-components";
import styled, { css } from "styled-components";
import { landscapeStyle } from "styles/landscapeStyle";
import PixelArt from "pages/Dashboard/JurorInfo/PixelArt";
import { getUserLevelData } from "utils/userLevelCalculation";

const Container = styled.div`
display: flex;
align-items: center;
gap: 16px;
gap: 8px;
label {
font-size: 12px !important;
&::before {
content: "Lv. ";
}
}
${landscapeStyle(
() => css`
gap: 16px;
label {
font-size: 16px !important;
&::before {
content: "Level ";
}
}
`
)}
`;

interface IHowItWorks {
Expand All @@ -19,7 +41,7 @@ const HowItWorks: React.FC<IHowItWorks> = ({ coherenceScore }) => {

return (
<Container>
<label> Level {level}</label>
<label>{level}</label>
<PixelArt width="32px" height="32px" level={level} />
</Container>
);
Expand Down
Loading

0 comments on commit 38f61bc

Please sign in to comment.