Skip to content

Commit 2a51f06

Browse files
authored
Merge pull request #89 from kleros/chore/migrate-from-styled-components-to-tailwind
chore: migrate from styled components to tailwind
2 parents bc5502a + 2055d8a commit 2a51f06

File tree

183 files changed

+4584
-5725
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+4584
-5725
lines changed

web/global.d.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import {} from "styled-components";
2-
import { lightTheme } from "./src/styles/themes";
3-
41
declare global {
52
module "*.svg" {
63
const content: React.FC<React.SVGAttributes<SVGElement>>;
@@ -12,8 +9,4 @@ declare global {
129
}
1310
}
1411

15-
declare module "styled-components" {
16-
type Theme = typeof lightTheme;
17-
//eslint-disable-next-line @typescript-eslint/no-empty-interface
18-
export interface DefaultTheme extends Theme {}
19-
}
12+
export {};

web/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@
4848
"@graphql-codegen/client-preset": "^4.2.0",
4949
"@kleros/curate-v2-tsconfig": "workspace:^",
5050
"@kleros/kleros-v2-contracts": "^0.10.0",
51+
"@tailwindcss/vite": "^4.1.16",
5152
"@types/react": "^18.3.12",
5253
"@types/react-dom": "^18.3.1",
53-
"@types/react-modal": "^3.16.3",
54-
"@types/styled-components": "^5.1.34",
5554
"@typescript-eslint/eslint-plugin": "^5.62.0",
5655
"@typescript-eslint/parser": "^5.62.0",
5756
"@typescript-eslint/utils": "^5.62.0",
@@ -61,6 +60,7 @@
6160
"eslint-plugin-react": "^7.33.2",
6261
"eslint-plugin-react-hooks": "^4.6.0",
6362
"lru-cache": "^7.18.3",
63+
"tailwindcss": "^4.1.16",
6464
"typescript": "^5.3.3",
6565
"vite": "^5.4.2",
6666
"vite-plugin-node-polyfills": "^0.22.0",
@@ -71,7 +71,7 @@
7171
"@cyntler/react-doc-viewer": "^1.17.0",
7272
"@kleros/curate-v2-templates": "workspace:^",
7373
"@kleros/kleros-app": "^2.0.2",
74-
"@kleros/ui-components-library": "^2.20.0",
74+
"@kleros/ui-components-library": "^3.6.0",
7575
"@reown/appkit": "^1.6.6",
7676
"@reown/appkit-adapter-wagmi": "^1.6.6",
7777
"@sentry/react": "^7.93.0",
@@ -82,6 +82,7 @@
8282
"@yornaath/batshit": "^0.9.0",
8383
"chart.js": "^3.9.1",
8484
"chartjs-adapter-moment": "^1.0.1",
85+
"clsx": "^2.1.1",
8586
"core-js": "^3.35.0",
8687
"graphql": "^16.9.0",
8788
"graphql-request": "^7.1.2",
@@ -98,13 +99,12 @@
9899
"react-is": "^18.2.0",
99100
"react-loading-skeleton": "^3.3.1",
100101
"react-markdown": "^8.0.7",
101-
"react-modal": "^3.16.1",
102102
"react-router-dom": "^6.21.2",
103103
"react-scripts": "^5.0.1",
104104
"react-toastify": "^9.1.3",
105105
"react-use": "^17.4.3",
106-
"styled-components": "^5.3.11",
107106
"subgraph-status": "^1.2.4",
107+
"tailwind-merge": "^3.3.1",
108108
"viem": "^2.27.2",
109109
"wagmi": "^2.14.10",
110110
"zod": "^3.24.2"

web/src/app.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { Route } from "react-router-dom";
33
import { SentryRoutes } from "./utils/sentry";
44
import "react-loading-skeleton/dist/skeleton.css";
55
import "react-toastify/dist/ReactToastify.css";
6+
import "overlayscrollbars/styles/overlayscrollbars.css";
7+
import "./global.css";
8+
import ThemeProvider from "context/ThemeProvider";
69
import Web3Provider from "context/Web3Provider";
710
import IsListViewProvider from "context/IsListViewProvider";
811
import QueryClientProvider from "context/QueryClientProvider";
9-
import StyledComponentsProvider from "context/StyledComponentsProvider";
1012
import Layout from "layout/index";
1113
import Home from "./pages/Home";
1214
import AllLists from "./pages/AllLists";
@@ -22,7 +24,7 @@ import Settings from "./pages/Settings";
2224

2325
const App: React.FC = () => {
2426
return (
25-
<StyledComponentsProvider>
27+
<ThemeProvider>
2628
<Web3Provider>
2729
<GraphqlBatcherProvider>
2830
<QueryClientProvider>
@@ -55,7 +57,7 @@ const App: React.FC = () => {
5557
</QueryClientProvider>
5658
</GraphqlBatcherProvider>
5759
</Web3Provider>
58-
</StyledComponentsProvider>
60+
</ThemeProvider>
5961
);
6062
};
6163

web/src/components/ActionButton/ExecuteButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const ExecuteButton: React.FC<IExecuteButton> = ({ registryAddress, itemId, refe
2626
<EnsureChain>
2727
<Button
2828
text="Execute"
29-
disabled={isLoading || isError || isExecuting || isPreparingConfig || disabled}
29+
isDisabled={isLoading || isError || isExecuting || isPreparingConfig || disabled}
3030
isLoading={isLoading || isExecuting}
3131
onClick={() => {
3232
if (!executeRequest || !config || !publicClient) return;
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import styled from "styled-components";
1+
import React from "react";
22

3-
export const ErrorButtonMessage = styled.div`
4-
display: flex;
5-
align-items: center;
6-
gap: 4px;
7-
justify-content: center;
8-
margin: 12px;
9-
color: ${({ theme }) => theme.error};
10-
font-size: 14px;
11-
`;
3+
export const ErrorButtonMessage: React.FC<{ children: React.ReactNode }> = ({ children }) => {
4+
return (
5+
<div className="flex gap-1 items-center justify-center m-3 text-klerosUIComponentsError text-sm">{children}</div>
6+
);
7+
};
Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
11
import React from "react";
2-
import styled from "styled-components";
32
import { Button } from "@kleros/ui-components-library";
43
import { EnsureChain } from "components/EnsureChain";
54
import EnsureAuth from "components/EnsureAuth";
65
import ClosedCircleIcon from "components/StyledIcons/ClosedCircleIcon";
76
import { ErrorButtonMessage } from "./ErrorButtonMessage";
87

9-
const Container = styled.div`
10-
display: flex;
11-
width: 100%;
12-
justify-content: space-between;
13-
flex-wrap: wrap;
14-
gap: 16px;
15-
`;
16-
17-
const ButtonsContainer = styled.div`
18-
display: flex;
19-
flex-direction: column;
20-
align-items: center;
21-
`;
22-
238
interface IButtons {
249
toggleModal: () => void;
2510
callback: () => void;
@@ -38,28 +23,28 @@ const Buttons: React.FC<IButtons> = ({
3823
insufficientBalance,
3924
}) => {
4025
return (
41-
<Container>
26+
<div className="flex flex-wrap gap-4 justify-between w-full">
4227
<Button variant="secondary" text="Return" onClick={toggleModal} />
4328
<EnsureChain>
4429
<EnsureAuth>
45-
<ButtonsContainer>
30+
<div className="flex flex-col items-center">
4631
<Button
4732
text={buttonText}
4833
onClick={() => {
4934
callback();
5035
}}
5136
isLoading={isLoading}
52-
disabled={isDisabled}
37+
isDisabled={isDisabled}
5338
/>
5439
{insufficientBalance ? (
5540
<ErrorButtonMessage>
5641
<ClosedCircleIcon /> Insufficient balance
5742
</ErrorButtonMessage>
5843
) : null}
59-
</ButtonsContainer>
44+
</div>
6045
</EnsureAuth>
6146
</EnsureChain>
62-
</Container>
47+
</div>
6348
);
6449
};
6550
export default Buttons;

web/src/components/ActionButton/Modal/ChallengeItemModal.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { useMemo, useState } from "react";
2-
import styled from "styled-components";
32
import Header from "./Header";
43
import Buttons from "./Buttons";
54
import DepositRequired from "./DepositRequired";
@@ -19,10 +18,6 @@ import {
1918
} from "hooks/useContract";
2019
import { useReadKlerosCoreArbitrationCost } from "hooks/contracts/generated";
2120

22-
const ReStyledModal = styled(Modal)`
23-
gap: 32px;
24-
`;
25-
2621
export enum ChallengeType {
2722
Submission,
2823
Removal,
@@ -129,7 +124,7 @@ const ChallengeItemModal: React.FC<IChallengeItemModal> = ({
129124
);
130125

131126
return (
132-
<ReStyledModal {...{ toggleModal }}>
127+
<Modal className="gap-8" {...{ toggleModal }}>
133128
<Header text={`Challenge ${isItem ? "Item" : "List"}`} />
134129
<DepositRequired value={depositRequired} />
135130
<EvidenceUpload {...{ setEvidence, setIsEvidenceUploading }} />
@@ -153,7 +148,7 @@ const ChallengeItemModal: React.FC<IChallengeItemModal> = ({
153148
{...{ insufficientBalance, toggleModal }}
154149
/>
155150
</div>
156-
</ReStyledModal>
151+
</Modal>
157152
);
158153
};
159154

web/src/components/ActionButton/Modal/DepositRequired.tsx

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,20 @@
11
import React from "react";
22
import { Card } from "@kleros/ui-components-library";
3-
import styled from "styled-components";
43
import { formatETH } from "utils/format";
5-
6-
const StyledCard = styled(Card)`
7-
display: flex;
8-
flex-direction: column;
9-
background-color: ${({ theme }) => theme.mediumBlue};
10-
height: 87px;
11-
width: 100%;
12-
border: none;
13-
justify-content: center;
14-
align-items: center;
15-
padding: 15px;
16-
gap: 5px;
17-
`;
18-
19-
const StyledHeader = styled.p`
20-
font-size: 14px;
21-
margin: 0;
22-
color: ${({ theme }) => theme.primaryBlue};
23-
`;
24-
25-
const StyledQuantity = styled.p`
26-
font-size: 24px;
27-
margin: 0;
28-
color: ${({ theme }) => theme.primaryBlue};
29-
font-weight: 600;
30-
`;
4+
import clsx from "clsx";
315

326
const FeeRequired: React.FC<{ value: bigint }> = ({ value }) => {
337
return (
34-
<StyledCard>
35-
<StyledHeader>Deposit required</StyledHeader>
36-
<StyledQuantity>{formatETH(value ?? 1, 5)} ETH</StyledQuantity>
37-
</StyledCard>
8+
<Card
9+
className={clsx(
10+
"flex flex-col gap-1.5",
11+
"w-full h-22 p-4 justify-center items-center",
12+
"bg-klerosUIComponentsMediumBlue border-none"
13+
)}
14+
>
15+
<p className="text-sm text-klerosUIComponentsPrimaryBlue">Deposit required</p>
16+
<p className="text-2xl font-semibold text-klerosUIComponentsPrimaryBlue">{formatETH(value ?? 1, 5)} ETH</p>
17+
</Card>
3818
);
3919
};
4020

web/src/components/ActionButton/Modal/EvidenceUpload.tsx

Lines changed: 17 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,10 @@
11
import React, { Dispatch, SetStateAction, useEffect, useState } from "react";
2-
import styled from "styled-components";
3-
import { FileUploader, Textarea } from "@kleros/ui-components-library";
4-
import LabeledInput from "components/LabeledInput";
5-
import { responsiveSize } from "styles/responsiveSize";
2+
import { FileUploader, TextArea, TextField } from "@kleros/ui-components-library";
63
import { errorToast, infoToast, successToast } from "utils/wrapWithToast";
74
import { Roles, useAtlasProvider } from "@kleros/kleros-app";
85
import { getFileUploaderMsg } from "src/utils";
96
import useIsDesktop from "hooks/useIsDesktop";
107

11-
const Container = styled.div`
12-
width: 100%;
13-
display: flex;
14-
flex-direction: column;
15-
gap: 38px;
16-
margin: 6px 0px;
17-
`;
18-
19-
const TitleField = styled(LabeledInput)`
20-
width: 100%;
21-
`;
22-
23-
const DescriptionContainer = styled.div`
24-
display: flex;
25-
flex-direction: column;
26-
gap: 12px;
27-
`;
28-
29-
const DescriptionField = styled(Textarea)`
30-
width: 100%;
31-
height: 180px;
32-
`;
33-
34-
const StyledLabel = styled.label`
35-
color: ${({ theme }) => theme.primaryText};
36-
`;
37-
38-
const StyledFileUploader = styled(FileUploader)`
39-
width: 100%;
40-
margin-bottom: ${responsiveSize(150, 72)};
41-
path {
42-
fill: ${({ theme }) => theme.primaryBlue};
43-
}
44-
small {
45-
white-space: pre-line;
46-
text-align: start;
47-
}
48-
`;
49-
508
export type Evidence = {
519
name: string;
5210
description: string;
@@ -92,29 +50,31 @@ const EvidenceUpload: React.FC<IEvidenceUpload> = ({ setEvidence, setIsEvidenceU
9250
};
9351

9452
return (
95-
<Container>
96-
<TitleField
97-
topLeftLabel={{ text: "Title" }}
53+
<div className="flex flex-col gap-9 w-full py-1.5">
54+
<TextField
55+
className="w-full"
56+
label="Title"
9857
placeholder="eg. The item is not legit."
9958
value={title}
100-
onChange={(event) => setTitle(event.target.value)}
59+
onChange={(value) => setTitle(value)}
60+
/>
61+
<TextArea
62+
label="Description"
63+
id="evidence-description"
64+
className="w-full [&_textarea]:w-full [&_textarea]:h-[180px]"
65+
placeholder="Explain what motivates you to challenge it. Why do you think the item is not compliant with the Policy?"
66+
value={description}
67+
onChange={(value) => setDescription(value)}
10168
/>
102-
<DescriptionContainer>
103-
<StyledLabel>Description</StyledLabel>
104-
<DescriptionField
105-
placeholder="Explain what motivates you to challenge it. Why do you think the item is not compliant with the Policy?"
106-
value={description}
107-
onChange={(event) => setDescription(event.target.value)}
108-
/>
109-
</DescriptionContainer>
110-
<StyledFileUploader
69+
<FileUploader
70+
className="w-full [&_small]:whitespace-pre-line [&_small]:text-start"
11171
callback={handleFileUpload}
11272
variant={isDesktop ? "info" : undefined}
11373
msg={
11474
"Additionally, you can add an external file.\n" + (getFileUploaderMsg(Roles.Evidence, roleRestrictions) ?? "")
11575
}
11676
/>
117-
</Container>
77+
</div>
11878
);
11979
};
12080

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import React from "react";
2-
import styled from "styled-components";
3-
4-
const StyledHeader = styled.h1`
5-
margin: 0;
6-
`;
72

83
interface IHeader {
94
text: string;
105
}
116

127
const Header: React.FC<IHeader> = ({ text }) => {
13-
return <StyledHeader>{text}</StyledHeader>;
8+
return <h1>{text}</h1>;
149
};
1510

1611
export default Header;

0 commit comments

Comments
 (0)