3.1.1 • Published 5 years ago

mwp-application-launcher v3.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

mwp-application-launcher

All the yarn commands below are applicable to npm.

Usage

Add the module to your dependencies:

> yarn add mwp-application-launcher

Import it in your code and initialize the module:

import { init } from 'mwp-application-launcher';

const launcher = init(
  {
    url: 'https://path/to/your/api/endpoint',
    hasPermission: (permission) => { ... },
  }
);
OptionTypeDefaultDescription
urlstringIndicate from which url the items should be fetched.
hasPermissionfunction(permission: string): boolean|PromiseTells whether the logged in user has the given permission.

The hasPermission function can either

  • be synchronous and return true for allowance, false otherwise
  • be asynchronous and return a promise that will be resolved for allowance, rejected otherwise

This init function returns 2 functions:

  • renderLauncher({ container, light, ...props }) to display the items in a vertical full-height bar,
  • renderLauncherButton({ container, light, ...props}) to display a control button which opens a modal containing the items.
OptionTypeDefaultDescription
containerstringnullA selector matching a HTML element to which the launcher will be attached.
lightbooleanfalseWhether to use the light theme instead of the dark one.
...propsany number of options of any typeThese options will be passed down to the launcher parent element.

Development

Launch the development server:

yarn dev

The source folder is /src. Files with global code and functions should directly be in /src. The associated test folder is /src/__tests__. Components folders are in the form: /src/NameOfComponent. They are composed of an index.jsx and style.module.scss files, and a __tests__ folder.

Build

Build the module in /dist:

yarn build

Test

Tests are made with Jest. The following command launches all tests:

yarn test

Jest CLI arguments can be passed directly to the above command, like so: yarn test -u (updates snapshots).

3.1.1

5 years ago

3.1.0

5 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.0.4

6 years ago

1.0.5

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago