Skip to content

Commit 6203139

Browse files
authored
Merge pull request #1558 from kleros/feat(web)/badges
feat(web): court-badges
2 parents 80ac304 + a9b93a9 commit 6203139

File tree

9 files changed

+100
-37
lines changed

9 files changed

+100
-37
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@
1212
"sonarlint.connectedMode.project": {
1313
"connectionId": "kleros",
1414
"projectKey": "kleros_kleros-v2"
15+
},
16+
"editor.codeActionsOnSave": {
17+
"source.fixAll.eslint": true
1518
}
1619
}

web/src/consts/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export const ETH_SIGNATURE_REGEX = /^0x[a-fA-F0-9]{130}$/;
2828

2929
export const isProductionDeployment = () => process.env.REACT_APP_DEPLOYMENT === "mainnet";
3030

31-
export const isKlerosUniversity = () => arbitratorType() === ArbitratorTypes.university;
32-
export const isKlerosNeo = () => arbitratorType() === ArbitratorTypes.neo;
33-
export const arbitratorType = (): ArbitratorTypes =>
31+
export const isKlerosUniversity = () => getArbitratorType() === ArbitratorTypes.university;
32+
export const isKlerosNeo = () => getArbitratorType() === ArbitratorTypes.neo;
33+
export const getArbitratorType = (): ArbitratorTypes =>
3434
ArbitratorTypes[process.env.REACT_APP_ARBITRATOR_TYPE?.toLowerCase() ?? "vanilla"];
3535

3636
export const GENESIS_BLOCK_ARBSEPOLIA = BigInt(process.env.REACT_APP_GENESIS_BLOCK_ARBSEPOLIA ?? 0);

web/src/layout/Header/DesktopHeader.tsx

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

4-
import { Link } from "react-router-dom";
54
import { useToggle } from "react-use";
65

7-
import KlerosCourtUniversityLogo from "svgs/header/kleros-court-university.svg";
8-
import KlerosCourtLogo from "svgs/header/kleros-court.svg";
96
import KlerosSolutionsIcon from "svgs/menu-icons/kleros-solutions.svg";
107

118
import { useLockOverlayScroll } from "hooks/useLockOverlayScroll";
129

13-
import { isKlerosUniversity } from "src/consts";
14-
1510
import { landscapeStyle } from "styles/landscapeStyle";
1611
import { responsiveSize } from "styles/responsiveSize";
1712

1813
import ConnectWallet from "components/ConnectWallet";
1914
import LightButton from "components/LightButton";
2015
import { Overlay } from "components/Overlay";
2116

17+
import Logo from "./Logo";
2218
import DappList from "./navbar/DappList";
2319
import Explore from "./navbar/Explore";
2420
import Menu from "./navbar/Menu";
2521
import Help from "./navbar/Menu/Help";
2622
import Settings from "./navbar/Menu/Settings";
2723

