Skip to content

Commit 393fd56

Browse files
committed
feat: json-view
1 parent 74eb3f5 commit 393fd56

7 files changed

Lines changed: 1827 additions & 45 deletions

File tree

packages/web/package.json

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,31 @@
1010
"preview": "rsbuild preview"
1111
},
1212
"dependencies": {
13+
"@mantine/carousel": "^9.4.1",
14+
"@mantine/charts": "^9.4.1",
15+
"@mantine/code-highlight": "^9.4.1",
16+
"@mantine/core": "^9.4.1",
17+
"@mantine/dates": "^9.4.1",
18+
"@mantine/dropzone": "^9.4.1",
19+
"@mantine/form": "^9.4.1",
20+
"@mantine/hooks": "^9.4.1",
21+
"@mantine/modals": "^9.4.1",
22+
"@mantine/notifications": "^9.4.1",
23+
"@mantine/nprogress": "^9.4.1",
24+
"@mantine/spotlight": "^9.4.1",
25+
"@mantine/tiptap": "^9.4.1",
26+
"@tiptap/extension-link": "^3.27.1",
27+
"@tiptap/pm": "^3.27.1",
28+
"@tiptap/react": "^3.27.1",
29+
"@tiptap/starter-kit": "^3.27.1",
30+
"dayjs": "^1.11.21",
31+
"embla-carousel": "^8.6.0",
32+
"embla-carousel-react": "^8.6.0",
1333
"react": "^19.2.7",
14-
"react-dom": "^19.2.7"
34+
"react-dom": "^19.2.7",
35+
"react-json-view": "^1.21.3",
36+
"react-router": "^8.1.0",
37+
"recharts": "^3.9.2"
1538
},
1639
"devDependencies": {
1740
"@rsbuild/core": "^2.1.4",
@@ -20,6 +43,10 @@
2043
"@types/node": "catalog:",
2144
"@types/react": "^19.2.17",
2245
"@types/react-dom": "^19.2.3",
46+
"postcss": "^8.5.16",
47+
"postcss-load-config": "^6.0.1",
48+
"postcss-preset-mantine": "^1.18.0",
49+
"postcss-simple-vars": "^7.0.1",
2350
"tailwindcss": "catalog:",
2451
"typescript": "catalog:"
2552
}

packages/web/postcss.config.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/** @type {import('postcss-load-config').Config} */
2+
const config = {
3+
plugins: {
4+
'postcss-preset-mantine': {},
5+
'postcss-simple-vars': {
6+
variables: {
7+
'mantine-breakpoint-xs': '36em',
8+
'mantine-breakpoint-sm': '48em',
9+
'mantine-breakpoint-md': '62em',
10+
'mantine-breakpoint-lg': '75em',
11+
'mantine-breakpoint-xl': '88em',
12+
},
13+
},
14+
},
15+
};
16+
17+
export default config;

packages/web/src/app.tsx

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { useMemo, useState } from 'react';
2+
import { JsonInput } from '@mantine/core';
3+
import ReactJson from 'react-json-view';
4+
5+
export default function JsonView() {
6+
const [value, setValue] = useState('');
7+
const json = useMemo(() => {
8+
try {
9+
return JSON.parse(value);
10+
} catch {
11+
return {};
12+
}
13+
}, [value]);
14+
15+
return (
16+
<>
17+
<JsonInput value={value} onChange={setValue} />
18+
<ReactJson src={json} />
19+
</>
20+
);
21+
}

packages/web/src/index.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom/client';
3-
import App from './app';
3+
import { HashRouter, Routes, Route } from 'react-router';
4+
import { MantineProvider } from '@mantine/core';
5+
import Layout from './layout';
6+
import JsonView from './components/json-view';
7+
import '@mantine/core/styles.css';
8+
import './index.css';
49

510
const rootEl = document.getElementById('root');
611
if (rootEl) {
712
const root = ReactDOM.createRoot(rootEl);
813
root.render(
914
<React.StrictMode>
10-
<App />
15+
<MantineProvider>
16+
<HashRouter>
17+
<Routes>
18+
<Route path="/" element={<Layout />}>
19+
<Route path="json-view" element={<JsonView />} />
20+
</Route>
21+
</Routes>
22+
</HashRouter>
23+
</MantineProvider>
1124
</React.StrictMode>,
1225
);
1326
}

packages/web/src/layout.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Outlet, Link } from 'react-router';
2+
3+
export default function Layout() {
4+
return (
5+
<div className="h-screen">
6+
<Link to="/json-view">Json View</Link>
7+
<Outlet />
8+
</div>
9+
);
10+
}

0 commit comments

Comments
 (0)