diff --git a/web/src/assets/pngs/dashboard/aristoteles.png b/web/src/assets/pngs/dashboard/aristoteles.png new file mode 100644 index 000000000..98710b0f2 Binary files /dev/null and b/web/src/assets/pngs/dashboard/aristoteles.png differ diff --git a/web/src/assets/pngs/dashboard/diogenes.png b/web/src/assets/pngs/dashboard/diogenes.png new file mode 100644 index 000000000..1c326ca1d Binary files /dev/null and b/web/src/assets/pngs/dashboard/diogenes.png differ diff --git a/web/src/assets/pngs/dashboard/plato.png b/web/src/assets/pngs/dashboard/plato.png new file mode 100644 index 000000000..7fb43789e Binary files /dev/null and b/web/src/assets/pngs/dashboard/plato.png differ diff --git a/web/src/assets/pngs/dashboard/pythagoras.png b/web/src/assets/pngs/dashboard/pythagoras.png new file mode 100644 index 000000000..7a4e49957 Binary files /dev/null and b/web/src/assets/pngs/dashboard/pythagoras.png differ diff --git a/web/src/assets/pngs/dashboard/socrates.png b/web/src/assets/pngs/dashboard/socrates.png new file mode 100644 index 000000000..6350b40f0 Binary files /dev/null and b/web/src/assets/pngs/dashboard/socrates.png differ diff --git a/web/src/pages/Dashboard/JurorInfo/Coherency.tsx b/web/src/pages/Dashboard/JurorInfo/Coherency.tsx index c20a3e8ab..e836754cf 100644 --- a/web/src/pages/Dashboard/JurorInfo/Coherency.tsx +++ b/web/src/pages/Dashboard/JurorInfo/Coherency.tsx @@ -1,15 +1,20 @@ import React from "react"; -import styled from "styled-components"; -import { useAccount } from "wagmi"; +import styled, { css } from "styled-components"; +import { landscapeStyle } from "styles/landscapeStyle"; import { CircularProgress } from "@kleros/ui-components-library"; import WithHelpTooltip from "../WithHelpTooltip"; -import { useUserQuery } from "queries/useUser"; const Container = styled.div` display: flex; flex-direction: column; align-items: center; gap: 4px; + + ${landscapeStyle( + () => css` + gap: 0; + ` + )} `; const tooltipMsg = @@ -18,44 +23,33 @@ const tooltipMsg = " using the number of times you have been coherent and the total cases you" + " have been in."; -const levelTitles = [ - { scoreRange: [0, 20], level: 0, title: "Diogenes" }, - { scoreRange: [20, 40], level: 1, title: "Pythagoras" }, - { scoreRange: [40, 60], level: 2, title: "Socrates" }, - { scoreRange: [60, 80], level: 3, title: "Plato" }, - { scoreRange: [80, 100], level: 4, title: "Aristotle" }, -]; - -const Coherency: React.FC = () => { - const { address } = useAccount(); - const { data } = useUserQuery(address?.toLowerCase()); - const totalCoherent = data?.user ? parseInt(data?.user?.totalCoherent) : 0; - const totalResolvedDisputes = data?.user ? parseInt(data?.user?.totalResolvedDisputes) : 1; - const coherencyScore = calculateCoherencyScore(totalCoherent, totalResolvedDisputes); - const roundedCoherencyScore = Math.round(coherencyScore * 100); - const { level, title } = - levelTitles.find(({ scoreRange }) => { - return roundedCoherencyScore >= scoreRange[0] && roundedCoherencyScore < scoreRange[1]; - }) ?? levelTitles[0]; +interface ICoherency { + userLevelData: { + scoreRange: number[]; + level: number; + title: string; + }; + score: number; + totalCoherent: number; + totalResolvedDisputes: number; +} +const Coherency: React.FC = ({ userLevelData, score, totalCoherent, totalResolvedDisputes }) => { return ( - {title} - + {userLevelData.title} + ); }; -const calculateCoherencyScore = (totalCoherent: number, totalDisputes: number): number => - totalCoherent / (Math.max(totalDisputes, 1) + 10); - export default Coherency; diff --git a/web/src/pages/Dashboard/JurorInfo/PixelArt.tsx b/web/src/pages/Dashboard/JurorInfo/PixelArt.tsx new file mode 100644 index 000000000..2545ac9ed --- /dev/null +++ b/web/src/pages/Dashboard/JurorInfo/PixelArt.tsx @@ -0,0 +1,42 @@ +import React, { useState } from "react"; +import styled from "styled-components"; +import Skeleton from "react-loading-skeleton"; +import diogenesImage from "assets/pngs/dashboard/diogenes.png"; +import pythagorasImage from "assets/pngs/dashboard/pythagoras.png"; +import socratesImage from "assets/pngs/dashboard/socrates.png"; +import platoImage from "assets/pngs/dashboard/plato.png"; +import aristotelesImage from "assets/pngs/dashboard/aristoteles.png"; + +const StyledImage = styled.img<{ show: boolean }>` + width: 189px; + height: 189px; + display: ${({ show }) => (show ? "block" : "none")}; +`; + +const StyledSkeleton = styled(Skeleton)` + width: 189px; + height: 189px; +`; + +const images = [diogenesImage, pythagorasImage, socratesImage, platoImage, aristotelesImage]; + +interface IPixelArt { + level: number; +} + +const PixelArt: React.FC = ({ level }) => { + const [imageLoaded, setImageLoaded] = useState(false); + return ( +
+ {!imageLoaded && } + setImageLoaded(true)} + show={imageLoaded} + /> +
+ ); +}; + +export default PixelArt; diff --git a/web/src/pages/Dashboard/JurorInfo/index.tsx b/web/src/pages/Dashboard/JurorInfo/index.tsx index 64e4636ae..9a2e803b8 100644 --- a/web/src/pages/Dashboard/JurorInfo/index.tsx +++ b/web/src/pages/Dashboard/JurorInfo/index.tsx @@ -4,6 +4,9 @@ import { landscapeStyle } from "styles/landscapeStyle"; import { Card as _Card } from "@kleros/ui-components-library"; import Coherency from "./Coherency"; import JurorRewards from "./JurorRewards"; +import PixelArt from "./PixelArt"; +import { useAccount } from "wagmi"; +import { useUserQuery } from "queries/useUser"; // import StakingRewards from "./StakingRewards"; const Container = styled.div``; @@ -13,37 +16,61 @@ const Header = styled.h1` `; const Card = styled(_Card)` - width: 100%; - height: auto; -`; - -const Layout = styled.div` display: flex; flex-direction: column; align-items: center; justify-content: center; - gap: 24px; - width: auto; - margin: 16px 32px; + gap: 40px; + width: 100%; + height: auto; + padding: 24px 0; ${landscapeStyle( () => css` flex-direction: row; - gap: 48px; + gap: calc(24px + (64 - 24) * (min(max(100vw, 375px), 1250px) - 375px) / 875); + height: 236px; ` )} `; +const levelTitles = [ + { scoreRange: [0, 20], level: 0, title: "Diogenes" }, + { scoreRange: [20, 40], level: 1, title: "Pythagoras" }, + { scoreRange: [40, 60], level: 2, title: "Socrates" }, + { scoreRange: [60, 80], level: 3, title: "Plato" }, + { scoreRange: [80, 100], level: 4, title: "Aristotle" }, +]; + +const calculateCoherencyScore = (totalCoherent: number, totalDisputes: number): number => + totalCoherent / (Math.max(totalDisputes, 1) + 10); + const JurorInfo: React.FC = () => { + const { address } = useAccount(); + const { data } = useUserQuery(address?.toLowerCase()); + const totalCoherent = data?.user ? parseInt(data?.user?.totalCoherent) : 0; + const totalResolvedDisputes = data?.user ? parseInt(data?.user?.totalResolvedDisputes) : 1; + + const coherencyScore = calculateCoherencyScore(totalCoherent, totalResolvedDisputes); + const roundedCoherencyScore = Math.round(coherencyScore * 100); + const userLevelData = + levelTitles.find(({ scoreRange }) => { + return roundedCoherencyScore >= scoreRange[0] && roundedCoherencyScore < scoreRange[1]; + }) ?? levelTitles[0]; + return (
Juror Dashboard
- - - - + + +
);