json-diff-viewer-component 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -4
- package/package.json +4 -1
- package/src/lib/styles.js +1 -2
- package/src/lib/viewer.js +1 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/metaory/json-diff-viewer-component/
|
|
2
|
+
<img src="https://raw.githubusercontent.com/metaory/json-diff-viewer-component/master/public/logo.svg" alt="logo" height="128" />
|
|
3
3
|
<h2>json-diff-viewer</h2>
|
|
4
4
|
<h5>
|
|
5
5
|
Compare JSON side-by-side, visually
|
|
@@ -8,13 +8,12 @@
|
|
|
8
8
|
A zero-dependency web component for visualizing JSON differences
|
|
9
9
|
<br>
|
|
10
10
|
with synchronized scrolling, collapsible nodes, and syntax highlighting
|
|
11
|
-
<br>
|
|
12
|
-
Perfect for debugging, API comparisons, and configuration diffs
|
|
13
11
|
</p>
|
|
14
|
-
<img src="https://raw.githubusercontent.com/metaory/json-diff-viewer-component/refs/heads/master/public/screenshot.png" alt="demo" width="80%" />
|
|
15
12
|
<h5>
|
|
16
13
|
<a href="https://metaory.github.io/json-diff-viewer-component/" target="_blank">metaory.github.io/json-diff-viewer-component</a>
|
|
17
14
|
</h5>
|
|
15
|
+
<img src="https://raw.githubusercontent.com/metaory/json-diff-viewer-component/master/public/screenshot.jpg" alt="demo" width="80%" />
|
|
16
|
+
<img src="https://raw.githubusercontent.com/metaory/json-diff-viewer-component/master/public/screenshot-light.jpg" alt="demo-light" width="80%" />
|
|
18
17
|
</div>
|
|
19
18
|
|
|
20
19
|
## Features
|
|
@@ -185,6 +184,8 @@ json-diff-viewer {
|
|
|
185
184
|
|
|
186
185
|
### Sizing
|
|
187
186
|
|
|
187
|
+
The component requires a defined height to enable scrolling. Without a height, the component will expand to fit all content.
|
|
188
|
+
|
|
188
189
|
```css
|
|
189
190
|
json-diff-viewer {
|
|
190
191
|
height: 600px;
|
|
@@ -192,6 +193,21 @@ json-diff-viewer {
|
|
|
192
193
|
}
|
|
193
194
|
```
|
|
194
195
|
|
|
196
|
+
For full-height layouts, use flexbox:
|
|
197
|
+
|
|
198
|
+
```css
|
|
199
|
+
.container {
|
|
200
|
+
display: flex;
|
|
201
|
+
flex-direction: column;
|
|
202
|
+
height: 100vh;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
json-diff-viewer {
|
|
206
|
+
flex: 1;
|
|
207
|
+
min-height: 0;
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
195
211
|
## Dev
|
|
196
212
|
|
|
197
213
|
```bash
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-diff-viewer-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vanilla JS web component for side-by-side JSON diff visualization",
|
|
6
|
+
"bugs": "https://github.com/metaory/json-diff-viewer-component/issues",
|
|
7
|
+
"homepage": "https://metaory.github.io/json-diff-viewer-component/",
|
|
8
|
+
"repository": "git+https://github.com/metaory/json-diff-viewer-component.git",
|
|
6
9
|
"keywords": [
|
|
7
10
|
"json",
|
|
8
11
|
"diff",
|
package/src/lib/styles.js
CHANGED
|
@@ -12,7 +12,6 @@ export default `
|
|
|
12
12
|
.container { display: grid; grid-template-columns: 1fr 1fr; flex: 1; min-height: 0; }
|
|
13
13
|
.panel { overflow: auto; padding: 1rem; background: var(--bg2); scrollbar-width: thin; scrollbar-color: var(--bdr) transparent; }
|
|
14
14
|
.panel:first-child { border-right: 2px solid var(--bdr); }
|
|
15
|
-
.header { padding: 0.25rem 0 0.5rem; font-weight: 600; color: var(--dim); border-bottom: 1px solid var(--bdr); margin-bottom: 0.5rem; font-size: 11px; }
|
|
16
15
|
.node { padding-left: 1.25rem; }
|
|
17
16
|
.node.root { padding-left: 0; }
|
|
18
17
|
.line { display: flex; align-items: flex-start; gap: 0.5rem; padding: 2px 4px; border-radius: 4px; cursor: pointer; transition: background .15s; }
|
|
@@ -48,7 +47,7 @@ export default `
|
|
|
48
47
|
.switch { display: inline-block; cursor: pointer; }
|
|
49
48
|
.checkbox { display: none; }
|
|
50
49
|
.slider { width: 48px; height: 24px; background-color: var(--bdr); border-radius: 16px; overflow: hidden; display: flex; align-items: center; border: 3px solid transparent; transition: .3s; box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.25) inset; cursor: pointer; }
|
|
51
|
-
.slider::before { content: ''; display: block; width: 100%; height: 100%; background-color: var(--
|
|
50
|
+
.slider::before { content: ''; display: block; width: 100%; height: 100%; background-color: var(--br); transform: translateX(-24px); border-radius: 16px; transition: .3s; box-shadow: 0 0 10px 3px rgba(0, 0, 0, 0.25); }
|
|
52
51
|
.checkbox:checked ~ .slider::before { transform: translateX(24px); box-shadow: 0 0 10px 3px rgba(0, 0, 0, 0.25); }
|
|
53
52
|
.checkbox:checked ~ .slider { background-color: var(--slider); }
|
|
54
53
|
.checkbox:active ~ .slider::before { transform: translate(0); }
|
package/src/lib/viewer.js
CHANGED
|
@@ -159,8 +159,7 @@ class JsonDiffViewer extends HTMLElement {
|
|
|
159
159
|
<div class="container">
|
|
160
160
|
${["left", "right"]
|
|
161
161
|
.map((side) => {
|
|
162
|
-
|
|
163
|
-
return `<div class="panel" data-side="${side}"><div class="header">${label}</div>${this.#renderNode(this.#tree, side, "")}</div>`;
|
|
162
|
+
return `<div class="panel" data-side="${side}">${this.#renderNode(this.#tree, side, "")}</div>`;
|
|
164
163
|
})
|
|
165
164
|
.join("")}
|
|
166
165
|
</div>`;
|