You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -13,8 +12,8 @@ A collapsable tree view for JSON. This package has some similarites with [vue-js
13
12
14
13
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.
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.
20
19
@@ -32,17 +31,17 @@ yarn add vue-json-component
32
31
### Import Locally
33
32
34
33
```js
35
-
import { JSONView } from"vue-json-component";
34
+
import { JSONView } from'vue-json-component';
36
35
exportdefaultVue.extend({
37
-
components: { "json-view": JSONView }
36
+
components: { 'json-view': JSONView }
38
37
});
39
38
```
40
39
41
40
### Import Globally
42
41
43
42
```js
44
-
importJSONViewfrom"vue-json-component";
45
-
Vue.use(JSONView)
43
+
importJSONViewfrom'vue-json-component';
44
+
Vue.use(JSONView);
46
45
```
47
46
48
47
### Use
@@ -56,39 +55,55 @@ Vue.use(JSONView)
56
55
57
56
### Customize
58
57
59
-
The font size and font family are inherited from the page.
58
+
The font size and font family are inherited from the page. The component now supports dark mode, and has switched to a CSS Variables based implementation.
60
59
61
60
#### Props
62
61
63
-
***data** (JSON): The valid JSON object you want rendered as a tree.
64
-
***rootKey** (String): The name of the top level root key; defaults to root.
65
-
***maxDepth** (Number): Depth of the tree that is open at first render; defaults to 1.
66
-
***styles** (Object): Override the color styles. Defaults shown below.
67
-
68
-
```js
69
-
constdefaultStyles= {
70
-
key:"#002b36",
71
-
valueKey:"#073642",
72
-
string:"#268bd2",
73
-
number:"#2aa198",
74
-
boolean:"#cb4b16",
75
-
null:"#6c71c4",
76
-
arrowSize:"6px"
77
-
};
62
+
-**data** (JSON): The valid JSON object you want rendered as a tree.
63
+
-**rootKey** (String): The name of the top level root key; defaults to root.
64
+
-**maxDepth** (Number): Depth of the tree that is open at first render; defaults to 1.
65
+
-**colorScheme (New)** (String): Setting to 'dark' enables dark mode.
66
+
67
+
#### Styles
68
+
69
+
⚠️ This API has changed to CSS Variables. All of these can be customized for light _and_ dark mode as is documented below.
70
+
71
+
```css
72
+
--vjc-key-color: #0977e6;
73
+
--vjc-valueKey-color: #073642;
74
+
--vjc-string-color: #268bd2;
75
+
--vjc-number-color: #2aa198;
76
+
--vjc-boolean-color: #cb4b16;
77
+
--vjc-null-color: #6c71c4;
78
+
--vjc-arrow-size: 6px;
79
+
--vjc-arrow-color: #444;
80
+
--vjc-hover-color: rgba(0, 0, 0, 0.15);
78
81
```
79
82
80
83
### Example
84
+
81
85
```js
82
86
<template>
83
87
<json-view
84
88
:data="data"
85
89
rootKey="view"
86
90
:maxDepth="1"
87
-
:styles="{ key: '#0977e6' }"
91
+
class="customize"
88
92
/>
89
93
</template>
94
+
95
+
<style lang="scss" scoped>
96
+
.customize {
97
+
--vjc-valueKey-color: green;
98
+
}
99
+
.customize.dark {
100
+
--vjc-valueKey-color: red;
101
+
}
102
+
</style>
90
103
```
91
104
105
+
Note: your styles will need to be scoped to override the scoped CSS Variables in the component.
106
+
92
107
## Advanced Features
93
108
94
109
### Selected Item Events
@@ -104,9 +119,9 @@ You can allow users to click elements, and receive an event when this occurs. Th
0 commit comments