Skip to content

Commit

Permalink
added some reviewed change
Browse files Browse the repository at this point in the history
  • Loading branch information
Gmin2 committed May 27, 2024
1 parent b616a30 commit 33e0b9f
Showing 1 changed file with 39 additions and 20 deletions.
59 changes: 39 additions & 20 deletions packages/ui/components/VisualEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export const VisualEditor: React.FC<VisualEditorProps> = ({ schema, onSchemaChan
{ type: 'regular', title: 'Number', onSelect: () => handleArrayItemTypeDropdownSelect('number') },
{ type: 'regular', title: 'Boolean', onSelect: () => handleArrayItemTypeDropdownSelect('boolean') },
{ type: 'regular', title: 'Object', onSelect: () => handleArrayItemTypeDropdownSelect('object') },
{ type: 'regular', title: 'Array', onSelect: () => handleArrayItemTypeDropdownSelect('array') },
];

const renderRootTypeDisplay = () => {
Expand All @@ -90,12 +89,6 @@ export const VisualEditor: React.FC<VisualEditorProps> = ({ schema, onSchemaChan
>
{displayRootType}
</span>
<DropdownMenu
trigger={<button><IoIosArrowDropdown /></button>}
items={rootTypeOptions}
side="bottom"
align="start"
/>
</div>
);
};
Expand All @@ -116,30 +109,56 @@ export const VisualEditor: React.FC<VisualEditorProps> = ({ schema, onSchemaChan
>
{`Array<${itemType}>`}
</span>
<DropdownMenu
trigger={<button><IoIosArrowDropdown /></button>}
items={itemTypeOptions}
side="bottom"
align="start"
/>
</div>
);
}
return null;
};

return (
<div className="visual-editor" style={{ width: '45vw', minWidth: '550px', background: '#0F172A', color: '#CBD5E1', fontFamily: 'Inter, sans-serif', padding: '20px'}}>
<div
className="visual-editor"
style={{
width: "45vw",
minWidth: "550px",
background: "#0F172A",
color: "#CBD5E1",
fontFamily: "Inter, sans-serif",
padding: "20px",
}}
>
<div className="flex items-center gap-2">
{renderRootTypeDisplay()}
{renderArrayItemTypeDisplay()}
<DropdownMenu
trigger={
<button>
<IoIosArrowDropdown />
</button>
}
items={rootTypeOptions}
/>
{schemaObject.type === "array" && (
<DropdownMenu
trigger={
<button>
<IoIosArrowDropdown />
</button>
}
items={itemTypeOptions}
/>
)}
</div>
<SchemaObject
schema={schemaObject.type === 'array' ? schemaObject.items : schemaObject}
onSchemaChange={(newSchema: any) => handleSchemaChange(newSchema)}
path={schemaObject.type === 'array' ? 'items' : ''}
level={0}
/>
{(schemaObject.type === "object" || schemaObject.type === "array") && (
<SchemaObject
schema={
schemaObject.type === "array" ? schemaObject.items : schemaObject
}
onSchemaChange={(newSchema: any) => handleSchemaChange(newSchema)}
path={schemaObject.type === "array" ? "items" : ""}
level={0}
/>
)}
</div>
);
};
Expand Down

0 comments on commit 33e0b9f

Please sign in to comment.