Skip to content

Commit 3afccd0

Browse files
committed
feat: improve auto-gen form playground
1 parent fecd5ee commit 3afccd0

File tree

1 file changed

+67
-61
lines changed
  • apps/instill-form-playground/src/pages

1 file changed

+67
-61
lines changed

apps/instill-form-playground/src/pages/index.tsx

Lines changed: 67 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -18,69 +18,75 @@ export default function Home() {
1818
);
1919

2020
return (
21-
<div className="flex min-h-screen min-w-[100vh] flex-1 flex-col">
22-
<div className="m-auto flex w-full max-w-[1200px] flex-row gap-x-10 p-10">
23-
{`isValid - ${isValid}`}
24-
<div className="flex w-1/2 flex-col gap-y-5">
25-
<div className="flex h-1/3 w-full flex-col">
26-
<MonacoEditor
27-
language="json"
28-
value={code ?? ""}
29-
theme="vs-light"
30-
height={300}
31-
onChange={(code) => {
32-
if (!code) return;
33-
setCode(code);
21+
<div className="flex min-h-screen min-w-[100vh] flex-1 flex-col p-10">
22+
<div className="flex flex-row border gap-x-5 rounded border-semantic-fg-primary h-full w-full p-10">
23+
<div className="flex w-[400px] flex-col gap-y-5">
24+
<h2 className="product-headings-heading-3 text-semantic-fg-primary">
25+
Your JSON Schema
26+
</h2>
27+
<MonacoEditor
28+
language="json"
29+
value={code ?? ""}
30+
theme="vs-light"
31+
height={800}
32+
onChange={(code) => {
33+
if (!code) return;
34+
setCode(code);
3435

35-
try {
36-
const parsedCode = JSON.parse(code);
37-
setIsValid(true);
38-
setSchema(parsedCode);
39-
} catch (err) {
40-
setIsValid(false);
41-
}
42-
}}
43-
options={{
44-
minimap: {
45-
enabled: false,
46-
},
47-
automaticLayout: true,
48-
}}
49-
className="h-full border border-black"
50-
/>
51-
</div>
52-
<div className="flex h-1/3 w-full flex-col">
53-
<MonacoEditor
54-
language="json"
55-
value={formTree ? JSON.stringify(formTree, null, 2) : ""}
56-
theme="vs-light"
57-
height={300}
58-
options={{
59-
minimap: {
60-
enabled: false,
61-
},
62-
automaticLayout: true,
63-
}}
64-
className="h-full border border-black"
65-
/>
66-
</div>
67-
<div className="flex h-1/3 w-full flex-col">
68-
<MonacoEditor
69-
language="json"
70-
value={error ? error : data ? data : ""}
71-
theme="vs-light"
72-
height={300}
73-
options={{
74-
minimap: {
75-
enabled: false,
76-
},
77-
automaticLayout: true,
78-
}}
79-
className="h-full border border-black"
80-
/>
81-
</div>
36+
try {
37+
const parsedCode = JSON.parse(code);
38+
setIsValid(true);
39+
setSchema(parsedCode);
40+
} catch (err) {
41+
setIsValid(false);
42+
}
43+
}}
44+
options={{
45+
minimap: {
46+
enabled: false,
47+
},
48+
automaticLayout: true,
49+
}}
50+
className="h-full border border-black"
51+
/>
8252
</div>
83-
<div className="flex h-full w-1/2 flex-col p-4">
53+
<div className="flex w-[400px] flex-col gap-y-5">
54+
<h2 className="product-headings-heading-3 text-semantic-fg-primary">
55+
Your Form Tree
56+
</h2>
57+
<MonacoEditor
58+
language="json"
59+
value={formTree ? JSON.stringify(formTree, null, 2) : ""}
60+
theme="vs-light"
61+
height={800}
62+
options={{
63+
minimap: {
64+
enabled: false,
65+
},
66+
automaticLayout: true,
67+
}}
68+
className="h-full border border-black"
69+
/>
70+
</div>
71+
<div className="flex w-[400px] flex-col gap-y-5">
72+
<h2 className="product-headings-heading-3 text-semantic-fg-primary">
73+
Your Form Data
74+
</h2>
75+
<MonacoEditor
76+
language="json"
77+
value={error ? error : data ? data : ""}
78+
theme="vs-light"
79+
height={800}
80+
options={{
81+
minimap: {
82+
enabled: false,
83+
},
84+
automaticLayout: true,
85+
}}
86+
className="h-full border border-black"
87+
/>
88+
</div>
89+
<div className="flex w-[400px] flex-col">
8490
<Form.Root {...form}>
8591
<form className="w-full">
8692
<div className="mb-5 flex flex-col gap-y-5">{fields}</div>

0 commit comments

Comments
 (0)