0.1.13 • Published 3 years ago

vue-jackbox v0.1.13

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

vue-jackbox

Requirements

Installation

# npm
$ npm install vue-jackbox

# yarn
$ yarn add vue-jackbox

Try it

API

Available methods inside a VueJS component

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

ParameterTypeDefaultDescription
titleHTML/stringemptyThe dialog title
messageHTML/stringemptyThe dialog message
questionHTML/stringemptyThe dialog question
placeholderstringemptyInput placeholder for prompt
valuestringemptyInput value for prompt
labelHTML/stringemptyInput label for prompt
centerButtonsbooleanfalseCenter action buttons in dialog footer
cancelOnBackdropbooleanfalseCancel dialog on backdrop click
showBackdropbooleantrueOption to display backdrop
cancelOnEscbooleantrueCancel dialog on esc
durationnumber-1The duration for which the alert will be shown, -1 = infinite
okobject{text: 'Continue', action: null}Text and callback on ok button.
cancelobject{text: 'Cancel', action: null}Text and callback on cancel button.
statestringinformationSets color on dialog, options: information, critical, warning ,success
buttonsstring[]'cancel', 'ok'Select which buttons to show, you can add a custom button, but you will also need to add property for that.
iconHTML/String!What icon to display, can me svg, text or img tag

Adding custom buttons

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

this.$alert({
  title: 'This is an test alert',
  message: 'I´m just testing'
})

Show an confirm

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

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

this.$alert({
  title: 'Name changed!',
  message: `Your name has successfully been changed to <strong>${this.firstName}</strong>`,
  state: 'success'
})

Usage

main.js

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

Vue.use(VueJackBox)

And import stylesheets manually:

import 'vue-jackbox/dist/vue-jackbox.css';

App.vue

<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

0.1.13

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago