oncogene

1.12.0 • Public • Published

npm version

Oncogene (JSON Config Generator) allows to create visual config generators. Demo 1. Demo 2. Custom Progressbar.

You only need to declare steps.

Warning! Oncogene is in active development. Minor versions may contain breaking changes.

Usage

new Oncogene(options)

Options reference

options {Object} | required

options.selector {String} | required

CSS selector of element which will be Oncogene root.

Example:

{
    selector: '.oncogene-root'
    ...
}

options.steps[] {Object} | required

List of generator's steps

options.steps[].key {String}

*required if options.steps[].callback not in use.

Config key for chosen value. May be nested (dot separated).

options.steps[].callback {Function}

*required if options.steps[].key not in use.

Step callback. You can use it for complicated logic when a key is not enough.

Params:

  • config {Object} — current config;
  • value — chosen value.

Returns:

  • config {Object} — new config.

Note: You can use key or callback or both

options.steps[].hint {String}

Common hint. Can contain HTML.

options.steps[].variants[] {Object}

Array of variants. It should contain at least two items.

options.steps[].variants[].hint {String}

Variant hint. Can contain HTML.

options.steps[].variants[].code {String}

Code example.

options.steps[].variants[].value {Any}

Any value that will be set by key or/and will be used in callback.

Example:

{
    ...
    steps: [
        {
            key: 'someConfigKey',
            hint: 'Common hint',
            variants: [
                {
                    hint: 'first variant hint',
                    code: 'first code example',
                    value: 'first variant value'
                },
                ...
            ],
            callback: (config, value) => {
                config.anotherConfigKey = value
                return config
            }
        },
        ...
    ]
}

options.config {Object}

Initial config. By default it is empty object ({}).

options.skipValidation {Boolean}

Options validation skipping. By default it is false.

options.result {Object}

Configuring of result step.

options.result.hint {String}

Result hint. Can contain HTML.

Package Sidebar

Install

npm i oncogene

Weekly Downloads

1

Version

1.12.0

License

MIT

Last publish

Collaborators

  • gwer