# @starchart-labs/flightdeck

> Lightweight and powerful Javascript hooks for common UI elements

Latest version **0.2.8** (published 2017-09-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @starchart-labs/flightdeck
pnpm add @starchart-labs/flightdeck
yarn add @starchart-labs/flightdeck
bun add @starchart-labs/flightdeck
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.8 |
| Published | 2017-09-06 |
| First published | 2017-09-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Starchart Labs |
| Maintainers | nickavv |
| Keywords | ui, ux, button, buttons, modal, modals |

## Links

- npm: https://www.npmjs.com/package/@starchart-labs/flightdeck
- Repository: https://github.com/StarChart-Labs/flightdeck
- Homepage: https://github.com/StarChart-Labs/flightdeck#readme
- Issues: https://github.com/StarChart-Labs/flightdeck/issues
- npm.io page: https://npm.io/package/@starchart-labs/flightdeck

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.2.8 (latest) — 2017-09-06
- 0.2.7 — 2017-09-06
- 0.2.6 — 2017-09-05
- 0.2.5 — 2017-09-05
- 0.2.4 — 2017-09-05
- 0.2.3 — 2017-09-05
- 0.2.2 — 2017-09-05
- 0.2.1 — 2017-09-05
- 0.2.0 — 2017-09-05
- 0.1.1 — 2017-09-05
- 0.1.0 — 2017-09-05

## README

# flightdeck.js
[![Build Status](https://travis-ci.org/StarChart-Labs/flightdeck.svg?branch=master)](https://travis-ci.org/StarChart-Labs/flightdeck)

Flightdeck is a collection of lightweight and powerful Javascript modules for common web UI elements. The goal is to bring object-oriented sensibilities to the script-side of the UI. For example, a button in HTML is tied to an instance of the Button class in Flightdeck.

Starchart Labs' web-applications use Flightdeck to power their frontends, and you can too!

## Button
```javascript
import { Button } from '@starchart-labs/flightdeck';

let myButton = new Button('demo-button');
myButton.onClick(() => console.log('hello'));
```
### Constructor
Creates an instance of Button.
#### Arguments
* `elementId` {string} - The ID of a DOM element on the page to tie to this instance of Button
* `loaderHtml` {string} (optional) - An HTML string to display when the button is in the loading state (see onClickAsync)

### onClick
Sets up a click event for the Button.
#### Arguments
* `func` {function} - A function to be called whenever the button is clicked

### onClickAsync
Sets up an asynchronous click event for the Button. While the event is being performed, the button will have the class `disabled` added to it, and the text of the button will be temporarily replaced by whatever `loaderHtml` was specified in the constructor (by default this is `<div class="loader"></div>`).
#### Arguments
* `func` {function returns Promise} - A function to be called whenever the button is clicked. This function must return the type `Promise` for the loading state to work correctly

## Modal
```javascript
import { Modal } from '@starchart-labs/flightdeck';

let myModal = new Modal('demo-modal');
myModal.open();
```
### Constructor
Creates an instance of Modal. Any DOM children of this Modal with the class `modal-close` will be automatically set up with an event listener to close this Modal when clicked. Additionally, the background area around the Modal will also close the Modal when clicked, unless `sticky` is set to true.
#### Arguments
* `elementId` {string} - The ID of a DOM element on the page to tie to this instance of Modal
* `sticky` {boolean} (optional) - If sticky is true, clicking the background around the modal will _not_ close it. This is false by default, so the modal can be easily closed.
* `closeFunction` {function} (optional) - A function to be run whenever the modal is closed. For example, to clear out the fields of a form in the modal.

### open
Shows the Modal by adding the class `open` to the DOM element.

### close
Closes the Modal by removing the class `open` from the DOM element. Will call `closeFunction` if one was provided in the constructor.

---
_Source: https://npm.io/package/@starchart-labs/flightdeck · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
