Skip to content

Commit 370eb83

Browse files
committed
update
1 parent 22e13fd commit 370eb83

File tree

1 file changed

+46
-5
lines changed

1 file changed

+46
-5
lines changed

example/example.html

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,35 @@
2020
color: #aaa;
2121
font-size:14px;
2222
font-family: monospace;
23+
margin-left: 6px;
24+
}
25+
.react-json-view {
26+
padding: 4px 6px;
27+
border-radius: 3px;
28+
display: inline-block;
2329
}
24-
.example {padding: 5px;}
2530
</style>
2631
</head>
2732
<body>
2833
<div id="app-container">
2934
<div class="code-comment">// example 1: JSON object</div>
3035
<div class="example" id="example1"></div>
3136
<br />
32-
<div class="code-comment">// example 2: array input</div>
37+
<div class="code-comment">// example 2: array input with "monokai" theme</div>
3338
<div class="example" id="example2"></div>
3439
<br />
3540
<div class="code-comment">// example 3: collapsed by default</div>
3641
<div class="example" id="example3"></div>
42+
<br />
43+
<div class="code-comment">// example 4: JSON with "chalk" theme</div>
44+
<div class="example" id="example4"></div>
3745
</div>
3846
<script src="https://unpkg.com/react@15/dist/react.js"></script>
3947
<script src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
4048
<script src="https://unpkg.com/react-json-view@latest/dist/main.js"></script>
4149
<style>
4250
#app-container>div{
43-
margin-bottom: 15px;
51+
margin-bottom: 5px;
4452
}
4553
</style>
4654
<script type="text/javascript">
@@ -76,13 +84,14 @@
7684
);
7785

7886
/*-----------EXAMPLE 2-----------*/
79-
//an example ARRAY
87+
//an example ARRAY with "monokai" theme
8088
var test_array = [
8189
'you can also display arrays!', 1, 2, 3, {'pretty_cool': true}
8290
];
8391
var jsonView2 = new reactJsonView.default({
8492
src: test_array,
85-
name: 'array-example'
93+
name: 'array-example',
94+
theme: 'monokai'
8695
});
8796
ReactDOM.render(
8897
jsonView2.render(),
@@ -112,6 +121,38 @@
112121
jsonView3.render(),
113122
document.getElementById('example3')
114123
);
124+
125+
/*-----------EXAMPLE 4-----------*/
126+
//some test JSON with "chalk" theme
127+
var test_json = {
128+
test: 'this is a test string',
129+
another_sibling: 42,
130+
how_will_array_do: [1, 2, 3, 'test'],
131+
how_will_floats_do: -2.757,
132+
parent: {
133+
sibling1: true,
134+
sibling2: false,
135+
sibling3: null,
136+
'last-sibling': {
137+
grand_child: NaN,
138+
'grand-child-func': (a) => {
139+
let b = a*a;
140+
return b;
141+
}
142+
}
143+
},
144+
string_number: "1234"
145+
};
146+
147+
// reactJsonView is a global variable
148+
var jsonView4 = new reactJsonView.default({
149+
src: test_json,
150+
theme: "chalk"
151+
});
152+
ReactDOM.render(
153+
jsonView4.render(),
154+
document.getElementById('example4')
155+
);
115156
</script>
116157
</body>
117158
</html>

0 commit comments

Comments
 (0)