mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-17 00:13:17 +00:00
0a0acacfdb
This PR adds a `CanvasProviderElement` to `@storyteller/studio-web` to manage the complexity of maintaining a single concrete `HTMLCanvasElement` for `@storyteller/studio`, while still being able to treat components like the `ViewerElement` as self-contained "views" that behave as expected with regards to CSS styling, DOM placement, etc. Consuming applications should wrap the new `<sts-canvas-provider />` element around some common ancestor of all views into the `@storyteller/studio` app, similar to a React context provider. The `react-frontend` application has been updated to take advantage of the new `CanvasProviderElement` by demonstrating a more realistic use case for the `ViewerElement`. The new demo presents a grid of "thumbnails," one for each object in our hard-coded "object library." Clicking on one of these thumbnails will render a `ViewerElement` for that object in a modal dialog.
16 lines
481 B
TypeScript
16 lines
481 B
TypeScript
import { CanvasProviderElement } from "@storyteller/studio-web/canvas-provider";
|
|
import "@storyteller/studio-web/canvas-provider";
|
|
import React, { ReactNode, forwardRef } from "react";
|
|
|
|
export interface Props extends React.HTMLProps<CanvasProviderElement> {
|
|
children?: ReactNode | ReactNode[];
|
|
}
|
|
|
|
export default forwardRef<CanvasProviderElement, Props>(
|
|
({ children, ...props }, ref) => (
|
|
<sts-canvas-provider {...props} ref={ref}>
|
|
{children}
|
|
</sts-canvas-provider>
|
|
)
|
|
);
|