Skip to content

Commit c5e1753

Browse files
committed
docs: improve docs
1 parent 8900389 commit c5e1753

File tree

8 files changed

+87
-85
lines changed

8 files changed

+87
-85
lines changed

docs/components/JsonViewerPreview.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import type { JsonViewerProps } from '@textea/json-viewer'
1+
import type { JsonViewerProps, JsonViewerTheme } from '@textea/json-viewer'
22
import { JsonViewer } from '@textea/json-viewer'
3+
import { useTheme } from 'nextra-theme-docs'
34
import type { FC } from 'react'
45

56
export const JsonViewerPreview: FC<JsonViewerProps> = (props) => {
7+
const { theme, systemTheme } = useTheme()
8+
const currentTheme = (theme === 'system' ? systemTheme : theme) as JsonViewerTheme
69
return (
710
<JsonViewer
8-
theme='auto'
11+
theme={currentTheme}
912
style={{
1013
fontSize: 12
1114
}}

docs/next.config.js

-24
This file was deleted.

docs/next.config.mjs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import nextra from 'nextra'
2+
3+
const withNextra = nextra({
4+
theme: 'nextra-theme-docs',
5+
themeConfig: './theme.config.js',
6+
staticImage: true,
7+
defaultShowCopyCode: true
8+
})
9+
10+
/** @type {import('next').NextConfig} */
11+
const nextConfig = {
12+
reactStrictMode: true,
13+
optimizeFonts: true,
14+
images: {
15+
domains: ['i.imgur.com', 'www.netlify.com']
16+
},
17+
transpilePackages: ['@textea/json-viewer']
18+
}
19+
20+
export default withNextra(nextConfig)

docs/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"@types/node": "^18.15.3",
2323
"@types/react": "^18.0.28",
2424
"@types/react-dom": "^18.0.11",
25-
"next-transpile-modules": "^10.0.0",
2625
"typescript": "^5.0.2"
2726
}
2827
}

docs/pages/full/index.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ const IndexPage: FC = () => {
128128
}))
129129
}
130130
const id = setInterval(loop, 1000)
131-
return () => {
132-
clearInterval(id)
133-
}
131+
return () => clearInterval(id)
134132
}, [])
135133
return (
136134
<div>
@@ -279,6 +277,9 @@ const IndexPage: FC = () => {
279277
}, []
280278
)
281279
}
280+
style={{
281+
paddingLeft: 16
282+
}}
282283
/>
283284
</div>
284285
)

docs/pages/index.mdx

+56-27
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,53 @@ import { JsonViewerPreview } from '../components/JsonViewerPreview'
44

55
# @textea/json-viewer
66

7-
### NPM
7+
## Overview
88

9-
```shell
10-
npm install @textea/json-viewer
11-
```
9+
> **Makes data visualization a breeze!**
1210
13-
### Yarn
11+
`@textea/json-viewer` allows you to display JSON data in a readable and user-friendly format. But it's not just limited to JSON - you can use it to view **ANY** kind of data. The library is highly customizable and supports 100% TypeScript, making it easy to modify and tailor to your specific needs.
1412

15-
```shell
16-
yarn add @textea/json-viewer
17-
```
13+
## Getting Started
1814

19-
### PNPM
15+
### Installation
2016

2117
```shell
18+
npm install @textea/json-viewer
19+
# or
20+
yarn add @textea/json-viewer
21+
# or
2222
pnpm add @textea/json-viewer
2323
```
2424

25+
You can also use it directly from a CDN:
26+
27+
```html {5,8-12} filename="index.html"
28+
<!DOCTYPE html>
29+
<html lang="en">
30+
<body>
31+
<div id="json-viewer"></div>
32+
<script src="https://cdn.jsdelivr.net/npm/@textea/json-viewer"></script>
33+
34+
<script>
35+
new JsonViewer({
36+
value: {
37+
/* ... */
38+
}
39+
}).render('#json-viewer')
40+
</script>
41+
</body>
42+
</html>
43+
```
44+
2545
### Basic Example
2646

2747
```tsx
2848
import { JsonViewer } from '@textea/json-viewer'
2949

30-
const object = { /* my json object */ }
31-
const Component = () => (<JsonViewer value={object}/>)
50+
const object = {
51+
/* my json object */
52+
}
53+
const Component = () => <JsonViewer value={object} />
3254
```
3355

3456
<JsonViewerPreview
@@ -37,13 +59,26 @@ const Component = () => (<JsonViewer value={object}/>)
3759
number: 1,
3860
float: 114.514,
3961
bigint: 10086n,
40-
object: {
41-
value: new Date('December 17, 1995 03:24:00')
42-
}
62+
object: { a: undefined },
63+
map: new Map([
64+
['oh no', null],
65+
['birth', new Date('December 17, 1995 03:24:00')]
66+
])
4367
}}
4468
/>
4569

46-
### Props
70+
### Full Example
71+
72+
<br />
73+
<Button variant="contained" component={Link} href="/full">
74+
DEMO
75+
</Button>
76+
77+
Check the [source code](https://github.com./TexteaInc/json-viewer/blob/main/docs/pages/full/index.tsx) for more details.
78+
79+
## Configuration
80+
81+
### Options
4782

4883
| Name | Type | Default | Description |
4984
| ---------------------------- | ------------------------------------------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
@@ -57,7 +92,7 @@ const Component = () => (<JsonViewer value={object}/>)
5792
| `valueTypes` | `ValueTypes` | - | Customize value types. |
5893
| `onChange` | `(path, oldVal, newVal) => void` | - | Callback when value changed. |
5994
| `onCopy` | `(path, value) => void` | - | Callback when value copied. |
60-
| `onSelect` | `(path, value) => void` | - | Callback when value selected. |
95+
| `onSelect` | `(path, value) => void` | - | Callback when value selected. |
6196
| `enableClipboard` | `boolean` | `true` | Whether enable clipboard feature. |
6297
| `editable` | `boolean` \|<br />`(path, currentValue) => boolean` | `false` | Whether enable edit feature. You can pass a function to customize the result. |
6398
| `defaultInspectDepth` | `number` | 5 | Default inspect depth for nested objects.<br /><br />_\* If the number is set too large, it could result in performance issues._ |
@@ -69,7 +104,7 @@ const Component = () => (<JsonViewer value={object}/>)
69104
| `displayDataTypes` | `boolean` | `true` | Whether display data type labels. |
70105
| `displayObjectSize` | `boolean` | `true` | Whether display the size of array and object. |
71106

72-
#### Props mapping from `react-json-view`
107+
#### Mapping from [`mac-s-g/react-json-view`](https://github.com./mac-s-g/react-json-view)
73108

74109
| Name | Type | Alternative |
75110
| ----------- | --------- | ------------------------------------------------- |
@@ -79,19 +114,13 @@ const Component = () => (<JsonViewer value={object}/>)
79114

80115
### Type Declaration
81116

82-
see [src/type.ts](https://github.com./TexteaInc/json-viewer/blob/main/src/type.ts)
83-
84-
### Full Example
85-
86-
<Link href="/full">
87-
<Button>
88-
View ->
89-
</Button>
90-
</Link>
117+
See [src/type.ts](https://github.com./TexteaInc/json-viewer/blob/main/src/type.ts)
91118

92119
## Contributors
93120

94-
<a href="https://github.com./TexteaInc/json-viewer/graphs/contributors"><img src="https://opencollective.com/json-viewer/contributors.svg?width=890&button=false" /></a>
121+
<a href="https://github.com./TexteaInc/json-viewer/graphs/contributors">
122+
<img src="https://opencollective.com/json-viewer/contributors.svg?width=890&button=false" />
123+
</a>
95124

96125
## Acknowledge
97126

docs/theme.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export default {
22
logo: '@textea/json-viewer',
3+
docsRepositoryBase: 'https://github.com./TexteaInc/json-viewer/tree/main/docs',
34
project: {
45
link: 'https://github.com./TexteaInc/json-viewer'
56
},

yarn.lock

+1-28
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,6 @@ __metadata:
16841684
"@types/react-dom": ^18.0.11
16851685
gray-matter: ^4.0.3
16861686
next: ^13.2.4
1687-
next-transpile-modules: ^10.0.0
16881687
nextra: ^2.2.19
16891688
nextra-theme-docs: ^2.2.19
16901689
react: ^18.2.0
@@ -3448,16 +3447,6 @@ __metadata:
34483447
languageName: node
34493448
linkType: hard
34503449

3451-
"enhanced-resolve@npm:^5.10.0":
3452-
version: 5.12.0
3453-
resolution: "enhanced-resolve@npm:5.12.0"
3454-
dependencies:
3455-
graceful-fs: ^4.2.4
3456-
tapable: ^2.2.0
3457-
checksum: bf3f787facaf4ce3439bef59d148646344e372bef5557f0d37ea8aa02c51f50a925cd1f07b8d338f18992c29f544ec235a8c64bcdb56030196c48832a5494174
3458-
languageName: node
3459-
linkType: hard
3460-
34613450
"entities@npm:^4.4.0":
34623451
version: 4.4.0
34633452
resolution: "entities@npm:4.4.0"
@@ -4636,7 +4625,7 @@ __metadata:
46364625
languageName: node
46374626
linkType: hard
46384627

4639-
"graceful-fs@npm:^4.1.6, graceful-fs@npm:^4.2.0, graceful-fs@npm:^4.2.10, graceful-fs@npm:^4.2.4, graceful-fs@npm:^4.2.6":
4628+
"graceful-fs@npm:^4.1.6, graceful-fs@npm:^4.2.0, graceful-fs@npm:^4.2.10, graceful-fs@npm:^4.2.6":
46404629
version: 4.2.11
46414630
resolution: "graceful-fs@npm:4.2.11"
46424631
checksum: ac85f94da92d8eb6b7f5a8b20ce65e43d66761c55ce85ac96df6865308390da45a8d3f0296dd3a663de65d30ba497bd46c696cc1e248c72b13d6d567138a4fc7
@@ -7056,15 +7045,6 @@ __metadata:
70567045
languageName: node
70577046
linkType: hard
70587047

7059-
"next-transpile-modules@npm:^10.0.0":
7060-
version: 10.0.0
7061-
resolution: "next-transpile-modules@npm:10.0.0"
7062-
dependencies:
7063-
enhanced-resolve: ^5.10.0
7064-
checksum: 3300fc7081f63b2c9487588db7cbe718f209dfd2111adec22d9c8af0e3c8ade2d95fd45f91e045546d78d98cafc78a49431de9a623360d33831b5e694bf007c9
7065-
languageName: node
7066-
linkType: hard
7067-
70687048
"next@npm:^13.2.4":
70697049
version: 13.2.4
70707050
resolution: "next@npm:13.2.4"
@@ -8957,13 +8937,6 @@ __metadata:
89578937
languageName: node
89588938
linkType: hard
89598939

8960-
"tapable@npm:^2.2.0":
8961-
version: 2.2.1
8962-
resolution: "tapable@npm:2.2.1"
8963-
checksum: 3b7a1b4d86fa940aad46d9e73d1e8739335efd4c48322cb37d073eb6f80f5281889bf0320c6d8ffcfa1a0dd5bfdbd0f9d037e252ef972aca595330538aac4d51
8964-
languageName: node
8965-
linkType: hard
8966-
89678940
"tar@npm:^6.1.11, tar@npm:^6.1.2":
89688941
version: 6.1.13
89698942
resolution: "tar@npm:6.1.13"

0 commit comments

Comments
 (0)