# vue-jackbox

> A small vue plugin to display nice looking alerts

Latest version **0.1.13** (published 2020-12-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-jackbox
pnpm add vue-jackbox
yarn add vue-jackbox
bun add vue-jackbox
```

## 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.1.13 |
| Published | 2020-12-10 |
| First published | 2020-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 186.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Jonathan Andersson |
| Maintainers | ja1984 |
| Keywords | vue, alert, confirm, notification, prompt |

## Links

- npm: https://www.npmjs.com/package/vue-jackbox
- Repository: https://github.com/ja1984/vue-jackbox
- Homepage: https://github.com/ja1984/vue-jackbox#readme
- Issues: https://github.com/ja1984/vue-jackbox/issues
- npm.io page: https://npm.io/package/vue-jackbox

## Dependencies (1)

- [vue](https://npm.io/package/vue.md) ^2.6.11

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 0.1.13 (latest) — 2020-12-10
- 0.1.12 — 2020-12-09
- 0.1.11 — 2020-12-09
- 0.1.10 — 2020-12-08
- 0.1.8 — 2020-12-08
- 0.1.7 — 2020-12-08
- 0.1.6 — 2020-12-04
- 0.1.5 — 2020-12-03
- 0.1.4 — 2020-12-02
- 0.1.3 — 2020-12-02
- 0.1.2 — 2020-12-02
- 0.1.1 — 2020-12-02
- 0.1.0 — 2020-12-02

## README

# vue-jackbox

## Requirements
- [Vue.js](https://github.com/vuejs/vue) `2.x`  

## Installation
```bash
# npm
$ npm install vue-jackbox

# yarn
$ yarn add vue-jackbox
```

## Try it
- [Demo](https://ja1984.github.io/vue-jackbox/)

## API

Available methods inside a VueJS component

The same parameters apply to all the methods in `$alert` expect the method `hide` and `clearDefault`

Parameter | Type |Default| Description
--------- | ---- | ------|-----------
title | `HTML/string` | _empty_ | The dialog title
message | `HTML/string` | _empty_ | The dialog message
question | `HTML/string` | _empty_ | The dialog question
placeholder | `string` | _empty_ | Input placeholder for prompt
value | `string` | _empty_ | Input value for prompt
label | `HTML/string` | _empty_ | Input label for prompt
centerButtons | `boolean` | false | Center action buttons in dialog footer
cancelOnBackdrop | `boolean` | _false_ | Cancel dialog on backdrop click
showBackdrop | `boolean` | _true_ | Option to display backdrop
cancelOnEsc | `boolean` | _true_ | Cancel dialog on esc
duration | `number` | -1 | The duration for which the alert will be shown, `-1 = infinite`
ok | `object` | _{text: 'Continue', action: null}_ | Text and callback on ok button.
cancel | `object` | _{text: 'Cancel', action: null}_ | Text and callback on cancel button.
state | `string` | _information_ | Sets color on dialog, options: `information`, `critical`, `warning` ,`success`
buttons | `string[]` | _['cancel', 'ok']_ | Select which buttons to show, you can add a custom button, but you will also need to add property for that.
icon | `HTML/String` | _!_ | What icon to display, can me svg, text or img tag



## Adding custom buttons
```javascript
this.$alert({
  title: 'This is an test alert',
  message: 'I´m just testing',
  retry: { text: 'Retry', className: 'jb-dialog__button--action', action: () => { this.doRetry(); } },
  buttons: ['cancel', 'retry', 'ok'],
})
```

If any of the values is not present on the method call then the default values will be used.

All dialogs use the same code in the background, so all options are always available, the diffrent methods are just short hands. (Except for the prompt, that is the only one that supports the input.)

## Show an alert
```javascript
this.$alert({
  title: 'This is an test alert',
  message: 'I´m just testing'
})
```
## Show an confirm
```javascript
this.$confirm({
  title: 'Unsaved changes',
  message: 'You have made changes that are not yet saved, if you continue these will get lost.',
  question: 'Do you want to discard changes and continue?',
  state: 'critical',
  ok: {
    action: () => { this.$emit('close'); },
  },
});
```
## Show an prompt
```javascript
this.$prompt({
  title: 'Change name',
  message: 'Enter the new first name',
  placeholder: 'Enter first name',
  value: this.firstName,
  ok: {
    action: (value) => { this.firstName = value; }
  }
})
```
## Show an notification
```javascript
this.$alert({
  title: 'Name changed!',
  message: `Your name has successfully been changed to <strong>${this.firstName}</strong>`,
  state: 'success'
})
```

## Usage

main.js

```javascript
import Vue from 'vue'
import VueJackBox from 'vue-jackbox'
import App from './App'

Vue.use(VueJackBox)
```
## And import stylesheets manually:
```javascript
import 'vue-jackbox/dist/vue-jackbox.css';
```
App.vue

```html
<template>
    <div id="app"></div>
</template>

<script>

export default {
  mounted () {
    this.$notification(
        {
          title: 'App loaded',
          text: 'The app has loaded successfully!',
          state: 'success'
        });
  }
}
</script>

<style>
</style>
```

# License

[The MIT License](http://opensource.org/licenses/MIT)

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