Skip to content

Commit 2fd219a

Browse files
authored
add codepod app to desktop-ui (#514)
1 parent 66118aa commit 2fd219a

File tree

3 files changed

+349
-55
lines changed

3 files changed

+349
-55
lines changed

apps/desktop-ui/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13+
"@apollo/client": "^3.8.3",
1314
"@codepod/ui": "workspace:^",
15+
"@emotion/react": "^11.11.1",
16+
"@emotion/styled": "^11.11.0",
17+
"@mui/icons-material": "^5.10.9",
18+
"@mui/material": "^5.14.5",
19+
"notistack": "^2.0.8",
1420
"react": "^18.2.0",
15-
"react-dom": "^18.2.0"
21+
"react-dom": "^18.2.0",
22+
"react-router-dom": "^6.4.2"
1623
},
1724
"devDependencies": {
1825
"@types/node": "^20.5.9",

apps/desktop-ui/src/App.tsx

Lines changed: 93 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,98 @@
11
import "./App.css";
2+
import "@codepod/ui/src/custom.css";
23

3-
import { Test } from "@codepod/ui";
4+
import {
5+
createBrowserRouter,
6+
createRoutesFromElements,
7+
Route,
8+
RouterProvider,
9+
} from "react-router-dom";
410

5-
function App() {
6-
return <Test />;
11+
import { createTheme, ThemeProvider } from "@mui/material/styles";
12+
13+
import { Dashboard, Repo, Test, Profile, Docs } from "@codepod/ui";
14+
15+
import { Header, Footer } from "@codepod/ui";
16+
import { AuthProvider } from "@codepod/ui";
17+
18+
import Box from "@mui/material/Box";
19+
import { SnackbarProvider } from "notistack";
20+
21+
const yjsWsUrl = import.meta.env.VITE_APP_YJS_WS_URL;
22+
const apiUrl = import.meta.env.VITE_APP_API_URL;
23+
const spawnerApiUrl = import.meta.env.VITE_APP_SPAWNER_API_URL;
24+
25+
if (!yjsWsUrl) {
26+
throw new Error("VITE_APP_YJS_WS_URL is not defined");
27+
}
28+
if (!apiUrl) {
29+
throw new Error("VITE_APP_API_URL is not defined");
730
}
31+
if (!spawnerApiUrl) {
32+
throw new Error("VITE_APP_RUNTIME_API_URL is not defined");
33+
}
34+
35+
const theme = createTheme({
36+
typography: {
37+
button: {
38+
textTransform: "none",
39+
},
40+
},
41+
});
42+
43+
type NormalLayoutProps = {
44+
currentPage?: string | null;
45+
children: React.ReactNode;
46+
};
847

9-
export default App;
48+
const NormalLayout: React.FC<NormalLayoutProps> = ({
49+
currentPage,
50+
children,
51+
}) => {
52+
return (
53+
<Box>
54+
<Header currentPage={currentPage} />
55+
<Box pt="50px">{children}</Box>
56+
{/* <Footer /> */}
57+
</Box>
58+
);
59+
};
60+
61+
const router = createBrowserRouter([
62+
{
63+
path: "repo/:id",
64+
element: (
65+
<Box height="100vh" width="100%" boxSizing={"border-box"}>
66+
<Repo yjsWsUrl={yjsWsUrl} />
67+
</Box>
68+
),
69+
},
70+
{
71+
path: "test",
72+
element: (
73+
<NormalLayout>
74+
<Test />
75+
</NormalLayout>
76+
),
77+
},
78+
{
79+
path: "/",
80+
element: (
81+
<NormalLayout>
82+
<Dashboard />
83+
</NormalLayout>
84+
),
85+
},
86+
]);
87+
88+
export default function App() {
89+
return (
90+
<ThemeProvider theme={theme}>
91+
<AuthProvider apiUrl={apiUrl} spawnerApiUrl={spawnerApiUrl}>
92+
<SnackbarProvider maxSnack={5}>
93+
<RouterProvider router={router} />
94+
</SnackbarProvider>
95+
</AuthProvider>
96+
</ThemeProvider>
97+
);
98+
}

0 commit comments

Comments
 (0)