-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
186 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Editor from "@monaco-editor/react"; | ||
|
||
export interface JsonEditorProps { | ||
value: string; | ||
onChange(value: string | undefined): void; | ||
} | ||
|
||
export function JsonEditor(props: JsonEditorProps) { | ||
return ( | ||
<div className="overflow-hidden rounded-md border-2 border-secondary"> | ||
<Editor | ||
loading={<SkeletonEditorLoading />} | ||
theme="vs-dark" | ||
height="200px" | ||
language="json" | ||
value={props.value} | ||
onChange={props.onChange} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
function SkeletonEditorLoading() { | ||
return ( | ||
<div | ||
aria-label="Loading Editor..." | ||
className="h-[200px] w-full bg-secondary animate-pulse p-6 flex flex-col gap-y-1.5" | ||
> | ||
<span className="block bg-primary h-3 w-full animate-pulse rounded" /> | ||
<span className="block bg-primary h-3 w-full animate-pulse rounded" /> | ||
<span className="block bg-primary h-3 w-full animate-pulse rounded" /> | ||
<span className="block bg-primary h-3 w-full animate-pulse rounded" /> | ||
<span className="block bg-primary h-3 w-full animate-pulse rounded" /> | ||
<span className="block bg-primary h-3 w-full animate-pulse rounded" /> | ||
<span className="block bg-primary h-3 w-full animate-pulse rounded" /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/ui/src/components/stories/editors/json-editor.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as React from "react"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { JsonEditor } from "../../editors/json-editor"; | ||
|
||
const meta = { | ||
title: "Editors/JSON Editor", | ||
component: JsonEditor, | ||
tags: ["autodocs"], | ||
} satisfies Meta<typeof JsonEditor>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof JsonEditor>; | ||
|
||
function DefaultRenderer() { | ||
const [value, setValue] = React.useState<string | undefined>(""); | ||
|
||
return <JsonEditor value={value ?? ""} onChange={setValue} />; | ||
} | ||
|
||
export const Default: Story = { | ||
render: () => <DefaultRenderer />, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.