@@ -10,6 +10,7 @@ import Launch from "@mui/icons-material/Launch";
10
10
import prettier from "prettier/standalone" ;
11
11
import * as babelPlugin from "prettier/parser-babel" ;
12
12
import * as estreeParser from "prettier/plugins/estree" ;
13
+ import Visualizer from "./Visualizer" ;
13
14
14
15
async function format ( code : string ) {
15
16
const formatted = await prettier . format ( `const a = ${ code } ` , {
@@ -24,11 +25,33 @@ async function format(code: string) {
24
25
25
26
function App ( ) {
26
27
const [ obj1Val , setObj1Val ] = useState ( `{
27
- a: 1, b: 2
28
+ a: 1, b: null, g: 8
28
29
}` ) ;
29
30
const [ obj2Val , setObj2Val ] = useState ( `{
30
- a: 2, c: 5
31
+ a: 2, g: 8, c: 'Hello World',
31
32
}` ) ;
33
+ // const [obj1Val, setObj1Val] = useState(`{
34
+ // foo: {
35
+ // bar: {
36
+ // a: ['a', 'b'],
37
+ // b: 2,
38
+ // c: ['x', 'y'],
39
+ // e: 100
40
+ // }
41
+ // },
42
+ // buzz: 'world'
43
+ // }`);
44
+ // const [obj2Val, setObj2Val] = useState(`{
45
+ // foo: {
46
+ // bar: {
47
+ // a: ['a'],
48
+ // b: 2,
49
+ // c: ['x', 'y', 'z'],
50
+ // d: 'Hello, world!'
51
+ // }
52
+ // },
53
+ // buzz: 'fizz'
54
+ // }`);
32
55
const [ raw , setRaw ] = useState < Array < DiffResult > > ( [ ] ) ;
33
56
34
57
useEffect ( ( ) => {
@@ -62,17 +85,18 @@ function App() {
62
85
< Box sx = { { } } >
63
86
< Box
64
87
sx = { {
65
- borderBottom : "1px solid grey " ,
88
+ borderBottom : "1px solid lightgrey " ,
66
89
p : 1 ,
67
90
px : 3 ,
68
91
display : "flex" ,
69
92
justifyContent : "space-between" ,
93
+ height : "50px" ,
70
94
} }
71
95
>
72
96
< Box sx = { { display : "flex" } } >
73
97
< img src = "/Logo.svg" alt = "Logo" height = "35" />
74
98
< Typography level = "h4" sx = { { ml : 2 , letterSpacing : "2px" } } >
75
- obj-diff
99
+ Obj-Diff
76
100
</ Typography >
77
101
</ Box >
78
102
< Link
@@ -82,104 +106,108 @@ function App() {
82
106
rel = "noopener"
83
107
fontSize = "sm"
84
108
>
85
- Github
109
+ GitHub
86
110
</ Link >
87
111
</ Box >
88
- < Box sx = { { display : "flex" , justifyContent : "center" , mt : 2 } } >
89
- < Alert variant = "soft" color = "success" >
90
- < Typography level = "body-md" >
91
- 🚀 The Fast, Accurate, JavaScript Objects Diffing Library.
92
- </ Typography >
93
- </ Alert >
94
- </ Box >
95
- < Box
96
- sx = { {
97
- display : "grid" ,
98
- gridTemplateColumns : "1fr 10px 1fr 10px 1fr" ,
99
- p : "50px" ,
100
- height : "600px" ,
101
- boxSizing : "border-box" ,
102
- } }
103
- >
104
- < Box sx = { { height : "100%" , overflow : "hidden" } } >
105
- < Sheet
106
- variant = "outlined"
107
- sx = { {
108
- height : "100%" ,
109
- overflow : "hidden" ,
110
- display : "flex" ,
111
- flexDirection : "column" ,
112
- boxSizing : "border-box" ,
113
- } }
114
- >
115
- < Typography level = "body-sm" sx = { { textAlign : "center" } } >
116
- Object 1
112
+ < Box sx = { { height : "calc(100vh - 100px)" } } >
113
+ < Box sx = { { display : "flex" , justifyContent : "center" , mt : 2 } } >
114
+ < Alert variant = "soft" color = "success" >
115
+ < Typography level = "body-md" >
116
+ 🚀 The Fast, Accurate, JavaScript Objects Diffing Library.
117
117
</ Typography >
118
- < Box sx = { { height : "calc(100% - 25px)" , overflow : "auto" } } >
119
- < CodeMirror
120
- value = { obj1Val }
121
- extensions = { [ javascript ( ) ] }
122
- onChange = { onChange1 }
123
- height = "100%"
124
- />
125
- </ Box >
126
- </ Sheet >
118
+ </ Alert >
127
119
</ Box >
128
- < Box />
129
- < Box sx = { { height : "100%" , overflow : "hidden" } } >
130
- < Sheet
131
- variant = "outlined"
132
- sx = { {
133
- height : "100%" ,
134
- overflow : "hidden" ,
135
- display : "flex" ,
136
- flexDirection : "column" ,
137
- boxSizing : "border-box" ,
138
- } }
139
- >
140
- < Typography level = "body-sm" sx = { { textAlign : "center" } } >
141
- Object 2
142
- </ Typography >
143
- < Box sx = { { height : "calc(100% - 25px)" , overflow : "auto" } } >
144
- < CodeMirror
145
- value = { obj2Val }
146
- extensions = { [ javascript ( ) ] }
147
- onChange = { onChange2 }
148
- />
149
- </ Box >
150
- </ Sheet >
151
- </ Box >
152
- < Box />
153
- < Box sx = { { height : "100%" , overflow : "hidden" } } >
154
- < Sheet
155
- variant = "outlined"
156
- sx = { { height : "100%" , boxSizing : "border-box" } }
157
- >
158
- < Tabs
159
- aria-label = "Basic tabs"
160
- defaultValue = { 0 }
161
- sx = { { height : "100%" } }
120
+ < Box
121
+ sx = { {
122
+ display : "grid" ,
123
+ gridTemplateColumns : "1fr 10px 1fr 10px 1fr" ,
124
+ p : "50px" ,
125
+ height : "75vh" ,
126
+ boxSizing : "border-box" ,
127
+ } }
128
+ >
129
+ < Box sx = { { height : "100%" , overflow : "hidden" } } >
130
+ < Sheet
131
+ variant = "outlined"
132
+ sx = { {
133
+ height : "100%" ,
134
+ overflow : "hidden" ,
135
+ display : "flex" ,
136
+ flexDirection : "column" ,
137
+ boxSizing : "border-box" ,
138
+ } }
139
+ >
140
+ < Typography level = "body-sm" sx = { { textAlign : "center" } } >
141
+ Object 1
142
+ </ Typography >
143
+ < Box sx = { { height : "calc(100% - 25px)" , overflow : "auto" } } >
144
+ < CodeMirror
145
+ value = { obj1Val }
146
+ extensions = { [ javascript ( ) ] }
147
+ onChange = { onChange1 }
148
+ height = "100%"
149
+ />
150
+ </ Box >
151
+ </ Sheet >
152
+ </ Box >
153
+ < Box />
154
+ < Box sx = { { height : "100%" , overflow : "hidden" } } >
155
+ < Sheet
156
+ variant = "outlined"
157
+ sx = { {
158
+ height : "100%" ,
159
+ overflow : "hidden" ,
160
+ display : "flex" ,
161
+ flexDirection : "column" ,
162
+ boxSizing : "border-box" ,
163
+ } }
164
+ >
165
+ < Typography level = "body-sm" sx = { { textAlign : "center" } } >
166
+ Object 2
167
+ </ Typography >
168
+ < Box sx = { { height : "calc(100% - 25px)" , overflow : "auto" } } >
169
+ < CodeMirror
170
+ value = { obj2Val }
171
+ extensions = { [ javascript ( ) ] }
172
+ onChange = { onChange2 }
173
+ />
174
+ </ Box >
175
+ </ Sheet >
176
+ </ Box >
177
+ < Box />
178
+ < Box sx = { { height : "100%" , overflow : "hidden" } } >
179
+ < Sheet
180
+ variant = "outlined"
181
+ sx = { { height : "100%" , boxSizing : "border-box" } }
162
182
>
163
- < TabList sx = { { display : "flex" , justifyContent : "center" } } >
164
- < Tab > Visualize</ Tab >
165
- < Tab > Raw</ Tab >
166
- </ TabList >
167
- < TabPanel
168
- value = { 0 }
169
- sx = { { height : "calc(100% - 35px)" , overflow : "auto" } }
170
- > </ TabPanel >
171
- < TabPanel
172
- value = { 1 }
173
- sx = { { height : "calc(100% - 35px)" , overflow : "auto" } }
183
+ < Tabs
184
+ aria-label = "Basic tabs"
185
+ defaultValue = { 0 }
186
+ sx = { { height : "100%" } }
174
187
>
175
- < Box component = "pre" > { JSON . stringify ( raw , null , 4 ) } </ Box >
176
- </ TabPanel >
177
- </ Tabs >
178
- </ Sheet >
188
+ < TabList sx = { { display : "flex" , justifyContent : "center" } } >
189
+ < Tab > Visualize</ Tab >
190
+ < Tab > Raw</ Tab >
191
+ </ TabList >
192
+ < TabPanel
193
+ value = { 0 }
194
+ sx = { { height : "calc(100% - 35px)" , overflow : "auto" , p : 0 } }
195
+ >
196
+ < Visualizer obj = { obj1Val } diff = { raw } />
197
+ </ TabPanel >
198
+ < TabPanel
199
+ value = { 1 }
200
+ sx = { { height : "calc(100% - 35px)" , overflow : "auto" } }
201
+ >
202
+ < Box component = "pre" > { JSON . stringify ( raw , null , 4 ) } </ Box >
203
+ </ TabPanel >
204
+ </ Tabs >
205
+ </ Sheet >
206
+ </ Box >
179
207
</ Box >
180
208
</ Box >
181
209
182
- < Box sx = { { display : "flex" , justifyContent : "center" , mt : 2 } } >
210
+ < Box sx = { { display : "flex" , justifyContent : "center" } } >
183
211
< Box sx = { { mr : 1 } } component = "span" >
184
212
{ " " }
185
213
© 2024
0 commit comments