28-
import { PopupContainer } from ".";
29-
3024
const Container = styled.div`
3125
display: none;
3226
position: absolute;
@@ -73,10 +67,6 @@ const LightButtonContainer = styled.div`
7367
margin-right: ${responsiveSize(12, 16)};
7468
`;
7569

76-
const StyledLink = styled(Link)`
77-
min-height: 48px;
78-
`;
79-
8070
const StyledKlerosSolutionsIcon = styled(KlerosSolutionsIcon)`
8171
fill: ${({ theme }) => theme.white} !important;
8272
`;
@@ -87,6 +77,15 @@ const ConnectWalletContainer = styled.div`
8777
}
8878
`;
8979

80+
const PopupContainer = styled.div`
81+
position: fixed;
82+
top: 0;
83+
left: 0;
84+
width: 100%;
85+
height: 100%;
86+
z-index: 30;
87+
`;
88+
9089
const DesktopHeader = () => {
9190
const [isDappListOpen, toggleIsDappListOpen] = useToggle(false);
9291
const [isHelpOpen, toggleIsHelpOpen] = useToggle(false);
@@ -106,7 +105,7 @@ const DesktopHeader = () => {
106105
Icon={StyledKlerosSolutionsIcon}
107106
/>
108107
</LightButtonContainer>
109-
<StyledLink to={"/"}>{isKlerosUniversity() ? <KlerosCourtUniversityLogo /> : <KlerosCourtLogo />}</StyledLink>
108+
<Logo />
110109
</LeftSide>
111110

112111
<MiddleSide>

web/src/layout/Header/Logo.tsx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React, { useMemo } from "react";
2+
import styled, { Theme } from "styled-components";
3+
4+
import { Link } from "react-router-dom";
5+
6+
import KlerosCourtLogo from "svgs/header/kleros-court.svg";
7+
8+
import { ArbitratorTypes, getArbitratorType } from "consts/index";
9+
import { isUndefined } from "utils/index";
10+
11+
const Container = styled.div`
12+
display: flex;
13+
flex-direction: row;
14+
align-items: center;
15+
gap: 16px;
16+
`;
17+
18+
const StyledLink = styled(Link)`
19+
min-height: 48px;
20+
`;
21+
22+
const BadgeContainer = styled.div<{ backgroundColor: keyof Theme }>`
23+
transform: skewX(-15deg);
24+
background-color: ${({ theme, backgroundColor }) => theme[backgroundColor]};
25+
border-radius: 3px;
26+
padding: 1px 8px;
27+
height: fit-content;
28+
`;
29+
30+
const BadgeText = styled.label`
31+
color: ${({ theme }) => theme.darkPurple};
32+
`;
33+
34+
const CourtBadge: React.FC = () => {
35+
const { text, color } = useMemo<{ text?: string; color?: keyof Theme }>(() => {
36+
switch (getArbitratorType()) {
37+
case ArbitratorTypes.neo:
38+
return { text: "Neo", color: "paleCyan" };
39+
case ArbitratorTypes.university:
40+
return { text: "Uni", color: "limeGreen" };
41+
}
42+
return {};
43+
}, []);
44+
45+
return !isUndefined(color) ? (
46+
<BadgeContainer {...{ backgroundColor: color }}>
47+
<BadgeText>{text}</BadgeText>
48+
</BadgeContainer>
49+
) : null;
50+
};
51+
52+
const Logo: React.FC = () => (
53+
<Container>
54+
{" "}
55+
<StyledLink to={"/"}>
56+
<KlerosCourtLogo />
57+
</StyledLink>
58+
<CourtBadge />
59+
</Container>
60+
);
61+
62+
export default Logo;

web/src/layout/Header/MobileHeader.tsx

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

4-
import { Link } from "react-router-dom";
54
import { useClickAway, useToggle } from "react-use";
65

76
import HamburgerIcon from "svgs/header/hamburger.svg";
8-
import KlerosCourtUniversityLogo from "svgs/header/kleros-court-university.svg";
9-
import KlerosCourtLogo from "svgs/header/kleros-court.svg";
10-
11-
import { isKlerosUniversity } from "src/consts";
127

138
import { landscapeStyle } from "styles/landscapeStyle";
149

1510
import LightButton from "components/LightButton";
1611

12+
import Logo from "./Logo";
1713
import NavBar from "./navbar";
1814

1915
const Container = styled.div`
@@ -41,10 +37,6 @@ const StyledLightButton = styled(LightButton)`
4137
}
4238
`;
4339

