Skip to content

feat(devtools): initial setup and ui for devtool website #1641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions web-devtools/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}
},
"extends": [
"next/core-web-vitals",
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
Expand Down Expand Up @@ -42,16 +43,16 @@
"version": "^16.12.0"
},
"import/resolver": {
"parcel": {
"rootDir": "src",
"typescript": {
"alwaysTryTypes": true,
"project": "./tsconfig.json"
},
"node": {
"extensions": [
".js",
".jsx",
".ts",
".tsx",
".svg",
".png",
".jpeg"
".tsx"
]
}
}
Expand Down
15 changes: 12 additions & 3 deletions web-devtools/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# dependencies
/.yarn/*
!/.yarn/versions
!/.yarn/plugins
Expand All @@ -6,14 +7,15 @@
/.pnp.*
node_modules

# Parcel
.parcel-cache
# next.js
/.next/
/out/
development
build
dist
parcel-bundle-reports

# misc
*.pem
.eslintcache
.DS_Store
.env
Expand All @@ -35,3 +37,10 @@ generatedNetlifyInfo.json
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# testing
/coverage

# typescript
*.tsbuildinfo
next-env.d.ts
6 changes: 6 additions & 0 deletions web-devtools/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { DefaultTheme } from "styled-components";
import { theme } from "styles/Theme";
declare module "styled-components" {
type Theme = typeof theme;
export interface DefaultTheme extends Theme {}
}
33 changes: 33 additions & 0 deletions web-devtools/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
compiler: {
styledComponents: true,
},
webpack(config) {
// Grab the existing rule that handles SVG imports
const fileLoaderRule = config.module.rules.find((rule) => rule.test?.test?.(".svg"));

config.module.rules.push(
// Reapply the existing rule, but only for svg imports ending in ?url
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: /url/, // *.svg?url
},
// Convert all other *.svg imports to React components
{
test: /\.svg$/i,
issuer: fileLoaderRule.issuer,
resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] }, // exclude if *.svg?url
use: ["@svgr/webpack"],
}
);

// Modify the file loader rule to ignore *.svg, since we have it handled now.
fileLoaderRule.exclude = /\.svg$/i;

return config;
},
};

export default nextConfig;
16 changes: 14 additions & 2 deletions web-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,30 @@
"license": "MIT",
"packageManager": "[email protected]+sha256.825003a0f561ad09a3b1ac4a3b3ea6207af2796d54f62a9420520915721f5186",
"volta": {
"node": "20.11.0"
"node": "20.11.0",
"yarn": "4.3.1"
},
"scripts": {
"hi": "echo hello world"
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"prettier": "@kleros/kleros-v2-prettier-config",
"devDependencies": {
"@svgr/webpack": "^8.1.0",
"@types/node": "^20",
"@types/react": "18.2.0",
"@types/react-dom": "^18.2.18",
"typescript": "^5.3.3"
},
"dependencies": {
"@kleros/kleros-sdk": "workspace:^",
"@kleros/ui-components-library": "^2.10.0",
"next": "14.2.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"styled-components": "^5.3.11",
"viem": "^1.21.4",
"wagmi": "^1.4.13"
}
Expand Down
51 changes: 51 additions & 0 deletions web-devtools/src/app/(main)/ChangeRuler.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from "react";
import styled from "styled-components";

import { Field } from "@kleros/ui-components-library";

import LightButton from "components/LightButton";

const Container = styled.div`
border: ${({ theme }) => theme.klerosUIComponentsPrimaryBlue} 1px solid;
border-radius: 4px;
padding: 16px;
`;

const RulingSettings = styled.div`
display: flex;
flex-direction: column;
gap: 8px;
margin: 16px 0;
`;
const FieldContainer = styled.div`
display: flex;
align-items: center;
width: fit-content;
height: fit-content;
padding-left: 8px;
gap: 8px;
font-size: 14px;
border-radius: 4px;
border: ${({ theme }) => theme.klerosUIComponentsStroke} 1px solid;
color: ${({ theme }) => theme.klerosUIComponentsPrimaryText};
`;

const ChangeRuler: React.FC = () => {
return (
<div>
<h3>Change Ruler</h3>
<Container>
<label>Current Ruler</label>
<Field value={"0xb78......09e441"}></Field>
<RulingSettings>
<LightButton text={"Change Ruler"} />
<FieldContainer>
address <Field placeholder={"0x00[dev address]"}></Field>
</FieldContainer>
</RulingSettings>
</Container>
</div>
);
};

export default ChangeRuler;
74 changes: 74 additions & 0 deletions web-devtools/src/app/(main)/RulingModes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React, { useState } from "react";
import styled from "styled-components";

import { Checkbox, Field } from "@kleros/ui-components-library";

import LightButton from "components/LightButton";

const Container = styled.div`
display: flex;
flex-wrap: wrap;
gap: 8px;
margin: 16px 0;
border: ${({ theme }) => theme.klerosUIComponentsPrimaryBlue} 1px solid;
border-radius: 4px;
padding: 16px;
`;
const RulingSettings = styled.div`
display: flex;
flex-direction: column;
gap: 8px;
margin: 16px 0;
`;
const FieldContainer = styled.div`
display: flex;
align-items: center;
width: fit-content;
height: fit-content;
padding-left: 8px;
gap: 8px;
font-size: 14px;
border-radius: 4px;
border: ${({ theme }) => theme.klerosUIComponentsStroke} 1px solid;
color: ${({ theme }) => theme.klerosUIComponentsPrimaryText};
`;

const RulingModes: React.FC = () => {
const [tie, setTie] = useState<boolean>(false);
const [overriden, setOverriden] = useState<boolean>(false);

return (
<div>
<h3>Ruling Mode</h3>
<Container>
<RulingSettings>
<LightButton text={"Rule Now Manually"} />
<FieldContainer>
ruling <Field placeholder={"1"}></Field>
</FieldContainer>
</RulingSettings>

<RulingSettings>
<LightButton text={"Run Automatically with a Preset"} />
<FieldContainer>
ruling <Field placeholder={"1"}></Field>
</FieldContainer>
<FieldContainer>
<Checkbox label="" small checked={tie} onChange={() => setTie((old) => !old)} />
<Field placeholder={"tie"}></Field>
</FieldContainer>
<FieldContainer>
<Checkbox label="" small checked={overriden} onChange={() => setOverriden((old) => !old)} />
<Field placeholder={"overriden"}></Field>
</FieldContainer>
</RulingSettings>

<RulingSettings>
<LightButton text={"Run Automatically Randomly"} />
</RulingSettings>
</Container>
</div>
);
};

export default RulingModes;
62 changes: 62 additions & 0 deletions web-devtools/src/app/(main)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"use client";
import React from "react";
import styled from "styled-components";

import { DropdownCascader, Field } from "@kleros/ui-components-library";

import { SelectArbitrable } from "utils/dummyData";

import ChangeRuler from "./ChangeRuler";
import RulingModes from "./RulingModes";

const Container = styled.div`
min-height: calc(100vh - 160px);
display: flex;
flex-direction: column;
margin: 16px 32px;
align-items: center;
`;
const Arbitrables = styled.div`
display: flex;
flex-wrap: wrap;
gap: 8px;
margin: 16px 0;
`;

const SettingsPane = styled.div`
display: flex;
flex-wrap: wrap;
gap: 16px;
margin: 16px 0;
`;

const Home: React.FC = () => {
return (
<Container>
<h1>Ruler</h1>

<Arbitrables>
<div>
<label>Select Arbitrable</label>
<DropdownCascader
placeholder={"Select Arbitrable"}
onSelect={() => {
//todo;
}}
items={SelectArbitrable}
/>
</div>
<div>
<label>Current Ruling Mode</label>
<Field value={"auto random"}></Field>
</div>
</Arbitrables>

<SettingsPane>
<RulingModes />
<ChangeRuler />
</SettingsPane>
</Container>
);
};
export default Home;
Binary file added web-devtools/src/app/favicon.ico
Binary file not shown.
34 changes: 34 additions & 0 deletions web-devtools/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from "react";

import type { Metadata } from "next";
import { Open_Sans } from "next/font/google";

import StyledComponentsProvider from "context/StyledComponentsProvider";
import StyledComponentsRegistry from "context/StyledComponentsRegistry";

import Footer from "layout/Footer";
import Header from "layout/Header";

const font = Open_Sans({ subsets: ["latin"] });

export const metadata: Metadata = {
title: "Dev Tools",
};

const RootLayout = ({ children }: Readonly<{ children: React.ReactNode }>) => {
return (
<html lang="en">
<body className={font.className}>
<StyledComponentsRegistry>
<StyledComponentsProvider>
<Header />
{children}
<Footer />
</StyledComponentsProvider>
</StyledComponentsRegistry>
</body>
</html>
);
};

export default RootLayout;
12 changes: 12 additions & 0 deletions web-devtools/src/assets/svgs/footer/secured-by-kleros.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading