-
Notifications
You must be signed in to change notification settings - Fork 8
Creating a Block or a Component
Josh_soporte edited this page Jul 15, 2020
·
2 revisions
Here are some steps to consider on creating a Block. They are not a meticulous guideline, but are some steps to have on mind when creating a new Maxi Block:
- Folder should contain an structure like has been specified here
- Block should be allowed on
./src/extensions/attributes/index.js
in order to use common attributes, and other places like:./src/extensions/save/index.js
./src/extensions/dom/index.js
./src/blocks.js
- As specified on structuring,
edit.js
is where MaxiBlock class should go. For a good use of Style API, it should contain a getter calledgetObject
with an object like this. - All blocks should include a common attribute called 'uniqueID' as a class in both files edit.js and save.js.
- Mostly all blocks need to add Toolbar on
edit.js
and ResponsiveSelector oninspector.js
.
Components doesn't use any class as MaxiBlocks does, but they still have some things to consider. Please, join this step guides with some of created components to have a full idea how to create one:
- In case the components needs to have options for responsive, is important to create an object like this.
- If its a reusable component, is recommended to save the main object on defaults.
- Sometimes, the object can't fit directly with
ResponsiveStylesResolver
necessities, so is necessary to use a handler - What the component should receive if using an object is the stringified object; onces on the component should be parsed and on returning the object stringified again.
- For manage of responsive settings inside of the component, is recommended to have a property normally called 'breakpoint'. Is it used to send what is normally found on blocks as 'deviceType'.
- Components should be inscribed on
./src/components/index.js
in order to re-export them when using on blocks.