Created
January 9, 2023 14:52
-
-
Save petrbrzek/ce65b44338d7319d65a321dfa6e77849 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { EditorCanvas, useEditor } from "@opendesign/react"; | |
import { importFile } from "@opendesign/universal"; | |
import { Suspense, useState } from "react"; | |
export function MinimalImport() { | |
const [design, setDesign] = useState(); | |
if (!design) { | |
return ( | |
<input | |
type="file" | |
onChange={(event) => { | |
importFile(event.currentTarget.files[0]).then((v) => setDesign(v)); | |
}} | |
/> | |
); | |
} | |
return <Editor design={design} />; | |
} | |
function Editor({ design }) { | |
const editor = useEditor({ design }); | |
return ( | |
<Suspense fallback="Loading..."> | |
<EditorCanvas editor={editor} /> | |
</Suspense> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment