base-theme
.
cms-library
.exp-test-component
contains three files:
index.ts
: This file serves as an entry point for the component.exp-test-component.tsx
: Responsible for returning the component’s JSX.exp-test-component-controller.tsx
: Implements all the business logic of the component. This includes tasks such as fetching data through API calls and manipulating the data that will be rendered by the component.index.ts
file located in the components
folder. You will understand how to do this by examining the contents of the index.ts
file.
widget
on the Visual Builder’s side panel.
index.ts
file of the widget folder.index.ts
file within the widget folder, you will notice that all existing widgets are imported, and their files are added to a widget
named array. This process ensures that your newly created widget becomes visible on the side panel of the Visual Builder.exp-test-component.tsx
index.ts
components > index.ts
widget
file,exp-test-component.tsx
Changes to Be Verified
To associate a component with the widget, follow the steps outlined in the code snippet above, where the component is imported asExpTestComponent
. Ensure that you pass the same component, unchanged, to theWidget.createWidget()
object. For thecomponent
key of that object, simply assign the component. In thecontent
key, provide the value as<ExpTestComponent data-cms-widget="true"/>
, but be sure to update the line according to the name of your new component. Similarly, provide the name of the component to thewidgetName
key. Review all the changes in the code snippet provided above.
widgets > index.ts