Documentation
Primary version
Primary version
  • Cubbles documentation
  • First steps
    • Generate a project
    • Create a webpackage
    • Create an elementary component
    • Create a compound component
      • Compound slot initialization
  • Runtime extension - RTE
    • User guide
      • RTE Integration
      • The Cubbles TAG API
        • The Cubbles Dependency API
      • The Cubbles Javascript API
        • Interacting with Cubbles from the outside
        • Adding dynamic connections
        • Interacting with Elementary Cubbles from the inside
      • The RTE Processing
        • RTE initialization and rendering timeline
      • The Cubbles IFrame API
        • The Cubbles IFrame Resizer API
      • The Cubbles mutation based start event API
      • FAQs
        • How to manually resolve dependency conflicts?
        • How to create a component instance dynamically?
        • How to render HTML Markup coming from input slot?
        • How to replace a dependency when declaring a component instance?
        • How to synchronize multiple dataflows between component instances?
        • How to handle the copyValue flag for non serializable instances?
    • Contributor guide
      • CIF processing
  • Developing with the vanilla boilerplate
    • Creating a new project
    • Developing elementaries using the vanilla boilerplate
    • Developing compounds using the vanilla boilerplate
    • Using the vanilla boilerplate scripts
  • Coder devtools - CDT
    • User guide
      • Create Cubbles artifacts
      • Upload a Webpackage
      • Generate a README file
      • Rename an artifact
      • Configure network proxy
      • Validate the manifest.webpackage file
      • Change active webpackage
      • Bulk upload of webpackages
      • Release a webpackage
      • Update the RTE version of a webpackage
      • Prepare a webpackage to be released
      • Update webpackage to the next development version
      • Generate a test environment for a component
      • Testing Cubbles components
      • Validate sources
      • Create a demo webpackage
    • Contributor guide
      • Checklist for releasing a new webpackage.modelVersion
  • Terms and concepts
    • Webpackage
    • Artifacts
    • User roles
    • Base
Powered by GitBook
On this page
  • Prerequisites
  • Development considerations
  • The MANIFEST.elementary.js
  • The element.html file
  • The element.js file
  • The element.sss file
  • The SHOWROOM.html file
  • Testing your elementary
  1. Developing with the vanilla boilerplate

Developing elementaries using the vanilla boilerplate

PreviousCreating a new projectNextDeveloping compounds using the vanilla boilerplate

Last updated 5 years ago

The easiest way to develop Cubbles elementaries is to modify the base sample contained in the vanilla boilerplate. In this section, we will give some recommendations to help you with that process. Below, we present an overview of the development process of a compound:

Prerequisites

Development considerations

The vanilla boilerplate includes a boilerplate for an elementary component called elem1. An elementary component has a manifest definition, a logic, and a view. You should rename this folder according to your needs. The name of the folder will be used to set the artifactId of your elementary in the built version of the final manifest.

Additionally, you should edit the following files according to your needs:

The MANIFEST.elementary.js

The following are the valid properties of an elementary manifest definition:

{
    "artifactId": , // Set automatically during building process
    "resources": [],
    "slots": [], // Optional
    "dependencies": [], // Optional
    "runnables": [], // Optional
    "dependencyExcludes": [], // Optional
    "description": "A description" // Optional
}

About the artifactId

The artifactId of your elementary is set automatically during the building process. By default it has the following format: [webpackageId]-[artifactId]. The webpackageId will be determined from the name property of the package.json file. And the artifactId will be based on the name of the folder that contains the component.

For instance, the artifactId of the elem1 elementary contained in vanilla boilerplate will be cubbles-vanilla-boilerplate-elem1, since the name property of the package.json file is @cubbles/vanilla-boilerplate and the container folder is called elem1. Note that the special characters (i.e., @ and /) of the name property were removed since artifactIds should be valid HTML elements names.

The element.html file

It contains the view of the elementary. You should remove the sample code except for <template> tag, here you should add the html code of your elementary. Also, have into account that the id="<%= elementName %>" attribute of that tag will be replaced with the artifactId defined in the MANIFEST.elementary.js. If you remove this attribute your elementary will not work properly. Similarly, if you hard code the id attribute and then change the artifactId in the manifest, you will have to update this manually or the elementary will not work. So, after edition your element.html file may look as follows:

<template id="<%= elementName %>">
    ... Your own code goes here
</template>

The element.js file

// imports

(function () {
  'use strict';

  CubxComponent({
    is: '/* @echo elementName */',

    // Life cycle methods
    created: function () { },

    ready: function () { },

    connected: function () { },

    disconnected: function () { },

    contextReady: function () { },

    // Slot changes listeners
    model[SlotId]Changed: function () { },

    // Additional code
    yorOwnMethod: function () { }
  });
}());

The element.sss file

The SHOWROOM.html file

After building your webpackage, the dist version of this file will have a working demo of your elementary. You don't need to add any code to make to work unless you want to improve it.

Testing your elementary

While developing your compound, you can run the npm run build command to build a developing dist version of your webpackage. Then, you should run the npm run start command to start a local web server and be able to run SHOWROOM.html file to watch your component working.

To start developing Cubbles elementaries using the vanilla boilerplate, this should be cloned locally and all dependencies should be installed (See for more information).

It contains only the of the elementary. As you may notice, it is a javascript script; thus, you have more freedom to play with the definition, but after building, it should be JSON and valid.

Check to know the type and structure of values that each property can take.

This file contains the logic of the sample elementary. To define the behavior of an elementary you should use the . The most important step is to define the is property of this object using the artifactId of the elementary, which is defined automatically during the building process. Then, if you want/need, you can define the life cycle associated methods of an elementary. Also, you may want to add listeners for changes in the slot values and implement additional methods to control the behavior of your elementary.

Since the vanilla boilerplate uses to build a distribution version of the webpackage and uses and to load javascript files, you can import other scripts and style files, which are loaded with , and .

It contains the style of the sample elementary using . It could also be a CSS style sheet. As you may have noticed, in this sample elementary, this style was imported in the element.js file.

For more information about those and other commands, check .

this guide
this
webpack
preprocess-loader
babel-loader
style-loader
css-loader
postcss-loader
sugarss
this guide
Cubbles manifest
manifest definition
CubxComponent
Developing a elementary with the vanilla boilerplate