Skip to content

Commit c8058f0

Browse files
authored
Merge pull request #70 from kleros/feat/add-header
Feat: Add header
2 parents 973fba7 + b021335 commit c8058f0

31 files changed

+463
-152
lines changed

web/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"src": "./src",
1111
"assets": "./src/assets",
1212
"components": "./src/components",
13+
"context": "./src/context",
14+
"layout": "./src/layout",
1315
"consts": "./src/consts",
1416
"hooks": "./src/hooks",
1517
"pages": "./src/pages",
@@ -47,7 +49,8 @@
4749
},
4850
"dependencies": {
4951
"@kleros/kleros-v2-contracts": "workspace:^",
50-
"@kleros/ui-components-library": "^0.1.3",
52+
"@kleros/ui-components-library": "^0.1.5",
53+
"core-js": "^3.21.1",
5154
"react": "^18.0.0",
5255
"react-dom": "^18.0.0",
5356
"react-is": "^18.0.0",

web/src/app.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
import React from "react";
22
import { Routes, Route } from "react-router-dom";
3-
import Layout from "components/layout";
3+
import StyledComponentsProvider from "context/StyledComponentsProvider";
4+
import Layout from "layout/index";
45
import Home from "./pages/home";
56

67
const App: React.FC = () => (
7-
<Routes>
8-
<Route path="/" element={<Layout />}>
9-
<Route index element={<Home />} />
10-
<Route path="cases" element={<h1>Cases</h1>} />
11-
<Route path="courts" element={<h1>Courts</h1>} />
12-
<Route path="dashboard" element={<h1>Dashboard</h1>} />
13-
<Route
14-
path="*"
15-
element={<h1>Justice not found here ¯\_( ͡° ͜ʖ ͡°)_/¯</h1>}
16-
/>
17-
</Route>
18-
</Routes>
8+
<StyledComponentsProvider>
9+
<Routes>
10+
<Route path="/" element={<Layout />}>
11+
<Route index element={<Home />} />
12+
<Route path="cases" element={<h1>Cases</h1>} />
13+
<Route path="courts" element={<h1>Courts</h1>} />
14+
<Route path="dashboard" element={<h1>Dashboard</h1>} />
15+
<Route
16+
path="*"
17+
element={<h1>Justice not found here ¯\_( ͡° ͜ʖ ͡°)_/¯</h1>}
18+
/>
19+
</Route>
20+
</Routes>
21+
</StyledComponentsProvider>
1922
);
2023

2124
export default App;
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

web/src/components/ConnectButton.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React from "react";
2+
import { Button } from "@kleros/ui-components-library";
3+
4+
const ConnectButton: React.FC = () => <Button small text={"Connect"} />;
5+
6+
export default ConnectButton;

web/src/components/LightButton.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React from "react";
2+
import styled from "styled-components";
3+
import { Button } from "@kleros/ui-components-library";
4+
5+
const StyledButton = styled(Button)`
6+
background-color: transparent;
7+
padding-left: 0;
8+
.button-text {
9+
color: ${({ theme }) => theme.primaryText};
10+
font-weight: 400;
11+
}
12+
.button-svg {
13+
fill: ${({ theme }) => theme.secondaryPurple};
14+
}
15+
16+
:focus,
17+
:hover {
18+
background-color: transparent;
19+
}
20+
`;
21+
22+
interface ILightButton {
23+
text: string;
24+
icon?: (className: string) => React.ReactNode;
25+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
26+
disabled?: boolean;
27+
className?: string;
28+
}
29+
30+
const LightButton: React.FC<ILightButton> = ({
31+
text,
32+
icon,
33+
onClick,
34+
disabled,
35+
className,
36+
}) => (
37+
<StyledButton
38+
variant="primary"
39+
small
40+
{...{ text, icon, onClick, disabled, className }}
41+
/>
42+
);
43+
44+
export default LightButton;

web/src/components/layout/footer/SecuredByKleros.tsx

Lines changed: 0 additions & 15 deletions
This file was deleted.

web/src/components/layout/footer/SocialMedia.tsx

Lines changed: 0 additions & 25 deletions
This file was deleted.

web/src/components/layout/footer/index.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

web/src/components/layout/header/KlerosCourt.tsx

Lines changed: 0 additions & 16 deletions
This file was deleted.

web/src/components/layout/header/index.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

web/src/consts/socialmedia.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,34 @@ export const socialmedia = {
1616
},
1717
github: {
1818
icon: <GithubLogo />,
19-
url: "",
19+
url: "https://github.com/kleros",
2020
},
2121
snapshot: {
2222
icon: <SnapshotLogo />,
23-
url: "",
23+
url: "https://snapshot.org/#/kleros.eth",
2424
},
2525
discord: {
2626
icon: <DiscordLogo />,
27-
url: "",
27+
url: "https://discord.com/invite/MhXQGCyHd9",
2828
},
2929
twitter: {
3030
icon: <TwitterLogo />,
31-
url: "",
31+
url: "https://twitter.com/kleros_io",
3232
},
3333
reddit: {
3434
icon: <RedditLogo />,
35-
url: "",
35+
url: "https://www.reddit.com/r/Kleros/",
3636
},
3737
telegram: {
3838
icon: <TelegramLogo />,
39-
url: "",
39+
url: "https://t.me/kleros",
4040
},
4141
ghost: {
4242
icon: <GhostBlogLogo />,
43-
url: "",
43+
url: "https://blog.kleros.io/",
4444
},
4545
linkedin: {
4646
icon: <LinkedinLogo />,
47-
url: "",
47+
url: "https://www.linkedin.com/company/kleros/",
4848
},
4949
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from "react";
2+
import { ThemeProvider } from "styled-components";
3+
import { useLocalStorage } from "hooks/useLocalStorage";
4+
import { ToggleThemeProvider } from "hooks/useToggleThemeContext";
5+
import { GlobalStyle } from "styles/global-style";
6+
import { lightTheme, darkTheme } from "styles/themes";
7+
8+
const StyledComponentsProvider: React.FC = ({ children }) => {
9+
const [theme, setTheme] = useLocalStorage<string>("theme", "light");
10+
const toggleTheme = () => {
11+
if (theme === "light") setTheme("dark");
12+
else setTheme("light");
13+
};
14+
return (
15+
<ThemeProvider theme={theme === "light" ? lightTheme : darkTheme}>
16+
<ToggleThemeProvider {...{ theme, toggleTheme }}>
17+
<GlobalStyle />
18+
{children}
19+
</ToggleThemeProvider>
20+
</ThemeProvider>
21+
);
22+
};
23+
24+
export default StyledComponentsProvider;

web/src/hooks/useFocusOutside.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { useEffect } from "react";
2+
3+
export function useFocusOutside(
4+
ref: React.RefObject<HTMLDivElement>,
5+
callback: () => void
6+
) {
7+
useEffect(() => {
8+
function handleEvent(event: any) {
9+
if (ref.current && !ref.current.contains(event.target)) {
10+
callback();
11+
}
12+
}
13+
14+
document.addEventListener("focusin", handleEvent);
15+
document.addEventListener("mousedown", handleEvent);
16+
return () => {
17+
document.removeEventListener("focusin", handleEvent);
18+
document.removeEventListener("mousedown", handleEvent);
19+
};
20+
}, [ref, callback]);
21+
}

web/src/hooks/useLocalStorage.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { useState } from "react";
2+
3+
export function useLocalStorage<T>(keyName: string, defaultValue: T) {
4+
const [storedValue, setStoredValue] = useState(() => {
5+
try {
6+
const value = window.localStorage.getItem(keyName);
7+
return value ? JSON.parse(value) : defaultValue;
8+
} catch (err) {
9+
return defaultValue;
10+
}
11+
});
12+
13+
const setValue = (newValue: T) => {
14+
try {
15+
window.localStorage.setItem(keyName, JSON.stringify(newValue));
16+
} finally {
17+
setStoredValue(newValue);
18+
}
19+
};
20+
21+
return [storedValue, setValue];
22+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React, { createContext, useContext } from "react";
2+
3+
// eslint-disable-next-line @typescript-eslint/no-empty-function
4+
const Context = createContext<[string, () => void]>(["light", () => {}]);
5+
6+
export const ToggleThemeProvider: React.FC<{
7+
theme: string;
8+
toggleTheme: () => void;
9+
}> = ({ theme, toggleTheme, children }) => {
10+
return (
11+
<Context.Provider value={[theme, toggleTheme]}>{children}</Context.Provider>
12+
);
13+
};
14+
15+
export const useToggleTheme: () => [string, () => void] = () => {
16+
const toggleTheme = useContext(Context);
17+
return toggleTheme;
18+
};

web/src/index.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import React from "react";
22
import { createRoot } from "react-dom/client";
3-
import { ThemeProvider } from "styled-components";
4-
import { GlobalStyle } from "./styles/global-style";
5-
import { lightTheme } from "./styles/themes";
63
import App from "./app";
74
import { HashRouter as Router } from "react-router-dom";
85

@@ -11,10 +8,7 @@ const root = createRoot(container!);
118
root.render(
129
<React.StrictMode>
1310
<Router>
14-
<ThemeProvider theme={lightTheme}>
15-
<GlobalStyle />
16-
<App />
17-
</ThemeProvider>
11+
<App />
1812
</Router>
1913
</React.StrictMode>
2014
);

0 commit comments

Comments
 (0)