-
Notifications
You must be signed in to change notification settings - Fork 110
/
index.html
128 lines (120 loc) · 3.47 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<html>
<head>
<script defer src="dist/json-formatter.umd.js" charset="UTF-8"></script>
<script defer src="demo/index.js" charset="UTF-8"></script>
<style type="text/css">
body {
max-width: 800px;
margin: 20px auto;
font-family: sans-serif;
}
.gh {
text-align: right;
}
.result h3 + div {
border: 1px solid lightgray;
border-radius: 5px;
padding: 10px;
}
h1 code {
font-size: 2em;
}
pre {
font-size: 1.5rem;
background: #efefef;
padding: 1em;
}
textarea {
font-family: monospace;
}
</style>
</head>
<body>
<div class="intro">
<div class="gh">
<iframe
src="http://ghbtns.com/github-btn.html?user=mohsen1&repo=json-formatter-js&type=watch&size=large&count=true"
frameborder="0"
width="170"
height="30"
scrolling="0"
>
</iframe>
<iframe
src="http://ghbtns.com/github-btn.html?user=mohsen1&repo=json-formatter-js&type=fork&size=large&count=true"
frameborder="0"
width="170"
height="30"
scrolling="0"
>
</iframe>
</div>
<h1><code>JSONFormatter</code></h1>
<p>Render JSON objects in HTML with a <b>collapsible</b> navigation.</p>
<p>
<b
><a href="https://github.com/mohsen1/json-formatter-js"
>JSON Formatter project on GitHub</a
></b
>
</p>
</div>
<h2>Usage</h2>
<div class="usage">
<p>Simple usage in ES6</p>
<!-- HTML generated using hilite.me
import JSONFormatter from 'json-formatter-js'
const myJSON = {ans: 42};
const formatter = new JSONFormatter(myJSON);
document.body.appendChild(formatter.render());
-->
<div
style="
background: #f0f3f3;
overflow: auto;
width: auto;
border: solid gray;
border-width: 0.1em 0.1em 0.1em 0.8em;
padding: 0.2em 0.6em;
"
>
<pre
style="margin: 0; line-height: 125%"
><span style="color: #006699; font-weight: bold">import</span> JSONFormatter from <span style="color: #CC3300">'json-formatter-js'</span>
<span style="color: #006699; font-weight: bold">const</span> myJSON <span style="color: #555555">=</span> {ans<span style="color: #555555">:</span> <span style="color: #FF6600">42</span>};
<span style="color: #006699; font-weight: bold">const</span> formatter <span style="color: #555555">=</span> <span style="color: #006699; font-weight: bold">new</span> JSONFormatter(myJSON);
<span style="color: #336666">document</span>.body.appendChild(formatter.render());
</pre>
</div>
</div>
<h2>Playground</h2>
<div class="playground">
<p>
Updating the JSON value in this textarea renders a new formatter on the
right.
</p>
<table>
<tr>
<td>
<textarea id="live" name="" id="" cols="30" rows="10">
{"foo": 42}</textarea
>
</td>
<td>
<div id="live-result"></div>
</td>
</tr>
<tr>
<p>
<input type="checkbox" id="hoverPreviewEnabled" />
<label for="hoverPreviewEnabled"
><code>hoverPreviewEnabled</code></label
>
</p>
</tr>
</table>
</div>
<h2>Examples</h2>
<div class="result"></div>
</body>
</html>