2
2
3
3
Simple JSON viewer component, for Vue.js 2
4
4
5
- ## Installing:
5
+ - [ Installing] ( #Installing )
6
+ - [ Example] ( #Example )
7
+ - [ Options] ( #Options )
8
+ - [ Theming] ( #Theming )
9
+
10
+ ## Installing
6
11
Using npm:
7
12
```
8
- $ npm install vue-json-viewer
13
+ $ npm install vue-json-viewer --save
9
14
```
10
15
11
16
Using yarn:
12
17
```
13
18
$ yarn add vue-json-viewer
14
19
```
15
20
16
- ## Example:
21
+ ## Example
17
22
18
23
``` html
19
24
<json-viewer :value =" jsonData" ></json-viewer >
@@ -103,11 +108,11 @@ new Vue({
103
108
}
104
109
})
105
110
```
106
- ## Result:
111
+ ### Preview
107
112
![ preview] ( ./example/preview.png )
108
113
109
114
110
- ## Options:
115
+ ## Options
111
116
112
117
| Property | Description | Default |
113
118
| ----------- | :------------- | ----------- |
@@ -117,3 +122,61 @@ new Vue({
117
122
| ` sort ` | Sort keys before displaying | ` false ` |
118
123
| ` boxed ` | Add a fancy "boxed" style to component | ` false ` |
119
124
| ` theme ` | Add a custom CSS class for theming purposes | ` jv-light ` |
125
+
126
+ ## Theming
127
+
128
+ To create custom theme, (e.g. ` my-awesome-json-theme ` ), in two easy steps:
129
+ 1 . add ` theme="my-awesome-json-theme" ` to the JsonViewer component
130
+ 2 . copy-pasta and customize this SCSS template:
131
+
132
+ ``` scss
133
+ // values are default one from jv-light template
134
+ .my-awesome-json-theme {
135
+ background : #fff ;
136
+ white-space : nowrap ;
137
+ color : #525252 ;
138
+ font-size : 14px ;
139
+ font-family : Consolas, Menlo, Courier , monospace ;
140
+
141
+ .jv-ellipsis {
142
+ color : #999 ;
143
+ background-color : #eee ;
144
+ display : inline-block ;
145
+ line-height : 0.9 ;
146
+ font-size : 0.9em ;
147
+ padding : 0px 4px 2px 4px ;
148
+ border-radius : 3px ;
149
+ vertical-align : 2px ;
150
+ cursor : pointer ;
151
+ user-select : none ;
152
+ }
153
+ .jv-button { color : #49b3ff }
154
+ .jv-key { color : #111111 }
155
+ .jv-item {
156
+ & .jv-array { color : #111111 }
157
+ & .jv-boolean { color : #fc1e70 }
158
+ & .jv-function { color : #067bca }
159
+ & .jv-number { color : #fc1e70 }
160
+ & .jv-object { color : #111111 }
161
+ & .jv-undefined { color : #e08331 }
162
+ & .jv-string {
163
+ color : #42b983 ;
164
+ word-break : break-word ;
165
+ white-space : normal ;
166
+ }
167
+ }
168
+ .jv-code {
169
+ .jv-toggle {
170
+ & :before {
171
+ padding : 0px 2px ;
172
+ border-radius : 2px ;
173
+ }
174
+ & :hover {
175
+ & :before {
176
+ background : #eee ;
177
+ }
178
+ }
179
+ }
180
+ }
181
+ }
182
+ ```
0 commit comments