Skip to content

Creating a Block or a Component

Josh_soporte edited this page Jul 15, 2020 · 2 revisions

Creating a Block

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:

  1. Folder should contain an structure like has been specified here
  2. 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
  3. As specified on structuring, edit.js is where MaxiBlock class should go. For a good use of Style API, it should contain a getter called getObject with an object like this.
  4. All blocks should include a common attribute called 'uniqueID' as a class in both files edit.js and save.js.
  5. Mostly all blocks need to add Toolbar on edit.js and ResponsiveSelector on inspector.js.

Creating a Component

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:

  1. In case the components needs to have options for responsive, is important to create an object like this.
  2. If its a reusable component, is recommended to save the main object on defaults.
  3. Sometimes, the object can't fit directly with ResponsiveStylesResolver necessities, so is necessary to use a handler
  4. 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.
  5. 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'.
  6. Components should be inscribed on ./src/components/index.js in order to re-export them when using on blocks.
Clone this wiki locally