@tindtechnologies/tinduicomponents
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Built With Stencil

Stencil

Stencil is a compiler for building fast web apps using Web Components.

Stencil combines the best concepts of the most popular frontend frameworks into a compile-time rather than run-time tool. Stencil takes TypeScript, JSX, a tiny virtual DOM layer, efficient one-way data binding, an asynchronous rendering pipeline (similar to React Fiber), and lazy-loading out of the box, and generates 100% standards-based Web Components that run in any browser supporting the Custom Elements v1 spec.

Stencil components are just Web Components, so they work in any major framework or with no framework at all.

Stencil Component Starter

The following documentation is inspired by this official guide.

Getting Started

To create a new StencilJS component go in the web docker container and in the tinduicomponents folder:

docker exec -it invenio_web_1 bash
cd /code/invenio/tinduicomponents/

and run:

npx stencil generate

It will be asked for the component name (please look the next section) and other option that you can set all as enabled.

At this point the auto-reload should build the component and make it usable (look the proper section below).

If for some reason it is not the case you can build manually with (still in the tinduicomponents folder):

npm run build

Naming Components

All component uses the dash-case and should be prefixed with the tindui- prefix.

Then it should follow with a category name in order to group all component with a similar purpose e.g.: tindui-button-

Conclude it with the component specific name to distinguish it among all other component in the same cat e.g.: tindui-button-generic or tindui-button-dropdown

If the component is planned to be used in a specific module or situation please indicate it like: tindui-table-result-globallist

Using this component

In order to use the tinduicomponents in your html is required to add the following imports:

<script type="module" src="/js/tinduicomponents/tinduicomponents/tinduicomponents.esm.js"></script>

At this point you can refer to the component using its tag name (that you can find in the auto-generate .tsx file):

<alert-box alert-type="success" message="Component successfully created."></alert-box>

Install additional npm packages

From the modules/tinduicomponents folder:

  npm install <yourpackage> --save

More

Stencil component official guide.

Using bootstrap css inside components: guide

Please read this article before writing a new component: guide

Common mistakes

  • Inline styles needs to be provided as an object:
let styles = {
  width: "45%",
  minWidth: "2em",
};
<div style={styles}></div>;
  • Do not set State variables in the render() method.
  • For arrays, the standard mutable array operations such as push() and unshift() won't work.
  • Define onEvent handler function with the syntax onEvent = () => {}. In this way the component this would be bound automatically.

Readme

Keywords

none

Package Sidebar

Install

npm i @tindtechnologies/tinduicomponents

Weekly Downloads

125

Version

1.0.2

License

none

Unpacked Size

45.8 MB

Total Files

488

Last publish

Collaborators

  • audub
  • tindrunner
  • thms-rmb