Skip to content

Commit 12eb79a

Browse files
committed
changed some readme and adding github pages
1 parent 52c75a1 commit 12eb79a

File tree

12 files changed

+119
-80
lines changed

12 files changed

+119
-80
lines changed

.browserslistrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
current node
2+
last 2 versions and > 2%
3+
ie > 10

README.md

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,33 @@
44
**NOTE**
55

66
This is primary a fork of [vue-json-component](https://github.com/tylerkrupicka/vue-json-component) which was created to achieve quick Vue 3 support.
7+
78
---
89

910
[![npm version](https://badge.fury.io/js/vue3-json-component.svg)](https://badge.fury.io/js/vue3-json-component) [![TypeScript](https://badges.frapsoft.com/typescript/code/typescript.svg?v=101)](https://github.com/ellerbrock/typescript-badges/) ![npm bundle size](https://img.shields.io/bundlephobia/min/vue3-json-component.svg) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
1011

1112
[Demo](http://tylerkrupicka.com/vue3-json-component/)
1213

13-
A collapsable tree view for JSON. This package has some similarites with [vue-json-tree-view](https://github.com/michaelfitzhavey/vue-json-tree-view) so I'll address the differences below. I'm not contributing this back to that package because it would require breaking API changes, and the code is entirely different. **Contributions welcome!**
14+
A collapsable tree view for JSON. This package has some similarites with [vue-json-tree-view](https://github.com/michaelfitzhavey/vue-json-tree-view) so I'll
15+
address the differences below. I'm not contributing this back to that package because it would require breaking API changes, and the code is entirely
16+
different. **Contributions welcome!**
1417

1518
![demo image](https://user-images.githubusercontent.com/5761061/55198958-7fa16400-518e-11e9-8448-7cd028007920.png)
1619

1720
## Philosophy
1821

19-
This package has a few major improvements over predecessors: builds, styles, and customization. For builds, this package ships CommonJS, Module, and UNPKG builds with no dependencies. [vue-json-tree-view](https://github.com/michaelfitzhavey/vue-json-tree-view) bundles in lots of dependencies -- including lodash. I also export global Vue imports, local Vue imports, and TypeScript declarations. The code itself is about as small as it can be while being easy to follow.
22+
This package has a few major improvements over predecessors: builds, styles, and customization. For builds, this package ships CommonJS, Module, and UNPKG
23+
builds with no dependencies. [vue-json-tree-view](https://github.com/michaelfitzhavey/vue-json-tree-view) bundles in lots of dependencies -- including lodash. I
24+
also export global Vue imports, local Vue imports, and TypeScript declarations. The code itself is about as small as it can be while being easy to follow.
2025

2126
- [vue-json-tree-view (84KB)](https://bundlephobia.com/result?p=vue-json-tree-view@2.1.4)
2227
- [vue3-json-component (9KB)](https://bundlephobia.com/result?p=vue3-json-component@0.3.0)
2328

24-
The styles in this package are all scoped, with key colors still being customizable. There are no extra margins or overflow rules and text properties are all inherited from the page. This makes the view much easier to integrate anywhere you need it.
29+
The styles in this package are all scoped, with key colors still being customizable. There are no extra margins or overflow rules and text properties are all
30+
inherited from the page. This makes the view much easier to integrate anywhere you need it.
2531

26-
The default color theme is based on solarized, and font weights are modified to increase readability. The component uses semantic HTML elements and tries to be fully keyboard accessible.
32+
The default color theme is based on solarized, and font weights are modified to increase readability. The component uses semantic HTML elements and tries to be
33+
fully keyboard accessible.
2734

2835
## Usage
2936

@@ -37,24 +44,27 @@ yarn add vue3-json-component
3744
### Import Locally
3845

3946
```js
40-
import { JSONView } from 'vue3-json-component';
41-
export default Vue.extend({
42-
components: { 'json-view': JSONView }
43-
});
47+
import { defineComponent } from 'vue';
48+
import { JsonView } from 'vue3-json-component';
49+
50+
export default defineComponent({
51+
components: {JsonView}
52+
})
4453
```
4554

4655
### Import Globally
4756

4857
```js
49-
import JSONView from 'vue3-json-component';
50-
Vue.use(JSONView);
58+
import JsonView from 'vue3-json-component';
59+
60+
Vue.use(JsonView);
5161
```
5262

5363
### Use
5464

55-
```js
65+
```vue
5666
<template>
57-
<json-view :data="data" />
67+
<json-view :data="data" />
5868
</template>
5969
6070
```
@@ -88,22 +98,22 @@ The font size and font family are inherited from the page. The component now sup
8898

8999
### Example
90100

91-
```js
101+
```vue
92102
<template>
93-
<json-view
94-
:data="data"
95-
rootKey="view"
96-
:maxDepth="1"
97-
class="customize"
98-
/>
103+
<json-view
104+
:data="data"
105+
rootKey="view"
106+
:maxDepth="1"
107+
class="customize"
108+
/>
99109
</template>
100110
101111
<style lang="scss" scoped>
102-
.customize {
103-
--vjc-valueKey-color: green;
112+
.customize {
113+
--vjc-valueKey-color: green;
104114
}
105-
.customize.dark {
106-
--vjc-valueKey-color: red;
115+
.customize.dark {
116+
--vjc-valueKey-color: red;
107117
}
108118
</style>
109119
```
@@ -114,12 +124,13 @@ Note: your styles will need to be scoped to override the scoped CSS Variables in
114124

115125
### Selected Item Events
116126

117-
You can allow users to click elements, and receive an event when this occurs. The `selected` event will pass you the key, value, and path of the selected value. If you do not listen for the event, the styles will not indicate that values are clickable.
127+
You can allow users to click elements, and receive an event when this occurs. The `selected` event will pass you the key, value, and path of the selected value.
128+
If you do not listen for the event, the styles will not indicate that values are clickable.
118129

119-
```js
130+
```vue
120131
<json-view
121-
:data="data"
122-
v-on:selected="itemSelected"
132+
:data="data"
133+
@update:selected="itemSelected"
123134
/>
124135
```
125136

@@ -149,14 +160,9 @@ yarn serve
149160
yarn build
150161
```
151162

152-
### Lints and fixes files
153-
154-
```bash
155-
yarn lint
156-
```
157-
158163
## Contributing
159164

160-
Contributions are welcome via pull request. If you want to discuss your feature before committing development time, feel free to open an issue and we can refine the idea.
165+
Contributions are welcome via pull request. If you want to discuss your feature before committing development time, feel free to open an issue and we can refine
166+
the idea.
161167

162168
Thanks!

build/rollup.config.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import ttypescript from 'ttypescript';
1313
import typescript from 'rollup-plugin-typescript2';
1414
import minimist from 'minimist';
1515
import scss from 'rollup-plugin-scss';
16-
import postcss from 'postcss';
17-
import autoprefixer from 'autoprefixer';
1816

1917
// Get browserslist config and remove ie from es build targets
2018
const esbrowserslist = fs.readFileSync('./.browserslistrc')
@@ -46,13 +44,14 @@ const baseConfig = {
4644
replace: {
4745
'process.env.NODE_ENV': JSON.stringify('production')
4846
},
49-
vue : {},
47+
vue : {
48+
preprocessStyles: true
49+
},
5050
postVue: [
5151
resolve({
5252
extensions: [ '.js', '.jsx', '.ts', '.tsx', '.vue' ]
5353
}),
5454
scss({
55-
processor : () => postcss([ autoprefixer() ]),
5655
includePaths: [
5756
path.join(__dirname, '../../node_modules/'),
5857
'node_modules/'
@@ -101,7 +100,7 @@ if (!argv.format || argv.format === 'es') {
101100
input : 'src/entry.esm.ts',
102101
external,
103102
output : {
104-
file : 'dist/JSONView.esm.js',
103+
file : 'dist/JsonView.esm.js',
105104
format : 'esm',
106105
exports: 'named'
107106
},
@@ -140,9 +139,9 @@ if (!argv.format || argv.format === 'cjs') {
140139
external,
141140
output : {
142141
compact: true,
143-
file : 'dist/JSONView.ssr.js',
142+
file : 'dist/JsonView.ssr.js',
144143
format : 'cjs',
145-
name : 'JSONView',
144+
name : 'JsonView',
146145
exports: 'auto',
147146
globals
148147
},
@@ -163,9 +162,9 @@ if (!argv.format || argv.format === 'iife') {
163162
external,
164163
output : {
165164
compact: true,
166-
file : 'dist/JSONView.min.js',
165+
file : 'dist/JsonView.min.js',
167166
format : 'iife',
168-
name : 'JSONView',
167+
name : 'JsonView',
169168
exports: 'auto',
170169
globals
171170
},

deploy.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env sh
2+
# abort on errors
3+
set -e
4+
# build
5+
yarn run build
6+
# navigate into the build output directory
7+
cd dist
8+
# if you are deploying to a custom domain
9+
# echo 'www.example.com' > CNAME
10+
git init
11+
git add -A
12+
git commit -m 'deploy'
13+
git push -f git@github.com:razorness/vue3-json-component.git master:gh-pages
14+
cd -

dev/serve.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@
3030

3131
<script lang="ts">
3232
import { defineComponent } from 'vue';
33-
import JsonView from '@/JSONView.vue';
33+
import JsonView from '@/JsonView.vue';
3434
3535
export default defineComponent({
3636
name : 'ServeDev',
37-
components: {
38-
JsonView
39-
},
37+
components: { JsonView },
4038
data() {
4139
return {
4240
events: [] as string[],

package.json

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"type": "git",
2424
"url": "https://github.com/razorness/vue3-json-component.git"
2525
},
26-
"main": "dist/JSONView.ssr.js",
27-
"browser": "dist/JSONView.esm.js",
28-
"module": "dist/JSONView.esm.js",
29-
"unpkg": "dist/JSONView.min.js",
26+
"main": "dist/JsonView.ssr.js",
27+
"browser": "dist/JsonView.esm.js",
28+
"module": "dist/JsonView.esm.js",
29+
"unpkg": "dist/JsonView.min.js",
3030
"types": "dist/types/src/entry.esm.d.ts",
3131
"files": [
3232
"dist/*",
@@ -40,7 +40,8 @@
4040
"build:ssr": "cross-env NODE_ENV=production rollup --config build/rollup.config.js --format cjs",
4141
"build:es": "cross-env NODE_ENV=production rollup --config build/rollup.config.js --format es",
4242
"build:unpkg": "cross-env NODE_ENV=production rollup --config build/rollup.config.js --format iife",
43-
"postbuild": "rimraf ./dist/types/dev ./dist/types/src/entry.d.ts"
43+
"postbuild": "rimraf ./dist/types/dev ./dist/types/src/entry.d.ts",
44+
"deploy:gh-pages": "vue-cli-service build dev/serve.ts && ./deploy.sh"
4445
},
4546
"dependencies": {},
4647
"devDependencies": {
@@ -69,6 +70,7 @@
6970
"rollup-plugin-terser": "^7.0.2",
7071
"rollup-plugin-typescript2": "^0.30.0",
7172
"rollup-plugin-vue": "^6.0.0",
73+
"sass": "^1.37.0",
7274
"sass-loader": "^10.2.0",
7375
"ttypescript": "^1.5.12",
7476
"typescript": "^4.0.3",
@@ -89,10 +91,5 @@
8991
"singleQuote": true,
9092
"endOfLine": "lf",
9193
"useTabs": true
92-
},
93-
"browserslist": [
94-
"current node",
95-
"last 2 versions and > 2%",
96-
"ie > 10"
97-
]
94+
}
9895
}

src/JSONView.vue renamed to src/JsonView.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<script lang="ts">
1212
import { defineComponent, PropType } from 'vue';
13-
import JSONViewItem from './JSONViewItem.vue';
13+
import JsonViewItem from './JsonViewItem.vue';
1414
import { ColorMode, JsonData, JsonDataType, SelectedJsonData } from '@/types';
1515
1616
export default /*#__PURE__*/defineComponent({
@@ -35,9 +35,7 @@
3535
default : ColorMode.LIGHT
3636
}
3737
},
38-
components: {
39-
'json-view-item': JSONViewItem
40-
},
38+
components: { JsonViewItem },
4139
emits : [ 'update:selected' ],
4240
methods : {
4341
build(key: string, val: any, depth: number, path: string, includeKey: boolean): JsonData {
File renamed without changes.

src/entry.esm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { App, Plugin } from 'vue';
22

33
// Import vue component
4-
import component from '@/JSONView.vue';
4+
import component from '@/JsonView.vue';
55

66
// Define typescript interfaces for installable component
77
type InstallableComponent = typeof component & { install: Exclude<Plugin['install'], undefined> };
@@ -15,7 +15,7 @@ export default /*#__PURE__*/((): InstallableComponent => {
1515

1616
// Attach install function executed by Vue.use()
1717
installable.install = (app: App) => {
18-
app.component('JSONView', installable);
18+
app.component('JsonView', installable);
1919
};
2020
return installable;
2121
})();

src/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import JsonView from './JsonView.vue';
2+
import { Plugin } from '@vue/runtime-core';
3+
4+
5+
export default {
6+
install(app) {
7+
app.component('json-view', JsonView);
8+
}
9+
} as Plugin;
10+
11+
export { JsonView };
12+
export * from './types';

vue.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
publicPath: process.env.NODE_ENV === 'production'
3+
? '/vue3-json-component/'
4+
: '/'
5+
};

0 commit comments

Comments
 (0)