diff --git a/samples/weather-forecast/dev/bootstrap.ts b/samples/weather-forecast/dev/bootstrap.ts index ef047de..df85871 100644 --- a/samples/weather-forecast/dev/bootstrap.ts +++ b/samples/weather-forecast/dev/bootstrap.ts @@ -15,6 +15,9 @@ import { BaseBlock } from "@staffbase/widget-sdk"; import WidgetApiMock from "./widget-api-mock"; import { fromDataUri, prepareAttributes } from "./utils/DataUtil"; import { baseAttributes } from "./constants"; +import Config from "./config"; +import ReactDOM from "react-dom"; +import React from "react"; /** * Simulated hosting class to run the widget @@ -69,4 +72,11 @@ window.defineBlock = function (externalBlockDefinition) { WidgetApiMock ); window.customElements.define(customElementName, CustomElementClass); + + ReactDOM.render( + React.createElement(Config, { + blockDefinition: externalBlockDefinition.blockDefinition, + }), + document.getElementById("config") + ); }; diff --git a/samples/weather-forecast/dev/config.tsx b/samples/weather-forecast/dev/config.tsx index 1a831b8..650ecb5 100644 --- a/samples/weather-forecast/dev/config.tsx +++ b/samples/weather-forecast/dev/config.tsx @@ -11,9 +11,9 @@ * limitations under the License. */ -import ReactDOM from "react-dom"; +import { ExternalBlockDefinition } from "widget-sdk"; import { configurationSchema, uiSchema } from "../src/configuration-schema"; -import React from "react"; +import React, { FC } from "react"; import Form from "@rjsf/material-ui"; const updateWidget = (data: Record) => { @@ -24,14 +24,69 @@ const updateWidget = (data: Record) => { } }; -ReactDOM.render( -
{ - updateWidget(e.formData); - }} - autoComplete={"off"} - />, - document.getElementById("config") -); +type BlockDefinition = ExternalBlockDefinition["blockDefinition"]; + +type Props = { + blockDefinition: BlockDefinition; +}; + +const Config: FC = ({ blockDefinition }) => { + return ( +
+
+

Icon preview:

+
+
+ + +
+
+
+
+

Configuration preview:

+
+ { + updateWidget(e.formData); + }} + autoComplete={"off"} + /> +
+
+
+ ); +}; + +export default Config; diff --git a/samples/weather-forecast/resources/index.html b/samples/weather-forecast/resources/index.html index db08fb4..a7e545d 100644 --- a/samples/weather-forecast/resources/index.html +++ b/samples/weather-forecast/resources/index.html @@ -3,12 +3,12 @@ - + staffbase/weather-forecast - - - + + + - -
-
-

Widget preview:

-
-
-
- -
-
-
-

Configuration preview:

-
-
+ +
+

Widget preview:

+
+
+
+ +
+
-