1111 * limitations under the License.
1212 */
1313
14- import ReactDOM from "react-dom " ;
14+ import { ExternalBlockDefinition } from "widget-sdk " ;
1515import { configurationSchema , uiSchema } from "../src/configuration-schema" ;
16- import React from "react" ;
16+ import React , { FC } from "react" ;
1717import Form from "@rjsf/material-ui" ;
1818
1919const updateWidget = ( data : Record < string , string > ) => {
@@ -24,14 +24,69 @@ const updateWidget = (data: Record<string, string>) => {
2424 }
2525} ;
2626
27- ReactDOM . render (
28- < Form
29- schema = { configurationSchema }
30- uiSchema = { uiSchema }
31- onSubmit = { ( e ) => {
32- updateWidget ( e . formData ) ;
33- } }
34- autoComplete = { "off" }
35- /> ,
36- document . getElementById ( "config" )
37- ) ;
27+ type BlockDefinition = ExternalBlockDefinition [ "blockDefinition" ] ;
28+
29+ type Props = {
30+ blockDefinition : BlockDefinition ;
31+ } ;
32+
33+ const Config : FC < Props > = ( { blockDefinition } ) => {
34+ return (
35+ < div className = "display: flex; flex-direction: column; justify-content: space-evenly" >
36+ < div className = "box" >
37+ < h3 > Icon preview:</ h3 >
38+ < section id = "icon" >
39+ < div
40+ aria-label = { blockDefinition . label }
41+ style = { {
42+ background : "rgb(247, 247, 247)" ,
43+ cursor : "pointer" ,
44+ height : "96px" ,
45+ flex : "0 0 20%" ,
46+ borderRadius : "3px" ,
47+ padding : "0px" ,
48+ margin : "0px" ,
49+ display : "flex" ,
50+ alignItems : "center" ,
51+ justifyContent : "center" ,
52+ flexDirection : "column" ,
53+ } }
54+ >
55+ < img
56+ height = "28"
57+ src = { blockDefinition . iconUrl }
58+ style = { { maxWidth : "80px" } }
59+ />
60+ < div
61+ aria-hidden = "true"
62+ style = { {
63+ textAlign : "center" ,
64+ fontSize : "14px" ,
65+ color : "rgb(120, 120, 120)" ,
66+ marginTop : "8px" ,
67+ width : "100%" ,
68+ } }
69+ >
70+ { blockDefinition . label }
71+ </ div >
72+ </ div >
73+ </ section >
74+ </ div >
75+ < div className = "box" >
76+ < h3 > Configuration preview:</ h3 >
77+ < section id = "config" >
78+ < Form
79+ schema = { configurationSchema }
80+ uiSchema = { uiSchema }
81+ onSubmit = { ( e ) => {
82+ updateWidget ( e . formData ) ;
83+ } }
84+ autoComplete = { "off" }
85+ />
86+ </ section >
87+ </ div >
88+ </ div >
89+ ) ;
90+ } ;
91+
92+ export default Config ;
0 commit comments