Skip to content

feat(web): use code splitting #1506

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 12 commits into from
Jul 1, 2024
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
80 changes: 65 additions & 15 deletions web/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { lazy, Suspense } from "react";

import { Route } from "react-router-dom";

Expand All @@ -9,17 +9,18 @@ import IsListProvider from "context/IsListProvider";
import { NewDisputeProvider } from "context/NewDisputeContext";
import QueryClientProvider from "context/QueryClientProvider";
import StyledComponentsProvider from "context/StyledComponentsProvider";
const Home = lazy(() => import("./pages/Home"));
const Cases = lazy(() => import("./pages/Cases"));
const Dashboard = lazy(() => import("./pages/Dashboard"));
const Courts = lazy(() => import("./pages/Courts"));
const DisputeTemplateView = lazy(() => import("./pages/DisputeTemplateView"));
const DisputeResolver = lazy(() => import("./pages/Resolver"));
const GetPnk = lazy(() => import("./pages/GetPnk"));
import Web3Provider from "context/Web3Provider";

import Loader from "components/Loader";
import Layout from "layout/index";

import Cases from "./pages/Cases";
import Courts from "./pages/Courts";
import Dashboard from "./pages/Dashboard";
import DisputeTemplateView from "./pages/DisputeTemplateView";
import GetPnk from "./pages/GetPnk";
import Home from "./pages/Home";
import DisputeResolver from "./pages/Resolver";
import { SentryRoutes } from "./utils/sentry";

const App: React.FC = () => {
Expand All @@ -32,13 +33,62 @@ const App: React.FC = () => {
<NewDisputeProvider>
<SentryRoutes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
<Route path="cases/*" element={<Cases />} />
<Route path="courts/*" element={<Courts />} />
<Route path="dashboard/:page/:order/:filter" element={<Dashboard />} />
<Route path="dispute-template" element={<DisputeTemplateView />} />
<Route path="resolver/*" element={<DisputeResolver />} />
<Route path="get-pnk/*" element={<GetPnk />} />
<Route
index
element={
<Suspense fallback={<Loader width={"48px"} height={"48px"} />}>
<Home />
</Suspense>
}
/>
<Route
path="cases/*"
element={
<Suspense fallback={<Loader width={"48px"} height={"48px"} />}>
<Cases />
</Suspense>
}
/>
<Route
path="courts/*"
element={
<Suspense fallback={<Loader width={"48px"} height={"48px"} />}>
<Courts />
</Suspense>
}
/>
<Route
path="dashboard/:page/:order/:filter"
element={
<Suspense fallback={<Loader width={"48px"} height={"48px"} />}>
<Dashboard />
</Suspense>
}
/>
<Route
path="dispute-template"
element={
<Suspense fallback={<Loader width={"48px"} height={"48px"} />}>
<DisputeTemplateView />
</Suspense>
}
/>
<Route
path="resolver/*"
element={
<Suspense fallback={<Loader width={"48px"} height={"48px"} />}>
<DisputeResolver />
</Suspense>
}
/>
<Route
path="get-pnk/*"
element={
<Suspense fallback={<Loader width={"48px"} height={"48px"} />}>
<GetPnk />
</Suspense>
}
/>
<Route path="*" element={<h1>Justice not found here ¯\_( ͡° ͜ʖ ͡°)_/¯</h1>} />
</Route>
</SentryRoutes>
Expand Down
1 change: 1 addition & 0 deletions web/src/components/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const StyledKlerosIcon = styled(KlerosIcon)`
`;

const Container = styled.div<{ width?: Width; height?: Height }>`
margin: auto;
width: ${({ width }) => width ?? "100%"};
height: ${({ height }) => height ?? "100%"};
`;
Expand Down
1 change: 1 addition & 0 deletions web/src/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const StyledToastContainer = styled(ToastContainer)`
`;

const OutletContainer = styled.div`
display: flex;
flex: 1;
background-color: ${({ theme }) => theme.lightBackground};
`;
Expand Down
Loading