From 9c3773c5ff8c02bf110cb5409a241de1210ff68f Mon Sep 17 00:00:00 2001 From: Prince Rajpoot <44585452+princerajpoot20@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:49:07 +0530 Subject: [PATCH 1/3] feat: add Visual JSON Schema Editor (#905) Co-authored-by: samz --- .../VisualJsonSchemaEditor.stories.tsx | 284 ++++++++++++++++++ package-lock.json | 3 +- package.json | 3 +- packages/ui/components/VisualEditor.tsx | 101 +++++++ .../ui/components/VisualEditor/CodeEditor.tsx | 51 ++++ .../ui/components/VisualEditor/Example.tsx | 12 + .../VisualEditor/PropertyControls.tsx | 88 ++++++ .../components/VisualEditor/SchemaObject.tsx | 73 +++++ .../VisualEditor/SchemaProperty.tsx | 148 +++++++++ .../ui/components/icons/NotRequiredIcon.tsx | 13 + packages/ui/components/icons/RequiredIcon.tsx | 13 + packages/ui/components/icons/index.tsx | 2 + packages/ui/components/index.tsx | 3 + 13 files changed, 792 insertions(+), 2 deletions(-) create mode 100644 apps/design-system/src/components/VisualJsonSchemaEditor.stories.tsx create mode 100644 packages/ui/components/VisualEditor.tsx create mode 100644 packages/ui/components/VisualEditor/CodeEditor.tsx create mode 100644 packages/ui/components/VisualEditor/Example.tsx create mode 100644 packages/ui/components/VisualEditor/PropertyControls.tsx create mode 100644 packages/ui/components/VisualEditor/SchemaObject.tsx create mode 100644 packages/ui/components/VisualEditor/SchemaProperty.tsx create mode 100644 packages/ui/components/icons/NotRequiredIcon.tsx create mode 100644 packages/ui/components/icons/RequiredIcon.tsx diff --git a/apps/design-system/src/components/VisualJsonSchemaEditor.stories.tsx b/apps/design-system/src/components/VisualJsonSchemaEditor.stories.tsx new file mode 100644 index 000000000..394eeabae --- /dev/null +++ b/apps/design-system/src/components/VisualJsonSchemaEditor.stories.tsx @@ -0,0 +1,284 @@ +import React, { useState } from 'react'; +import { VisualEditor, CodeEditor, Examples } from '@asyncapi/studio-ui'; + +export default { + component: VisualEditor, + parameters: { + layout: 'fullscreen', + }, +}; +type TemplateProps = { + initialSchema: string; +}; + +const Template: React.FC = ({ initialSchema }) => { + const [schema, setSchema] = useState(initialSchema); + const [editorType, setEditorType] = useState<'visual' | 'code' | 'examples'>('visual'); + + + return ( +
+
+ + + +
+
+ {editorType === 'visual' && ( + + )} + {editorType === 'code' && ( + + )} + {editorType === 'examples' && ( + + )} +
+
+ ); +}; + +export const Sample_Schema = () => ( +