Skip to content

Commit

Permalink
feat: add basic example
Browse files Browse the repository at this point in the history
  • Loading branch information
Yell0wflash committed Aug 11, 2022
1 parent 76f7b73 commit 0146150
Show file tree
Hide file tree
Showing 8 changed files with 516 additions and 8 deletions.
15 changes: 9 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
**/.yarn/*
**/!.yarn/patches
**/!.yarn/plugins
**/!.yarn/releases
**/!.yarn/sdks
**/!.yarn/versions

# Swap the comments on the following lines if you don't wish to use zero-installs
# Documentation here: https://yarnpkg.com/features/zero-installs
Expand All @@ -14,3 +14,6 @@ dist
tsconfig.tsbuildinfo
.eslintcache
node_modules

.next
.vercel
5 changes: 5 additions & 0 deletions examples/basic/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
15 changes: 15 additions & 0 deletions examples/basic/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
optimizeFonts: true,
experimental: {
externalDir: true
}
}

const withTM = require('next-transpile-modules')([], {
resolveSymlinks: true,
debug: false
})

module.exports = withTM(nextConfig)
21 changes: 21 additions & 0 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@textea/json-viewer-example-basic",
"private": true,
"scripts": {
"dev": "next dev -p 3020",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"next": "^12.2.4",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"next-transpile-modules": "^9.0.0",
"typescript": "^4.7.4"
}
}
27 changes: 27 additions & 0 deletions examples/basic/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type React from 'react'
import JsonViewer from '@textea/json-viewer'

const example = {
string: 'this is a test string',
integer: 42,
array: [1, 2, 3, 'test', NaN],
float: 3.14159,
undefined: undefined,
object: {
'first-child': true,
'second-child': false,
'last-child': null
},
string_number: '1234',
date: new Date()
}

const IndexPage: React.FC = () => {
return (
<div>
<JsonViewer src={example}/>
</div>
)
}

export default IndexPage
20 changes: 20 additions & 0 deletions examples/basic/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "@textea/dev-kit/config/tsconfig.root.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@textea/json-viewer": ["../../src/index"]
},
"jsx": "preserve",
"jsxImportSource": "react",
"noEmit": true
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
]
}
Loading

0 comments on commit 0146150

Please sign in to comment.