44-
const StyledLink = styled(Link)`
45-
min-height: 48px;
46-
`;
47-
4840
const OpenContext = React.createContext({
4941
isOpen: false,
5042
toggleIsOpen: () => {
@@ -64,7 +56,7 @@ const MobileHeader = () => {
6456
return (
6557
<Container ref={containerRef}>
6658
<OpenContext.Provider value={memoizedContext}>
67-
<StyledLink to={"/"}>{isKlerosUniversity() ? <KlerosCourtUniversityLogo /> : <KlerosCourtLogo />}</StyledLink>
59+
<Logo />
6860
<NavBar />
6961
<StyledLightButton text="" Icon={HamburgerIcon} onClick={toggleIsOpen} />
7062
</OpenContext.Provider>

web/src/layout/Header/index.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ const HeaderContainer = styled.div`
2323
padding: 4px 24px 8px;
2424
`;
2525

26-
export const PopupContainer = styled.div`
27-
position: fixed;
28-
top: 0;
29-
left: 0;
30-
width: 100%;
31-
height: 100%;
32-
z-index: 30;
33-
`;
34-
3526
const Header: React.FC = () => {
3627
return (
3728
<Container>

web/src/layout/Header/navbar/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import ConnectWallet from "components/ConnectWallet";
1212
import LightButton from "components/LightButton";
1313
import { Overlay } from "components/Overlay";
1414

15-
import { PopupContainer } from "..";
1615
import { useOpenContext } from "../MobileHeader";
1716

1817
import DappList from "./DappList";
@@ -72,6 +71,15 @@ const DisconnectWalletButtonContainer = styled.div`
7271
align-items: center;
7372
`;
7473

74+
const PopupContainer = styled.div`
75+
position: fixed;
76+
top: 0;
77+
left: 0;
78+
width: 100%;
79+
height: 100%;
80+
z-index: 30;
81+
`;
82+
7583
export interface ISettings {
7684
toggleIsSettingsOpen: () => void;
7785
}

web/src/styles/themes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const lightTheme = {
66
white: "#FFFFFF",
77
primaryPurple: "#4D00B4",
88
secondaryPurple: "#9013FE",
9+
darkPurple: "#220050",
910
mediumPurple: "#F8F1FF",
1011
lightPurple: "#FBF9FE",
1112
violetPurple: "#6A1DCD",
@@ -41,6 +42,9 @@ export const lightTheme = {
4142

4243
skeletonBackground: "#EBEBEB",
4344
skeletonHighlight: "#F5F5F5",
45+
46+
paleCyan: "#ACFFFF",
47+
limeGreen: "#F3FFD9",
4448
};
4549

4650
export const darkTheme = {
@@ -49,6 +53,7 @@ export const darkTheme = {
4953
white: "#FFFFFF",
5054
primaryPurple: "#7E1BD4",
5155
secondaryPurple: "#B45FFF",
56+
darkPurple: "#220050",
5257
mediumPurple: "#390F6C",
5358
lightPurple: "#FCFBFF",
5459
violetPurple: "#6A1DCD",
@@ -84,4 +89,7 @@ export const darkTheme = {
8489

8590
skeletonBackground: "#3A2270",
8691
skeletonHighlight: "#3E307C",
92+
93+
paleCyan: "#ACFFFF",
94+
limeGreen: "#F3FFD9",
8795
};

web/wagmi.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Abi } from "viem";
1010
import IArbitrableV2 from "@kleros/kleros-v2-contracts/artifacts/src/arbitration/interfaces/IArbitrableV2.sol/IArbitrableV2.json" assert { type: "json" };
1111
import IHomeGateway from "@kleros/kleros-v2-contracts/artifacts/src/gateway/interfaces/IHomeGateway.sol/IHomeGateway.json" assert { type: "json" };
1212

13-
import { ArbitratorTypes, arbitratorType } from "src/consts";
13+
import { ArbitratorTypes, getArbitratorType } from "src/consts";
1414

1515
dotenv.config();
1616

@@ -71,7 +71,7 @@ const readArtifacts = async (type: ArbitratorTypes, viemChainName: string, hardh
7171

7272
const getConfig = async (): Promise<Config> => {
7373
const deployment = process.env.REACT_APP_DEPLOYMENT ?? "testnet";
74-
const type = arbitratorType();
74+
const type = getArbitratorType();
7575

7676
let viemNetwork: string;
7777
let hardhatNetwork: string;

0 commit comments

Comments
 (0)