0.3.2 • Published 4 years ago

@adecrown/whoosh v0.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Whoosh

Project setup

npm install @adecrown/whoosh

or

yarn add @adecrown/whoosh

Basic Usage

Inside your main.js file

import Whoosh from "@adecrown/whoosh";
Vue.use(Whoosh);

then inside your App.vue file use Whoosh like this

<Whoosh/>

Whoosh can then be called anywhere like this

this.$whoosh({
  status: "error",
  title: "Something went wrong",
  message: "We could not find the id"
});

API

this.$whoosh({
  // (optional) Notification status 'success,warn,error'
  // custom status can also be passed here
  status: "success",

  // (optional) Notification title
  title: "I am the title",

  // (optional) Notification message
  message: "I am the message",

  // (optional) This will override the default duration and the provided prop duration
  duration: 5,

  // (optional) This will override the default size and the provided prop size
  size: {
    width: 400,
    height: 250
  },

  // (optional) Provide a callback function that gets called when the notification closes
  onClose: () =>{},

  // (optional) allows the notification to reveal extra data
  expandable:{
    data:"New Data" | Login // (required) string or a registered component,
    height:600, //(optional) will expand to this height
    isComponent:false, //(optional) but required and should be set to true if expandable is to display a component
    noBackground: boolean // (optional);
    buttonColor: string // (optional);
    hideHeader: boolean // (optional);
    headerStyle: object // (optional);
  },

});

Props Table

All props below are optional.

NameTypeDefaultDescription
durationNumber5how long you want the notification to stay on for (5 equals 5 seconds)
fillBooleanfalsefill the whole card with the status color
closeOnClickBooleanfalsenotification will only close when it's clicked on
textColorStringblackset the text color to what you prefer
progressColorString#dcd9d9set the progress color to what you prefer
sizeObject{width:500,height:210}use it to set your prefered width and height
messageStyleObjectgive a custom style to the message section
titleStyleObjectgive a custom style to the title section
displayleft or rightrightcontrols which side the notification should come out from
mobileDisplaytop or bottomtopcontrols which position the notification should be displayed on mobile
isResponsiveBooleantruehandles responsiveness of notifications. Set it to false if you don't want the mobile view.
skindefault or launchdefaultset the notification skin type to use
queueBooleanfalsewait for existing notification to close before showing a new one

Custom Status

If the default status (success, error, warn) are not enough or not to your taste, you can create your own custom statuses which is an array of objects status and each object requires a name and color.

Inside your main.js file add the options parameter like below.

import Whoosh from "@adecrown/whoosh";
Vue.use(Whoosh, {
  statuses: [
    {
      name: "Testing",
      color: "red"
    },
    {
      name: "Testing 3",
      color: "green"
    }
  ]
});

Use Whoosh as normal to call your custom status

this.$whoosh({
  status: "Testing",
  title: "This is my custom status",
  message: "Hello Testing"
});

The defualt statuses are still available along with your custom ones but you can also override the color of the default statuses by adding it to the statuses array

  {
    name: 'error',
    color: 'black'
  }

launch skin notification (usage)

Making use of the launch notification only require one prop, just add a skin prop to whoosh and specify 'launch' as the string. It's duration is fixed to 5 seconds.

  <Whoosh skin="launch"/>
this.$whoosh({
  status: "success",
  message: "My launch message"
});