@staffbase/create-widget

2.3.5 • Public • Published

Staffbase Logo

Staffbase Create-Widget

Description

The "Create Widget" repository is an utility to kick start the development of a custom element, used in the employee application. It generates the file and folder structure, a first small example widget and the toolbelt to run the development cycle and build the final script.

The widgets are based on the web component standard and leverage the lifecycle methods of it. Read more about web components in the documentation.

File structure

The root folder contains the configuration files and package manager description. For Webpack the config differentiate between development and production environments for more clarity.

.
├── README.md
├── favicon.png
├── index.html
├── package.json
├── src
│   ├── bootstrap.ts
│   ├── config.tsx
│   ├── configuration-schema.ts
│   ├── dummy-widget.tsx
│   └── index.tsx
├── tsconfig.json
├── webpack.common.js
├── webpack.dev.js
└── webpack.prod.js

Source files

bootstrap.ts

A mocked implementation of the registration methods used in the real application. It is needed to preview the widget in development.

config.tsx

The configuration form which is rendered from the configuration schema in the widget. It is also used in the preview to alter the component.

configuration-schema.ts

A simple schema to define custom settings for the widget. For more information, please refer to the documentation of RJFS.

widget.tsx

The naming of this file should reflect the chosen widget name. This file contains the logic of the widget. It is rendered within the render method of the index.tsx file.

index.tsx

Bootstrap the widget here to be used inside the target platform. Also the block definition is set here.

Usage:

npx @staffbase/create-widget

Read more about custom-element naming conventions here.

cli-options:

--packageManager=[npm|yarn]

Running Locally

To run the generator from a local copy of the source code, first install dependencies:

npm install

then build the generator:

npm run build

and finally, start the generator using:

node bin/index.js

The generated widget code will reside in the current directory.

Known Issues:

  • The development preview of the widget and the preview of the configuration are not connected. Submitting the form doesn't update the widget on the left hand side.
  • not compatible with npm 7

Dependencies (3)

Dev Dependencies (10)

Package Sidebar

Install

npm i @staffbase/create-widget

Weekly Downloads

13

Version

2.3.5

License

Apache-2.0

Unpacked Size

4.21 MB

Total Files

84

Last publish

Collaborators

  • staffbase.com
  • scthi
  • holgerstein