Skip to content

Commit ad2c61b

Browse files
committed
refactor: migrate global styling and theme management to tailwind
1 parent 8b8fadc commit ad2c61b

File tree

9 files changed

+212
-298
lines changed

9 files changed

+212
-298
lines changed

web/src/app.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import React from "react";
22
import { Route } from "react-router-dom";
33
import { SentryRoutes } from "./utils/sentry";
4+
import "./global.css";
45
import "react-loading-skeleton/dist/skeleton.css";
56
import "react-toastify/dist/ReactToastify.css";
7+
import ThemeProvider from "context/ThemeProvider";
68
import Web3Provider from "context/Web3Provider";
79
import IsListViewProvider from "context/IsListViewProvider";
810
import QueryClientProvider from "context/QueryClientProvider";
9-
import StyledComponentsProvider from "context/StyledComponentsProvider";
1011
import Layout from "layout/index";
1112
import Home from "./pages/Home";
1213
import AllLists from "./pages/AllLists";
@@ -22,7 +23,7 @@ import Settings from "./pages/Settings";
2223

2324
const App: React.FC = () => {
2425
return (
25-
<StyledComponentsProvider>
26+
<ThemeProvider>
2627
<Web3Provider>
2728
<GraphqlBatcherProvider>
2829
<QueryClientProvider>
@@ -55,7 +56,7 @@ const App: React.FC = () => {
5556
</QueryClientProvider>
5657
</GraphqlBatcherProvider>
5758
</Web3Provider>
58-
</StyledComponentsProvider>
59+
</ThemeProvider>
5960
);
6061
};
6162

web/src/context/StyledComponentsProvider.tsx

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

web/src/context/ThemeProvider.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React, { useEffect } from "react";
2+
import { useLocalStorage } from "hooks/useLocalStorage";
3+
import { ToggleThemeProvider } from "hooks/useToggleThemeContext";
4+
5+
const ThemeProvider: React.FC<{
6+
children: React.ReactNode;
7+
}> = ({ children }) => {
8+
const [theme, setTheme] = useLocalStorage<string>("theme", "dark");
9+
10+
const toggleTheme = () => {
11+
if (theme === "light") setTheme("dark");
12+
else setTheme("light");
13+
};
14+
15+
useEffect(() => {
16+
const root = document.documentElement;
17+
if (theme === "dark") {
18+
root.classList.add("dark");
19+
} else {
20+
root.classList.remove("dark");
21+
}
22+
}, [theme]);
23+
24+
return <ToggleThemeProvider {...{ theme, toggleTheme }}>{children}</ToggleThemeProvider>;
25+
};
26+
27+
export default ThemeProvider;

web/src/global.css

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
@import "@kleros/ui-components-library/theme.css";
2+
@import "tailwindcss";
3+
4+
@theme {
5+
--color-white: #ffffff;
6+
--color-black: #000000;
7+
--color-light-grey: #f0f0f0;
8+
--color-dark-purple: #220050;
9+
--color-violet-purple: #6a1dcd;
10+
--color-lavender-purple: #bb72ff;
11+
--color-pale-cyan: #acffff;
12+
--color-lime-green: #f3ffd9;
13+
--color-white-low-opacity-subtle: #ffffff0d;
14+
--color-white-low-opacity-strong: #ffffff26;
15+
--color-black-low-opacity: #00000080;
16+
--color-skeleton-bg: #ebebeb;
17+
--color-skeleton-highlight: #f5f5f5;
18+
--breakpoint-landscape: 900px;
19+
--max-width-landscape: 1400px;
20+
}
21+
22+
.dark {
23+
--color-skeleton-bg: #3a2270;
24+
--color-skeleton-highlight: #3e307c;
25+
}
26+
27+
:root {
28+
--toastify-color-info: var(--klerosUIComponentsPrimaryBlue);
29+
--toastify-color-success: var(--klerosUIComponentsSuccess);
30+
--toastify-color-warning: var(--klerosUIComponentsWarning);
31+
--toastify-color-error: var(--klerosUIComponentsError);
32+
}
33+
34+
.react-loading-skeleton {
35+
z-index: 0;
36+
--base-color: var(--color-skeleton-bg);
37+
--highlight-color: var(--color-skeleton-highlight);
38+
}
39+
40+
body {
41+
font-family: "Open Sans", sans-serif;
42+
margin: 0;
43+
background-color: var(--klerosUIComponentsLightBlue);
44+
}
45+
46+
html {
47+
box-sizing: border-box;
48+
}
49+
50+
*,
51+
*:before,
52+
*:after {
53+
box-sizing: inherit;
54+
}
55+
56+
*:focus {
57+
outline: none;
58+
}
59+
60+
.ReactModal__Overlay {
61+
background-color: #1b003fcc !important;
62+
}
63+
64+
h1 {
65+
margin: 0 0 16px 0;
66+
font-weight: 600;
67+
font-size: 24px;
68+
line-height: 32px;
69+
color: var(--klerosUIComponentsPrimaryText);
70+
}
71+
72+
h2 {
73+
margin: 0 0 16px 0;
74+
font-weight: 400;
75+
font-size: 24px;
76+
line-height: 32px;
77+
color: var(--klerosUIComponentsPrimaryText);
78+
}
79+
80+
h3 {
81+
margin: 0 0 16px 0;
82+
font-weight: 600;
83+
font-size: 16px;
84+
line-height: 24px;
85+
color: var(--klerosUIComponentsPrimaryText);
86+
}
87+
88+
p {
89+
font-weight: 400;
90+
font-size: 16px;
91+
line-height: 24px;
92+
color: var(--klerosUIComponentsPrimaryText);
93+
}
94+
95+
textarea {
96+
font-family: "Open Sans";
97+
font-size: 14px;
98+
}
99+
100+
small {
101+
font-weight: 600;
102+
font-size: 14px;
103+
line-height: 18px;
104+
color: var(--klerosUIComponentsPrimaryText);
105+
}
106+
107+
label {
108+
font-weight: 400;
109+
font-size: 14px;
110+
line-height: 18px;
111+
color: var(--klerosUIComponentsSecondaryText);
112+
}
113+
114+
a {
115+
font-weight: 400;
116+
font-size: 14px;
117+
text-decoration: none;
118+
color: var(--klerosUIComponentsPrimaryBlue);
119+
}
120+
121+
hr {
122+
opacity: 1;
123+
border: 1px solid var(--klerosUIComponentsStroke);
124+
}
125+
126+
svg,
127+
img {
128+
display: inline-block;
129+
vertical-align: middle;
130+
visibility: visible;
131+
}
132+
133+
ul {
134+
li {
135+
color: var(--klerosUIComponentsPrimaryText);
136+
}
137+
}
138+
139+
.os-theme-dark {
140+
--os-handle-bg: var(--color-violet-purple);
141+
--os-handle-bg-hover: var(--klerosUIComponentsSecondaryPurple);
142+
--os-handle-bg-active: var(--color-lavender-purple);
143+
}
144+
145+
[class*="Toastify__toast-container"] {
146+
top: unset;
147+
padding-top: 20px !important;
148+
}
149+
150+
/* Custom Scrollbar */
151+
.custom-scrollbar::-webkit-scrollbar {
152+
width: 6px;
153+
height: 6px;
154+
}
155+
156+
.custom-scrollbar::-webkit-scrollbar-track {
157+
background: transparent;
158+
}
159+
160+
.custom-scrollbar::-webkit-scrollbar-thumb {
161+
background-color: var(--color-violet-purple);
162+
border-radius: 10px;
163+
transition:
164+
opacity 0.15s,
165+
background-color 0.15s,
166+
border-color 0.15s,
167+
width 0.15s;
168+
}
169+
170+
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
171+
background-color: var(--klerosUIComponentsSecondaryPurple);
172+
}
173+
174+
.custom-scrollbar::-webkit-scrollbar-thumb:active {
175+
background-color: var(--color-lavender-purple);
176+
}
177+
178+
.custom-scrollbar {
179+
scrollbar-width: thin;
180+
scrollbar-color: var(--color-violet-purple) transparent;
181+
}

web/src/styles/commonStyles.ts

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

web/src/styles/customScrollbar.ts

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

0 commit comments

Comments
 (0)