Skip to content

Instantly share code, notes, and snippets.

@petrbrzek
Created January 9, 2023 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petrbrzek/ce65b44338d7319d65a321dfa6e77849 to your computer and use it in GitHub Desktop.
Save petrbrzek/ce65b44338d7319d65a321dfa6e77849 to your computer and use it in GitHub Desktop.
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