Skip to content

Commit e2f266f

Browse files
committed
feat: add basic example
1 parent 16a61cd commit e2f266f

File tree

8 files changed

+516
-8
lines changed

8 files changed

+516
-8
lines changed

.gitignore

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
.yarn/*
2-
!.yarn/patches
3-
!.yarn/plugins
4-
!.yarn/releases
5-
!.yarn/sdks
6-
!.yarn/versions
1+
**/.yarn/*
2+
**/!.yarn/patches
3+
**/!.yarn/plugins
4+
**/!.yarn/releases
5+
**/!.yarn/sdks
6+
**/!.yarn/versions
77

88
# Swap the comments on the following lines if you don't wish to use zero-installs
99
# Documentation here: https://yarnpkg.com/features/zero-installs
@@ -14,3 +14,6 @@ dist
1414
tsconfig.tsbuildinfo
1515
.eslintcache
1616
node_modules
17+
18+
.next
19+
.vercel

examples/basic/next-env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.

examples/basic/next.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {
3+
reactStrictMode: true,
4+
optimizeFonts: true,
5+
experimental: {
6+
externalDir: true
7+
}
8+
}
9+
10+
const withTM = require('next-transpile-modules')([], {
11+
resolveSymlinks: true,
12+
debug: false
13+
})
14+
15+
module.exports = withTM(nextConfig)

examples/basic/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "@textea/json-viewer-example-basic",
3+
"private": true,
4+
"scripts": {
5+
"dev": "next dev -p 3020",
6+
"build": "next build",
7+
"start": "next start",
8+
"lint": "next lint"
9+
},
10+
"dependencies": {
11+
"next": "^12.2.4",
12+
"react": "^18.2.0",
13+
"react-dom": "^18.2.0"
14+
},
15+
"devDependencies": {
16+
"@types/react": "^18.0.17",
17+
"@types/react-dom": "^18.0.6",
18+
"next-transpile-modules": "^9.0.0",
19+
"typescript": "^4.7.4"
20+
}
21+
}

examples/basic/pages/index.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type React from 'react'
2+
import JsonViewer from '@textea/json-viewer'
3+
4+
const example = {
5+
string: 'this is a test string',
6+
integer: 42,
7+
array: [1, 2, 3, 'test', NaN],
8+
float: 3.14159,
9+
undefined: undefined,
10+
object: {
11+
'first-child': true,
12+
'second-child': false,
13+
'last-child': null
14+
},
15+
string_number: '1234',
16+
date: new Date()
17+
}
18+
19+
const IndexPage: React.FC = () => {
20+
return (
21+
<div>
22+
<JsonViewer src={example}/>
23+
</div>
24+
)
25+
}
26+
27+
export default IndexPage

examples/basic/tsconfig.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"extends": "@textea/dev-kit/config/tsconfig.root.json",
3+
"compilerOptions": {
4+
"baseUrl": ".",
5+
"paths": {
6+
"@textea/json-viewer": ["../../src/index"]
7+
},
8+
"jsx": "preserve",
9+
"jsxImportSource": "react",
10+
"noEmit": true
11+
},
12+
"include": [
13+
"next-env.d.ts",
14+
"**/*.ts",
15+
"**/*.tsx"
16+
],
17+
"exclude": [
18+
"node_modules"
19+
]
20+
}

0 commit comments

Comments
 (0)