In order to do so, nexweave autoform require you to do follwing things:
export const schema = {
title: 'My Widget',
type: 'object',
properties: {
backgroundColor: { type: 'string' },
font:{
type: "string",
span: 24,
ishidden: false,
instanceOf: "typography",
uniforms: {
allowedFields: ["fontFamily", "fontWeight", "fontSize", "letterSpacing", "align", "color", "fontStyle", "textDecoration"]
},
}
},
required: ['firstName', 'lastName'],
};
As you can see, we've defined three properties - backgroundColor
and font
, that are of string and backgroundColor
, which is an instance of typograpy
.
Once the schema is defied, Nexweave widget development kit will automatically pick the schema and render form accordingly.
Your widget will receive the data as per the properties field defined. So for our example the widget will receive interaction
props which have the data
property containing all the data defined under schema .
interactions : {
data : {
backgroundColod : "#FFFFFF",
font: {
fontFamily: "Montserrat",
fontSize: 3.5,
color: "#000",
align: "left",
direction: "ltr",
lineHeight: 0,
fontWeight: 700,
fontStyle: "normal",
letterSpacing: 5,
textDecoration: "none"
}
}
}
Now you're free to do whatever you want inside your widget component with this data 🙌🏻