Rendering widgets
We can render a widget by referencing it using its id
To render th widget widget_languages
anywhere in the app we can use the simple syntax:
{
"component": "widget",
"id": "widget_languages"
}
Widgets can also be used to render complex items, say I want to render the list of contributors to each file.
Here, the widget can be constructed as:
const widgetJSON = {
component: "div",
id: "file_contributors",
items: [ // adding components to the widget
{
component: "div",
items: [
{
component: "icon",
icon: "file"
},
{
component: "label",
label: "@fileName"
}
]
},
{
component: "list",
data: "@contributors",
itemConfig: {
component: "label"
}
}
]
},
Now to render a list of contributors for each file, we write the list as:
const listJSON = {
component: "list"
data: "@files"
itemConfig: {
component: "widget",
id: "file_contributors"
}
}
Here @files
is a list of file objects containg fields
- fileName: string
- contributors: Array<String>
recommendation-more-help
11125c99-e1a1-4369-b5d7-fb3098b9b178